temp commit

This commit is contained in:
BaoXuebin 2023-12-10 17:56:21 +08:00
parent 19dae50c07
commit e905eebf60
5 changed files with 20 additions and 10 deletions

View File

@ -270,7 +270,7 @@ func LoadLedgerAccountsMap() error {
if err != nil { if err != nil {
return err return err
} }
err = LoadLedgerCurrencyMap(config) err = LoadLedgerCurrencyMap(&config)
if err != nil { if err != nil {
return err return err
} }
@ -408,7 +408,7 @@ func LoadServerCurrencyMap() {
serverCurrencies = append(serverCurrencies, LedgerCurrency{Name: "俄罗斯卢布", Currency: "RUB", Symbol: "₽"}) serverCurrencies = append(serverCurrencies, LedgerCurrency{Name: "俄罗斯卢布", Currency: "RUB", Symbol: "₽"})
} }
func LoadLedgerCurrencyMap(config Config) error { func LoadLedgerCurrencyMap(config *Config) error {
LoadServerCurrencyMap() LoadServerCurrencyMap()
path := GetLedgerCurrenciesFilePath(config.DataPath) path := GetLedgerCurrenciesFilePath(config.DataPath)
if !FileIfExist(path) { if !FileIfExist(path) {
@ -443,7 +443,7 @@ func LoadLedgerCurrencyMap(config Config) error {
ledgerCurrencyMap[config.Id] = currencies ledgerCurrencyMap[config.Id] = currencies
LogSystemInfo(fmt.Sprintf("Success load [%s] account type cache", config.Mail)) LogSystemInfo(fmt.Sprintf("Success load [%s] account type cache", config.Mail))
// 刷新汇率 // 刷新汇率
RefreshLedgerCurrency(&config) RefreshLedgerCurrency(config)
return nil return nil
} }

View File

@ -331,7 +331,7 @@ func RefreshAccountCache(c *gin.Context) {
return return
} }
// 加载货币缓存 // 加载货币缓存
err = script.LoadLedgerCurrencyMap(*ledgerConfig) err = script.LoadLedgerCurrencyMap(ledgerConfig)
if err != nil { if err != nil {
InternalError(c, err.Error()) InternalError(c, err.Error())
return return

View File

@ -273,7 +273,7 @@ func createNewLedger(loginForm LoginForm, ledgerId string) (*script.Config, erro
return nil, err return nil, err
} }
// add currency cache // add currency cache
err = script.LoadLedgerCurrencyMap(ledgerConfig) err = script.LoadLedgerCurrencyMap(&ledgerConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -92,5 +92,14 @@ func UpdateLedgerSourceFileContent(c *gin.Context) {
return return
} }
// 更新外币种源文件后,更新缓存
if strings.Contains(updateSourceFileForm.Path, "currency.json") {
err = script.LoadLedgerCurrencyMap(ledgerConfig)
if err != nil {
InternalError(c, err.Error())
return
}
}
OK(c, nil) OK(c, nil)
} }

View File

@ -70,10 +70,11 @@ type AddTransactionForm struct {
type AddTransactionEntryForm struct { type AddTransactionEntryForm struct {
Account string `form:"account" binding:"required" json:"account"` Account string `form:"account" binding:"required" json:"account"`
Number decimal.Decimal `form:"number" json:"number"` Number decimal.Decimal `form:"number" json:"number,omitempty"`
Currency string `form:"currency" json:"currency"` Currency string `form:"currency" json:"currency"`
Price decimal.Decimal `form:"price" json:"price"` Price decimal.Decimal `form:"price" json:"price,omitempty"`
PriceCurrency string `form:"priceCurrency" json:"priceCurrency"` PriceCurrency string `form:"priceCurrency" json:"priceCurrency,omitempty"`
IsAnotherCurrency bool `form:"isAnotherCurrency" json:"isAnotherCurrency,omitempty"`
} }
func sum(entries []AddTransactionEntryForm, openingBalances string) decimal.Decimal { func sum(entries []AddTransactionEntryForm, openingBalances string) decimal.Decimal {