Sunday, February 25, 2007

Calculating Discounts

Today we found an interesting bug in the software when discounts are applied to the transaction.

Here is an example.
Variables
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
At 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.
Round Up Values
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)
As 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.

Wednesday, February 21, 2007

Two Jobs

Yes I now have two jobs!

Mode is now its own company and I've just started part time in a support role. I may also do some occasional development work.

I don't know if I should revive my old blog.

Sunday, February 04, 2007

New Guinness

There is a new Guinness pint coming to a pub near you.

Guinness Red!

Can't wait to give it a try.