Adjust computation for services #167

This commit is contained in:
Kendrick Chan 2018-11-06 15:14:22 +08:00
parent 15ad135d48
commit 2f32f9666d

View file

@ -27,7 +27,8 @@ class InvoiceCreator
public function getVATAmount($price)
{
$vat_ex_price = $this->getVATExclusivePrice($price);
return round($vat_ex_price * self::VAT_RATE, 2);
return $price - $vat_ex_price;
// return round($vat_ex_price * self::VAT_RATE, 2);
}
public function getVATExclusivePrice($price)
@ -300,9 +301,10 @@ class InvoiceCreator
$total_price += 1600;
}
$vat = round($total_price * self::VAT_RATE, 2);
$vat_ex_price = $this->getVATExclusivePrice($total_price);
$vat = $total_price - $vat_ex_price;
$total['total_price'] = $total_price;
$total['vat_ex_price'] = $total_price - $vat;
$total['vat_ex_price'] = $vat_ex_price;
$total['vat'] = $vat;
}
@ -322,9 +324,10 @@ class InvoiceCreator
$invoice->addItem($item);
$total_price = $fee;
$vat = round($total_price * self::VAT_RATE, 2);
$vat_ex_price = $this->getVATExclusivePrice($total_price);
$vat = $total_price - $vat_ex_price;
$total['total_price'] = $total_price;
$total['vat_ex_price'] = $total_price - $vat;
$total['vat_ex_price'] = $vat_ex_price;
$total['vat'] = $vat;
}
@ -348,6 +351,9 @@ class InvoiceCreator
$total_price = $fee;
// $total['total_price'] = 200.00;
$gas_price = 260;
$diesel_price = 220;
$fuel = new InvoiceItem();
error_log('fuel type - ' . $ftype);
switch ($ftype)
@ -356,20 +362,20 @@ class InvoiceCreator
$fuel->setInvoice($invoice)
->setTitle('4L Fuel - Gas')
->setQuantity(1)
->setPrice(240);
->setPrice($gas_price);
$invoice->addItem($fuel);
$total_price += 240.00;
$total_price += $gas_price;
break;
case FuelType::DIESEL:
$fuel->setInvoice($invoice)
->setTitle('4L Fuel - Diesel')
->setQuantity(1)
->setPrice(200);
$total_price += 200.00;
->setPrice($diesel_price);
$total_price += $diesel_price;
$invoice->addItem($fuel);
break;
default:
// should never get to this point
// NOTE: should never get to this point
$fuel->setInvoice($invoice)
->setTitle('Fuel - Unknown')
->setQuantity(1)
@ -379,9 +385,10 @@ class InvoiceCreator
break;
}
$vat = round($total_price * self::VAT_RATE, 2);
$vat_ex_price = $this->getVATExclusivePrice($total_price);
$vat = $total_price - $vat_ex_price;
$total['total_price'] = $total_price;
$total['vat_ex_price'] = $total_price - $vat;
$total['vat_ex_price'] = $vat_ex_price;
$total['vat'] = $vat;
}