Skip to content

Instantly share code, notes, and snippets.

@domtalbot
Created July 11, 2018 20:03
Show Gist options
  • Save domtalbot/3c7ccf081a05939504bc4446066494e6 to your computer and use it in GitHub Desktop.
Save domtalbot/3c7ccf081a05939504bc4446066494e6 to your computer and use it in GitHub Desktop.
Pricing Calc
// The base price entered by the sculpter
$base_price = $result['Sculpture'] ['price']; // 1050
// Default vat rate to 1, changing to the standard 1.2 if vat is applicable.
$vat_rate = 1;
if ($result['Sculpture']['vat'] == 1) {
$vat_rate = 1.2;
}
// Get the commission rate, stored as a number eg. 33% = 1.33
$commission_rate = $result['Sculpture']['commission_rate']; // 2
// Calculate the commission amount, by multipling the base price by the commission rate then subtracting the base price
$commission_amount = ($base_price * $commission_rate) - $base_price; // 1050
// Calculate the vat amount by multiplying the base price by vat rate then subtracting the base price (always zero if vat rate is 1)
$vat_amount = ($base_price * $vat_rate) - $base_price; // 0
// Add up all of the different amounts
$brochure_price = $base_price + $commission_amount + $vat_amount; // 2100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment