fix(loads/find): Adding est_loading_date field to the find query
This commit is contained in:
@@ -374,6 +374,8 @@ This endpoint is part of /loads endpoint
|
|||||||
- product
|
- product
|
||||||
- shipment_code
|
- shipment_code
|
||||||
- shipper_warehouse : id of a company branch
|
- shipper_warehouse : id of a company branch
|
||||||
|
- est_loading_date[gte] : Date greater than.
|
||||||
|
- est_loading_date[lte] : Date less than.
|
||||||
- company_name[$regex] : Regex string to find company_name
|
- company_name[$regex] : Regex string to find company_name
|
||||||
- company_name[$options] : Regex options from MongoDB filter description
|
- company_name[$options] : Regex options from MongoDB filter description
|
||||||
- $sort[ field ] : -1/1 ; Sort result by field name
|
- $sort[ field ] : -1/1 ; Sort result by field name
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ function getAndFilterList( query ){
|
|||||||
categories,
|
categories,
|
||||||
product,
|
product,
|
||||||
shipment_code,
|
shipment_code,
|
||||||
shipper_warehouse
|
shipper_warehouse,
|
||||||
|
est_loading_date
|
||||||
} = query;
|
} = query;
|
||||||
|
|
||||||
if( company ){ filter_list.push( { company } ); }
|
if( company ){ filter_list.push( { company } ); }
|
||||||
@@ -72,6 +73,20 @@ function getAndFilterList( query ){
|
|||||||
if( product ) { filter_list.push({ product }); }
|
if( product ) { filter_list.push({ product }); }
|
||||||
if( shipment_code ) { filter_list.push({ shipment_code }); }
|
if( shipment_code ) { filter_list.push({ shipment_code }); }
|
||||||
if( shipper_warehouse ) { filter_list.push({ shipper_warehouse }); }
|
if( shipper_warehouse ) { filter_list.push({ shipper_warehouse }); }
|
||||||
|
if( est_loading_date ) {
|
||||||
|
if( (est_loading_date.gte == undefined) || (est_loading_date.gte == null) ){
|
||||||
|
throw "est_loading_date[gte] is required";
|
||||||
|
}
|
||||||
|
if( (est_loading_date.lte == undefined) || (est_loading_date.lte == null) ){
|
||||||
|
throw "est_loading_date[lte] is required";
|
||||||
|
}
|
||||||
|
filter_list.push({
|
||||||
|
"est_loading_date" : {
|
||||||
|
$gte : new Date( est_loading_date["gte"] ),
|
||||||
|
$lte : new Date( est_loading_date["lte"] )
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if( filter_list.length == 0 ){
|
if( filter_list.length == 0 ){
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user