mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 12:49:38 +02:00
Handle nil name for entries (#1550)
* Handle nil name for entries * Fix tests
This commit is contained in:
parent
9130089950
commit
45add7512b
10 changed files with 16 additions and 38 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,4 +10,8 @@ class Account::Valuation < ApplicationRecord
|
|||
false
|
||||
end
|
||||
end
|
||||
|
||||
def name
|
||||
"Balance update"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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" %>
|
||||
|
|
|
@ -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" %>
|
||||
|
|
|
@ -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
bin/erblint
27
bin/erblint
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'erblint' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
bundle_binstub = File.expand_path("bundle", __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
load Gem.bin_path("erb_lint", "erblint")
|
|
@ -2,8 +2,6 @@
|
|||
en:
|
||||
account:
|
||||
valuations:
|
||||
valuation:
|
||||
balance_update: Balance update
|
||||
form:
|
||||
amount: Amount
|
||||
submit: Add balance update
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue