Layered architecture decision

if i have 2 api items and invoice: the invoice api will reduce the items quantity is it better to make it on -make decrease quantity from items repo and import it to invoice service layer -same but import to invoice repo layer -make it on invoice repo layer because it relate on invoice
7 Replies
scot22
scot2212mo ago
Why not one api layer for both?
chnmrn.
chnmrn.12mo ago
both different must be separated different table
scot22
scot2212mo ago
Different schemas?
paxol
paxol12mo ago
I would call ItemRepo.decrease from invoice service layer, the "decrease item quantity when invoice things happen" is a business logic rule, so keep it outside of the repository
chnmrn.
chnmrn.11mo ago
how to increase the stock back when u delete invoice,is it impossible because my stock has different purchase price
scot22
scot2211mo ago
I mean it’s not impossible Maybe a diagram would help
chnmrn.
chnmrn.11mo ago
thx man ,alr solved im use history table to undo