Files
SupplierSystem/server/tests/processingPickRespectReservations.test.ts
T
Ubuntu deb3e72750
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
chore: 以 AI 生鲜配送系统 当前版本作为 SupplierSystem 起点
来源仓库:jxc/ai-fresh-delivery
来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d
快照树:  09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件)

按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据
(生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、
deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值),
整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。
供应商系统后续开发自本提交开始。
2026-10-08 17:35:43 +08:00

65 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
/**
* 仓内加工领料必须扣除库存预留(2026-09-22 开发者实测报告)。
*
* 现象:需求单领料弹窗把**已被预留占用**的货显示成"可用"并能真的领走
* (BR004 实测:前夹精瘦肉 显示 15 / 真实可领 0;抄手皮 显示 16.2 / 真实可领 8.2)。
* 根因:候选列表用毛可用;三处领料校验也用毛可用,且扣减显式 `respectOtherReservations: false`
* 关掉了预留保护(与分拣/发车路径、与 getClaimableStockQty 口径不一致)。
* 见 docs/design/20260922-processing-pick-respect-reservations.md
*/
const read = (rel: string) => readFileSync(new URL(`../src/${rel}`, import.meta.url), 'utf8');
describe('仓内加工领料:预留口径', () => {
const standalone = read('services/processingStandaloneService.ts');
const demand = read('services/processingDemandSheetService.ts');
const amend = read('services/processingDemandPickAmendService.ts');
it('候选列表的"可用"必须减去在用预留(status=10)', () => {
expect(standalone).toContain('FROM inventory_reservations r');
expect(standalone).toContain('r.status = 10');
expect(standalone).toContain('GREATEST(0,');
expect(standalone).toContain('reserved_qty');
// 不再直接把毛可用当"可用"
expect(standalone).not.toContain('COALESCE(SUM(inv.available_qty), 0)::float AS available_qty');
});
it('三处领料校验都用 getClaimableStockQty(毛可用 − 全部在用预留)', () => {
expect(demand).toContain('getClaimableStockQty(client, skuCode, branchCode, null)');
expect(amend).toContain('getClaimableStockQty(client, skuCode, input.branchCode, null)');
expect(standalone).toContain('getClaimableStockQty(client, skuCode, branchCode, null)');
for (const [name, src] of [
['processingDemandSheetService', demand],
['processingDemandPickAmendService', amend],
['processingStandaloneService', standalone],
] as const) {
expect(src, name).toContain("from './inventoryStockCoverService'");
}
});
it('任何领料路径都不得关掉 FIFO 的预留守卫', () => {
for (const [name, src] of [
['processingDemandSheetService', demand],
['processingDemandPickAmendService', amend],
['processingStandaloneService', standalone],
] as const) {
expect(src, name).not.toContain('respectOtherReservations: false');
}
});
it('分拣/发车路径的显式守卫保持开启(本改动不碰)', () => {
const outbound = read('services/inventoryOutboundService.ts');
expect(outbound).toContain('respectOtherReservations: true');
expect(outbound).toContain('默认 true:扣库不得超过「毛可用−他单预留」');
});
it('保留可复跑的口径审计入口', () => {
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as {
scripts: Record<string, string>;
};
expect(pkg.scripts['audit:stock-claimable']).toContain('scripts/audit-stock-claimable.ts');
});
});