| | |
| | | LEFT JOIN ( |
| | | SELECT |
| | | sl.customer_id, |
| | | SUM(IFNULL(slp.shipped_quantity, 0) * IFNULL(slp.tax_inclusive_unit_price, 0)) AS receipt_payment_amount, |
| | | SUM((IFNULL(slp.stocked_quantity, 0) - IFNULL(slp.shipped_quantity, 0)) * IFNULL(slp.tax_inclusive_unit_price, 0)) AS unReceipt_payment_amount |
| | | SUM(IFNULL(slp.shipped_quantity, 0) * IF(IFNULL(slp.quantity, 0) > 0, slp.tax_inclusive_total_price / slp.quantity, 0)) AS receipt_payment_amount, |
| | | SUM((IFNULL(slp.stocked_quantity, 0) - IFNULL(slp.shipped_quantity, 0)) * IF(IFNULL(slp.quantity, 0) > 0, slp.tax_inclusive_total_price / slp.quantity, 0)) AS unReceipt_payment_amount |
| | | FROM sales_ledger sl |
| | | JOIN sales_ledger_product slp ON sl.id = slp.sales_ledger_id AND slp.type = 1 |
| | | GROUP BY sl.customer_id |