refs #5410 feat: añadido filtro a las columnas created y defaulterSinced
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-03-16 13:55:21 +01:00
parent 38bf49c0b6
commit bc47fc35d6
2 changed files with 37 additions and 2 deletions

View File

@ -46,11 +46,11 @@ export default class Controller extends Section {
},
{
field: 'created',
searchable: false
datepicker: true
},
{
field: 'defaulterSinced',
searchable: false
datepicker: true
}
]
};
@ -136,8 +136,25 @@ export default class Controller extends Section {
case 'workerFk':
case 'salesPersonFk':
return {[`d.${param}`]: value};
case 'created':
return {'d.created': {
between: this.dateRange(value)}
};
case 'defaulterSinced':
return {'d.defaulterSinced': {
between: this.dateRange(value)}
};
}
}
dateRange(value) {
const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value);
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
}
}
ngModule.vnComponent('vnClientDefaulter', {

View File

@ -117,5 +117,23 @@ describe('client defaulter', () => {
expect(controller.balanceDueTotal).toEqual(875);
});
});
describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => {
const now = Date.vnNew();
const today = now.getDate();
const dateRange = controller.dateRange(now);
const start = dateRange[0].toString();
const end = dateRange[1].toString();
expect(start).toContain(today);
expect(start).toContain('00:00:00');
expect(end).toContain(today);
expect(end).toContain('23:59:59');
});
});
});
});