1
This commit is contained in:
@@ -27,6 +27,35 @@ export function buildFinalizeResource(fixture, finalData, completeResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
export function collectPhase4InboundProducerFixture(previous, producer) {
|
||||
const existing = previous?.marker === producer?.marker && Array.isArray(previous?.containers)
|
||||
? previous.containers : []
|
||||
const containers = [...existing.filter((item) => item.eventKey !== producer.eventKey), producer]
|
||||
const byDestinationType = Object.fromEntries(['FBA', 'OVERSEAS'].map((destinationType) => [
|
||||
destinationType,
|
||||
containers.filter((item) => item.destinationType === destinationType),
|
||||
]))
|
||||
const distinctContainerCount = new Set(containers.map((item) => item.containerNo).filter(Boolean)).size
|
||||
return {
|
||||
marker: producer.marker,
|
||||
containers,
|
||||
byDestinationType,
|
||||
readiness: {
|
||||
fbaContainerCount: byDestinationType.FBA.length,
|
||||
overseasContainerCount: byDestinationType.OVERSEAS.length,
|
||||
distinctContainerCount,
|
||||
readyForPhase4Pda: byDestinationType.FBA.length >= 1
|
||||
&& byDestinationType.OVERSEAS.length >= 1
|
||||
&& distinctContainerCount >= 3,
|
||||
},
|
||||
requiredEntryOrchestration: [
|
||||
'FBA: orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
|
||||
'OVERSEAS-PRIMARY: orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
|
||||
'SECONDARY(FBA|OVERSEAS): orders -> inbound-measurement -> phase3-loading -> phase3-customs -> phase3-loading-finalize',
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
async function request(context, method, path, body, headers = {}) {
|
||||
try {
|
||||
const response = await fetch(`${context.options.gateway}${path}`, {
|
||||
@@ -323,4 +352,27 @@ export async function run(context) {
|
||||
settlementMode,
|
||||
settledOrderId: id(loadedSlice?.childOrderId) || orderId,
|
||||
}
|
||||
const producer = {
|
||||
marker: context.context?.phase4ProducerMatrixMarker || context.marker,
|
||||
eventType: 'FIRST_LEG_LOADING_PLAN_COMPLETED',
|
||||
eventVersion: 2,
|
||||
eventKey: `FIRSTLEG_LOADING_COMPLETED:${loadingPlanId}:${tenantId}:2`,
|
||||
resourceKey: `${context.marker}:${fixture.destinationType || 'UNKNOWN'}:${fixture.containerNo || containerBookingId}`,
|
||||
tenantId,
|
||||
aggregateType: 'LOADING_PLAN',
|
||||
aggregateId: loadingPlanId,
|
||||
loadingPlanId,
|
||||
containerBookingId,
|
||||
sourceOrderId: orderId,
|
||||
sourceInboundId: inboundId,
|
||||
destinationType: fixture.destinationType || null,
|
||||
destinationWarehouseId: id(fixture.destinationWarehouseId),
|
||||
destinationWarehouseCode: fixture.destinationWarehouseCode || null,
|
||||
containerNo: fixture.containerNo || null,
|
||||
sourceStatus: 'LOADED',
|
||||
verification: 'PRODUCED_IN_COMPLETE_TRANSACTION_PENDING_BRIDGE_CONSUMER_HTTP',
|
||||
}
|
||||
context.createdResources.phase3LoadingCompletedProducer = producer
|
||||
context.createdResources.phase4InboundProducerFixtures = collectPhase4InboundProducerFixture(
|
||||
context.createdResources.phase4InboundProducerFixtures, producer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user