fix(web-admin): avoid duplicate 零 in RMB uppercase for yi+rest

Add regression tests for 亿到元段间零填充。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-30 11:01:33 +08:00
1 parent e6d7eecdc6
commit 0a24f707bf
2 files changed
+11 -4

No files matched your search

+6 -4
View File
@@ -44,7 +44,7 @@ export function toRmbUpper(value: number | null | undefined): string {
if (yuan > 0) {
const yi = Math.floor(yuan / 100000000)
const wan = Math.floor((yuan % 100000000) / 10000)
const wan = Math.floor(yuan / 10000) % 10000
const rest = yuan % 10000
if (yi > 0) {
@@ -55,11 +55,13 @@ export function toRmbUpper(value: number | null | undefined): string {
result += '零'
}
result += sectionToChinese(wan) + '万'
} else if (yi > 0 && rest > 0) {
result += '零'
}
if (rest > 0) {
if ((yi > 0 || wan > 0) && rest < 1000) {
if (wan > 0) {
if (rest < 1000) {
result += '零'
}
} else if (yi > 0) {
result += '零'
}
result += sectionToChinese(rest)