diff --git a/v1/src/apps/observers/private/loads/services.js b/v1/src/apps/observers/private/loads/services.js index 42bd704..161d0d2 100644 --- a/v1/src/apps/observers/private/loads/services.js +++ b/v1/src/apps/observers/private/loads/services.js @@ -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"] ) } }); } diff --git a/v1/src/lib/Handlers/Events/Loads/index.js b/v1/src/lib/Handlers/Events/Loads/index.js index 5b23b20..38e1000 100644 --- a/v1/src/lib/Handlers/Events/Loads/index.js +++ b/v1/src/lib/Handlers/Events/Loads/index.js @@ -20,7 +20,6 @@ async function onDelivered( userId, elementId ){ const proposal_list = await proposalsModel.find({ load: elementId, - is_accepted: true, is_completed: false }); diff --git a/v1/src/lib/Handlers/Events/Vehicles/index.js b/v1/src/lib/Handlers/Events/Vehicles/index.js index a452928..2d155e3 100644 --- a/v1/src/lib/Handlers/Events/Vehicles/index.js +++ b/v1/src/lib/Handlers/Events/Vehicles/index.js @@ -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