Calculates balance based on previous transaction on the same date (#1483)

This commit is contained in:
Nico
2024-11-22 11:38:41 -03:00
committed by GitHub
parent 6996a225ba
commit 242eb5cea1
2 changed files with 20 additions and 1 deletions

View File

@@ -110,4 +110,15 @@ class Account::EntryTest < ActiveSupport::TestCase
assert_equal Money.new(100), transaction.balance_after_entry
end
test "prior_entry_balance returns last transaction entry balance" do
family = families(:empty)
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
new_valuation = create_valuation(account: account, amount: 1)
transaction = create_transaction(date: new_valuation.date, account: account, amount: -100)
assert_equal Money.new(100), transaction.prior_entry_balance
end
end