mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 04:55:20 +02:00
Start and end balance breakdown in activity view (#2466)
* Initial data objects * Remove trend calculator * Fill in balance reconciliation for entry group * Initial tooltip component * Balance trends in activity view * Lint fixes * trade partial alignment fix * Tweaks to balance calculation to acknowledge holdings value better * More lint fixes * Bump brakeman dep * Test fixes * Remove unused class
This commit is contained in:
parent
ab6fdbbb68
commit
e8eb32d2ae
27 changed files with 1088 additions and 119 deletions
|
@ -15,33 +15,6 @@ module EntriesTestHelper
|
|||
Entry.create! entry_defaults.merge(entry_attributes)
|
||||
end
|
||||
|
||||
def create_opening_anchor_valuation(account:, balance:, date:)
|
||||
create_valuation(
|
||||
account: account,
|
||||
kind: "opening_anchor",
|
||||
amount: balance,
|
||||
date: date
|
||||
)
|
||||
end
|
||||
|
||||
def create_reconciliation_valuation(account:, balance:, date:)
|
||||
create_valuation(
|
||||
account: account,
|
||||
kind: "reconciliation",
|
||||
amount: balance,
|
||||
date: date
|
||||
)
|
||||
end
|
||||
|
||||
def create_current_anchor_valuation(account:, balance:, date: Date.current)
|
||||
create_valuation(
|
||||
account: account,
|
||||
kind: "current_anchor",
|
||||
amount: balance,
|
||||
date: date
|
||||
)
|
||||
end
|
||||
|
||||
def create_valuation(attributes = {})
|
||||
entry_attributes = attributes.except(:kind)
|
||||
valuation_attributes = attributes.slice(:kind)
|
||||
|
@ -77,4 +50,33 @@ module EntriesTestHelper
|
|||
currency: currency,
|
||||
entryable: trade
|
||||
end
|
||||
|
||||
def create_transfer(from_account:, to_account:, amount:, date: Date.current, currency: "USD")
|
||||
outflow_transaction = Transaction.create!(kind: "funds_movement")
|
||||
inflow_transaction = Transaction.create!(kind: "funds_movement")
|
||||
|
||||
transfer = Transfer.create!(
|
||||
outflow_transaction: outflow_transaction,
|
||||
inflow_transaction: inflow_transaction
|
||||
)
|
||||
|
||||
# Create entries for both accounts
|
||||
from_account.entries.create!(
|
||||
name: "Transfer to #{to_account.name}",
|
||||
date: date,
|
||||
amount: -amount.abs,
|
||||
currency: currency,
|
||||
entryable: outflow_transaction
|
||||
)
|
||||
|
||||
to_account.entries.create!(
|
||||
name: "Transfer from #{from_account.name}",
|
||||
date: date,
|
||||
amount: amount.abs,
|
||||
currency: currency,
|
||||
entryable: inflow_transaction
|
||||
)
|
||||
|
||||
transfer
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue