fix(vehicles::events): on driver changed modify loads that are applicable
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version" : {
|
"version" : {
|
||||||
"version" : "1.5.8",
|
"version" : "1.5.9",
|
||||||
"name": "ETA Beta",
|
"name": "ETA Beta",
|
||||||
"date":"22/07/2025"
|
"date":"22/07/2025"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -50,16 +50,18 @@ async function onVehicleDriverChanged( userId, vehicleId ){
|
|||||||
for( const proposal of proposal_list ){
|
for( const proposal of proposal_list ){
|
||||||
if( proposal.is_accepted === true ){
|
if( proposal.is_accepted === true ){
|
||||||
const load = await loadsModel.findById( proposal.load );
|
const load = await loadsModel.findById( proposal.load );
|
||||||
const origin_warehouse = await branchesModel.findById( load.origin_warehouse );
|
if( load ){
|
||||||
const destination_warehouse = await branchesModel.findById( load.destination_warehouse );
|
const origin_warehouse = await branchesModel.findById( load.origin_warehouse );
|
||||||
const carrier = await companiesModel.findById( load.carrier ) || {};
|
const destination_warehouse = await branchesModel.findById( load.destination_warehouse );
|
||||||
const product = await productsModel.findById( load.product ) || {};
|
const carrier = await companiesModel.findById( load.carrier ) || {};
|
||||||
|
const product = await productsModel.findById( load.product ) || {};
|
||||||
|
|
||||||
if( origin_warehouse ){
|
if( origin_warehouse ){
|
||||||
await onDriverChanged.sendWarehouseNotification( origin_warehouse, load, carrier, product, vehicle, driver );
|
await onDriverChanged.sendWarehouseNotification( origin_warehouse, load, carrier, product, vehicle, driver );
|
||||||
}
|
}
|
||||||
if( destination_warehouse ){
|
if( destination_warehouse ){
|
||||||
await onDriverChanged.sendWarehouseNotification( destination_warehouse, load, carrier, product, vehicle, driver );
|
await onDriverChanged.sendWarehouseNotification( destination_warehouse, load, carrier, product, vehicle, driver );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user