test: provision finance fixture prerequisites

This commit is contained in:
2026-08-15 17:58:15 +08:00
parent 0e2a291e7a
commit 2cec065582
5 changed files with 56 additions and 5 deletions
@@ -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) {