| | |
| | | |
| | | |
| | | <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},'%') |