import { readFileSync } from 'node:fs'; import path from 'path'; import { describe, expect, it } from 'vitest'; describe('称上分批入库(少入允许)', () => { it('需求量扣抵扣(库存抵扣比量)', () => { // 设计文档 20260828-weigh-station-partial-inbound.md 已按仓库整理要求删除,仅保留源码口径断言 const demand = readFileSync( path.join(__dirname, '../src/services/inventorySurplusCostService.ts'), 'utf8' ); expect(demand).toContain('inventory_cover_qty'); expect(demand).toContain('sumCompletedInboundQtyForLine'); }); it('submitInspectionCompliance:部分入库留待验 sibling', () => { const src = readFileSync( path.join(__dirname, '../src/services/inspectionComplianceService.ts'), 'utf8' ); expect(src).toContain('isPartialInbound'); expect(src).toContain('partial_follow_up_of'); expect(src).toContain('followUpInspectionId'); expect(src).toContain('partialInbound'); expect(src).toContain('!isPartialInbound'); }); it('覆盖判定:成功验收即覆盖(实收不挡状态);库存抵扣仍比量', () => { const state = readFileSync( path.join(__dirname, '../src/services/orderInspectionStateService.ts'), 'utf8' ); expect(state).toContain('SELECT 1 FROM inspections i'); expect(state).not.toContain('SUM(COALESCE(i.actual_qty, 0))'); expect(state).toContain('inventory_cover_qty'); const reject = readFileSync( path.join(__dirname, '../src/services/inspectionRejectFulfillmentService.ts'), 'utf8' ); expect(reject).toContain('hasOpenPendingInspection'); expect(reject.slice(reject.indexOf('export async function hasSuccessfulInboundInspection'))).toContain( 'isOrderSkuInboundCovered' ); }); it('称上待验列表返回 received_qty / total_demand_qty', () => { const weigh = readFileSync( path.join(__dirname, '../src/services/weighStationService.ts'), 'utf8' ); expect(weigh).toContain('received_qty'); expect(weigh).toContain('total_demand_qty'); }); });