feat(travelFilter): add daysOnward
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Alex Moreno 2024-09-23 15:30:10 +02:00
parent c0cc25219f
commit 882f1eb7c2
1 changed files with 15 additions and 2 deletions

View File

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