...
Similarly for destination hub allocation following logic will be added in getMultipleConsignmentDestinationHub
fn:
Code Block |
---|
else if (orgConfig.partition_based_hub_allocation) { const lat = get(consignment, 'destination_address.lat', null); const lng = get(consignment, 'destination_address.lng', null); let plannedDestinationHubId = null, plannedDestinationHubCode = null, plannedDestinationHubActive = null; if (!lat || !lng){ throw helper.wrongInputError('', { message: `${consignment.reference_number}:latitude and latitude should be present for partition based hub allocation` }); } const partition = await extendedModels.Partition.findValidPartition( organisationId, { lat, lng, }, options); if (partition && partition.hub_id) { const requiredHub = await extendedModels.Hub.findOne({ where: { id: hubId } }); if (!requiredHub) { throw helper.wrongInputError('Hub not found!'); } plannedDestinationHubId = requiredHub.id; plannedDestinationHubCode = requiredHub.code; plannedDestinationHubActive = requiredHub.is_active; } toRet[consignment.reference_number] = { plannedDestinationHubId, plannedDestinationHubCode, plannedDestinationHubActive }; } |