1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00

Add RejectedTransfer model, simplify auto matching (#1690)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Allow transfers to match when inflow is after outflow

* Simplify transfer auto matching with RejectedTransfer model

* Validations

* Reset migrations
This commit is contained in:
Zach Gollwitzer 2025-01-27 16:56:46 -05:00 committed by GitHub
parent 0b4e314f58
commit de90b29201
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 221 additions and 79 deletions

View file

@ -14,15 +14,6 @@ class TransferTest < ActiveSupport::TestCase
end
end
test "auto matches transfers" do
outflow_entry = create_transaction(date: 1.day.ago.to_date, account: accounts(:depository), amount: 500)
inflow_entry = create_transaction(date: Date.current, account: accounts(:credit_card), amount: -500)
assert_difference -> { Transfer.count } => 1 do
Transfer.auto_match_for_account(accounts(:depository))
end
end
test "transfer has different accounts, opposing amounts, and within 4 days of each other" do
outflow_entry = create_transaction(date: 1.day.ago.to_date, account: accounts(:depository), amount: 500)
inflow_entry = create_transaction(date: Date.current, account: accounts(:credit_card), amount: -500)
@ -131,4 +122,16 @@ class TransferTest < ActiveSupport::TestCase
transfer.save!
end
end
test "transaction can only belong to one transfer" do
outflow_entry = create_transaction(date: Date.current, account: accounts(:depository), amount: 500)
inflow_entry1 = create_transaction(date: Date.current, account: accounts(:credit_card), amount: -500)
inflow_entry2 = create_transaction(date: Date.current, account: accounts(:credit_card), amount: -500)
Transfer.create!(inflow_transaction: inflow_entry1.account_transaction, outflow_transaction: outflow_entry.account_transaction)
assert_raises ActiveRecord::RecordInvalid do
Transfer.create!(inflow_transaction: inflow_entry2.account_transaction, outflow_transaction: outflow_entry.account_transaction)
end
end
end