update: auto refresh currency cache
This commit is contained in:
parent
f0aa8ab0c0
commit
017bf20c56
|
|
@ -30,7 +30,11 @@ func SyncCommodityPrice(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新货币最新汇率值
|
// 刷新货币最新汇率值
|
||||||
script.RefreshLedgerCurrency(ledgerConfig)
|
err = script.LoadLedgerCurrencyMap(ledgerConfig)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
OK(c, syncCommodityPriceForm)
|
OK(c, syncCommodityPriceForm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,9 @@ func saveTransaction(c *gin.Context, addTransactionForm AddTransactionForm, ledg
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, isCurrency := currencyMap[account.Currency]
|
||||||
// 货币跳过汇率转换
|
// 货币跳过汇率转换
|
||||||
if _, ok := currencyMap[account.Currency]; !ok {
|
if !isCurrency {
|
||||||
// 根据 number 的正负来判断是买入还是卖出
|
// 根据 number 的正负来判断是买入还是卖出
|
||||||
if entry.Number.GreaterThan(zero) {
|
if entry.Number.GreaterThan(zero) {
|
||||||
// {351.729 CNY, 2021-09-29}
|
// {351.729 CNY, 2021-09-29}
|
||||||
|
|
@ -203,6 +204,14 @@ func saveTransaction(c *gin.Context, addTransactionForm AddTransactionForm, ledg
|
||||||
}
|
}
|
||||||
return errors.New("internal error")
|
return errors.New("internal error")
|
||||||
}
|
}
|
||||||
|
// 刷新币种汇率
|
||||||
|
if isCurrency {
|
||||||
|
err = script.LoadLedgerCurrencyMap(ledgerConfig)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return errors.New("internal error")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue