I am working on a pricing algorithm where I want to generalize the calculation of certain components/charges. There are 3 components to the charges. 1 - a basic/core charge, 2- a handling charge (may have many number of  these), 3- tax components (may have many varieties of these as well).I am wondering if I can store an algorithm like below in a database and use this for calculating the charges every time.. Or is there a better way of handling such pricing in a flexible way?Step 1: Step1Result = Sum(value of component1, value of component2,    value of component4) (Let us say the freight charges  are the sum of a    few core charges) Step 2: Step2Result = Step1Result * .01 (let us say    some handling charge is about 1 percent on the step 1 result) Step 3:    Step3Result = Step1Result * .103 (let us say some tax on step 1    result is 10.3 percent) Step 4: Step4Result =  Step3Result * .0203    (let us say some special tax surcharge as 2.03 percent) Total:    TotalResult = step1result + step2result + step3result + step4result[Edit]Adding a sample of a logistics freight service which is what we are working on now.A Parcel booked may get transported from location A to Location E via C,D and E.So the base freight charge is calculated as the cost of transportation between A to B, B to C, C to E. The parcel may be unloaded from one vehicle at location D and loaded to another vehicle for which loading/unloading charges may have to be added. This may be a percentage of the transportation charge or an absolute value. There may be additional charges which may be added in the future as wellThen we may have some other premium facility chargesWe have taxes which will have to be computed not on the entire cost but one tax may go to basic freight charge and the other may go to the other charges and another set will be on the total cost.Now I need a flexible logic so that the calculation is configurable pricing logic for the user.If someone has worked on such a generic algorithm, pls give an idea. Please note that I have searched for such stuff in SO as well as google and unable to come up with a concrete one yet. If I missed something, please feel free to point out.Basically I would like to store the formula and workout the price with it. This logic is going to be implemented in C# and Sql Server. 
Storing simple / flexible pricing logic in the database
algorithms;pricing