fix(loads/observers): Affect proposals that are not completed, even if not accepted

This commit is contained in:
Josepablo C
2025-07-22 18:51:05 -06:00
parent 76915cfb57
commit 1d0e6e887f
3 changed files with 5 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
"use strict"; "use strict";
const { getModel } = require( '../../../../lib/Models' ); 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 { GenericHandler } = require( '../../../../lib/Handlers/Generic.handler.js' );
const BranchesModel = getModel('branches'); const BranchesModel = getModel('branches');
@@ -81,8 +81,8 @@ function getAndFilterList( query ){
} }
filter_list.push({ filter_list.push({
"est_loading_date" : { "est_loading_date" : {
$gte : new Date( est_loading_date["gte"] ), $gte : normalizeDate( est_loading_date["gte"] ),
$lte : new Date( est_loading_date["lte"] ) $lte : normalizeDate( est_loading_date["lte"] )
} }
}); });
} }
@@ -96,8 +96,8 @@ function getAndFilterList( query ){
} }
filter_list.push({ filter_list.push({
"est_unloading_date" : { "est_unloading_date" : {
$gte : new Date( est_unloading_date["gte"] ), $gte : normalizeDate( est_unloading_date["gte"] ),
$lte : new Date( est_unloading_date["lte"] ) $lte : normalizeDate( est_unloading_date["lte"] )
} }
}); });
} }

View File

@@ -20,7 +20,6 @@ async function onDelivered( userId, elementId ){
const proposal_list = await proposalsModel.find({ const proposal_list = await proposalsModel.find({
load: elementId, load: elementId,
is_accepted: true,
is_completed: false is_completed: false
}); });

View File

@@ -16,12 +16,10 @@ async function onVehicleDriverChanged( userId, vehicleId ){
const driver = await usersModel.findById( vehicle.driver ); const driver = await usersModel.findById( vehicle.driver );
const proposal_list = await proposalsModel.find({ const proposal_list = await proposalsModel.find({
vehicle: vehicleId, vehicle: vehicleId,
is_accepted: true,
is_completed: false is_completed: false
}); });
/// Update proposals related to this load. Ideally, just one. /// Update proposals related to this load. Ideally, just one.
// remove vehicle for data safety.
for( const proposal of proposal_list ){ for( const proposal of proposal_list ){
/// Update Load: /// Update Load:
/// Add driver and vehicle /// Add driver and vehicle