double_entry icon indicating copy to clipboard operation
double_entry copied to clipboard

update account balance only after line creation is successful

Open ollaollu opened this issue 5 years ago • 1 comments

Had instances where during Line creation, AccountWouldBeSentNegative is thrown. This rolled back the Line record but the balance update for AccountBalance wasn't getting rolled back. This made positive-only accounts go into negative balances without creating corresponding line item records.

Ideally we want to make sure all Line items are created successfully before we update the account balance. That way, when any error gets thrown while creating a Line record, we wouldn't worry about any updates to the Account Balance.

ollaollu avatar Aug 25 '20 16:08 ollaollu

Isn't this all happening in a transaction anyway? I don't understand how this would possibly be happening ... could you perhaps write a failing test that passes after your changes?

swrobel avatar Oct 01 '20 20:10 swrobel