Ensure transfer name is populated (#1042)

* Ensure transfer name is populated

* Transfer amount fallback
This commit was merged in pull request #1042.
This commit is contained in:
Zach Gollwitzer
2024-08-01 12:10:30 -04:00
committed by GitHub
parent f2a2d2f7e4
commit c70c8b6d86
3 changed files with 6 additions and 5 deletions

View File

@@ -9,19 +9,18 @@ class Account::Transfer < ApplicationRecord
end
def amount_money
entries.first&.amount_money&.abs
entries.first&.amount_money&.abs || Money.new(0)
end
def from_name
outflow_transaction&.account&.name
outflow_transaction&.account&.name || I18n.t("account.transfer.from_fallback_name")
end
def to_name
inflow_transaction&.account&.name
inflow_transaction&.account&.name || I18n.t("account.transfer.to_fallback_name")
end
def name
return nil unless from_name && to_name
I18n.t("account.transfer.name", from_account: from_name, to_account: to_name)
end

View File

@@ -11,7 +11,7 @@
<%= tag.div class: short ? "max-w-[250px]" : "max-w-[325px]" do %>
<div class="flex items-center gap-2">
<%= circle_logo("T") %>
<%= circle_logo(transfer.from_name[0].upcase) %>
<%= tag.p transfer.name, class: "truncate text-gray-900" %>
</div>

View File

@@ -2,4 +2,6 @@
en:
account:
transfer:
from_fallback_name: Originator
name: Transfer from %{from_account} to %{to_account}
to_fallback_name: Receiver