From 605388e6668026ddc44afe7df6db7b6e5dad492e Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Fri, 2 Oct 2026 11:33:51 +0800 Subject: [PATCH] fix(client): retain customs access after order completion --- .../first-leg/utils/customsEligibility.ts | 6 ++ .../views/CustomsDocumentsView.test.mjs | 91 +++++++++++++++++++ .../first-leg/views/CustomsDocumentsView.vue | 8 +- .../views/FirstLegOrdersView.test.mjs | 4 +- .../first-leg/views/FirstLegOrdersView.vue | 5 +- 5 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 src/modules/first-leg/utils/customsEligibility.ts create mode 100644 src/modules/first-leg/views/CustomsDocumentsView.test.mjs diff --git a/src/modules/first-leg/utils/customsEligibility.ts b/src/modules/first-leg/utils/customsEligibility.ts new file mode 100644 index 0000000..f766f37 --- /dev/null +++ b/src/modules/first-leg/utils/customsEligibility.ts @@ -0,0 +1,6 @@ +import type { FirstLegOrder } from '../types/firstLegOrder' + +export function isCustomsOrderCandidate(order: Pick): boolean { + return order.taxMode === 'TAX_REFUND' + && (order.status === 'LOADED' || order.status === 'DELIVERED' || order.status === 'COMPLETED') +} diff --git a/src/modules/first-leg/views/CustomsDocumentsView.test.mjs b/src/modules/first-leg/views/CustomsDocumentsView.test.mjs new file mode 100644 index 0000000..269b13f --- /dev/null +++ b/src/modules/first-leg/views/CustomsDocumentsView.test.mjs @@ -0,0 +1,91 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { readFileSync } from 'node:fs' +import ts from 'typescript' +import * as vue from 'vue' + +function evaluate(source, dependencies = {}) { + const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 } }).outputText + const exports = {} + new Function('require', 'exports', code)(id => { + assert.ok(id in dependencies, `Unexpected dependency ${id}`) + return dependencies[id] + }, exports) + return exports +} +const eligibility = evaluate(readFileSync(new URL('../utils/customsEligibility.ts', import.meta.url), 'utf8')) +const order = (id, status = 'LOADED', taxMode = 'TAX_REFUND') => ({ id, status, taxMode, orderNo: `ORDER-${id}`, businessSummary: { inboundCode: `IN-${id}` } }) +const detail = id => ({ status: 'COMPLETED', merchantStatus: 'CUSTOMS_COMPLETED', inbounds: [{ orderId: id, taxMode: 'TAX_REFUND' }] }) +function harness(t, orders, getDetail = async id => detail(id)) { + const store = { orders, loadError: '', load: async () => {} }, calls = [] + const source = readFileSync(new URL('./CustomsDocumentsView.vue', import.meta.url), 'utf8').match(/