Fix VAT computation when trade ins and discounts are present. #636
This commit is contained in:
parent
97070ded9a
commit
44611915e5
1 changed files with 27 additions and 3 deletions
|
|
@ -363,6 +363,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
|
||||
$this->processBatteries($total, $con_batts, $invoice);
|
||||
$this->processTradeIns($total, $con_tis, $invoice);
|
||||
$this->processVAT($total);
|
||||
}
|
||||
|
||||
protected function processBatteries(&$total, $con_batts, Invoice $invoice)
|
||||
|
|
@ -374,12 +375,13 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
$qty = $con_data['qty'];
|
||||
|
||||
$sell_price = $batt->getSellingPrice();
|
||||
$vat = $this->getTaxAmount($sell_price);
|
||||
// comment out the getting of tax amount
|
||||
// $vat = $this->getTaxAmount($sell_price);
|
||||
// $vat_ex_price = $this->getTaxExclusivePrice($sell_price);
|
||||
|
||||
$total['sell_price'] += $sell_price * $qty;
|
||||
$total['vat'] += $vat * $qty;
|
||||
$total['vat_ex_price'] += ($sell_price - $vat) * $qty;
|
||||
// $total['vat'] += $vat * $qty;
|
||||
// $total['vat_ex_price'] += ($sell_price - $vat) * $qty;
|
||||
|
||||
$total['total_price'] += $sell_price * $qty;
|
||||
|
||||
|
|
@ -816,4 +818,26 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
}
|
||||
return $cust_tag_info;
|
||||
}
|
||||
|
||||
protected function processVAT(&$total)
|
||||
{
|
||||
// total trade in amount to deduct from SRP before we compute VAT
|
||||
$total_ti_amt = 0;
|
||||
// need to check if there are trade-ins
|
||||
if (isset($total['ti_rate']))
|
||||
$total_ti_amt = $total['ti_rate'];
|
||||
|
||||
// compute the vat for battery
|
||||
// get the total selling price. That should be SRP.
|
||||
// we need to deduct the trade-ins before computing VAT
|
||||
$total_srp = $total['sell_price'];
|
||||
|
||||
$total_price_minus_ti = bcsub($total_srp, $total_ti_amt, 2);
|
||||
|
||||
$total_vat = $this->getTaxAmount($total_price_minus_ti);
|
||||
$total_vat_ex_price = bcsub($total_price_minus_ti, $total_vat, 2);
|
||||
|
||||
$total['vat'] = $total_vat;
|
||||
$total['vat_ex_price'] = $total_vat_ex_price;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue