Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save biscuitrainbow/05c5c30d8f4395ba51af47a4ae52cf80 to your computer and use it in GitHub Desktop.
Save biscuitrainbow/05c5c30d8f4395ba51af47a4ae52cf80 to your computer and use it in GitHub Desktop.
Lab -5
$data = $request->getParsedBody();
$price = (float)$data['price'];
$hasVat = @$data['hasVat'];
$hasTax = @$data['hasTax'];
$vat = $data['vat'];
$tax = $data['tax'];
if ($hasVat) {
if ($vat == 'included') {
$priceExcludeVat = $price * (100 / 107);
$VatCost = $price - $priceExcludeVat;
} else {
$priceExcludeVat = $price;
$VatCost = $price * (7 / 100);
}
} else {
$priceExcludeVat = $price;
$VatCost = 0;
}
$taxCost = 0;
if($hasTax) {
$taxCost = $priceExcludeVat * ($tax / 100);
}
$payment = $priceExcludeVat + $VatCost - $taxCost;
$priceIncludeVat = $priceExcludeVat + $VatCost;
return view('payment-result', [
'price' => $price,
'hasTax' => $hasTax,
'hasVat' => $hasVat,
'vat' => $vat,
'tax' => $tax,
'priceExcludeVat' => $priceExcludeVat,
'VatCost' => $VatCost,
'taxCost' => $taxCost,
'payment' => $payment,
'priceIncludeVat' => $priceIncludeVat,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment