Merge pull request '4258-worker_time-control_tests' (#1014) from 4217-worker_time-control_tests into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1014 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
1b39446552
|
@ -1967,7 +1967,8 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`
|
|||
(1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))),
|
||||
(1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))),
|
||||
(1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))),
|
||||
(1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY)));
|
||||
(1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))),
|
||||
(1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY));
|
||||
|
||||
INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
|
||||
VALUES
|
||||
|
@ -2237,8 +2238,8 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`)
|
|||
VALUES
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in'),
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle'),
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 10:10'), TRUE, 'middle'),
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 15:00'), TRUE, 'out');
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle'),
|
||||
(1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out');
|
||||
|
||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||
VALUES
|
||||
|
@ -2606,3 +2607,7 @@ INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`)
|
|||
INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`)
|
||||
VALUES
|
||||
(1, 1);
|
||||
|
||||
INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`)
|
||||
VALUES
|
||||
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
|
|
@ -44093,6 +44093,7 @@ WHERE
|
|||
RETURN vPhyto;
|
||||
END ;;
|
||||
DELIMITER ;
|
||||
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
|
|
|
@ -911,52 +911,16 @@ export default {
|
|||
dialogTimeInput: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newTimeEntry.timed"]',
|
||||
dialogTimeDirection: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.newTimeEntry.direction"]',
|
||||
mondayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button',
|
||||
tuesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button',
|
||||
wednesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button',
|
||||
thursdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-icon-button',
|
||||
fridayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(5) > vn-icon-button',
|
||||
saturdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(6) > vn-icon-button',
|
||||
sundayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(7) > vn-icon-button',
|
||||
firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > vn-chip > div:nth-child(2)',
|
||||
firstEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > vn-icon[icon="cancel"]',
|
||||
secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > vn-icon[icon="cancel"]',
|
||||
thirdEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > vn-chip > div:nth-child(2)',
|
||||
mondayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(1)',
|
||||
tuesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(2)',
|
||||
wednesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(3)',
|
||||
thursdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(4)',
|
||||
fridayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(5)',
|
||||
saturdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(6)',
|
||||
sundayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)',
|
||||
weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span',
|
||||
nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]',
|
||||
previousMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_left]',
|
||||
monthName: 'vn-worker-time-control vn-side-menu vn-calendar div > .title',
|
||||
secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number',
|
||||
thrirdWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(15) > .day-number',
|
||||
navigateBackToIndex: 'vn-worker-descriptor [name="goToModuleIndex"]'
|
||||
},
|
||||
workerCalendar: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
|
@ -10,414 +11,105 @@ describe('Worker time control path', () => {
|
|||
await page.loginAndModule('salesBoss', 'worker');
|
||||
await page.accessToSearchResult('HankPym');
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
describe('as salesBoss', () => {
|
||||
describe('on Monday', () => {
|
||||
it('should scan in Hank Pym', async() => {
|
||||
const scanTime = '07:00';
|
||||
const eightAm = '08:00';
|
||||
const fourPm = '16:00';
|
||||
const hankPymId = 1107;
|
||||
|
||||
it('should go to the next month', async() => {
|
||||
const date = new Date();
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
const month = date.toLocaleString('default', {month: 'long'});
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||
|
||||
expect(result).toContain(month);
|
||||
});
|
||||
|
||||
it('should go to current month', async() => {
|
||||
const date = new Date();
|
||||
const month = date.toLocaleString('default', {month: 'long'});
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||
|
||||
expect(result).toContain(month);
|
||||
});
|
||||
|
||||
it('should go 1 month in the past', async() => {
|
||||
const date = new Date();
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
const timestamp = Math.round(date.getTime() / 1000);
|
||||
const month = date.toLocaleString('default', {month: 'long'});
|
||||
|
||||
await page.loginAndModule('salesBoss', 'worker');
|
||||
await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||
|
||||
expect(result).toContain(month);
|
||||
});
|
||||
|
||||
it(`should return error when insert 'out' of first entry`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toBeDefined();
|
||||
});
|
||||
|
||||
it(`should insert 'in' monday`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
expect(result).toEqual(eightAm);
|
||||
});
|
||||
|
||||
it(`should scan out Hank Pym for break`, async() => {
|
||||
const scanTime = '10:00';
|
||||
|
||||
it(`should insert 'out' monday`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
expect(result).toEqual(fourPm);
|
||||
});
|
||||
|
||||
it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => {
|
||||
const scanTime = '18:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
it(`should check Hank Pym worked 8:20 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.');
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.');
|
||||
});
|
||||
|
||||
it(`should delete the wrong entry for Hank Pym`, async() => {
|
||||
const wrongScanTime = '18:00';
|
||||
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime);
|
||||
await page.waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete);
|
||||
it('should remove first entry of monday', async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm);
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm);
|
||||
await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete);
|
||||
await page.respondToDialog('accept');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Entry removed');
|
||||
});
|
||||
|
||||
it(`should scan out Hank Pym to leave early`, async() => {
|
||||
const scanTime = '14:00';
|
||||
it(`should be the 'out' the first entry of monday`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
expect(result).toEqual(fourPm);
|
||||
});
|
||||
|
||||
it(`should add the break's scan in for Hank Pym and be in the right order`, async() => {
|
||||
const scanTime = '10:20';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual('14:00');
|
||||
});
|
||||
|
||||
it(`should the third entry be the scan in from break`, async() => {
|
||||
const scanTime = '10:20';
|
||||
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 6:40 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Tuesday', () => {
|
||||
it('should happily scan in Hank Pym', async() => {
|
||||
const scanTime = '08:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfTuesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should happily scan out Hank Pym for break`, async() => {
|
||||
const scanTime = '10:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfTuesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should happily scan in Hank Pym from the break`, async() => {
|
||||
const scanTime = '10:20';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfTuesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should happily scan out Hank Pym for the day`, async() => {
|
||||
const scanTime = '16:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfTuesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Wednesday', () => {
|
||||
it('should cheerfully scan in Hank Pym', async() => {
|
||||
const scanTime = '09:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfWednesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should cheerfully scan out Hank Pym for break`, async() => {
|
||||
const scanTime = '10:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfWednesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should cheerfully scan in Hank Pym from the break`, async() => {
|
||||
const scanTime = '10:20';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfWednesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should cheerfully scan out Hank Pym for the day`, async() => {
|
||||
const scanTime = '17:00';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfWednesday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 cheerfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Thursday', () => {
|
||||
it('should joyfully scan in Hank Pym', async() => {
|
||||
const scanTime = '09:59';
|
||||
|
||||
await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfThursday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should joyfully scan out Hank Pym for break`, async() => {
|
||||
const scanTime = '10:00';
|
||||
await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfThursday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should joyfully scan in Hank Pym from the break`, async() => {
|
||||
const scanTime = '10:20';
|
||||
await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfThursday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should joyfully scan out Hank Pym for the day`, async() => {
|
||||
const scanTime = '17:59';
|
||||
await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfThursday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 joyfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Friday', () => {
|
||||
it('should smilingly scan in Hank Pym', async() => {
|
||||
const scanTime = '07:30';
|
||||
await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfFriday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should smilingly scan out Hank Pym for break`, async() => {
|
||||
const scanTime = '10:00';
|
||||
await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfFriday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should smilingly scan in Hank Pym from the break`, async() => {
|
||||
const scanTime = '10:20';
|
||||
await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfFriday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should smilingly scan out Hank Pym for the day`, async() => {
|
||||
const scanTime = '15:30';
|
||||
await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfFriday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 hours with a smile on his face`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('as HHRR', () => {
|
||||
describe('on Saturday', () => {
|
||||
it('should log in as hr and pick the worker module', async() => {
|
||||
await page.loginAndModule('hr', 'worker');
|
||||
});
|
||||
|
||||
it('should search for a worker and access to its summary', async() => {
|
||||
await page.accessToSearchResult('HankPym');
|
||||
await page.waitForState('worker.card.summary');
|
||||
});
|
||||
|
||||
it('should access to the time control section', async() => {
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitForState('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
it('should lovingly scan in Hank Pym', async() => {
|
||||
const scanTime = '06:00';
|
||||
await page.waitForTimeout(1000); // without this timeout the dialog doesn't pop up
|
||||
await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSaturday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should lovingly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
|
||||
const scanTime = '13:40';
|
||||
await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSaturday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 hours with all his will`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Sunday', () => {
|
||||
it('should gladly scan in Hank Pym', async() => {
|
||||
const scanTime = '05:00';
|
||||
await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSunday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should gladly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
|
||||
const scanTime = '12:40';
|
||||
await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSunday, 'innerText');
|
||||
|
||||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7:40 glad hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '07:40 h.');
|
||||
});
|
||||
|
||||
it(`should check Hank Pym doesn't have hours set on the next months second week`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.');
|
||||
});
|
||||
|
||||
it(`should check he didn't scan in this week yet`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.navigateBackToIndex);
|
||||
await page.accessToSearchResult('salesBoss');
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
|
||||
const wholeWeekHours = await page
|
||||
.waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
|
||||
|
||||
expect(wholeWeekHours).toEqual('00:00 h.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('after all this amazing week', () => {
|
||||
it('should log in Hank', async() => {
|
||||
await page.loginAndModule('HankPym', 'worker');
|
||||
await page.accessToSearchResult('HankPym');
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
it('should check his weekly hours are alright', async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '52:40 h.');
|
||||
});
|
||||
it('should change week of month', async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.thrirdWeekDay);
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '00:00 h.');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -124,5 +124,13 @@
|
|||
"isWithoutNegatives": "isWithoutNegatives",
|
||||
"routeFk": "routeFk",
|
||||
"Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data",
|
||||
"Can't change the password of another worker": "Can't change the password of another worker"
|
||||
"Can't change the password of another worker": "Can't change the password of another worker",
|
||||
"No hay un contrato en vigor": "There is no existing contract",
|
||||
"No está permitido trabajar": "Not allowed to work",
|
||||
"Dirección incorrecta": "Wrong direction",
|
||||
"No se permite fichar a futuro": "It is not allowed to sign in the future",
|
||||
"Descanso diario 12h.": "Daily rest 12h.",
|
||||
"Fichadas impares": "Odd signs",
|
||||
"Descanso diario 9h.": "Daily rest 9h.",
|
||||
"Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h."
|
||||
}
|
|
@ -227,5 +227,12 @@
|
|||
"This ticket is already a refund": "Este ticket ya es un abono",
|
||||
"isWithoutNegatives": "isWithoutNegatives",
|
||||
"routeFk": "routeFk",
|
||||
"Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador"
|
||||
"Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador",
|
||||
"No hay un contrato en vigor": "No hay un contrato en vigor",
|
||||
"No se permite fichar a futuro": "No se permite fichar a futuro",
|
||||
"No está permitido trabajar": "No está permitido trabajar",
|
||||
"Fichadas impares": "Fichadas impares",
|
||||
"Descanso diario 12h.": "Descanso diario 12h.",
|
||||
"Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
|
||||
"Dirección incorrecta": "Dirección incorrecta"
|
||||
}
|
|
@ -46,30 +46,11 @@ module.exports = Self => {
|
|||
if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss))
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
const minTime = new Date(args.timed);
|
||||
minTime.setHours(0, 0, 0, 0);
|
||||
query = `CALL vn.workerTimeControl_clockIn(?,?,?)`;
|
||||
const [response] = await Self.rawSql(query, [workerId, args.timed, args.direction], myOptions);
|
||||
if (response[0] && response[0].error)
|
||||
throw new UserError(response[0].error);
|
||||
|
||||
query = `SELECT * FROM vn.workerLabour WHERE workerFk = ? AND (ended >= ? OR ended IS NULL);`;
|
||||
const [workerLabour] = await Self.rawSql(query, [workerId, minTime]);
|
||||
const absence = await models.Calendar.findOne({
|
||||
where: {
|
||||
businessFk: workerLabour.businessFk,
|
||||
dated: minTime
|
||||
}
|
||||
});
|
||||
if (absence) {
|
||||
const absenceType = await models.AbsenceType.findById(absence.dayOffTypeFk, null, myOptions);
|
||||
const isNotHalfAbsence = absenceType.code != 'halfHoliday'
|
||||
&& absenceType.code != 'halfPaidLeave'
|
||||
&& absenceType.code != 'halfFurlough';
|
||||
if (isNotHalfAbsence)
|
||||
throw new UserError(`The worker has a marked absence that day`);
|
||||
}
|
||||
return models.WorkerTimeControl.create({
|
||||
userFk: workerId,
|
||||
direction: args.direction,
|
||||
timed: args.timed,
|
||||
manual: true
|
||||
}, myOptions);
|
||||
return response;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const models = app.models;
|
||||
|
||||
describe('workerTimeControl add/delete timeEntry()', () => {
|
||||
const HHRRId = 37;
|
||||
|
@ -8,6 +8,14 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
const employeeId = 1;
|
||||
const salesPersonId = 1106;
|
||||
const salesBossId = 19;
|
||||
const hankPymId = 1107;
|
||||
const jessicaJonesId = 1110;
|
||||
const monday = 1;
|
||||
const tuesday = 2;
|
||||
const thursday = 4;
|
||||
const friday = 5;
|
||||
const saturday = 6;
|
||||
const sunday = 7;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 50},
|
||||
};
|
||||
|
@ -19,6 +27,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('as Role errors', () => {
|
||||
it('should fail to add a time entry if the target user is not a subordinate', async() => {
|
||||
activeCtx.accessToken.userId = employeeId;
|
||||
const workerId = 2;
|
||||
|
@ -54,7 +63,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
expect(error.message).toBe(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
it('should add if the current user is team boss and the target user is a himself', async() => {
|
||||
it('should add if the current user is team boss and the target user is himself', async() => {
|
||||
activeCtx.accessToken.userId = teamBossId;
|
||||
const workerId = teamBossId;
|
||||
|
||||
|
@ -62,11 +71,11 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayAtSix = new Date();
|
||||
todayAtSix.setHours(18, 30, 0, 0);
|
||||
const todayAtOne = new Date();
|
||||
todayAtOne.setHours(1, 0, 0, 0);
|
||||
|
||||
ctx.args = {timed: todayAtSix, direction: 'in'};
|
||||
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
ctx.args = {timed: todayAtOne, direction: 'in'};
|
||||
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
expect(createdTimeEntry.id).toBeDefined();
|
||||
|
||||
|
@ -77,23 +86,6 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should fail to add a time entry if the target user has absent that day', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = salesPersonId;
|
||||
let error;
|
||||
|
||||
const calendar = await app.models.Calendar.findById(3);
|
||||
|
||||
try {
|
||||
ctx.args = {timed: new Date(calendar.dated), direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`The worker has a marked absence that day`);
|
||||
});
|
||||
|
||||
it('should try but fail to delete his own time entry', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = salesBossId;
|
||||
|
@ -103,11 +95,11 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayAtSeven = new Date();
|
||||
todayAtSeven.setHours(19, 30, 0, 0);
|
||||
const todayAtOne = new Date();
|
||||
todayAtOne.setHours(1, 0, 0, 0);
|
||||
|
||||
ctx.args = {timed: todayAtSeven, direction: 'in'};
|
||||
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
ctx.args = {timed: todayAtOne, direction: 'in'};
|
||||
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
activeCtx.accessToken.userId = salesPersonId;
|
||||
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
|
||||
|
@ -131,11 +123,11 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayAtFive = new Date();
|
||||
todayAtFive.setHours(17, 30, 0, 0);
|
||||
const todayAtOne = new Date();
|
||||
todayAtOne.setHours(1, 0, 0, 0);
|
||||
|
||||
ctx.args = {timed: todayAtFive, direction: 'in'};
|
||||
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
ctx.args = {timed: todayAtOne, direction: 'in'};
|
||||
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
expect(createdTimeEntry.id).toBeDefined();
|
||||
|
||||
|
@ -159,11 +151,11 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayAtFive = new Date();
|
||||
todayAtFive.setHours(17, 30, 0, 0);
|
||||
const todayAtOne = new Date();
|
||||
todayAtOne.setHours(1, 0, 0, 0);
|
||||
|
||||
ctx.args = {timed: todayAtFive, direction: 'in'};
|
||||
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
ctx.args = {timed: todayAtOne, direction: 'in'};
|
||||
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
expect(createdTimeEntry.id).toBeDefined();
|
||||
|
||||
|
@ -187,11 +179,11 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const todayAtFive = new Date();
|
||||
todayAtFive.setHours(17, 30, 0, 0);
|
||||
const todayAtOne = new Date();
|
||||
todayAtOne.setHours(1, 0, 0, 0);
|
||||
|
||||
ctx.args = {timed: todayAtFive, direction: 'in'};
|
||||
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
ctx.args = {timed: todayAtOne, direction: 'in'};
|
||||
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
expect(createdTimeEntry.id).toBeDefined();
|
||||
|
||||
|
@ -206,3 +198,504 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('WorkerTimeControl_clockIn calls', () => {
|
||||
it('should fail to add a time entry if the target user has an absence that day', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - 16);
|
||||
date.setHours(8, 0, 0);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
try {
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`No está permitido trabajar`);
|
||||
});
|
||||
|
||||
it('should fail to add a time entry for a worker without an existing contract', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() - 2);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`No hay un contrato en vigor`);
|
||||
});
|
||||
|
||||
describe('direction errors', () => {
|
||||
it('should throw an error when trying "in" direction twice', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(10, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Dirección incorrecta`);
|
||||
});
|
||||
|
||||
it('should throw an error when trying "in" direction after insert "in" and "middle"', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(9, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'middle'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(10, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Dirección incorrecta`);
|
||||
});
|
||||
|
||||
it('Should throw an error when trying "out" before closing a "middle" couple', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(9, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'middle'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(10, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Dirección incorrecta`);
|
||||
});
|
||||
|
||||
it('should throw an error when trying "middle" after "out"', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(9, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(10, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'middle'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Dirección incorrecta`);
|
||||
});
|
||||
|
||||
it('should throw an error when trying "out" direction twice', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(9, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(10, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Dirección incorrecta`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('12h rest', () => {
|
||||
it('should throw an error when the 12h rest is not fulfilled yet', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(16, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date = weekDay(date, tuesday);
|
||||
date.setHours(4, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Descanso diario 12h.`);
|
||||
});
|
||||
|
||||
it('should not fail as the 12h rest is fulfilled', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(16, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date = weekDay(date, tuesday);
|
||||
date.setHours(4, 1, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('for 3500kg drivers with enforced 9h rest', () => {
|
||||
it('should throw an error when the 9h enforced rest is not fulfilled', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = jessicaJonesId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(16, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date = weekDay(date, tuesday);
|
||||
date.setHours(1, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Descanso diario 9h.`);
|
||||
});
|
||||
|
||||
it('should not fail when the 9h enforced rest is fulfilled', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = jessicaJonesId;
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 21);
|
||||
date = weekDay(date, monday);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
date.setHours(16, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date = weekDay(date, tuesday);
|
||||
date.setHours(1, 1, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('for 36h weekly rest', () => {
|
||||
it('should throw an error when the 36h weekly rest is not fulfilled', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setMonth(date.getMonth() - 2);
|
||||
date.setDate(1);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
await populateWeek(date, monday, sunday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, thursday, ctx, workerId, options);
|
||||
date = weekDay(date, friday);
|
||||
date.setHours(6, 59, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date.setHours(7, 1, 0);
|
||||
ctx.args = {timed: date, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Descanso semanal 36h. / 72h.`);
|
||||
});
|
||||
|
||||
it('should throw an error when the 36h weekly rest is not fulfilled again', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setMonth(date.getMonth() - 2);
|
||||
date.setDate(1);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
await populateWeek(date, monday, sunday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, thursday, ctx, workerId, options);
|
||||
|
||||
try {
|
||||
date = weekDay(date, saturday);
|
||||
date.setHours(3, 59, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Descanso semanal 36h. / 72h.`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('for 72h weekly rest', () => {
|
||||
it('should throw when the 72h weekly rest is not fulfilled yet', async() => {
|
||||
activeCtx.accessToken.userId = salesBossId;
|
||||
const workerId = hankPymId;
|
||||
|
||||
let date = new Date();
|
||||
date.setMonth(date.getMonth() - 2);
|
||||
date.setDate(1);
|
||||
let error;
|
||||
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
await populateWeek(date, monday, sunday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, thursday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, friday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, saturday, ctx, workerId, options);
|
||||
date = nextWeek(date);
|
||||
await populateWeek(date, monday, saturday, ctx, workerId, options);
|
||||
date = lastWeek(date);
|
||||
|
||||
try {
|
||||
date = weekDay(date, sunday);
|
||||
date.setHours(8, 0, 0);
|
||||
ctx.args = {timed: date, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe(`Descanso semanal 36h. / 72h.`);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function weekDay(date, dayToSet) {
|
||||
const currentDay = date.getDay();
|
||||
const distance = dayToSet - currentDay;
|
||||
|
||||
date.setDate(date.getDate() + distance);
|
||||
return date;
|
||||
}
|
||||
|
||||
function nextWeek(date) {
|
||||
const sunday = 7;
|
||||
const currentDay = date.getDay();
|
||||
let newDate = date;
|
||||
if (currentDay != 0)
|
||||
newDate = weekDay(date, sunday);
|
||||
|
||||
newDate.setDate(newDate.getDate() + 1);
|
||||
return newDate;
|
||||
}
|
||||
|
||||
function lastWeek(date) {
|
||||
const monday = 1;
|
||||
newDate = weekDay(date, monday);
|
||||
|
||||
newDate.setDate(newDate.getDate() - 1);
|
||||
return newDate;
|
||||
}
|
||||
|
||||
async function populateWeek(date, dayStart, dayEnd, ctx, workerId, options) {
|
||||
const dateStart = new Date(weekDay(date, dayStart));
|
||||
const dateEnd = new Date(dateStart);
|
||||
dateEnd.setDate(dateStart.getDate() + dayEnd);
|
||||
|
||||
for (let i = dayStart; i <= dayEnd; i++) {
|
||||
dateStart.setHours(8, 0, 0);
|
||||
ctx.args = {timed: dateStart, direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
dateStart.setHours(16, 0, 0);
|
||||
ctx.args = {timed: dateStart, direction: 'out'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
dateStart.setDate(dateStart.getDate() + 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue