amount_due and change_due were incorrect if multiple items in sale

(#136)
This commit is contained in:
jekkos
2015-09-09 19:25:44 +02:00
parent e9ea2ba792
commit 506aced23e

View File

@@ -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');