When the client inserts an Order
and some Lineitems
, the business logic must check that the balance < creditLimit
. This requires that we derive the Customer's balance
from the Order.amountUnPaid
, a rollup of the Lineitem amounts
.
These rules:
- compute the Orders AmountTotal from the LineItems and Product for Ready Orders,
- roll this into the Customer Balance,
- and ensure the Balance does not exceed the Credit Limit
This example illusrates that rules apply automatically to many Stories:
- Delete Order - the balance is reduced
- Pay Order - the balance is reduced
- UnPay the Order - balance is increased
- Make Order Ready - balance increased
- Make Order Unready - balance reduced
- Reassign Order to a new customer - new customer balance increased, old balance decreased (for unpaid Orders)
- Reassign a Line Item to a different Product (see above)
- Add a Line Item
- Delete a Line Item
- Change Line Item Quantity
- Reassign Product to Line Item