Some New Features:
- Stock control multiple locations.
- Branch transfers.
- Remote back office client.
- Branch level pricing.
My personal blog.
VariablesNow the both the new price and the discount value will add up to the original price.
ItemPrice = 50.00
Discount = 14.49%
Calculate Discount Value (DisValue)
DisValue = ItemPrice * (Discount/100)
DisValue = 50.00 * (14.49/100)
DisValue = 50.00 * 0.1449
DisValue = 7.245
Calculate NewPrice
NewPrice = ItemPrice - DisValue
NewPrice = 50.00 - 7.245
NewPrice = 42.755
Round Down Values
NewPrice = 42.75
DisValue = 7.24
PriceDown = 49.99
Calculate CheckTotal
CheckTotal = NewPrice + DisValue
CheckTotal = 42.75 + 7.24
CheckTotal = 49.99
Calculate Missing Value
MissValue = ItemPrice - CheckTotal
MissValue = 50.00 - CheckTotal
MissValue = 0.01
Add Missing Discount
DisValue = DisValue + MissValue
DisValue = 7.25
VariablesAt this point we need to round the values, becuase prices have two decimal places. There are two options, we can either round the values up or down.
ItemPrice = 50.00
Discount = 14.49%
Calculate Discount Value (DisValue)
DisValue = ItemPrice * (Discount/100)
DisValue = 50.00 * (14.49/100)
DisValue = 50.00 * 0.1449
DisValue = 7.245
Calculate NewPrice
NewPrice = ItemPrice - DisValue
NewPrice = 50.00 - 7.245
NewPrice = 42.755
Round Up ValuesAs you can see, when we add up the rounded totals, they do not match the original item price. So we need find a way to solve this problem.
NewPrice = 42.76
DisValue = 7.25
Total = 50.01 (1p over)
Round Down Values
NewPrice = 42.75
DisValue = 7.24
Total = 49.99 (1p under)