feat: Adding observers/loads endpoint

This commit is contained in:
Josepablo C
2025-06-06 23:26:46 -06:00
parent ef66a297d4
commit 661c550cb2
7 changed files with 156 additions and 257 deletions

View File

@@ -83,17 +83,7 @@ async function onProposalAccepted( userId, proposalId ){
} );
const load = await loadsModel.findById( proposal.load );
const carrier = await companiesModel.findById( load.carrier );
const product = await productsModel.findById( load.product );
const driver = await usersModel.findById( load.driver );
const warehouse = await branchesModel.findById( load.shipper_warehouse );
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 );
}
}
module.exports = { onProposalCreate, onProposalRejected, onProposalAccepted };

View File

@@ -43,7 +43,8 @@ const schema = new Schema({
alert_list: [{ type: String, lowercase: true }],
shipper_warehouse : { type: Schema.Types.ObjectId, ref: 'branches' },
origin_warehouse : { type: Schema.Types.ObjectId, ref: 'branches' },
destination_warehouse : { type: Schema.Types.ObjectId, ref: 'branches' },
origin: address,
origin_geo: {