From 118afd697fe3197236dcf0ffd6cfd39bcec2d85f Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期一, 14 七月 2025 13:37:57 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml | 35 +++++++++++++++++++---------------- 1 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml index 731b5c5..0b29502 100644 --- a/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml +++ b/src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml @@ -6,23 +6,26 @@ <select id="selectPurchaseReport" resultType="com.ruoyi.purchase.dto.InvoicePurchaseReportDto"> - select sl.customer_contract_no, - sl.customer_name, - sl.project_name, - sl.contract_amount, - pl.contract_amount as purchase_amount, - sum(slp.tax_exclusive_total_price) as sale_tax_exclusive_total_price, - sum(pr.tax_exclusive_total_price) as tax_exclusive_total_price, - (sl.contract_amount-pl.contract_amount) as balance, - CONCAT(FORMAT((sl.contract_amount - pl.contract_amount) / sl.contract_amount * 100, 2), '%') AS balance_ratio, - sl.contract_amount-sum(slp.tax_exclusive_total_price)-(pl.contract_amount-sum(pr.tax_exclusive_total_price)) as balance_amount + select A.*, + FORMAT(A.contract_amount-A.sale_tax_exclusive_total_price-A.purchase_amount+A.tax_exclusive_total_price,2) as balance_amount + from (select sl.customer_contract_no, + sl.id, + pl.id as pl_id, + sl.customer_name, + sl.project_name, + sl.contract_amount, + pl.contract_amount as purchase_amount, + sum(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, + (sl.contract_amount - pl.contract_amount) as balance, + CONCAT(FORMAT((sl.contract_amount - pl.contract_amount) / sl.contract_amount * 100, 2), + '%') AS balance_ratio from purchase_ledger pl - left join sales_ledger sl on pl.sales_ledger_id = sl.id - left join product_record pr on pr.purchase_ledger_id = pl.id - left join sales_ledger_product slp on slp.sales_ledger_id = sl.id - - group by sl.customer_contract_no, sl.customer_name, sl.project_name, sl.contract_amount, pl.contract_amount - having sl.customer_contract_no is not null + 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.contract_amount, pl.contract_amount,sl.id,pl.id + having sl.customer_contract_no is not null) A <where> <if test="c.customerName != null and c.customerName != ''"> and sl.customer_name like concat('%',#{c.customerName},'%') -- Gitblit v1.9.3