mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Show inflow/outflow totals for transfer filter (#1134)
* Show inflow/outflow totals when filtering by transfers When filtering transactions by "Transfer" type, the summary bar previously showed $0 for both Income and Expenses because transfers were excluded from those sums. Now computes transfer inflow/outflow in the same SQL pass and switches labels to "Inflow"/"Outflow" when transfer amounts are non-zero. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add mixed filter comment and transfer-only test coverage Document the intentional mixed filter behavior where transfer amounts are excluded from the summary bar when non-transfer types are present. Add test exercising Inflow/Outflow label switching for transfer-only results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
f1991eaefe
commit
f42b593b9e
@@ -159,7 +159,9 @@ end
|
||||
totals = OpenStruct.new(
|
||||
count: 1,
|
||||
expense_money: Money.new(10000, "USD"),
|
||||
income_money: Money.new(0, "USD")
|
||||
income_money: Money.new(0, "USD"),
|
||||
transfer_inflow_money: Money.new(0, "USD"),
|
||||
transfer_outflow_money: Money.new(0, "USD")
|
||||
)
|
||||
|
||||
Transaction::Search.expects(:new).with(family, filters: {}, accessible_account_ids: [ account.id ]).returns(search)
|
||||
@@ -181,7 +183,9 @@ end
|
||||
totals = OpenStruct.new(
|
||||
count: 1,
|
||||
expense_money: Money.new(10000, "USD"),
|
||||
income_money: Money.new(0, "USD")
|
||||
income_money: Money.new(0, "USD"),
|
||||
transfer_inflow_money: Money.new(0, "USD"),
|
||||
transfer_outflow_money: Money.new(0, "USD")
|
||||
)
|
||||
|
||||
Transaction::Search.expects(:new).with(family, filters: { "categories" => [ "Food" ], "types" => [ "expense" ] }, accessible_account_ids: [ account.id ]).returns(search)
|
||||
@@ -191,6 +195,31 @@ end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "shows inflow/outflow labels when filtering by transfers only" do
|
||||
family = families(:empty)
|
||||
sign_in users(:empty)
|
||||
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
|
||||
|
||||
create_transaction(account: account, amount: 100)
|
||||
|
||||
search = Transaction::Search.new(family, filters: { "types" => [ "transfer" ] })
|
||||
totals = OpenStruct.new(
|
||||
count: 2,
|
||||
expense_money: Money.new(0, "USD"),
|
||||
income_money: Money.new(0, "USD"),
|
||||
transfer_inflow_money: Money.new(5000, "USD"),
|
||||
transfer_outflow_money: Money.new(3000, "USD")
|
||||
)
|
||||
|
||||
Transaction::Search.expects(:new).with(family, filters: { "types" => [ "transfer" ] }, accessible_account_ids: [ account.id ]).returns(search)
|
||||
search.expects(:totals).once.returns(totals)
|
||||
|
||||
get transactions_url(q: { types: [ "transfer" ] })
|
||||
assert_response :success
|
||||
assert_select "#total-income", text: totals.transfer_inflow_money.format
|
||||
assert_select "#total-expense", text: totals.transfer_outflow_money.format
|
||||
end
|
||||
|
||||
test "mark_as_recurring creates a manual recurring transaction" do
|
||||
family = families(:empty)
|
||||
sign_in users(:empty)
|
||||
|
||||
Reference in New Issue
Block a user