fix(ProposalEvents): Trigger warehouse event only if there is a warehouse asociated
This commit is contained in:
@@ -89,7 +89,11 @@ async function onProposalAccepted( userId, proposalId ){
|
|||||||
const warehouse = await branchesModel.findById( load.shipper_warehouse );
|
const warehouse = await branchesModel.findById( load.shipper_warehouse );
|
||||||
|
|
||||||
await onAcceptedEvents.sendNotification( proposal, load );
|
await onAcceptedEvents.sendNotification( proposal, load );
|
||||||
|
|
||||||
|
if( warehouse ){
|
||||||
|
/// Notify warehouse only if there is any associated to the load/proposal
|
||||||
await onAcceptedEvents.sendWarehouseEmail( warehouse, load, carrier, product, vehicle, driver );
|
await onAcceptedEvents.sendWarehouseEmail( warehouse, load, carrier, product, vehicle, driver );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = { onProposalCreate, onProposalRejected, onProposalAccepted };
|
module.exports = { onProposalCreate, onProposalRejected, onProposalAccepted };
|
||||||
|
|||||||
Reference in New Issue
Block a user