1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Transaction transfers, payments, and matching (#883)

* Add transfer model and clean up family snapshot fixtures

* Ignore transfers in income and expense snapshots

* Add transfer validations

* Implement basic transfer matching UI

* Fix merge conflicts

* Add missing translations

* Tweak selection states for transfer types

* Add missing i18n translation
This commit is contained in:
Zach Gollwitzer 2024-06-19 06:52:08 -04:00 committed by GitHub
parent b462bc8f8c
commit ca39b26070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 991 additions and 427 deletions

View file

@ -5,16 +5,6 @@ class AccountTest < ActiveSupport::TestCase
def setup
@account = accounts(:checking)
@family = families(:dylan_family)
@snapshots = CSV.read("test/fixtures/family/expected_snapshots.csv", headers: true).map do |row|
{
"date" => (Date.current + row["date_offset"].to_i.days).to_date,
"assets" => row["assets"],
"liabilities" => row["liabilities"],
"Account::Depository" => row["depositories"],
"Account::Credit" => row["credits"],
"Account::OtherAsset" => row["other_assets"]
}
end
end
test "new account should be valid" do
@ -47,26 +37,23 @@ class AccountTest < ActiveSupport::TestCase
test "syncs regular account" do
@account.sync
assert_equal "ok", @account.status
assert_equal 31, @account.balances.count
assert_equal 32, @account.balances.count
end
test "syncs foreign currency account" do
account = accounts(:eur_checking)
account.sync
assert_equal "ok", account.status
assert_equal 31, account.balances.where(currency: "USD").count
assert_equal 31, account.balances.where(currency: "EUR").count
assert_equal 32, account.balances.where(currency: "USD").count
assert_equal 32, account.balances.where(currency: "EUR").count
end
test "groups accounts by type" do
@family.accounts.each do |account|
account.sync
end
result = @family.accounts.by_group(period: Period.all)
expected_assets = @snapshots.last["assets"].to_d
expected_liabilities = @snapshots.last["liabilities"].to_d
assets = result[:assets]
liabilities = result[:liabilities]
@ -84,14 +71,14 @@ class AccountTest < ActiveSupport::TestCase
other_liabilities = liabilities.children.find { |group| group.name == "Account::OtherLiability" }
assert_equal 4, depositories.children.count
assert_equal 0, properties.children.count
assert_equal 0, vehicles.children.count
assert_equal 0, investments.children.count
assert_equal 1, properties.children.count
assert_equal 1, vehicles.children.count
assert_equal 1, investments.children.count
assert_equal 1, other_assets.children.count
assert_equal 1, credits.children.count
assert_equal 0, loans.children.count
assert_equal 0, other_liabilities.children.count
assert_equal 1, loans.children.count
assert_equal 1, other_liabilities.children.count
end
test "generates series with last balance equal to current account balance" do