1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +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

@ -77,12 +77,20 @@ class Account::Entry < ApplicationRecord
end
def transfer_match_candidates
account.family.entries
.where.not(account_id: account_id)
.where.not(id: id)
.where(amount: -amount)
.where(currency: currency)
.where(date: (date - 4.days)..(date + 4.days))
candidates_scope = account.transfer_match_candidates
candidates_scope = if amount.negative?
candidates_scope.where("inflow_candidates.entryable_id = ?", entryable_id)
else
candidates_scope.where("outflow_candidates.entryable_id = ?", entryable_id)
end
candidates_scope.map do |pm|
Transfer.new(
inflow_transaction_id: pm.inflow_transaction_id,
outflow_transaction_id: pm.outflow_transaction_id,
)
end
end
class << self