From b49af98eef2255bcbfb0aba780baa97076e5be6f Mon Sep 17 00:00:00 2001 From: linfso Date: Tue, 20 Aug 2024 22:54:10 +0800 Subject: [PATCH] md --- .../impl/EmisSettlePayRecordServiceImpl.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java index 8c76bdccf..bb0b69483 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java @@ -151,6 +151,8 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I // 计算已收款金额 BigDecimal totalPayMoney = BigDecimal.ZERO; + BigDecimal totalRefundMoney = BigDecimal.ZERO; + // 抵扣金额 BigDecimal satisfyMoney = BigDecimal.ZERO; /* allowance_money */ @@ -160,26 +162,40 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I /* other_money */ BigDecimal otherMoney = BigDecimal.ZERO; + // refund_money + BigDecimal refundMoney = BigDecimal.ZERO; + log.debug("收款状态更新===>应收:{}",oldBill.getRecMoney()); for(EmisSettlePayRecord item:payRecordList){ - totalPayMoney=totalPayMoney.add(item.getPayMoney()); - satisfyMoney=satisfyMoney.add(item.getSatisfyMoney()==null?BigDecimal.ZERO:item.getSatisfyMoney()); - allowanceMoney=allowanceMoney.add(item.getAllowanceMoney()==null?BigDecimal.ZERO:item.getAllowanceMoney()); - deductionMoney=deductionMoney.add(item.getDeductionMoney()==null?BigDecimal.ZERO:item.getDeductionMoney()); - otherMoney=otherMoney.add(item.getOtherMoney()==null?BigDecimal.ZERO:item.getOtherMoney()); + + if("1".equals(item.getRecType())) { + totalPayMoney = totalPayMoney.add(item.getPayMoney()); + satisfyMoney = satisfyMoney.add(item.getSatisfyMoney() == null ? BigDecimal.ZERO : item.getSatisfyMoney()); + allowanceMoney = allowanceMoney.add(item.getAllowanceMoney() == null ? BigDecimal.ZERO : item.getAllowanceMoney()); + deductionMoney = deductionMoney.add(item.getDeductionMoney() == null ? BigDecimal.ZERO : item.getDeductionMoney()); + otherMoney = otherMoney.add(item.getOtherMoney() == null ? BigDecimal.ZERO : item.getOtherMoney()); + } + else if("2".equals(item.getRecType())) { + refundMoney = refundMoney.add(item.getRefundMoney() == null ? BigDecimal.ZERO : item.getRefundMoney()); + } } // 总应收金额 log.debug("收款状态更新===>totalPayMoney:{},satisfyMoney:{},allowanceMoney:{},deductionMoney:{},otherMoney:{}" ,totalPayMoney,satisfyMoney,allowanceMoney,allowanceMoney,deductionMoney,otherMoney); + // 收款金额-退款金额 totalAllPayMoney=totalAllPayMoney .add(totalPayMoney) .add(satisfyMoney) .add(allowanceMoney) .add(deductionMoney) - .add(otherMoney); + .add(otherMoney) + .subtract(refundMoney) + ; + + totalRefundMoney=totalRefundMoney.add(refundMoney); EmisSettleBill newBill = new EmisSettleBill(); newBill.setId(oldBill.getId()); @@ -188,6 +204,9 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I newBill.setAllowanceMoney(allowanceMoney); newBill.setOtherMoney(otherMoney); + // 退款金额 + newBill.setRefundMoney(refundMoney); + // 判断收款状态 收款金额 int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney()); log.debug("收款状态更新===>收款总金额:{},应收:{},rsDif:{}",totalAllPayMoney,oldBill.getRecMoney(),rstDif);