From 5cd829ae27b1db9deacfdc5458d4d7b784530039 Mon Sep 17 00:00:00 2001 From: BaoXuebin Date: Mon, 8 Jul 2024 23:59:35 +0800 Subject: [PATCH] query transaction api add isAnotherCurrency filed --- service/transactions.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/service/transactions.go b/service/transactions.go index 6fbe29d..82d35b8 100644 --- a/service/transactions.go +++ b/service/transactions.go @@ -31,6 +31,7 @@ type Transaction struct { Tags []string `bql:"tags" json:"tags"` CurrencySymbol string `json:"currencySymbol,omitempty"` CostCurrencySymbol string `json:"costCurrencySymbol,omitempty"` + IsAnotherCurrency bool `json:"isAnotherCurrency,omitempty"` } func QueryTransactions(c *gin.Context) { @@ -44,8 +45,16 @@ func QueryTransactions(c *gin.Context) { InternalError(c, err.Error()) return } + + currencyMap := script.GetLedgerCurrencyMap(ledgerConfig.Id) + // 格式化金额 for i := 0; i < len(transactions); i++ { + _, ok := currencyMap[transactions[i].Currency] + if ok { + transactions[i].IsAnotherCurrency = transactions[i].Currency != ledgerConfig.OperatingCurrency + } + symbol := script.GetCommoditySymbol(ledgerConfig.Id, transactions[i].Currency) transactions[i].CurrencySymbol = symbol transactions[i].CostCurrencySymbol = symbol