- 下单即建分拣/配送,待取货/散客/独立进货守卫 - 30/40/45 直接发车/分拣,入库与分拣二选一 - 分拣完成补上游、清理 pending 验收,直接配送补分拣 - 库存抵扣/计划/实收 FIFO,软扣部分扣减,并发出库串行 - 结束配送不被库存不足/待入库残留阻断 - 待验收并发唯一索引(含 name-only),finalize 共享连接修复 - 售后自动绑定订单明细、客户取货/采购并发修复 - 仓库表格自适应、弹窗滚动锁闪烁修复
55 lines
2.9 KiB
TypeScript
55 lines
2.9 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const picking = readFileSync(new URL('../src/services/pickingService.ts', import.meta.url), 'utf8');
|
|
const fulfillment = readFileSync(new URL('../src/services/orderWorkflowFulfillmentService.ts', import.meta.url), 'utf8');
|
|
|
|
function body(source: string, name: string, next: string): string {
|
|
const start = source.indexOf(name);
|
|
const end = source.indexOf(next, start + 1);
|
|
return start >= 0 && end > start ? source.slice(start, end) : '';
|
|
}
|
|
|
|
describe('T4 分拣完成自动补上游', () => {
|
|
it('补备货/采购并写 delivery_loading_backfill_logs 责任记录', () => {
|
|
const fn = body(picking, 'async function backfillPendingFulfillmentForPicking', 'async function isNoAutoDeliveryOrder');
|
|
expect(fn).toContain('UPDATE supplier_preparations');
|
|
expect(fn).toContain('updatePurchaseOrderStatus');
|
|
expect(fn).toContain('delivery_loading_backfill_logs');
|
|
expect(fn).toContain("'prep'");
|
|
expect(fn).toContain("'purchase'");
|
|
});
|
|
|
|
it('分拣完成只补备货/采购成本,不再自动入库;30 只补成本', () => {
|
|
const fn = body(picking, 'async function autoInboundFromPickingBeforeComplete', 'async function forceOrderReadyForDeliveryAfterPicking');
|
|
expect(fn).toContain('backfillPendingFulfillmentForPicking');
|
|
expect(fn).toContain('if (status >= 40) return');
|
|
expect(fn).toContain('finalizeAutoCompletedSupplierPreparations');
|
|
expect(fn).not.toContain('ensureInspectionsForOrder');
|
|
expect(fn).not.toContain('submitInspectionCompliance');
|
|
expect(fulfillment).toContain('picking_skipped_on_30_departure');
|
|
});
|
|
|
|
it('待取货/全直送/自提/独立进货/散客跳过自动入库与配送', () => {
|
|
const fn = body(picking, 'async function isNoAutoDeliveryOrder', 'async function autoInboundFromPickingBeforeComplete');
|
|
for (const guard of ['isRetailOrder', 'isOrderOnlyDirectDelivery', 'isOrderIndependentInbound', 'isSelfPickupOrder', 'isOrderFullySkipInbound']) {
|
|
expect(fn, guard).toContain(guard);
|
|
}
|
|
});
|
|
|
|
it('分拣完成 30/40/45 强制到 50;列表加载修复历史卡单', () => {
|
|
const force = body(picking, 'async function forceOrderReadyForDeliveryAfterPicking', 'export async function recoverOrdersReadyForDeliveryAfterPicking');
|
|
expect(force).toContain('order_status = 50');
|
|
expect(force).toContain('ensureDeliveryTaskForOrder');
|
|
expect(force).toContain('countUnfinishedPickingTasks');
|
|
expect(force).toContain('countWarehouseItemsMissingPicking');
|
|
expect(picking).toContain('recoverOrdersReadyForDeliveryAfterPicking(ctx)');
|
|
expect(picking).toContain('await forceOrderReadyForDeliveryAfterPicking(');
|
|
});
|
|
|
|
it('不引入“未入库禁止完成分拣”闸', () => {
|
|
expect(picking).not.toContain('尚未完成入库验收,暂不能确认分拣完成');
|
|
expect(picking).not.toContain('assertPickingTaskReadyForCompletion');
|
|
});
|
|
});
|