Skip to content

Instantly share code, notes, and snippets.

@jophde
Created June 19, 2020 18:58
Show Gist options
  • Save jophde/9a0f6e379307020272aa880beb90fd69 to your computer and use it in GitHub Desktop.
Save jophde/9a0f6e379307020272aa880beb90fd69 to your computer and use it in GitHub Desktop.
item_subtotal = 465.777
item_subtotal = 465.77
employee_discount = 46.58
monitor_price = 396.77
adapter_price = 69.00
monitor_price_ratio = monitor_price / item_subtotal
adapter_price_ratio = adapter_price / item_subtotal
monitor_discount = monitor_price_ratio * employee_discount
adapter_discount = adapter_price_ratio * employee_discount
monitor_discount = 39.67955557463984
adapter_discount = 6.900444425360155
monitor_price_after_discount_before_tax = monitor_price - monitor_discount
adapter_price_after_discount_before_tax = adapter_price - adapter_discount
monitor_price_after_discount_before_tax = 357.09044442536015
adapter_price_after_discount_before_tax = 62.099555574639844
adapter_price_after_discount_before_tax + monitor_price_after_discount_before_tax => 419.19
taxable_subtotal = adapter_price_after_discount_before_tax + monitor_price_after_discount_before_tax
monitor_ratio_taxable = monitor_price_after_discount_before_tax / taxable_subtotal
adapter_ratio_taxable = adapter_price_after_discount_before_tax / taxable_subtotal
monitor_ratio_taxable = 0.8518582132812332
adapter_ratio_taxable = 0.14814178671876677
taxes = 42.34
monitor_tax = monitor_ratio_taxable * taxes
adapter_tax = adapter_ratio_taxable * taxes
monitor_tax = 36.067676750327415
adapter_tax = 6.272323249672586
monitor_price_adjusted = monitor_price + monitor_tax - monitor_discount
adapter_price_adjusted = adapter_price + adapter_tax - adapter_discount
monitor_price_adjusted = 393.15812117568754
adapter_price_adjusted = 68.37187882431243
monitor_price_adjusted + adapter_price_adjusted = 461.53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment