fix(loads): onDelivered, proposal.load doesn't exists

This commit is contained in:
Josepablo C
2025-07-14 16:56:34 -06:00
parent 9ffa97ac0b
commit c9d5566288

View File

@@ -13,18 +13,18 @@ const proposalsModel = getModel('proposals');
async function onDelivered( userId, elementId ){
const load = await loadsModel.findById( elementId );
const proposal_list = await proposalsModel.find({
load: load.id,
load: elementId,
is_accepted: true,
is_completed: false
});
const vehicle_list = await vehiclesModel.find({
active_load: load.id
active_load: elementId
});
const current_date = new Date();
/// Update Load: Remove vehicle and driver reference for data safety.
await loadsModel.findByIdAndUpdate( proposal.load, {
await loadsModel.findByIdAndUpdate( elementId, {
driver: null,
vehicle: null,
status: "Closed",