fix(loads/observers): Affect proposals that are not completed, even if not accepted
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
const { getModel } = require( '../../../../lib/Models' );
|
||||
const { getPagination } = require( '../../../../lib/Misc.js' );
|
||||
const { getPagination, normalizeDate } = require( '../../../../lib/Misc.js' );
|
||||
const { GenericHandler } = require( '../../../../lib/Handlers/Generic.handler.js' );
|
||||
|
||||
const BranchesModel = getModel('branches');
|
||||
@@ -81,8 +81,8 @@ function getAndFilterList( query ){
|
||||
}
|
||||
filter_list.push({
|
||||
"est_loading_date" : {
|
||||
$gte : new Date( est_loading_date["gte"] ),
|
||||
$lte : new Date( est_loading_date["lte"] )
|
||||
$gte : normalizeDate( est_loading_date["gte"] ),
|
||||
$lte : normalizeDate( est_loading_date["lte"] )
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -96,8 +96,8 @@ function getAndFilterList( query ){
|
||||
}
|
||||
filter_list.push({
|
||||
"est_unloading_date" : {
|
||||
$gte : new Date( est_unloading_date["gte"] ),
|
||||
$lte : new Date( est_unloading_date["lte"] )
|
||||
$gte : normalizeDate( est_unloading_date["gte"] ),
|
||||
$lte : normalizeDate( est_unloading_date["lte"] )
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ async function onDelivered( userId, elementId ){
|
||||
|
||||
const proposal_list = await proposalsModel.find({
|
||||
load: elementId,
|
||||
is_accepted: true,
|
||||
is_completed: false
|
||||
});
|
||||
|
||||
|
||||
@@ -16,12 +16,10 @@ async function onVehicleDriverChanged( userId, vehicleId ){
|
||||
const driver = await usersModel.findById( vehicle.driver );
|
||||
const proposal_list = await proposalsModel.find({
|
||||
vehicle: vehicleId,
|
||||
is_accepted: true,
|
||||
is_completed: false
|
||||
});
|
||||
|
||||
/// Update proposals related to this load. Ideally, just one.
|
||||
// remove vehicle for data safety.
|
||||
for( const proposal of proposal_list ){
|
||||
/// Update Load:
|
||||
/// Add driver and vehicle
|
||||
|
||||
Reference in New Issue
Block a user