Adapt Cashups to new Sales Summary Report

This commit is contained in:
Steve Ireland
2019-03-23 10:36:30 -04:00
parent a146bbaa86
commit 4ae1c575fc
2 changed files with 23 additions and 18 deletions

View File

@@ -106,22 +106,25 @@ class Cashups extends Secure_Controller
foreach($reports_data as $row)
{
if($row['payment_type'] == $this->lang->line('sales_cash'))
if($row['trans_group'] == $this->lang->line('reports_trans_payments'))
{
$cash_ups_info->closed_amount_cash += $this->xss_clean($row['payment_amount']);
}
elseif($row['payment_type'] == $this->lang->line('sales_due'))
{
$cash_ups_info->closed_amount_due += $this->xss_clean($row['payment_amount']);
}
elseif($row['payment_type'] == $this->lang->line('sales_debit') ||
$row['payment_type'] == $this->lang->line('sales_credit'))
{
$cash_ups_info->closed_amount_card += $this->xss_clean($row['payment_amount']);
}
elseif($row['payment_type'] == $this->lang->line('sales_check'))
{
$cash_ups_info->closed_amount_check += $this->xss_clean($row['payment_amount']);
if($row['trans_type'] == $this->lang->line('sales_cash'))
{
$cash_ups_info->closed_amount_cash += $this->xss_clean($row['trans_amount']);
}
elseif($row['trans_type'] == $this->lang->line('sales_due'))
{
$cash_ups_info->closed_amount_due += $this->xss_clean($row['trans_amount']);
}
elseif($row['trans_type'] == $this->lang->line('sales_debit') ||
$row['trans_type'] == $this->lang->line('sales_credit'))
{
$cash_ups_info->closed_amount_card += $this->xss_clean($row['trans_amount']);
}
elseif($row['trans_type'] == $this->lang->line('sales_check'))
{
$cash_ups_info->closed_amount_check += $this->xss_clean($row['trans_amount']);
}
}
}

View File

@@ -131,11 +131,9 @@ class Summary_payments extends Summary_report
{
$decimals = totals_decimals();
$tax = 'IFNULL(MAX(sumpay_taxes.total_taxes), 0)';
$trans_amount = 'ROUND(SUM(CASE WHEN sales_items.discount_type = ' . PERCENT
. ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) '
. 'ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END), ' . $decimals . ') + ' . $tax . ' AS trans_amount';
. 'ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END), ' . $decimals . ') AS trans_amount';
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sumpay_taxes_temp') .
@@ -163,6 +161,10 @@ class Summary_payments extends Summary_report
)'
);
$this->db->query('UPDATE ' . $this->db->dbprefix('sumpay_items_temp') . ' AS sumpay_items '
. 'SET trans_amount = trans_amount + (SELECT total_taxes FROM ' . $this->db->dbprefix('sumpay_taxes_temp')
. ' AS sumpay_taxes WHERE sumpay_items.sale_id = sumpay_taxes.sale_id)');
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sumpay_payments_temp') .
' (INDEX(sale_id))
(