| | |
| | | AND slp.sales_ledger_id = qi.purchase_ledger_id |
| | | AND slp.product_model_id = qi.product_model_id |
| | | WHERE sir.approval_status = 1 |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT slp.id AS sales_ledger_product_id, |
| | | sir.stock_in_num |
| | | FROM stock_in_record sir |
| | | INNER JOIN quality_unqualified qu |
| | | ON TRIM(sir.record_type) = '11' |
| | | AND sir.record_id = qu.id |
| | | INNER JOIN quality_inspect qi |
| | | ON qi.id = qu.inspect_id |
| | | INNER JOIN sales_ledger_product slp |
| | | ON slp.type = 2 |
| | | AND slp.sales_ledger_id = qi.purchase_ledger_id |
| | | AND slp.product_model_id = qi.product_model_id |
| | | WHERE sir.approval_status = 1 |
| | | |
| | | ) rel |
| | | GROUP BY rel.sales_ledger_product_id |
| | | ) approved_qty ON approved_qty.sales_ledger_product_id = slp.id |
| | |
| | | <if test="c.stockInStatus != null and c.stockInStatus != ''"> |
| | | WHERE result.stock_in_status = #{c.stockInStatus} |
| | | </if> |
| | | ORDER BY result.entry_date DESC |
| | | ORDER BY result.entry_date DESC, result.purchase_contract_number DESC |
| | | </select> |
| | | |
| | | <select id="selectTotalPurchaseAmount" resultType="java.math.BigDecimal"> |