Now if it can be done transfer with same currency between cards will show symbol of either of the cards

This commit is contained in:
qowevisa 2024-11-24 00:39:02 +02:00
parent 957f1e8363
commit 46ab4ee7a0

View File

@ -22,6 +22,13 @@ var transferTransform func(inp *db.Transfer) types.DbTransfer = func(inp *db.Tra
haveDiffCurrs = inp.FromCard.CurrencyID != inp.ToCard.CurrencyID haveDiffCurrs = inp.FromCard.CurrencyID != inp.ToCard.CurrencyID
} }
var showValue string 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 { if haveDiffCurrs {
showValue = fmt.Sprintf("%d.%02d%s -> %d.%02d%s", showValue = fmt.Sprintf("%d.%02d%s -> %d.%02d%s",
inp.FromValue/100, inp.FromValue/100,
@ -32,7 +39,7 @@ var transferTransform func(inp *db.Transfer) types.DbTransfer = func(inp *db.Tra
inp.ToCard.Currency.Symbol, inp.ToCard.Currency.Symbol,
) )
} else { } 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{ return types.DbTransfer{
ID: inp.ID, ID: inp.ID,