fix(product-archive): 结算价公式修正为成本价÷0.9(模块化)
- 模块化分支由 ×0.9 改为 ÷0.9:聚水潭里模块化成本价按 9 折记, 结算价需除以 0.9 还原(如成本 34.00 → 结算 37.78) - 非模块化仍为成本价原样展示;先取整到分再除、四舍五入保留两位 - 同步更新测试期望值(76.20→84.67、123.45→137.17、85→94.44、34.00→37.78)
This commit is contained in:
parent
b6a326d996
commit
d1496b0c11
@ -204,10 +204,11 @@ describe('supply-chain product archive field mapping', () => {
|
||||
})
|
||||
|
||||
it('derives the settlement price from the cost price and modular product tag', () => {
|
||||
expect(settlementPriceText('76.20', '模块化成品,预估尺寸')).toBe('68.58')
|
||||
expect(settlementPriceText('76.20', '模块化部件,简尚-崔桥工厂半成品包装项目仓')).toBe('68.58')
|
||||
expect(settlementPriceText('123.45', '模块化成品')).toBe('111.11')
|
||||
expect(settlementPriceText('85', '模块化部件')).toBe('76.50')
|
||||
expect(settlementPriceText('76.20', '模块化成品,预估尺寸')).toBe('84.67')
|
||||
expect(settlementPriceText('76.20', '模块化部件,简尚-崔桥工厂半成品包装项目仓')).toBe('84.67')
|
||||
expect(settlementPriceText('123.45', '模块化成品')).toBe('137.17')
|
||||
expect(settlementPriceText('85', '模块化部件')).toBe('94.44')
|
||||
expect(settlementPriceText('34.00', '模块化成品')).toBe('37.78')
|
||||
expect(settlementPriceText('76.20', '1688一件代发,已匹配')).toBe('76.20')
|
||||
expect(settlementPriceText('76.20', '')).toBe('76.20')
|
||||
expect(settlementPriceText('', '模块化成品')).toBe('')
|
||||
|
||||
@ -37,11 +37,12 @@ function percentageText(
|
||||
return value ? `${value.mul(100).toFixed(2)}%` : ''
|
||||
}
|
||||
|
||||
// 结算价展示口径(2026-10-14 用户确认):结算价 = 成本价 × 系数,非模块化 ×1
|
||||
// 原样展示,模块化 ×0.9(四舍五入保留两位)。模块化以产品标签含「模块化」为
|
||||
// 准(聚水潭标签里的“模块化成品/模块化部件”)。查询映射层实时计算,不落库。
|
||||
// 结算价展示口径(2026-10-15 用户修正):结算价 = 成本价 ÷ 0.9(模块化),
|
||||
// 非模块化原样展示(成本价即结算价)。模块化以产品标签含「模块化」为准
|
||||
// (聚水潭标签里的“模块化成品/模块化部件”,其成本价按 9 折记)。查询映射层
|
||||
// 实时计算,不落库。
|
||||
const SETTLEMENT_MODULAR_TAG = '模块化'
|
||||
const SETTLEMENT_MODULAR_FACTOR = 0.9
|
||||
const SETTLEMENT_MODULAR_DIVISOR = 0.9
|
||||
|
||||
export function settlementPriceText(
|
||||
costPrice: string | null | undefined,
|
||||
@ -52,8 +53,8 @@ export function settlementPriceText(
|
||||
if (!(productTag ?? '').includes(SETTLEMENT_MODULAR_TAG)) return cost
|
||||
const value = Number(cost)
|
||||
if (!Number.isFinite(value)) return ''
|
||||
// 先取整到分再打折,避免浮点误差让 123.45×0.9 这类半厘值四舍五入方向漂移。
|
||||
const settled = Math.round(Math.round(value * 100) * SETTLEMENT_MODULAR_FACTOR) / 100
|
||||
// 先取整到分再除,避免浮点误差让 123.45÷0.9 这类值四舍五入方向漂移。
|
||||
const settled = Math.round(Math.round(value * 100) / SETTLEMENT_MODULAR_DIVISOR) / 100
|
||||
return settled.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user