diff --git a/v1/src/config/apiConfig.json b/v1/src/config/apiConfig.json index 92c2c18..a9a87f7 100644 --- a/v1/src/config/apiConfig.json +++ b/v1/src/config/apiConfig.json @@ -16,7 +16,7 @@ } }, "version" : { - "version" : "1.5.8", + "version" : "1.5.9", "name": "ETA Beta", "date":"22/07/2025" }, diff --git a/v1/src/lib/Handlers/Events/Vehicles/index.js b/v1/src/lib/Handlers/Events/Vehicles/index.js index aebafb9..46119cf 100644 --- a/v1/src/lib/Handlers/Events/Vehicles/index.js +++ b/v1/src/lib/Handlers/Events/Vehicles/index.js @@ -50,16 +50,18 @@ async function onVehicleDriverChanged( userId, vehicleId ){ for( const proposal of proposal_list ){ if( proposal.is_accepted === true ){ const load = await loadsModel.findById( proposal.load ); - const origin_warehouse = await branchesModel.findById( load.origin_warehouse ); - const destination_warehouse = await branchesModel.findById( load.destination_warehouse ); - const carrier = await companiesModel.findById( load.carrier ) || {}; - const product = await productsModel.findById( load.product ) || {}; + if( load ){ + const origin_warehouse = await branchesModel.findById( load.origin_warehouse ); + const destination_warehouse = await branchesModel.findById( load.destination_warehouse ); + const carrier = await companiesModel.findById( load.carrier ) || {}; + const product = await productsModel.findById( load.product ) || {}; - if( origin_warehouse ){ - await onDriverChanged.sendWarehouseNotification( origin_warehouse, load, carrier, product, vehicle, driver ); - } - if( destination_warehouse ){ - await onDriverChanged.sendWarehouseNotification( destination_warehouse, load, carrier, product, vehicle, driver ); + if( origin_warehouse ){ + await onDriverChanged.sendWarehouseNotification( origin_warehouse, load, carrier, product, vehicle, driver ); + } + if( destination_warehouse ){ + await onDriverChanged.sendWarehouseNotification( destination_warehouse, load, carrier, product, vehicle, driver ); + } } } }