Compare commits

..

3 Commits
v1.2.1 ... main

Author SHA1 Message Date
BaoXuebin 2c18b17b09 fixbug: 汇率转换的账目修改失败 2025-01-12 10:10:55 +08:00
BaoXuebin 5c88d90101 version 1.2.2 2024-12-29 20:37:13 +08:00
BaoXuebin 5938f3aef9 fixbug: #94 1000以上的数值兼容千分位 2024-12-22 23:14:53 +08:00
3 changed files with 21 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
) )
@ -268,13 +269,30 @@ func CleanString(str string) string {
if IsComment(str) { if IsComment(str) {
return "" return ""
} }
result := getAccountWithNumber(str)
// 去除 " ", ";", "\r" // 去除 " ", ";", "\r"
result := strings.ReplaceAll(str, " ", "") result = strings.ReplaceAll(result, ",", "")
result = strings.ReplaceAll(result, " ", "")
// 过滤空白的商户信息 ““
result = strings.ReplaceAll(result, "\"\"", "")
result = strings.ReplaceAll(result, ";", "") result = strings.ReplaceAll(result, ";", "")
result = strings.ReplaceAll(result, "\r", "") result = strings.ReplaceAll(result, "\r", "")
// 清楚汇率转换
return result return result
} }
// 正则提取:
// Assets:Flow:Cash:现金 -20.00 USD {xxx CNY, 2025-01-01} -> Assets:Flow:Cash:现金 -20.00 USD
func getAccountWithNumber(str string) string {
// 定义正则表达式模式
pattern := `^[^\{]+`
// 编译正则表达式
re := regexp.MustCompile(pattern)
// 使用正则提取匹配的部分
return re.FindString(str)
}
func IsComment(line string) bool { func IsComment(line string) bool {
trimmed := strings.TrimLeft(line, " ") trimmed := strings.TrimLeft(line, " ")
if strings.HasPrefix(trimmed, ";") { if strings.HasPrefix(trimmed, ";") {

View File

@ -3,5 +3,5 @@ package service
import "github.com/gin-gonic/gin" import "github.com/gin-gonic/gin"
func QueryVersion(c *gin.Context) { func QueryVersion(c *gin.Context) {
OK(c, "v1.2.1") OK(c, "v1.2.2")
} }

View File

@ -1,2 +1,2 @@
tag=1.1.12 tag=1.2.2
dataPath=/data/beancount dataPath=/data/beancount