mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Do not include income transactions in liability accounts for savings rate (#1385)
* Do not include income transactions in liability accounts for savings rate * Do not include income in liability accounts in savings rate chart
This commit is contained in:
parent
7946cd7819
commit
2b61821336
2 changed files with 5 additions and 1 deletions
|
@ -71,7 +71,9 @@ class Family < ApplicationRecord
|
|||
end
|
||||
|
||||
def snapshot_transactions
|
||||
candidate_entries = entries.account_transactions.without_transfers
|
||||
candidate_entries = entries.account_transactions.without_transfers.excluding(
|
||||
entries.joins(:account).where(amount: ..0, accounts: { classification: Account.classifications[:liability] })
|
||||
)
|
||||
rolling_totals = Account::Entry.daily_rolling_totals(candidate_entries, self.currency, period: Period.last_30_days)
|
||||
|
||||
spending = []
|
||||
|
|
|
@ -125,9 +125,11 @@ class FamilyTest < ActiveSupport::TestCase
|
|||
|
||||
test "calculates rolling transaction totals" do
|
||||
account = create_account(balance: 1000, accountable: Depository.new)
|
||||
liability_account = create_account(balance: 1000, accountable: Loan.new)
|
||||
create_transaction(account: account, date: 2.days.ago.to_date, amount: -500)
|
||||
create_transaction(account: account, date: 1.day.ago.to_date, amount: 100)
|
||||
create_transaction(account: account, date: Date.current, amount: 20)
|
||||
create_transaction(account: liability_account, date: 2.days.ago.to_date, amount: -333)
|
||||
|
||||
snapshot = @family.snapshot_transactions
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue