From 506aced23ecf544e4cb7b14ea2a1f0cbd43b34da Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 9 Sep 2015 19:25:44 +0200 Subject: [PATCH] amount_due and change_due were incorrect if multiple items in sale (#136) --- application/models/sale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/sale.php b/application/models/sale.php index 98a5b15b1..9f4b7212f 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -23,7 +23,7 @@ class Sale extends CI_Model { $this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased, CONCAT(customer.first_name," ",customer.last_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, - sale_payment_amount AS amount_tendered, total AS amount_due, (sale_payment_amount - total) AS change_due, payment_type, invoice_number', FALSE); + sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due, payment_type, invoice_number', FALSE); $this->db->from('sales_items_temp'); $this->db->join('people AS customer', 'sales_items_temp.customer_id = customer.person_id', 'left');