Fix summary report and detailed sale report different tax issue (#1133)

This commit is contained in:
FrancescoUK
2017-07-03 20:13:37 +01:00
parent 0057c77721
commit 3f73e449f0
2 changed files with 13 additions and 13 deletions

View File

@@ -146,17 +146,17 @@ class Sale extends CI_Model
$decimals = totals_decimals();
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
$sale_cost = 'ROUND(SUM(sales_items.item_cost_price * sales_items.quantity_purchased), ' . $decimals . ')';
$tax = 'ROUND(IFNULL(SUM(sales_items_taxes.tax), 0), ' . $decimals . ')';
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
if($this->config->item('tax_included'))
{
$sale_total = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_total = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_subtotal = $sale_total . ' - ' . $tax;
}
else
{
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_total = $sale_subtotal . ' + ' . $tax;
}
@@ -1084,17 +1084,17 @@ class Sale extends CI_Model
$decimals = totals_decimals();
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
$sale_cost = 'ROUND(IFNULL(SUM(sales_items.item_cost_price * sales_items.quantity_purchased), 0), ' . $decimals . ')';
$tax = 'ROUND(IFNULL(SUM(sales_items_taxes.tax), 0), ' . $decimals . ')';
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
if($this->config->item('tax_included'))
{
$sale_total = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_total = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_subtotal = $sale_total . ' - ' . $tax;
}
else
{
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_total = $sale_subtotal . ' + ' . $tax;
}

View File

@@ -24,17 +24,17 @@ abstract class Summary_report extends Report
$decimals = totals_decimals();
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
$sale_cost = 'ROUND(IFNULL(SUM(sales_items.item_cost_price * sales_items.quantity_purchased), 0), ' . $decimals . ')';
$tax = 'ROUND(IFNULL(SUM(sales_items_taxes.tax), 0), ' . $decimals . ')';
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
if($this->config->item('tax_included'))
{
$sale_total = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_total = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_subtotal = $sale_total . ' - ' . $tax;
}
else
{
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '),' . $decimals . ')';
$sale_subtotal = 'ROUND(SUM(' . $sale_price . '), ' . $decimals . ')';
$sale_total = $sale_subtotal . ' + ' . $tax;
}
@@ -51,7 +51,7 @@ abstract class Summary_report extends Report
ON sales.sale_id = sales_items_taxes.sale_id
INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
WHERE sale_status = 0 AND ' . $where . '
WHERE sales.sale_status = 0 AND ' . $where . '
GROUP BY sale_id, item_id, line
)'
);