Last active
July 20, 2021 01:50
-
-
Save wagura-maurice/c4cec4112df5346df25e4f6e86b0fb8b to your computer and use it in GitHub Desktop.
estimation of motor vehicle importation costs (including, importation duty payable) in Kenya.
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
<?php | |
/** | |
* A simple PHP function that calculates an estimation cost for car importation into kenya. | |
* | |
* @param int $cif This is the customs value of the vehicle i.e. the Cost, Insurance & Freight paid for the vehicle. | |
* @param int $clearance This is the clearing Agent's sum fee together with some other port handling charges. | |
* @param int $import_duty This is 25% of the CIF value of the vehicle. | |
* @param int $excise_duty This is 20% of the (CIF value + Import Duty). | |
* @param int $vat This is 16% of the (CIF value + Import Duty + Excise Duty). | |
* @param int $idf This is 2.25% of the CIF value or Ksh. 5,000, whichever is higher, is payable. | |
* @return string This is the final result. | |
*/ | |
public function duty_payable($cif = 440000, $clearance = 50000) : String | |
{ | |
$payable = new stdClass; | |
$payable->import_duty = getPercentOfNumber(25, $cif); | |
$payable->excise_duty = $cif + $payable->import_duty; | |
$payable->vat = getPercentOfNumber(16, ($cif + $payable->import_duty + $payable->excise_duty)); | |
$payable->idf = getPercentOfNumber(2.25, $cif) >= 5000 ? getPercentOfNumber(2.25, $cif) : 5000; | |
return number_format($payable->import_duty + $payable->excise_duty + $payable->vat + $payable->idf + $clearance, 2); | |
} | |
// load into script as a helper method. | |
if (! function_exists('getPercentOfNumber')) { | |
/** | |
* A simple PHP function that calculates the percentage of a given number. | |
* | |
* @param int $percent The percentage that you want to calculate. | |
* @param int $number The number you want a percentage of. | |
* @return int The final result. | |
*/ | |
function getPercentOfNumber($percent, $number) : int | |
{ | |
return ($percent / 100) * $number; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment