A Transaction
contains one or more LineItem
. One LineItem
has a relation with an Item
. Every Item
has a number field that represent quantity in stock.
Using this approach, every Transaction
creation will need to decrease quantity in Item
. If user update a Transaction
then quantity in Item
will need to be adjusted. If user delete a Transaction
then quantity in Item
will need to be increased.
What is the best way to implement this rule or behaviour in domain model layer? Transaction
operations (like create, update, or delete) are located in data access layer.