database/algorithm for a rate structure

vucsmxpsfe

New Member
I have to calculate a price based on a rate structure along these lines:\[code\]$303.00 fixed price up to 500 units$0.023 additional per unit from 501-10,000 units$0.022 additional per unit from 10,001-25,000 units$0.021 additional per unit from 25,001-50,000 units\[/code\]I'm a little lost on setting up a database structure and algorithm (the larger sticking point) for calculating this. Has anyone done this? Is there a nice, elegant way of calculating this sort of thing?edit: As an example, a 25,100 unit run would cost $303.00 for the first 500 units, $218.50 for the next 9,500 units, $330.00 for the next 15,000 units, and $2.10 for the next 100 units, for a total of $853.60.It wouldn't be a simple 25,100 * $0.021 calculation - I'm well aware of how to select and calculate that.Similar to the way income tax is assessed - on a marginal basis.
 
Back
Top