Fix included destination tax

This commit is contained in:
SteveIreland committed 2020-06-28 18:12:46 -04:00
1 parent be44fb2aa7
commit 6d91ae3845
4 files changed
+58 -56

No files matched your search

+15 -17
View File
@@ -472,29 +472,27 @@ class Sale_lib
$prediscount_subtotal= bcadd($prediscount_subtotal, $extended_amount);
$total = bcadd($total, $extended_discounted_amount);
if($this->CI->config->item('tax_included'))
{
$subtotal = bcadd($subtotal, $this->get_extended_total_tax_exclusive($item['item_id'], $extended_discounted_amount, $item['quantity'], $item['price'], $item['discount'],$item['discount_type']));
}
else
{
$subtotal = bcadd($subtotal, $extended_discounted_amount);
}
$subtotal = bcadd($subtotal, $extended_discounted_amount);
}
$totals['prediscount_subtotal'] = $prediscount_subtotal;
$totals['total_discount'] = $total_discount;
$totals['subtotal'] = $subtotal;
$sales_tax = 0;
foreach($taxes as $tax_excluded)
foreach($taxes as $tax)
{
if($tax_excluded['tax_type'] == Tax_lib::TAX_TYPE_EXCLUDED)
if($tax['tax_type'] === Tax_lib::TAX_TYPE_EXCLUDED)
{
$total = bcadd($total, $tax_excluded['sale_tax_amount']);
$sales_tax = bcadd($sales_tax, $tax_excluded['sale_tax_amount']);
$total = bcadd($total, $tax['sale_tax_amount']);
$sales_tax = bcadd($sales_tax, $tax['sale_tax_amount']);
}
else
{
$subtotal = bcsub($subtotal, $tax['sale_tax_amount']);
}
}
$totals['subtotal'] = $subtotal;
$totals['total'] = $total;
$totals['tax_total'] = $sales_tax;
@@ -1215,19 +1213,19 @@ class Sale_lib
public function get_item_tax($quantity, $price, $discount, $discount_type, $tax_percentage)
{
$price = $this->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
$item_total = $this->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
if($this->CI->config->item('tax_included'))
{
$tax_fraction = bcdiv(bcadd(100, $tax_percentage), 100);
$price_tax_excl = bcdiv($price, $tax_fraction);
$price_tax_excl = bcdiv($item_total, $tax_fraction);
return bcsub($price, $price_tax_excl);
return bcsub($item_total, $price_tax_excl);
}
$tax_fraction = bcdiv($tax_percentage, 100);
return bcmul($price, $tax_fraction);
return bcmul($item_total, $tax_fraction);
}
public function calculate_subtotal($include_discount = FALSE, $exclude_tax = FALSE)