mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-02-28 12:57:13 -05:00
Fix discount totals
This commit is contained in:
@@ -7,7 +7,7 @@ class Summary_discounts extends Summary_report
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array(
|
||||
array('discount' => $this->lang->line('reports_discount_percent'), 'sorter' => 'number_sorter'),
|
||||
array('discount' => $this->lang->line('reports_discount'), 'sorter' => 'number_sorter'),
|
||||
array('count' => $this->lang->line('reports_count')),
|
||||
array('total' => $this->lang->line('reports_total')));
|
||||
}
|
||||
@@ -16,12 +16,12 @@ class Summary_discounts extends Summary_report
|
||||
{
|
||||
if($inputs['discount_type'] == FIXED)
|
||||
{
|
||||
$this->db->select('SUM(payment_amount) AS total, MAX(CONCAT("'.$this->config->item('currency_symbol').'",sales_items.discount)) AS discount, count(*) AS count');
|
||||
$this->db->select('SUM(sales_items.discount) AS total, MAX(CONCAT("'.$this->config->item('currency_symbol').'",sales_items.discount)) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_type',FIXED);
|
||||
}
|
||||
elseif($inputs['discount_type'] == PERCENT)
|
||||
{
|
||||
$this->db->select('SUM(payment_amount) AS total, MAX(CONCAT(sales_items.discount, "%")) AS discount, count(*) AS count');
|
||||
$this->db->select('SUM(payment_amount) * sales_items.discount / 100.0 AS total, MAX(CONCAT(sales_items.discount, "%")) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_type',PERCENT);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ class Summary_discounts extends Summary_report
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
$this->db->join('sales_payments', 'sales_payments.sale_id = sales_items.sale_id');
|
||||
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
|
||||
$this->db->where('payment_type <>', 'Cash');
|
||||
|
||||
$this->_where($inputs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user