From dfc2f1b36a4488428ffd3c06aab5c7799047a09a Mon Sep 17 00:00:00 2001 From: BaoXuebin Date: Sun, 10 Mar 2024 22:05:40 +0800 Subject: [PATCH] =?UTF-8?q?fixbug:=20=E8=B4=A6=E6=88=B7=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=88=96=E6=89=93=E5=BC=80=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/config.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script/config.go b/script/config.go index 2d2dc5a..660cc80 100644 --- a/script/config.go +++ b/script/config.go @@ -322,9 +322,9 @@ func LoadLedgerAccounts(ledgerId string) error { if words[1] == "open" { account.StartDate = words[0] - if account.StartDate != "" && temp.StartDate != "" && account.StartDate >= temp.StartDate { + if account.StartDate != "" && temp.StartDate != "" && strings.Compare(account.StartDate, temp.StartDate) < 0 { // 重复定义的账户,取最早的开始时间为准 - continue + account.StartDate = temp.StartDate } // 货币单位 if len(words) >= 4 { @@ -332,9 +332,9 @@ func LoadLedgerAccounts(ledgerId string) error { } } else if words[1] == "close" { account.EndDate = words[0] - if account.EndDate != "" && temp.EndDate != "" && account.EndDate < temp.EndDate { + if account.EndDate != "" && temp.EndDate != "" && strings.Compare(account.EndDate, temp.EndDate) > 0 { // 重复定义的账户,取最晚的开始时间为准 - continue + account.EndDate = temp.EndDate } } @@ -349,7 +349,7 @@ func LoadLedgerAccounts(ledgerId string) error { } // 如果结束时间小于开始时间,则结束时间为空 - if account.EndDate != "" && account.StartDate > account.EndDate { + if account.EndDate != "" && strings.Compare(account.StartDate, account.EndDate) > 0 { account.EndDate = "" } accountMap[key] = account @@ -357,6 +357,7 @@ func LoadLedgerAccounts(ledgerId string) error { } } } + accounts := make([]Account, 0) for _, account := range accountMap { accounts = append(accounts, account)