Adjust computation for services #167 #1011
1 changed files with 19 additions and 12 deletions
|
|
@ -27,7 +27,8 @@ class InvoiceCreator
|
||||||
public function getVATAmount($price)
|
public function getVATAmount($price)
|
||||||
{
|
{
|
||||||
$vat_ex_price = $this->getVATExclusivePrice($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)
|
public function getVATExclusivePrice($price)
|
||||||
|
|
@ -300,9 +301,10 @@ class InvoiceCreator
|
||||||
$total_price += 1600;
|
$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['total_price'] = $total_price;
|
||||||
$total['vat_ex_price'] = $total_price - $vat;
|
$total['vat_ex_price'] = $vat_ex_price;
|
||||||
$total['vat'] = $vat;
|
$total['vat'] = $vat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,9 +324,10 @@ class InvoiceCreator
|
||||||
$invoice->addItem($item);
|
$invoice->addItem($item);
|
||||||
$total_price = $fee;
|
$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['total_price'] = $total_price;
|
||||||
$total['vat_ex_price'] = $total_price - $vat;
|
$total['vat_ex_price'] = $vat_ex_price;
|
||||||
$total['vat'] = $vat;
|
$total['vat'] = $vat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,6 +351,9 @@ class InvoiceCreator
|
||||||
$total_price = $fee;
|
$total_price = $fee;
|
||||||
// $total['total_price'] = 200.00;
|
// $total['total_price'] = 200.00;
|
||||||
|
|
||||||
|
$gas_price = 260;
|
||||||
|
$diesel_price = 220;
|
||||||
|
|
||||||
$fuel = new InvoiceItem();
|
$fuel = new InvoiceItem();
|
||||||
error_log('fuel type - ' . $ftype);
|
error_log('fuel type - ' . $ftype);
|
||||||
switch ($ftype)
|
switch ($ftype)
|
||||||
|
|
@ -356,20 +362,20 @@ class InvoiceCreator
|
||||||
$fuel->setInvoice($invoice)
|
$fuel->setInvoice($invoice)
|
||||||
->setTitle('4L Fuel - Gas')
|
->setTitle('4L Fuel - Gas')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(240);
|
->setPrice($gas_price);
|
||||||
$invoice->addItem($fuel);
|
$invoice->addItem($fuel);
|
||||||
$total_price += 240.00;
|
$total_price += $gas_price;
|
||||||
break;
|
break;
|
||||||
case FuelType::DIESEL:
|
case FuelType::DIESEL:
|
||||||
$fuel->setInvoice($invoice)
|
$fuel->setInvoice($invoice)
|
||||||
->setTitle('4L Fuel - Diesel')
|
->setTitle('4L Fuel - Diesel')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(200);
|
->setPrice($diesel_price);
|
||||||
$total_price += 200.00;
|
$total_price += $diesel_price;
|
||||||
$invoice->addItem($fuel);
|
$invoice->addItem($fuel);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// should never get to this point
|
// NOTE: should never get to this point
|
||||||
$fuel->setInvoice($invoice)
|
$fuel->setInvoice($invoice)
|
||||||
->setTitle('Fuel - Unknown')
|
->setTitle('Fuel - Unknown')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
|
|
@ -379,9 +385,10 @@ class InvoiceCreator
|
||||||
break;
|
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['total_price'] = $total_price;
|
||||||
$total['vat_ex_price'] = $total_price - $vat;
|
$total['vat_ex_price'] = $vat_ex_price;
|
||||||
$total['vat'] = $vat;
|
$total['vat'] = $vat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue