diff --git a/application/models/Item.php b/application/models/Item.php index 46de993c4..f5e47771d 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -102,7 +102,7 @@ class Item extends CI_Model if($filters['stock_location_id'] > -1) { $this->db->select('max(item_quantities.item_id) as qty_item_id'); $this->db->select('max(item_quantities.location_id) as location_id'); - $this->db->select('sum(item_quantities.quantity) as quantity'); + $this->db->select('max(item_quantities.quantity) as quantity'); } $this->db->from('items as items'); diff --git a/application/models/Sale.php b/application/models/Sale.php index 5bc2b0a62..993e51a7d 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -163,8 +163,8 @@ class Sale extends CI_Model ROUND($sale_cost, $decimals) AS cost, ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit, IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due, - SUM(payments.sale_payment_amount) AS amount_tendered, - (SUM(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due, + MAX(payments.sale_payment_amount) AS amount_tendered, + (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due, " . ' MAX(payments.payment_type) AS payment_type ');