mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-25 22:27:05 -04:00
fix(sales): aggregate reference codes for multi-payment sales
Use GROUP_CONCAT to combine multiple payment reference codes into a single comma-separated value, and group only by sale_id to correctly handle sales with multiple payment records. Signed-off-by: Travis Garrison <travis@chiraqbookstore.com>
This commit is contained in:
@@ -1095,12 +1095,12 @@ class Sale extends Model
|
||||
SUM(CASE WHEN payments.cash_adjustment = 1 THEN payments.payment_amount ELSE 0 END) AS sale_cash_adjustment,
|
||||
SUM(payments.cash_refund) AS sale_cash_refund,
|
||||
GROUP_CONCAT(CONCAT(payments.payment_type, " ", (payments.payment_amount - payments.cash_refund)) SEPARATOR ", ") AS payment_type,
|
||||
payments.reference_code AS reference_code
|
||||
GROUP_CONCAT(payments.reference_code SEPARATOR ", ") AS reference_code
|
||||
FROM ' . $this->db->prefixTable('sales_payments') . ' AS payments
|
||||
INNER JOIN ' . $this->db->prefixTable('sales') . ' AS sales
|
||||
ON sales.sale_id = payments.sale_id
|
||||
WHERE ' . $where . '
|
||||
GROUP BY payments.sale_id, payments.reference_code
|
||||
GROUP BY payments.sale_id
|
||||
)';
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
Reference in New Issue
Block a user