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

Ensure transfer name is populated (#1042)

* Ensure transfer name is populated

* Transfer amount fallback
This commit is contained in:
Zach Gollwitzer 2024-08-01 12:10:30 -04:00 committed by GitHub
parent f2a2d2f7e4
commit c70c8b6d86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View file

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

View file

@ -11,7 +11,7 @@
<%= tag.div class: short ? "max-w-[250px]" : "max-w-[325px]" do %> <%= tag.div class: short ? "max-w-[250px]" : "max-w-[325px]" do %>
<div class="flex items-center gap-2"> <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" %> <%= tag.p transfer.name, class: "truncate text-gray-900" %>
</div> </div>

View file

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