Classic scenario, where an order has order lines.
The client wants to be able to apply a rebate to the entire order, that is either a fixed amount or a percentage.
What would be the best way to implement that?
I am thinking storing two fields on the order-object:
And then I can calculate the total rebate - and make the rebate an order line, that I re-calc every time the rebate-fields or order lines are changed.
Caveats, hints, best practices?
Take a look into using something like the composite pattern.
The rebates should not be stored within the objects themselves but should be applied as an external entity. Think about providing enough flexibility for realistic changes.