Skip to content

Commit

Permalink
fix: double conversion of total value
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Feb 15, 2021
1 parent dd03701 commit 2e5d30c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/currency/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func GetCurrencyRates(client resty.Client, symbols []string, targetCurrency stri
func GetCurrencyRateFromContext(ctx c.Context, fromCurrency string) (float64, float64, string) {
if currencyRate, ok := ctx.Reference.CurrencyRates[fromCurrency]; ok {
if ctx.Config.Currency != "" {
return currencyRate.Rate, currencyRate.Rate, currencyRate.ToCurrency
return currencyRate.Rate, 1.0, currencyRate.ToCurrency
}

return 1.0, currencyRate.Rate, currencyRate.ToCurrency
Expand Down
2 changes: 1 addition & 1 deletion internal/currency/currency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var _ = Describe("Currency", func() {
}
outputRate, outputDefaultRate, outputCurrencyCode := GetCurrencyRateFromContext(inputCtx, "USD")
Expect(outputRate).To(Equal(1.25))
Expect(outputDefaultRate).To(Equal(1.25))
Expect(outputDefaultRate).To(Equal(1.0))
Expect(outputCurrencyCode).To(Equal("EUR"))
})
})
Expand Down

0 comments on commit 2e5d30c

Please sign in to comment.