From 46ab4ee7a0ff4807743168f1a0c5860c2287161a Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sun, 24 Nov 2024 00:39:02 +0200 Subject: [PATCH] Now if it can be done transfer with same currency between cards will show symbol of either of the cards --- handlers/transfer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handlers/transfer.go b/handlers/transfer.go index d05447d..946bb07 100644 --- a/handlers/transfer.go +++ b/handlers/transfer.go @@ -22,6 +22,13 @@ var transferTransform func(inp *db.Transfer) types.DbTransfer = func(inp *db.Tra haveDiffCurrs = inp.FromCard.CurrencyID != inp.ToCard.CurrencyID } var showValue string + sameCurrSymbol := "" + if inp.FromCard != nil && inp.FromCard.Currency != nil { + sameCurrSymbol = inp.FromCard.Currency.Symbol + } + if sameCurrSymbol == "" && inp.ToCard != nil && inp.ToCard.Currency != nil { + sameCurrSymbol = inp.ToCard.Currency.Symbol + } if haveDiffCurrs { showValue = fmt.Sprintf("%d.%02d%s -> %d.%02d%s", inp.FromValue/100, @@ -32,7 +39,7 @@ var transferTransform func(inp *db.Transfer) types.DbTransfer = func(inp *db.Tra inp.ToCard.Currency.Symbol, ) } else { - showValue = fmt.Sprintf("%d.%02d", inp.Value/100, inp.Value%100) + showValue = fmt.Sprintf("%d.%02d%s", inp.Value/100, inp.Value%100, sameCurrSymbol) } return types.DbTransfer{ ID: inp.ID,