File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010### Added
1111- Make ` Currency ` JSON-serializable
1212
13+ ### Fixed
14+ - Wrap balance calculations in a database transaction
15+
1316## [ 0.21.0] - 2025-06-05
1417
1518### Added
Original file line number Diff line number Diff line change @@ -9,8 +9,13 @@ module Bill::ParentNetAmount
99 end
1010
1111 def net_amount ! : Amount
12- sum = amount!
13- sum -= self .credit_notes_amount! if responds_to?(:credit_notes_amount! )
12+ sum = Amount .new(0 )
13+
14+ self .class.database.transaction do
15+ sum += amount!
16+ sum -= self .credit_notes_amount! if responds_to?(:credit_notes_amount! )
17+ end
18+
1419 sum
1520 end
1621
Original file line number Diff line number Diff line change @@ -56,7 +56,12 @@ module Bill::InvoicesLedger
5656
5757 # :ditto:
5858 def over_owing !(user)
59- balance = @ledger .balance!(user) - amount_not_overdue!(user)
59+ balance = Amount .new(0 )
60+
61+ user.class.database.transaction do
62+ balance += @ledger .balance!(user) - amount_not_overdue!(user)
63+ end
64+
6065 balance if balance.debit?
6166 end
6267
You can’t perform that action at this time.
0 commit comments