This commit is contained in:
2026-09-15 11:54:14 +08:00
parent 3fb9909dd3
commit c1f01e1e87
56 changed files with 973 additions and 231 deletions
@@ -5,7 +5,7 @@ import test from 'node:test'
import { oceanBookingDraft, oceanBookingDraftWithoutCustomer, publishPlatformLogisticsChannels, resolveOceanBookingAgent, resolveOceanBookingMaster } from './ocean-booking-fixture.mjs'
const read = (name) => readFileSync(new URL(name, import.meta.url), 'utf8')
const master = { customerId: '21', customerName: 'IT 测试客户', channelCode: 'SEA-US', channelName: '美西海运', warehouseId: '41', warehouseName: '深圳仓' }
const master = { customerId: '21', customerName: 'IT 测试客户', channelCode: 'MATSON_CLX_TRUCK', channelName: '美森正班海卡', warehouseId: '41', warehouseName: '深圳仓' }
test('fixture resolves current-marker customer channel and warehouse without inventing data', async () => {
const steps = []
@@ -22,6 +22,7 @@ test('fixture resolves current-marker customer channel and warehouse without inv
test('shared DRAFT uses requirements and never registers a real container number', () => {
const draft = oceanBookingDraft({ marker: 'ADMIN-RUN-3' }, '3', master)
assert.equal(draft.channelName, undefined)
assert.equal(draft.channelCode, 'MATSON_CLX')
assert.equal(draft.warehouseName, undefined)
assert.deepEqual(draft.containerRequirements, [{ containerType: '40HQ', containerKind: 'FCL', quantity: 1, capacityCbm: 68, maxWeightKg: 19500 }])
assert.equal(Object.hasOwn(draft, 'containers'), false)
@@ -1,3 +1,5 @@
import { channelGroup } from './smart-loading-channel-group.mjs'
function text(value) { return value == null ? '' : String(value).trim() }
const PLATFORM_CHANNELS = '/api/platform/v1/ocean-bookings/channels'
@@ -73,6 +75,7 @@ export function oceanBookingDraft(context, suffix, master, labels = {}) {
}]
return {
...writableMaster,
channelCode: channelGroup(writableMaster.channelCode),
billOfLadingNo: labels.billOfLadingNo || `BL-${suffix}`,
carrierCode: labels.carrierCode || 'OTHER',
shippingCompanyId: labels.shippingCompanyId ?? null,
@@ -1,5 +1,7 @@
export function channelGroup(channelCode) {
const value = String(channelCode || '').trim().toUpperCase()
if (['MATSON_CLX', 'MATSON_MAX', 'EXX', 'HEDE', 'OA_LA', 'OA_CHICAGO',
'OA_HOUSTON', 'OA_SAVANNAH', 'OA_NEW_YORK_TRUCK'].includes(value)) return value
if (value.startsWith('EXX_') || ['EXXHK', 'EXXHWK', 'NYEXX'].includes(value)) return 'EXX'
if (value.startsWith('MATSON_CLX_') || ['ZBYHK', 'ZBYHWK', 'ZBYHP'].includes(value)) return 'MATSON_CLX'
if (value.startsWith('MATSON_MAX_') || ['BYHK', 'BYHWK', 'BYHP'].includes(value)) return 'MATSON_MAX'