1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-25 08:09:38 +02:00

Preserve original transaction names when enriching (#1556)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Preserve original transaction name

* Remove stale method

* Fix tests
This commit is contained in:
Zach Gollwitzer 2024-12-19 10:16:09 -05:00 committed by GitHub
parent 68617514b0
commit 7be6a372bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 100 additions and 76 deletions

View file

@ -10,7 +10,7 @@ class Account::Entry < ApplicationRecord
delegated_type :entryable, types: Account::Entryable::TYPES, dependent: :destroy
accepts_nested_attributes_for :entryable
validates :date, :amount, :currency, presence: true
validates :date, :name, :amount, :currency, presence: true
validates :date, uniqueness: { scope: [ :account_id, :entryable_type ] }, if: -> { account_valuation? }
validates :date, comparison: { greater_than: -> { min_supported_date } }
@ -47,14 +47,6 @@ class Account::Entry < ApplicationRecord
account.sync_later(start_date: sync_start_date)
end
def inflow?
amount <= 0 && account_transaction?
end
def outflow?
amount > 0 && account_transaction?
end
def entryable_name_short
entryable_type.demodulize.underscore
end
@ -63,6 +55,10 @@ class Account::Entry < ApplicationRecord
Account::BalanceTrendCalculator.new(self, entries, balances).trend
end
def display_name
enriched_name.presence || name
end
class << self
# arbitrary cutoff date to avoid expensive sync operations
def min_supported_date