修正客户端费用换算信息空态
This commit is contained in:
@@ -16,5 +16,12 @@ test('translates backend rounding modes into customer-facing calculation labels'
|
||||
assert.match(source, /export function getRoundingModeLabel/)
|
||||
assert.match(source, /CEILING: '向上取整'/)
|
||||
assert.match(source, /HALF_UP: '四舍五入'/)
|
||||
assert.match(source, /return labels\[value\] \|\| value \|\| '-'/)
|
||||
assert.match(source, /return value \? labels\[value\] \|\| value : '-'/)
|
||||
})
|
||||
|
||||
test('renders conversion metadata as one complete label or a single empty marker', () => {
|
||||
assert.match(source, /export function formatConversionPrecision/)
|
||||
assert.match(source, /roundingScale === null \|\| roundingScale === undefined/)
|
||||
assert.match(source, /\|\| !roundingMode\) return '-'/)
|
||||
assert.match(source, /`系数 \$\{formatInboundNumber\(conversionFactor\)\} · 保留 \$\{roundingScale\} 位 \$\{getRoundingModeLabel\(roundingMode\)\}`/)
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ export function getTaxModeLabel(value: string) {
|
||||
return value || '-'
|
||||
}
|
||||
|
||||
export function getRoundingModeLabel(value: string) {
|
||||
export function getRoundingModeLabel(value: string | null | undefined) {
|
||||
const labels: Record<string, string> = {
|
||||
UP: '向上舍入',
|
||||
DOWN: '向下舍入',
|
||||
@@ -56,5 +56,16 @@ export function getRoundingModeLabel(value: string) {
|
||||
HALF_DOWN: '五舍六入',
|
||||
HALF_EVEN: '银行家舍入',
|
||||
}
|
||||
return labels[value] || value || '-'
|
||||
return value ? labels[value] || value : '-'
|
||||
}
|
||||
|
||||
export function formatConversionPrecision(
|
||||
conversionFactor: number | null | undefined,
|
||||
roundingScale: number | null | undefined,
|
||||
roundingMode: string | null | undefined,
|
||||
) {
|
||||
if (conversionFactor === null || conversionFactor === undefined
|
||||
|| roundingScale === null || roundingScale === undefined
|
||||
|| !roundingMode) return '-'
|
||||
return `系数 ${formatInboundNumber(conversionFactor)} · 保留 ${roundingScale} 位 ${getRoundingModeLabel(roundingMode)}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user