I'm developing a price calculation engine. I've looked all over and there's nothing that really fits what we need. However, I'm now looking how to implement specific prices and/or discounts. I don't want to introduce a rule based engine to my end-users, because they won't get it.
For example, when you order an ItemX the price is $30. But in combination with ItemY the price of ItemX is $20. Or when ordering five of ItemX, each after it will be only $15.
Any ideas on where to start? How to take this on? Perhaps some (open source) example applications that contain practices like these? Any (technical) patterns I could use? Preferably in C#. Thanks in advance!
There are many ways you can achieve this, but I think the one which might be most useful for you would be to define a DSL that you can use to express your discounts in such a way where they can be easily explained and rationalised with business users. An example from one of ayende's articles on DSLs in boo is:
apply_discount_of 5.percent:
when order.Total > 1000 and customer.IsPreferred
when order.Total > 10000
suggest_registered_to_preferred:
when order.Total > 100 and not customer.IsPreferred
As you can see you can see, this is the kind of thing you can print out and show to a client and they will immediately understand what's going on.
Of course developing something like this is time consuming, expensive and fraught with funky edge cases. However it has the benefit of being code which can be unit tested, executed and debugged.
If boo isn't your thing, then maybe you could look at defining something similar in ironruby, ironpython or F#. I would however suggest staying away from XML for defining these rules unless you really enjoy a world of pain.
This is however the kind of thing that products like Biztalk were designed to handle. Which rules engines have you evaluated and found lacking?
We use a Rule Engine for this type of complex calculation. Our platform is Java and we use Drools (which we're happy with). Drools is also available for .Net. Here's a list of open source Rules Engines for .NET.
I am sorry to have to say this, but this would seem like you would have to apply some Pricing Rule Engine to achive what you are after.
Would seem like you have to
In general there is a lot of possible rules/combinations that can be thought of, and you as developer can implement these and hide them from the user, or allow the user to create them, but somebody has to do so.
And then, when you dont feel like implementing your own, GOOGLE shold provide some:
Open Source Rule Engines
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With