feat(travelFilter): add daysOnward #3008

Merged
alexm merged 3 commits from hotFix_travelList_daysOnward into test 2024-09-24 10:21:56 +00:00
1 changed files with 15 additions and 2 deletions

View File

@ -79,6 +79,10 @@ module.exports = Self => {
arg: 'landingHour',
type: 'string',
description: 'The landing hour'
}, {
arg: 'daysOnward',
type: 'number',
description: 'The days onward'
}
],
returns: {
@ -92,8 +96,11 @@ module.exports = Self => {
});
Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector;
let where = buildFilter(ctx.args, (param, value) => {
const conn = Self.dataSource.connector;
const today = Date.vnNew();
const future = Date.vnNew();
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
@ -109,6 +116,12 @@ module.exports = Self => {
return {'t.landed': {gte: value}};
case 'landedTo':
return {'t.landed': {lte: value}};
case 'daysOnward':
Review

from , to ?

from , to ?
today.setHours(0, 0, 0, 0);
future.setDate(today.getDate() + value);
future.setHours(23, 59, 59, 999);
return {'t.landed': {between: [today, future]}};
case 'id':
case 'agencyModeFk':
case 'warehouseOutFk':