fix(ProposalEvents): Trigger warehouse event only if there is a warehouse asociated

This commit is contained in:
Josepablo C
2025-04-09 20:01:10 -06:00
parent ca84654306
commit 3b2215c842

View File

@@ -89,7 +89,11 @@ async function onProposalAccepted( userId, proposalId ){
const warehouse = await branchesModel.findById( load.shipper_warehouse );
await onAcceptedEvents.sendNotification( proposal, load );
await onAcceptedEvents.sendWarehouseEmail( warehouse, load, carrier, product, vehicle, driver );
if( warehouse ){
/// Notify warehouse only if there is any associated to the load/proposal
await onAcceptedEvents.sendWarehouseEmail( warehouse, load, carrier, product, vehicle, driver );
}
}
module.exports = { onProposalCreate, onProposalRejected, onProposalAccepted };