fix(loads): onDelivered, proposal.load doesn't exists
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user