import { readFileSync } from 'node:fs'; import path from 'path'; import { describe, expect, it } from 'vitest'; describe('结案跳过本单过手未入台账行', () => { const outbound = readFileSync( path.join(__dirname, '../src/services/inventoryOutboundService.ts'), 'utf8' ); const inspect = readFileSync( path.join(__dirname, '../src/services/inspectionComplianceService.ts'), 'utf8' ); const picking = readFileSync(path.join(__dirname, '../src/services/pickingService.ts'), 'utf8'); it('判定只认验收流水备注「过手履约跳过库存台账」,不看当前 stock_mode', () => { expect(outbound).toContain("export const PASS_THROUGH_LEDGER_SKIP_REMARK = '过手履约跳过库存台账'"); expect(outbound).toContain('export async function orderSkuSkippedPassThroughLedger'); expect(outbound).toContain("AND operation_type = 'inspection_in'"); expect(outbound).toContain("remark ILIKE '%' || $3 || '%'"); expect(outbound).toContain("OR remark ILIKE '%' || $4 || '%'"); expect(outbound).toContain("export const WAREHOUSE_FINISHED_LEDGER_SKIP_REMARK = '仓内加工成品不入可领库存'"); expect(inspect).toContain('过手履约跳过库存台账 ${input.id}'); const helperStart = outbound.indexOf('export async function orderSkuSkippedPassThroughLedger'); const helperEnd = outbound.indexOf('function businessError', helperStart); expect(helperStart).toBeGreaterThan(-1); expect(outbound.slice(helperStart, helperEnd)).not.toContain('isPassThroughSku'); expect(outbound.slice(helperStart, helperEnd)).not.toContain('stock_mode'); }); it('发车扣库与结案/回冲计划均跳过该备注行', () => { expect(outbound).toContain('orderSkuSkippedPassThroughLedger(client, code, row.sku)'); expect(outbound).toContain('orderSkuSkippedPassThroughLedger(client, orderCode, row.sku)'); expect(outbound).toContain('orderSkuSkippedPassThroughLedger(client, orderCode, sku)'); const planStart = outbound.indexOf('async function planDeductLinesForOrder'); const planSrc = outbound.slice(planStart, planStart + 4500); expect(planSrc).toContain('orderSkuSkippedPassThroughLedger'); expect(outbound).toContain('ensureOrderInventorySettledOnComplete'); expect(outbound).toContain('planDeductLinesForOrder(client, code, branchCode)'); }); it('不合单复用主单批次、不改 fifo 本体与分拣扣库', () => { const helperStart = outbound.indexOf('export async function orderSkuSkippedPassThroughLedger'); const fifoStart = outbound.indexOf('export async function fifoDeductInventory'); expect(outbound.slice(helperStart, fifoStart)).not.toContain('合单复用主单批次'); const fifoBody = outbound.slice(fifoStart, outbound.indexOf('export async function deductInventoryForOrderDeparture')); expect(fifoBody).not.toContain('orderSkuSkippedPassThroughLedger'); expect(picking).toContain('orderSkuSkippedPassThroughLedger'); expect(picking).toContain('isPassThroughSku'); }); });