Created
July 28, 2021 10:22
-
-
Save biscuitrainbow/05c5c30d8f4395ba51af47a4ae52cf80 to your computer and use it in GitHub Desktop.
Lab -5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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