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:
parent
f2a2d2f7e4
commit
c70c8b6d86
3 changed files with 6 additions and 5 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue