diff --git a/v1/README.md b/v1/README.md index 99236ce..ca2e54d 100644 --- a/v1/README.md +++ b/v1/README.md @@ -374,6 +374,8 @@ This endpoint is part of /loads endpoint - product - shipment_code - 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[$options] : Regex options from MongoDB filter description - $sort[ field ] : -1/1 ; Sort result by field name diff --git a/v1/src/apps/private/loads/services.js b/v1/src/apps/private/loads/services.js index 509d43b..2efa7ad 100644 --- a/v1/src/apps/private/loads/services.js +++ b/v1/src/apps/private/loads/services.js @@ -54,7 +54,8 @@ function getAndFilterList( query ){ categories, product, shipment_code, - shipper_warehouse + shipper_warehouse, + est_loading_date } = query; if( company ){ filter_list.push( { company } ); } @@ -72,6 +73,20 @@ function getAndFilterList( query ){ if( product ) { filter_list.push({ product }); } if( shipment_code ) { filter_list.push({ shipment_code }); } 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 ){ return null;