1.DZ本次核销金额小于等于未清金额
2.取绝对值(凭证类型除DZ之外合计)=取绝对值(账扣DG+回款DZ+尾差)
This commit is contained in:
		
							parent
							
								
									85ea8f066f
								
							
						
					
					
						commit
						c6722fb6e1
					
				|  | @ -46,6 +46,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|         DynamicObject prinfo;//清账明细单 | ||||
|         DynamicObject clearBillInfo;//清账单 | ||||
|         String billno; | ||||
|         String amountCheckResult; | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             //列表操作时系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下 | ||||
|             prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName()); | ||||
|  | @ -75,9 +76,10 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
| //                    e.setCancelMessage(billno+"【未清金额】+【账扣】+【尾差】≥【本次核销金额合计】,【本次核销金额合计】-【账扣】-【尾差】>=0,才允许提交"); | ||||
| //                    e.setCancel(true); | ||||
| //                } | ||||
|                 //校验本次核销金额填写是否有误,防止在正数行填写负数,在负数行中填写正数 | ||||
|                 if(checkEntryAmount(prinfo)){ | ||||
|                     e.setCancelMessage(billno+"分录本次核销或账扣尾差金额填写有误,合计等于0,分录负数金额合计的绝对值小于等于未清金额,才允许提交"); | ||||
|                 //校验本次核销金额 账扣尾差 填写是否有误 | ||||
|                 amountCheckResult = checkEntryAmount(prinfo); | ||||
|                 if(!"ok".equals(amountCheckResult)){ | ||||
|                     e.setCancelMessage(billno+"金额校验结果:"+amountCheckResult); | ||||
|                     e.setCancel(true); | ||||
|                 } | ||||
|             }else if("revoke".equals(eok)){ | ||||
|  | @ -120,23 +122,38 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean checkEntryAmount(DynamicObject prinfo){ | ||||
|     private boolean isDZvourcherType(String pzlx){ | ||||
|         if(JhzjUtils.isEmpty(pzlx)){ | ||||
|             return false; | ||||
|         }else if(pzlx.contains("DZ")){ | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     private String checkEntryAmount(DynamicObject prinfo){ | ||||
|         //校验分录本次核销金额的合计等于0 负数金额相加部分的绝对值不能大于未清金额 | ||||
|         BigDecimal entrytotal = BigDecimal.ZERO;//本次核销金额合计 | ||||
|         BigDecimal entrynegatetotal = BigDecimal.ZERO;//负数本次核销金额合计 | ||||
|         BigDecimal entrynegatetotal = BigDecimal.ZERO;//回款DZ本次核销金额合计 | ||||
|         BigDecimal nodztotal = BigDecimal.ZERO;//回款DZ之外的本次核销金额合计 | ||||
|         DynamicObjectCollection doc = prinfo.getDynamicObjectCollection("shjh_details");//获取分录 | ||||
|         //校验本次核销金额填写是否有误,防止在正数行填写负数,在负数行中填写正数 | ||||
|         BigDecimal cursettle;//本次核销金额 | ||||
|         DynamicObject rowinfo;//分录具体行对象 | ||||
|         for (int i = 0; i < doc.size(); i++) { | ||||
|             cursettle = doc.get(i).getBigDecimal("shjh_e_cursettle"); | ||||
|             rowinfo = doc.get(i); | ||||
|             cursettle = rowinfo.getBigDecimal("shjh_e_cursettle"); | ||||
|             if(cursettle != null){ | ||||
|                 entrytotal = entrytotal.add(cursettle);//累计分录本次核销金额 | ||||
|                 if(cursettle.signum() == -1){ | ||||
|                 //当凭证类型是DZ才统计 | ||||
|                 if(isDZvourcherType(rowinfo.getString("shjh_e_pzlx"))){ | ||||
|                     entrynegatetotal = entrynegatetotal.add(cursettle); | ||||
|                 }else{ | ||||
|                     nodztotal = nodztotal.add(cursettle); | ||||
|                 } | ||||
|                 if(cursettle.multiply(doc.get(i).getBigDecimal("shjh_e_unsettle")).signum() == -1){ | ||||
|                 if(cursettle.multiply(rowinfo.getBigDecimal("shjh_e_unsettle")).signum() == -1){ | ||||
|                     //当本次核销金额与未核销金额相乘后得出是负数的话,说明金额正负数填写反了 | ||||
|                     return true; | ||||
|                     return "本次核销金额与未核销金额正负号不一致"; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | @ -149,13 +166,26 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|             entrytotal = entrytotal.add(a3); | ||||
|         } | ||||
|         if(entrytotal.signum() != 0){ | ||||
|             return true; | ||||
|             return "本次核销金额合计+账扣+尾差不等于0"; | ||||
|         } | ||||
| 
 | ||||
|         BigDecimal a1 = prinfo.getBigDecimal("shjh_unclaimamount");//未清金额 | ||||
|         //回款DZ合计的绝对值代表收款合计,不能超过未清金额 | ||||
|         if(entrynegatetotal.abs().compareTo(a1) > 0){ | ||||
|             return true; | ||||
|             return "回款DZ本次核销金额合计的绝对值不能超过未清金额"; | ||||
|         } | ||||
|         return false; | ||||
| 
 | ||||
|         //取绝对值(凭证类型除DZ之外本次核销金额合计)=取绝对值(账扣DG+回款DZ本次核销金额合计+尾差) | ||||
|         if(a2 != null){ | ||||
|             entrynegatetotal = entrynegatetotal.add(a2); | ||||
|         } | ||||
|         if(a3 != null){ | ||||
|             entrynegatetotal = entrynegatetotal.add(a3); | ||||
|         } | ||||
|         if(nodztotal.abs().compareTo(entrynegatetotal.abs()) != 0){ | ||||
|             return "取绝对值(凭证类型除DZ之外本次核销金额合计)不等于 取绝对值(账扣+回款DZ本次核销金额合计+尾差)"; | ||||
|         } | ||||
|         return "ok"; | ||||
|     } | ||||
| 
 | ||||
|     private boolean checkAmount(DynamicObject prinfo){ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue