src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -402,7 +402,7 @@ paymentHistoryRecordVo.setCurrentPaymentAmount(currentPaymentAmount); paymentHistoryRecordVo.setInvoiceAmount(invoiceAmount); amountTotal = paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()); paymentHistoryRecordVo.setPayableAmount(amountTotal); paymentHistoryRecordVo.setPayableAmount(amountTotal.abs()); result.add(paymentHistoryRecordVo); } @@ -410,11 +410,16 @@ for (int i = 0; i < result.size(); i++) { PaymentHistoryRecordVo paymentHistoryRecordVo = result.get(i); if (i == 0) { paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount())); paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo .getInvoiceAmount() .subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()) .abs()); }else { PaymentHistoryRecordVo paymentHistoryRecordVo1 = result.get(i-1); paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo1.getPayableAmount() .add(paymentHistoryRecordVo.getInvoiceAmount()).subtract(paymentHistoryRecordVo.getCurrentPaymentAmount())); .add(paymentHistoryRecordVo.getInvoiceAmount()) .subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()) .abs()); } newResult.add(paymentHistoryRecordVo); } src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
@@ -275,18 +275,21 @@ customerInteractionDto.setInvoiceAmount(invoiceAmount); customerInteractionDto.setReceiptAmount(currentReceiptAmount); amountTotal = customerInteractionDto.getInvoiceAmount().subtract(customerInteractionDto.getReceiptAmount()); customerInteractionDto.setUnReceiptAmount(amountTotal); customerInteractionDto.setUnReceiptAmount(amountTotal.abs()); result.add(customerInteractionDto); } ArrayList<CustomerInteractionDto> newResult = new ArrayList<>(); for (int i = 0; i < result.size(); i++) { CustomerInteractionDto customerInteractionDto = result.get(i); if (i == 0) { customerInteractionDto.setUnReceiptAmount(customerInteractionDto.getInvoiceAmount().subtract(customerInteractionDto.getReceiptAmount())); customerInteractionDto.setUnReceiptAmount(customerInteractionDto .getInvoiceAmount() .subtract(customerInteractionDto.getReceiptAmount()) .abs()); }else { CustomerInteractionDto customerInteractionDto1 = result.get(i-1); customerInteractionDto.setUnReceiptAmount(customerInteractionDto1.getUnReceiptAmount() .add(customerInteractionDto.getInvoiceAmount()).subtract(customerInteractionDto.getReceiptAmount())); .add(customerInteractionDto.getInvoiceAmount()).subtract(customerInteractionDto.getReceiptAmount()).abs()); } newResult.add(customerInteractionDto); } src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml
@@ -7,49 +7,28 @@ <select id="selectPurchaseReport" resultType="com.ruoyi.purchase.dto.InvoicePurchaseReportDto"> SELECT A.*, FORMAT(A.sales_tax_amount - A.purchase_tax_amount, 2) AS balance_amount FROM ( SELECT sl.customer_contract_no, sl.id, pl.id AS pl_id, sl.sales_contract_no AS customerContractNo, sl.customer_name, sl.contract_amount AS contract_amount, sl.project_name, slp.tax_inclusive_total_price - slp.tax_exclusive_total_price AS contract_amount, SUM(slp1.tax_inclusive_total_price - slp1.tax_exclusive_total_price) AS purchase_amount, (slp.tax_exclusive_total_price) / COUNT(slp.id) AS sale_tax_exclusive_total_price, SUM(slp1.tax_exclusive_total_price) AS tax_exclusive_total_price, (slp.tax_inclusive_total_price - slp.tax_exclusive_total_price) - SUM(slp1.tax_inclusive_total_price - slp1.tax_exclusive_total_price) AS balance, CONCAT( FORMAT( ((slp.tax_inclusive_total_price - slp.tax_exclusive_total_price) - SUM(slp1.tax_inclusive_total_price - slp1.tax_exclusive_total_price)) / (slp.tax_inclusive_total_price - slp.tax_exclusive_total_price) * 100, 2), '%' ) AS balance_ratio, (slp.tax_inclusive_total_price - slp.tax_exclusive_total_price) AS sales_tax_amount, SUM(slp1.tax_inclusive_total_price - slp1.tax_exclusive_total_price) AS purchase_tax_amount SUM( pl.contract_amount ) AS purchase_amount, ( sl.contract_amount - SUM( pl.contract_amount )) AS balance, CONCAT( ROUND( ( sl.contract_amount - SUM( pl.contract_amount )) / sl.contract_amount * 100, 1 ), '%' ) AS balance_ratio FROM purchase_ledger pl LEFT JOIN sales_ledger sl ON pl.sales_ledger_id = sl.id LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id AND slp.type = 1 LEFT JOIN sales_ledger_product slp1 ON slp1.sales_ledger_id = pl.id AND slp1.type = 2 GROUP BY sl.customer_contract_no, sl.customer_name, sl.project_name, sl.id, pl.id HAVING sl.customer_contract_no IS NOT NULL ) A sales_ledger sl INNER JOIN purchase_ledger pl ON sl.sales_contract_no = pl.sales_contract_no <where> <if test="c.customerName != null and c.customerName != ''"> AND A.customer_name LIKE CONCAT('%', #{c.customerName}, '%') AND sl.customer_name LIKE CONCAT('%', #{c.customerName}, '%') </if> </where> GROUP BY sl.sales_contract_no, sl.customer_name, sl.contract_amount ORDER BY sl.sales_contract_no </select> <select id="listVat" resultType="com.ruoyi.purchase.dto.VatDto"> select *