| | |
| | | T1.update_user, |
| | | T1.tenant_id, |
| | | T1.is_white, |
| | | T2.nick_name AS maintainUserName |
| | | T2.nick_name AS maintainUserName, |
| | | T1.supplier_type |
| | | FROM supplier_manage T1 |
| | | LEFT JOIN sys_user T2 ON T1.maintain_user_id = T2.user_id |
| | | <where> |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="supplierTransactions" resultType="com.ruoyi.purchase.vo.SupplierTransactionsVo"> |
| | | SELECT T1.supplier_id, |
| | | sm.supplier_name, |
| | | T1.contractAmounts, |
| | | IFNULL(T3.InboundAmount, 0) AS shippedAmount, |
| | | T1.contractAmounts - IFNULL(T3.InboundAmount, 0) AS unshippedAmount |
| | | FROM (SELECT supplier_id, SUM(contract_amount) AS contractAmounts FROM purchase_ledger GROUP BY supplier_id) T1 |
| | | LEFT JOIN ( |
| | | SELECT pl.supplier_id, |
| | | SUM(IFNULL(qi.quantity, 0) * slp.tax_inclusive_unit_price) AS InboundAmount |
| | | FROM quality_inspect qi |
| | | INNER JOIN purchase_ledger pl ON pl.id = qi.purchase_ledger_id |
| | | INNER JOIN sales_ledger_product slp ON slp.sales_ledger_id = pl.id AND slp.product_model_id = qi.product_model_id |
| | | WHERE qi.inspect_state = 1 AND slp.type = 2 |
| | | GROUP BY pl.supplier_id |
| | | ) T3 ON T3.supplier_id = T1.supplier_id |
| | | LEFT JOIN supplier_manage sm ON T1.supplier_id = sm.id |
| | | <where> |
| | | <if test="supplierName!=null and supplierName!=''"> |
| | | AND sm.supplier_name LIKE CONCAT('%',#{supplierName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |
| | | <select id="supplierTransactionsDetails" |
| | | resultType="com.ruoyi.purchase.vo.SupplierTransactionsDetailsVo"> |
| | | SELECT pl.id purchaseLedgerId, |
| | | pl.purchase_contract_number, |
| | | pl.execution_date, |
| | | pl.contract_amount, |
| | | IFNULL(T2.InboundAmount, 0) AS shippedAmount, |
| | | pl.contract_amount - IFNULL(T2.InboundAmount, 0) AS unshippedAmount |
| | | FROM purchase_ledger pl |
| | | LEFT JOIN ( |
| | | SELECT slp.sales_ledger_id, |
| | | SUM(IFNULL(qi.quantity, 0) * slp.tax_inclusive_unit_price) AS InboundAmount |
| | | FROM quality_inspect qi |
| | | INNER JOIN sales_ledger_product slp ON slp.sales_ledger_id = qi.purchase_ledger_id AND slp.product_model_id = qi.product_model_id |
| | | WHERE qi.inspect_state = 1 AND slp.type = 2 |
| | | GROUP BY slp.sales_ledger_id |
| | | ) T2 ON T2.sales_ledger_id = pl.id |
| | | WHERE pl.supplier_id = #{supplierId} |
| | | </select> |
| | | |
| | | </mapper> |