import { describe, expect, it } from 'vitest'; import { readFileSync } from 'node:fs'; import path from 'path'; describe('商品成本明细导出接口', () => { it('financeRoutes 注册 sku-cost-lines 且服务导出 getSkuDirectCostLinesPaged', () => { const routes = readFileSync( path.join(__dirname, '../src/modules/workflow/routes/financeRoutes.ts'), 'utf8' ); const svc = readFileSync( path.join(__dirname, '../src/services/marginQueryService.ts'), 'utf8' ); expect(routes).toContain("router.get('/cost/sku-cost-lines/:cycleCode'"); expect(routes).toContain('getSkuDirectCostLinesPaged'); expect(svc).toContain('export async function getSkuDirectCostLinesPaged'); expect(svc).toContain('skuListDisplayCostBucketSql'); // 2026-10-14:导出与列表页同口径 —— 采购金额 = 缺口量 × unit_cost // (全量常量 ORDER_ITEM_CACHED_COST_AMOUNT_SQL 已随口径变更删除,见 // docs/design/20261014-订单成本排除独立进货与库存成本分类.md §5.1) // 2026-10-14 拆段后:缺口段一行 = 缺口量 × unit_cost(抵扣段的对应金额恒 0) expect(svc).toContain('(GREATEST(0, full_qty - cover_qty) * unit_cost)::numeric AS purchase_cost'); }); });