优化寄售仓库现货统计与可匹配矩阵
This commit is contained in:
@@ -210,3 +210,33 @@ test('筛选项排序:苏尔南手枪固定排第一,其余保持配置顺
|
||||
['苏尔南手枪', '密钥', '其它'],
|
||||
)
|
||||
})
|
||||
|
||||
test('现货统计:按 remaining_quantity 汇总,成本乘数量,并输出系统+系列+钻级汇总', async () => {
|
||||
const source = await readFile(
|
||||
new URL('../../repositories/worker-platform/consignment-repo.ts', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const totalsSql = source.slice(
|
||||
source.indexOf('const totalsSql'),
|
||||
source.indexOf('const buyerSql'),
|
||||
)
|
||||
assert.ok(!totalsSql.includes('ci.allow_matching'), '顶部在库统计保持全部在库口径')
|
||||
assert.ok(totalsSql.includes('GREATEST(ci.remaining_quantity, 0)'), '在库件数必须按剩余数量')
|
||||
assert.ok(
|
||||
totalsSql.includes('ci.cost_price_fen::bigint * GREATEST(ci.remaining_quantity, 0)'),
|
||||
'在库成本必须乘剩余数量',
|
||||
)
|
||||
assert.ok(source.includes('byStockSpec: stockSpecRes.rows'), '统计结果必须返回现货分布字段')
|
||||
const stockSpecSql = source.slice(
|
||||
source.indexOf('const stockSpecSql'),
|
||||
source.indexOf('const stockSpecRes'),
|
||||
)
|
||||
assert.ok(stockSpecSql.includes("ci.spec_values_json ->> 'system'"), '现货分布必须优先读动态规格')
|
||||
assert.ok(stockSpecSql.includes("ci.spec_values_json ->> 'series'"), '现货分布必须优先读动态规格')
|
||||
assert.ok(
|
||||
stockSpecSql.includes("ci.spec_values_json ->> 'diamondLevel'"),
|
||||
'现货分布必须优先读动态规格',
|
||||
)
|
||||
assert.ok(stockSpecSql.includes('ci.allow_matching = TRUE'), '现货分布必须只包含允许匹配的库存')
|
||||
assert.ok(!stockSpecSql.includes('brillianceCount'), '璀璨数不参与分组')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user