test: provision finance fixture prerequisites
This commit is contained in:
@@ -97,6 +97,10 @@ node scripts/admin-test-env-acceptance.mjs --modules suppliers
|
||||
node --test scripts/admin-test-env-modules/suppliers-contract.test.mjs
|
||||
```
|
||||
|
||||
## Finance 全链前置
|
||||
|
||||
`finance-full-fixtures` 会通过正式供应商 API 创建本轮隔离的 ACTIVE 供应商,并按费用项目类别校验后再生成 PAYABLE;不会使用历史供应商 ID。只请求 `finance-full-fixtures,finance-reconciliation-full,finance-settlement-full` 时,总入口会自动补齐 `merchant-qualification-fixture -> orders -> inbound-measurement -> phase3-container-loading`,确保 Finance 能消费本轮真实已完成柜次。若这些前置仍未产出同 marker 的完成柜次,Finance 会 fail-closed,不能把 finance-only 前置不足计为 Finance 业务成功。
|
||||
|
||||
## 国内整柜与客户运营统计
|
||||
|
||||
- `domestic-container.mjs`:整柜入库、出库、库存列表和详情;静态契约为 `domestic-container-contract.test.mjs`。
|
||||
|
||||
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { buildContainerCostBody, normalizeFinanceFixtureSources, run,
|
||||
import { buildContainerCostBody, buildSupplierBody, normalizeFinanceFixtureSources, run,
|
||||
supplierCategoryForFeeItem } from './finance-full-fixtures.mjs'
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url))
|
||||
@@ -40,6 +40,16 @@ test('PAYABLE fee selection requires the formal flag and a Finance-supported sup
|
||||
assert.equal(supplierCategoryForFeeItem({ feeCode: 'UNSUPPORTED', feeName: '操作费' }), null)
|
||||
})
|
||||
|
||||
test('Finance PAYABLE fixture creates an isolated ACTIVE supplier through the formal API', () => {
|
||||
const body = buildSupplierBody('ADMIN-API-20260815-FINANCE', 'BOOKING')
|
||||
assert.equal(body.category, 'BOOKING')
|
||||
assert.equal(body.scope, 'DOMESTIC')
|
||||
assert.equal(body.status, 'ACTIVE')
|
||||
assert.match(body.name, /^财务验收供应商-/)
|
||||
assert.match(source, /POST', '\/api\/platform\/v1\/suppliers\?tenantId=0'/)
|
||||
assert.match(source, /detail\?\.status === 'ACTIVE' && detail\?\.category === category/)
|
||||
})
|
||||
|
||||
test('automatic fee fixture completes the reviewed pricing workflow without recalculating', () => {
|
||||
assert.match(source, /latest\?\.feeId/)
|
||||
assert.doesNotMatch(source, /latest\?\.id/)
|
||||
|
||||
@@ -36,6 +36,19 @@ export function supplierCategoryForFeeItem(item) {
|
||||
return null
|
||||
}
|
||||
|
||||
export function buildSupplierBody(marker, category) {
|
||||
const suffix = String(marker || '').replace(/[^0-9A-Za-z]/g, '').slice(-24)
|
||||
return {
|
||||
name: `财务验收供应商-${suffix}`,
|
||||
category,
|
||||
...(category === 'BOOKING' ? { scope: 'DOMESTIC' } : {}),
|
||||
region: '宁波', legalRepresentative: '财务验收法人', contactName: '财务验收联系人',
|
||||
phone: '13800000000', email: `finance-supplier-${suffix || 'fixture'}@example.com`,
|
||||
address: '财务验收地址', businessLicenseNo: `FIN${suffix}`.slice(0, 64),
|
||||
licenseFileId: null, status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: marker,
|
||||
}
|
||||
}
|
||||
|
||||
async function createOrder(context, suffix, pricingProfile = null) {
|
||||
if (context.financeFixtureHooks?.createOrder) return context.financeFixtureHooks.createOrder(context, suffix, pricingProfile)
|
||||
const originalMarker = context.marker
|
||||
@@ -230,10 +243,19 @@ async function loadPublishedAutomaticFee(context, resource) {
|
||||
async function loadSupplier(context, category) {
|
||||
if (context.financeFixtureHooks?.loadSupplier) return context.financeFixtureHooks.loadSupplier(context, category)
|
||||
if (!category) return null
|
||||
const path = `/api/platform/v1/suppliers?page=1&size=200&status=ACTIVE&category=${encodeURIComponent(category)}`
|
||||
const response = await context.request('GET', path)
|
||||
const page = context.apiSuccess(MODULE, '查询 Warehouse ACTIVE 费用类别供应商', response, `category=${category}`, OPTIONS)
|
||||
return rows(page).find((item) => item?.status === 'ACTIVE' && item?.category === category && item?.id && item?.name) || null
|
||||
const body = buildSupplierBody(context.marker, category)
|
||||
const response = await request(context, 'POST', '/api/platform/v1/suppliers?tenantId=0', body)
|
||||
const supplierId = id(context.apiSuccess(MODULE, '创建本轮 Finance 隔离供应商', response,
|
||||
`category=${category}`, OPTIONS))
|
||||
if (!supplierId) return null
|
||||
const detailResponse = await context.request('GET', `/api/platform/v1/suppliers/${encodeURIComponent(supplierId)}?tenantId=0`)
|
||||
const detail = context.apiSuccess(MODULE, '回读本轮 Finance 隔离供应商', detailResponse,
|
||||
`supplierId=${supplierId}`, OPTIONS)
|
||||
context.assert(MODULE, 'Finance 供应商为 ACTIVE 且类别匹配费用项目', detailResponse,
|
||||
id(detail?.id) === supplierId && detail?.status === 'ACTIVE' && detail?.category === category
|
||||
&& detail?.name === body.name,
|
||||
`supplierId=${supplierId}, status=${detail?.status || 'missing'}, category=${detail?.category || 'missing'}`, OPTIONS)
|
||||
return detail?.status === 'ACTIVE' && detail?.category === category ? detail : null
|
||||
}
|
||||
|
||||
async function uploadVoucher(context, customerId) {
|
||||
|
||||
Reference in New Issue
Block a user