Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nil name for entries #1550

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
4 changes: 3 additions & 1 deletion app/models/account/data_enricher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def enrich_transactions
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?
Expand All @@ -48,7 +50,7 @@ def enrich_transactions
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
Expand Down
2 changes: 1 addition & 1 deletion app/models/account/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def searchable_keys
end

def name
entry.name || "(no description)"
entry.name || (entry.amount.positive? ? "Expense" : "Income")
end

def eod_balance
Expand Down
4 changes: 4 additions & 0 deletions app/models/account/valuation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ def requires_search?(_params)
false
end
end

def name
"Balance update"
end
end
6 changes: 3 additions & 3 deletions app/views/account/transactions/_transaction.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<% if entry.account_transaction.merchant&.icon_url %>
<%= image_tag entry.account_transaction.merchant.icon_url, class: "w-6 h-6 rounded-full" %>
<% else %>
<%= render "shared/circle_logo", name: entry.name, size: "sm" %>
<%= render "shared/circle_logo", name: transaction.name, size: "sm" %>
<% end %>

<div class="truncate">
<% if entry.new_record? %>
<%= content_tag :p, entry.name %>
<%= content_tag :p, transaction.name %>
<% else %>
<%= link_to entry.name,
<%= link_to transaction.name,
entry.transfer.present? ? account_transfer_path(entry.transfer) : account_entry_path(entry),
data: { turbo_frame: "drawer", turbo_prefetch: false },
class: "hover:underline hover:text-gray-800" %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/account/valuations/_valuation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

<div class="truncate text-gray-900">
<% if entry.new_record? %>
<%= content_tag :p, entry.name %>
<%= content_tag :p, entry.entryable.name %>
<% else %>
<%= link_to entry.name || t(".balance_update"),
<%= link_to entry.entryable.name,
account_entry_path(entry),
data: { turbo_frame: "drawer", turbo_prefetch: false },
class: "hover:underline hover:text-gray-800" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_circle_logo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

<%= tag.div style: mixed_hex_styles(hex),
class: [size_classes[size], "flex shrink-0 items-center justify-center rounded-full"] do %>
<%= tag.span name[0].upcase, class: ["font-medium", size == "sm" ? "text-xs" : "text-sm"] %>
<%= tag.span (name.presence&.first || "T").upcase, class: ["font-medium", size == "sm" ? "text-xs" : "text-sm"] %>
<% end %>
27 changes: 0 additions & 27 deletions bin/erblint

This file was deleted.

2 changes: 0 additions & 2 deletions config/locales/views/account/valuations/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
en:
account:
valuations:
valuation:
balance_update: Balance update
form:
amount: Amount
submit: Add balance update
Expand Down
3 changes: 2 additions & 1 deletion config/locales/views/settings/hostings/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ en:
settings:
hostings:
data_enrichment_settings:
description: Enable data enrichment for your account transactions. This will incur additional Synth credits.
description: Enable data enrichment for your account transactions. This will
incur additional Synth credits.
title: Data Enrichment
invite_code_settings:
description: Every new user that joins your instance of Maybe can only do
Expand Down
Loading