So, I need to implement a very flexible way to calculate a price of an item - a service really. I have the following requirements:
- List item
- Different service items
- Different service types (private or business)
- Different service packages (from starter to pro)
- Base prices that depend on the country of origin of the customer
- VAT taxation based on country of origin of the customer
- Special pricing for partners (5-10% off the base price)
- Various add ons that can be booked together with the main item to which all of the above applies
- Some of the add ons can only be booked together with certain base items
- Annual/Monthly recurrent billing
- Over time the price of an item, or its VAT rate will change, due to a promotion or a price drop or hike - this price change will only apply to new users, not old ones that get the recurrent billings
My current method of having one complex class per service article breaks down at requirement 10 and 11 from the above list. No way to maintain that. I am thinking about using a decorator or chain pattern, but then I will have to worry about order of by decorator/chain items and how to store them. Does anybody have an idea in which direction I should take this and which patterny are applicable?
Aucun commentaire:
Enregistrer un commentaire