1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Handle nil name for entries (#1550)

* Handle nil name for entries

* Fix tests
This commit is contained in:
Zach Gollwitzer 2024-12-16 12:52:11 -05:00 committed by GitHub
parent 9130089950
commit 45add7512b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 16 additions and 38 deletions

View file

@ -23,6 +23,8 @@ class Account::DataEnricher
candidates.each do |entry|
if entry.enriched_at.nil? || entry.entryable.merchant_id.nil? || entry.entryable.category_id.nil?
begin
next unless entry.name.present?
info = self.class.synth_provider.enrich_transaction(entry.name).info
next unless info.present?
@ -48,7 +50,7 @@ class Account::DataEnricher
category.save! if category.present?
entry.update!(
enriched_at: Time.current,
name: entry.enriched_at.nil? ? info.name : entry.name,
name: entry.enriched_at.nil? && info.name ? info.name : entry.name,
entryable_attributes: entryable_attributes
)
end

View file

@ -49,7 +49,7 @@ class Account::Transaction < ApplicationRecord
end
def name
entry.name || "(no description)"
entry.name || (entry.amount.positive? ? "Expense" : "Income")
end
def eod_balance

View file

@ -10,4 +10,8 @@ class Account::Valuation < ApplicationRecord
false
end
end
def name
"Balance update"
end
end