Skip to content

Commit

Permalink
fix: conversion rate target
Browse files Browse the repository at this point in the history
  • Loading branch information
namnhce committed Nov 11, 2023
1 parent 23dbb71 commit d262adb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 5 additions & 9 deletions pkg/controller/conversionrate/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/shopspring/decimal"
)

var srcCurrencies = []string{"USD", "VND"}
var destCurrencies = []string{"USD", "VND"}

func (r *controller) Sync(c *gin.Context) error {
tx, done := r.repo.NewTransaction()
Expand All @@ -18,17 +18,13 @@ func (r *controller) Sync(c *gin.Context) error {

currencyRateMap := make(map[string]float64)
for _, conversionRate := range conversionRates {
for _, srcCurrency := range srcCurrencies {
if conversionRate.Currency.Name == srcCurrency {
continue
}

// Get rate
rate, err := r.service.Wise.GetRate(srcCurrency, conversionRate.Currency.Name)
srcCurrency := conversionRate.Currency.Name
for _, destCurrency := range destCurrencies {
rate, err := r.service.Wise.GetRate(srcCurrency, destCurrency)
if err != nil {
return done(err)
}
currencyRateMap[conversionRate.Currency.Name] = rate
currencyRateMap[destCurrency] = rate
}

for k, v := range currencyRateMap {
Expand Down
1 change: 0 additions & 1 deletion pkg/service/wise/wise.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (w *wiseService) GetRate(sourceCurrency, targetCurrency string) (float64, e
if sourceCurrency == targetCurrency {
return 1, nil
}

return w.getTWRate(sourceCurrency, targetCurrency)
}

Expand Down

0 comments on commit d262adb

Please sign in to comment.