yzc 11 сар өмнө
parent
commit
51f252af6f

+ 5 - 0
hx-common/src/main/java/com/fjhx/common/entity/logistics/vo/LogisticsEndingAmountVo.java

@@ -36,6 +36,11 @@ public class LogisticsEndingAmountVo extends LogisticsEndingAmount {
     private BigDecimal deductionAmount;
 
     /**
+     * 应付抵扣金额
+     */
+    private BigDecimal paymentDeductionAmount;
+
+    /**
      * 账期月份
      */
     private Integer accountPeriodMonth;

+ 27 - 4
hx-common/src/main/java/com/fjhx/common/service/logistics/impl/LogisticsEndingAmountServiceImpl.java

@@ -135,6 +135,10 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
                 yearBeginBalance = lastYearEndAmount.getEndingBalance();
                 yearBeginPayableBalance = lastYearEndAmount.getEndingPayableBalance();
             }
+            //排空
+            yearBeginBalance = ObjectUtil.defaultIfNull(yearBeginBalance, BigDecimal.ZERO);
+            yearBeginPayableBalance = ObjectUtil.defaultIfNull(yearBeginPayableBalance, BigDecimal.ZERO);
+
             logisticsCompanyInfoJson.put("yearBeginBalance", yearBeginBalance);
             logisticsCompanyInfoJson.put("yearBeginPayableBalance", yearBeginPayableBalance);
 
@@ -153,20 +157,35 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
                 BigDecimal advanceAmount = logisticsRecharge.getAdvanceAmount();
                 if (advanceAmount == null) {
                     advanceAmount = BigDecimal.ZERO;
+                } else {
+                    //数据转负数
+                    advanceAmount = BigDecimal.ZERO.subtract(advanceAmount);
+                    logisticsRecharge.setAdvanceAmount(advanceAmount);
                 }
+
+                //应付报表抵扣(负数)
+                BigDecimal paymentDeductionAmount = BigDecimal.ZERO;
                 //抵扣
                 BigDecimal deductionAmount = logisticsRecharge.getDeductionAmount();
                 if (deductionAmount == null) {
                     deductionAmount = BigDecimal.ZERO;
+                } else {
+                    //数据转负数
+                    paymentDeductionAmount = BigDecimal.ZERO.subtract(deductionAmount);
+                    logisticsRecharge.setPaymentDeductionAmount(paymentDeductionAmount);
                 }
                 //付款
                 BigDecimal paymentAmount = logisticsRecharge.getPaymentAmount();
                 if (paymentAmount == null) {
                     paymentAmount = BigDecimal.ZERO;
+                } else {
+                    //数据转负数
+                    paymentAmount = BigDecimal.ZERO.subtract(paymentAmount);
+                    logisticsRecharge.setPaymentAmount(paymentAmount);
                 }
 
-                //期末余额 = 上期末余额 + 预付 - 抵扣
-                logisticsRecharge.setEndingBalance(lastEndingBalance.add(advanceAmount).subtract(deductionAmount));
+                //期末余额 = 上期末余额 + 抵扣(贷方)+ 预付(借方)负数
+                logisticsRecharge.setEndingBalance(lastEndingBalance.add(deductionAmount).add(advanceAmount));
 
                 //获取 贷方发生额
                 LogisticsAmount logisticsAmount = logisticsAmountMap.getOrDefault(logisticsCompanyInfo.getId(), new LogisticsAmount());
@@ -177,11 +196,15 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
                 }
                 logisticsRecharge.setCreditAmount(creditAmount);
 
-                //期末应付余额 = 上期末应付余额 + 贷方发生额 - 付款 - 抵扣
-                BigDecimal endingPayableBalance = lastEndingPayableBalance.add(creditAmount).subtract(paymentAmount).subtract(deductionAmount);
+                //期末应付余额 = 上期末应付余额 + 贷方发生额 + 借方付款(负数) + 抵扣(负数)
+                BigDecimal endingPayableBalance = lastEndingPayableBalance.add(creditAmount).add(paymentAmount).add(paymentDeductionAmount);
                 logisticsRecharge.setEndingPayableBalance(endingPayableBalance);
 
                 logisticsCompanyInfoJson.put("" + i, logisticsRecharge);
+
+                //赋值上一期末余额,上一期末应付余额
+                lastEndingBalance = logisticsRecharge.getEndingBalance();
+                lastEndingPayableBalance = logisticsRecharge.getEndingPayableBalance();
             }
 
             outList.add(logisticsCompanyInfoJson);