优化
This commit is contained in:
@@ -30,6 +30,8 @@ function ok(data) {
|
||||
|
||||
function fakeContext(withFixture = true, permissions = financePermissions, denyFinanceWrites = false,
|
||||
missingSubject = false, omitPayableSource = false) {
|
||||
process.env.MERCHANT_TEST_USERNAME = 'fixture-client'
|
||||
process.env.MERCHANT_TEST_PASSWORD = 'fixture-password'
|
||||
const marker = 'FIN-TEST-MARKER'
|
||||
const receivables = [
|
||||
{ feeSourceId: '101', orderId: '201', direction: 'RECEIVABLE', currency: 'CNY', businessDate: '2026-08-10' },
|
||||
@@ -75,6 +77,8 @@ function fakeContext(withFixture = true, permissions = financePermissions, denyF
|
||||
line.adjustmentReason = adjustment.reason
|
||||
}
|
||||
}
|
||||
if (body.action === 'ISSUE') statement.customerConfirmationStatus = 'PENDING_CONFIRMATION'
|
||||
if (body.action === 'VOID' || body.action === 'REOPEN') statement.customerConfirmationStatus = 'NOT_REQUIRED'
|
||||
return responseForStatement(statement)
|
||||
}
|
||||
|
||||
@@ -88,6 +92,9 @@ function fakeContext(withFixture = true, permissions = financePermissions, denyF
|
||||
if (method === 'GET' && requestPath === '/api/platform/v1/iam/authorization/permissions') {
|
||||
return ok(permissions)
|
||||
}
|
||||
if (method === 'POST' && requestPath === '/api/auth/login') {
|
||||
return ok({ accessToken: 'client-token' })
|
||||
}
|
||||
if (method === 'GET' && requestPath === '/api/platform/finance/v1/accounts?page=1&pageSize=20&customerId=11') {
|
||||
return ok({ records: [{ customerId: '11', customerCode: 'TEN11', customerName: 'Fixture Account',
|
||||
contactName: 'Fixture Contact', contactPhone: '13800000000', outstandingReceivable: 100,
|
||||
@@ -182,6 +189,23 @@ function fakeContext(withFixture = true, permissions = financePermissions, denyF
|
||||
createdBy: item.createdBy, createdAt: item.createdAt, updatedBy: item.updatedBy, updatedAt: item.updatedAt,
|
||||
})))
|
||||
}
|
||||
if (method === 'GET' && requestPath === '/api/client/finance/v1/statements') {
|
||||
return ok([...statements.values()].map((item) => ({
|
||||
statementId: item.statementId, customerId: item.customerId, status: item.status,
|
||||
version: item.version, customerConfirmationStatus: item.customerConfirmationStatus,
|
||||
})))
|
||||
}
|
||||
const clientConfirmMatch = requestPath.match(/\/api\/client\/finance\/v1\/statements\/(\d+)\/confirm$/)
|
||||
if (method === 'POST' && clientConfirmMatch) {
|
||||
const statement = statements.get(clientConfirmMatch[1])
|
||||
statement.customerConfirmationStatus = 'CONFIRMED'
|
||||
statement.version += 1
|
||||
const result = { statementId: statement.statementId, confirmationStatus: 'CONFIRMED',
|
||||
confirmedBy: '7002', confirmedByName: 'fixture-client', confirmedAt: '2026-08-10T10:00:00',
|
||||
version: statement.version }
|
||||
if (idem) idempotency.set(idem, result)
|
||||
return ok(structuredClone(result))
|
||||
}
|
||||
const detailMatch = requestPath.match(/\/reconciliation-statements\/(\d+)$/)
|
||||
if (method === 'GET' && detailMatch) return ok(responseForStatement(statements.get(detailMatch[1])))
|
||||
throw new Error(`Unexpected request: ${method} ${requestPath}`)
|
||||
|
||||
Reference in New Issue
Block a user