diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index d3e3e4cc..0ce95e75 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -35,8 +35,8 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface const WARRANTY_FEE = 0; const OTHER_SERVICES_FEE = 200; const COOLANT_FEE = 1600; - const REFUEL_FEE_GAS = 260; - const REFUEL_FEE_DIESEL = 220; + const REFUEL_FEE_GAS = 300; + const REFUEL_FEE_DIESEL = 260; private $security; protected $em; @@ -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; + } } diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index e29d7aa5..e85a89f3 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -552,7 +552,7 @@
- +