feat: Adding observers/loads endpoint
This commit is contained in:
@@ -29,7 +29,8 @@ const populate_list = [
|
||||
'product',
|
||||
'company',
|
||||
'categories',
|
||||
'shipper_warehouse',
|
||||
'origin_warehouse',
|
||||
'destination_warehouse',
|
||||
{path:'carrier',select: carrier_projection },
|
||||
{path:'vehicle',select: vehicle_projection },
|
||||
{path:'driver',select: user_projection },
|
||||
@@ -54,8 +55,10 @@ function getAndFilterList( query ){
|
||||
categories,
|
||||
product,
|
||||
shipment_code,
|
||||
shipper_warehouse,
|
||||
origin_warehouse,
|
||||
destination_warehouse,
|
||||
est_loading_date,
|
||||
est_unloading_date,
|
||||
alert_list,
|
||||
} = query;
|
||||
|
||||
@@ -73,7 +76,8 @@ function getAndFilterList( query ){
|
||||
if( categories ) { filter_list.push({ categories }); }
|
||||
if( product ) { filter_list.push({ product }); }
|
||||
if( shipment_code ) { filter_list.push({ shipment_code }); }
|
||||
if( shipper_warehouse ) { filter_list.push({ shipper_warehouse }); }
|
||||
if( origin_warehouse ) { filter_list.push({ origin_warehouse }); }
|
||||
if( destination_warehouse ) { filter_list.push({ destination_warehouse }); }
|
||||
if( alert_list ) { filter_list.push({ alert_list }); }
|
||||
if( est_loading_date ) {
|
||||
if( (est_loading_date.gte == undefined) || (est_loading_date.gte == null) ){
|
||||
@@ -90,6 +94,21 @@ function getAndFilterList( query ){
|
||||
});
|
||||
}
|
||||
|
||||
if( est_unloading_date ) {
|
||||
if( (est_unloading_date.gte == undefined) || (est_unloading_date.gte == null) ){
|
||||
throw "est_unloading_date[gte] is required";
|
||||
}
|
||||
if( (est_unloading_date.lte == undefined) || (est_unloading_date.lte == null) ){
|
||||
throw "est_unloading_date[lte] is required";
|
||||
}
|
||||
filter_list.push({
|
||||
"est_unloading_date" : {
|
||||
$gte : new Date( est_unloading_date["gte"] ),
|
||||
$lte : new Date( est_unloading_date["lte"] )
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if( filter_list.length == 0 ){
|
||||
return null;
|
||||
}
|
||||
@@ -147,7 +166,6 @@ async function findCalendarLoads( userId, companyId, query ){
|
||||
const select = null;
|
||||
const { date, load_status , $sort } = query;
|
||||
const { global } = query;
|
||||
const { shipper_warehouse } = query;
|
||||
|
||||
if( ! date ){
|
||||
throw "Date field is required";
|
||||
@@ -185,10 +203,6 @@ async function findCalendarLoads( userId, companyId, query ){
|
||||
andFilterList.push( { load_status } )
|
||||
}
|
||||
|
||||
if( shipper_warehouse ){
|
||||
andFilterList.push( { shipper_warehouse } )
|
||||
}
|
||||
|
||||
const filter = {
|
||||
$and : andFilterList,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user