Merge branch 'dev' into 4221-intrastat
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-07-12 06:10:20 +00:00
commit 2d57b3bd54
50 changed files with 802 additions and 1517 deletions

View File

@ -24,9 +24,6 @@
},
"isManaged":{
"type": "boolean"
},
"hasStowaway":{
"type": "boolean"
}
},
"acls": [

View File

@ -0,0 +1 @@
ALTER TABLE `vn`.`item` MODIFY COLUMN description TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;

View File

@ -139,14 +139,14 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
(1, 'Main Warehouse'),
(2, 'Gotham');
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
VALUES
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1, 1),
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13, 1),
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0);
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1),
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1),
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
VALUES
@ -698,10 +698,6 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
(23, 16, 21, util.VN_NOW()),
(24, 16, 21, util.VN_NOW());
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
VALUES
(12, 13, util.VN_CURDATE());
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES
(1, 'Gotham','1007 Mountain Drive, Gotham');
@ -1967,7 +1963,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 +2234,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 +2603,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);

View File

@ -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 */ ;

View File

@ -565,8 +565,6 @@ export default {
isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]',
goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]',
moreMenu: 'vn-ticket-descriptor vn-ticket-descriptor-menu > vn-icon-button[icon=more_vert]',
moreMenuAddStowaway: '.vn-menu [name="addStowaway"]',
moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]',
moreMenuAddToTurn: '.vn-menu [name="addTurn"]',
moreMenuDeleteTicket: '.vn-menu [name="deleteTicket"]',
moreMenuRestoreTicket: '.vn-menu [name="restoreTicket"]',
@ -579,8 +577,6 @@ export default {
sendSMSbutton: 'button[response="accept"]',
changeShippedHourDialog: '.vn-dialog.shown',
changeShippedHour: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newShipped"]',
addStowawayDialogFirstTicket: '.vn-dialog.shown vn-table vn-tbody vn-tr',
shipButton: 'vn-ticket-descriptor vn-icon[icon="icon-stowaway"]',
thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)',
saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)',
acceptDialog: '.vn-dialog.shown button[response="accept"]',
@ -588,7 +584,6 @@ export default {
descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span',
descriptorDeliveryAgency: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(5) > section > span',
acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]',
acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]'
},
ticketNotes: {
firstNoteRemoveButton: 'vn-icon[icon="delete"]',
@ -911,52 +906,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: {

View File

@ -45,7 +45,7 @@ describe('Client Add address path', () => {
expect(province).toContain('Province five');
});
it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
it(`should throw after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner');
await page.write(selectors.clientAddresses.streetAddress, '320 Park Avenue New York');
await page.waitToClick(selectors.clientAddresses.saveButton);

View File

@ -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;
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
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.firstEntryOfMonday, 'innerText');
it('should go to the next month', async() => {
const date = new Date();
date.setMonth(date.getMonth() + 1);
const month = date.toLocaleString('default', {month: 'long'});
expect(result).toEqual(scanTime);
});
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
it(`should scan out Hank Pym for break`, async() => {
const scanTime = '10: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.secondEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime);
});
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 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);
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';
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);
});
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.');
});
});
expect(result).toContain(month);
});
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 go to current month', async() => {
const date = new Date();
const month = date.toLocaleString('default', {month: 'long'});
it('should search for a worker and access to its summary', async() => {
await page.accessToSearchResult('HankPym');
await page.waitForState('worker.card.summary');
});
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText');
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.');
});
});
expect(result).toContain(month);
});
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 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'});
it('should check his weekly hours are alright', async() => {
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '52:40 h.');
});
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, 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(eightAm);
});
it(`should insert 'out' monday`, async() => {
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
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(fourPm);
});
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 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 be the 'out' the first entry of monday`, async() => {
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
expect(result).toEqual(fourPm);
});
it('should change week of month', async() => {
await page.waitToClick(selectors.workerTimeControl.thrirdWeekDay);
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '00:00 h.');
});
});

View File

@ -75,59 +75,6 @@ describe('Ticket descriptor path', () => {
});
});
describe('Add stowaway', () => {
it('should search for a ticket', async() => {
await page.accessToSearchResult('16');
await page.waitForState('ticket.card.summary');
});
it('should open the add stowaway dialog', async() => {
await page.waitForFunction(() => {
let element = document.querySelector('vn-ticket-descriptor-menu');
return element.$ctrl.canShowStowaway === true;
});
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
await page.waitForSelector(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const isVisible = await page.isVisible(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
expect(isVisible).toBeTruthy();
});
it('should add a ticket as stowaway', async() => {
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should check the state of the stowaway ticket is embarked`, async() => {
await page.waitForState('ticket.card.summary');
const state = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
expect(state).toEqual('State Embarcando');
});
it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
await page.waitToClick(selectors.ticketDescriptor.shipButton);
await page.waitForState('ticket.card.summary');
});
it('should delete the stowaway', async() => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton);
await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should confirm the ship buton doesn't exisist any more`, async() => {
await page.waitForSelector(selectors.ticketDescriptor.shipButton, {hidden: true});
});
});
describe('Make invoice', () => {
it('should login as administrative role then search for a ticket', async() => {
const invoiceableTicketId = '14';

View File

@ -6,7 +6,6 @@ describe('Ticket create path', () => {
let page;
let nextMonth = new Date();
nextMonth.setMonth(nextMonth.getMonth() + 1);
let stowawayTicketId;
beforeAll(async() => {
browser = await getBrowser();
@ -36,8 +35,6 @@ describe('Ticket create path', () => {
it('should check the url is now the summary of the ticket', async() => {
await page.waitForState('ticket.card.summary');
stowawayTicketId = await page.waitToGetProperty(selectors.ticketSummary.descriptorTicketId, 'innerText');
stowawayTicketId = stowawayTicketId.substring(1);
});
it('should again open the new ticket form', async() => {
@ -61,15 +58,6 @@ describe('Ticket create path', () => {
await page.waitForState('ticket.card.summary');
});
it('should make the previously created ticket the stowaway of the current ticket', async() => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should delete the current ticket', async() => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
@ -78,11 +66,4 @@ describe('Ticket create path', () => {
expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour');
});
it('should search for the stowaway ticket of the previously deleted ticket', async() => {
await page.accessToSearchResult(stowawayTicketId);
const result = await page.countElement(selectors.ticketDescriptor.shipButton);
expect(result).toBe(0);
});
});

View File

@ -343,9 +343,6 @@
.icon-splur:before {
content: "\e970";
}
.icon-stowaway:before {
content: "\e94f";
}
.icon-supplier:before {
content: "\e925";
}

View File

@ -85,8 +85,6 @@
<glyph unicode="&#xe94b;" glyph-name="deaulter" d="M677.973-64c-30.72 35.84-61.867 70.827-91.307 107.52-40.96 51.2-80.64 103.253-121.173 154.88-16.64 21.333-21.76 20.48-30.72-4.693-13.227-36.693-25.6-73.387-40.107-109.653-5.12-12.8-13.227-26.88-24.32-34.56-51.627-34.987-104.107-69.12-157.867-100.693-10.667-6.4-30.72-5.547-41.813 0.853-8.107 4.693-12.373 23.893-11.093 35.84 0.853 8.96 11.093 19.627 19.627 25.6 39.253 26.453 78.933 51.627 119.040 76.8 18.347 11.52 30.293 26.027 35.84 47.787 12.373 48.213 27.307 95.573 39.253 143.36 8.533 33.707 26.88 58.88 56.32 77.227 40.533 25.173 80.64 52.053 120.747 78.507 6.4 4.267 10.24 11.52 15.36 17.493-7.253 2.56-14.933 7.253-22.187 6.827-75.52-6.4-151.467-13.227-226.987-20.48-2.133 0-4.693-0.853-6.827-0.853-22.613-1.707-39.253 10.24-40.96 29.867s12.373 33.707 35.413 35.84c45.227 4.267 90.88 8.96 136.107 12.8 65.707 5.547 131.84 10.667 197.547 15.36 26.027 1.707 53.76-21.76 67.413-55.467 9.813-23.893 5.12-46.080-18.347-65.28-49.92-40.107-100.693-78.933-151.040-118.187-23.040-17.92-23.893-23.467-6.4-46.507 58.453-78.080 116.48-156.587 174.933-234.667 27.307-36.693 25.173-50.773-12.373-75.52-5.12 0-9.813 0-14.080 0zM791.893 649.813c-43.093 1.28-76.373-31.573-77.227-75.52-0.853-44.373 29.44-76.8 72.107-77.653 45.227-1.28 77.653 29.44 78.080 73.813 0.427 45.227-29.44 78.080-72.96 79.36zM671.147 737.707c0-72.107-34.133-136.107-87.467-176.64l-235.52-21.76c-72.107 36.693-122.027 111.787-122.027 198.4 0 122.88 99.84 222.293 222.72 222.293 122.453 0 222.293-99.413 222.293-222.293zM592.213 680.533l-50.347 18.347c-2.133-8.533-5.12-16.213-9.813-22.613-5.12-6.4-10.24-11.947-16.213-17.067-5.973-4.267-12.373-8.107-19.2-11.093s-13.653-4.693-20.053-5.547c-17.92-2.987-33.707-0.427-48.64 6.827s-26.88 18.347-36.693 32.853l76.373 12.373 7.253 32.427-97.28-15.787c-1.28 5.547-2.987 11.093-3.84 16.64l-0.853 4.267 99.413 16.213 7.253 32.427-106.667-17.493c0.853 9.387 2.987 17.493 6.4 26.027 3.84 8.533 8.107 16.213 14.080 23.040 5.547 6.827 12.8 12.373 21.333 17.067s17.92 8.107 28.587 9.813c6.827 1.28 13.227 1.707 20.907 1.28s14.507-1.707 21.333-3.84c6.827-2.133 13.653-5.973 20.053-10.24 5.973-4.693 11.947-11.093 17.493-18.773l38.827 37.973c-13.227 17.92-30.293 31.147-52.053 39.253-21.76 8.533-46.080 10.667-73.387 6.4-19.627-2.987-36.267-9.387-51.2-17.92-14.507-8.533-26.88-19.2-37.547-32-10.667-12.373-18.773-26.027-23.893-40.96-5.547-14.507-8.96-29.867-9.813-45.653l-21.76-3.84-7.253-32.427 29.013 4.693 0.427-2.987c1.28-6.827 2.56-12.8 4.267-18.347l-23.467-3.84-8.107-32.427 43.52 7.253c6.827-13.653 15.787-26.027 26.027-36.693 10.24-11.52 22.187-20.48 35.413-27.733 13.227-7.68 27.307-12.8 42.667-15.787s31.573-3.413 47.36-0.853c12.373 2.133 24.32 5.12 35.84 10.667s22.613 11.52 32.853 19.2c10.24 8.107 18.347 16.64 26.027 26.453 6.827 9.387 12.373 20.48 15.36 32.427z" />
<glyph unicode="&#xe94c;" glyph-name="services" d="M951.467 217.6c0 8.533 0 21.333 0 29.867s0 21.333-4.267 29.867l64 51.2c4.267 4.267 8.533 12.8 4.267 21.333l-64 106.667c-4.267 8.533-12.8 8.533-17.067 8.533l-76.8-29.867c-17.067 12.8-34.133 21.333-51.2 29.867l-12.8 81.067c0 8.533-8.533 12.8-17.067 12.8h-123.733c-8.533 0-12.8-4.267-17.067-12.8l-12.8-81.067c-17.067-8.533-38.4-17.067-51.2-29.867l-76.8 29.867c-8.533 4.267-17.067 0-17.067-8.533l-64-106.667c-4.267-8.533-4.267-17.067 4.267-21.333l64-51.2c0-8.533-4.267-21.333-4.267-29.867s0-21.333 4.267-29.867l-55.467-51.2c-4.267-4.267-8.533-12.8-4.267-21.333l64-106.667c4.267-8.533 12.8-8.533 17.067-8.533l76.8 29.867c17.067-12.8 34.133-21.333 51.2-29.867l12.8-81.067c0-8.533 8.533-12.8 17.067-12.8h123.733c8.533 0 12.8 4.267 17.067 12.8l12.8 81.067c17.067 8.533 38.4 17.067 51.2 29.867l76.8-29.867c8.533-4.267 17.067 0 17.067 8.533l64 106.667c4.267 8.533 4.267 17.067-4.267 21.333 0 0-68.267 51.2-68.267 51.2zM721.067 132.267c-64 0-115.2 51.2-115.2 115.2s51.2 115.2 115.2 115.2 115.2-51.2 115.2-115.2c0-64-51.2-115.2-115.2-115.2zM345.6 174.933h-89.6v102.4h81.067c4.267 34.133 8.533 68.267 21.333 102.4h-102.4v102.4h162.133c34.133 42.667 72.533 76.8 119.467 102.4h-281.6v102.4h520.533v-59.733c51.2-8.533 102.4-25.6 145.067-51.2v281.6c0 55.467-46.933 102.4-102.4 102.4h-622.933c-55.467 0-102.4-46.933-102.4-102.4v-819.2c0-55.467 46.933-102.4 102.4-102.4h302.933c-81.067 55.467-136.533 140.8-153.6 238.933z" />
<glyph unicode="&#xe94d;" glyph-name="albaran" d="M819.2 960h-622.933c-55.467 0-102.4-46.933-102.4-102.4v-819.2c0-55.467 46.933-102.4 102.4-102.4h622.933c55.467 0 102.4 46.933 102.4 102.4v819.2c0 55.467-46.933 102.4-102.4 102.4zM358.4 174.933h-102.4v102.4h503.467v-102.4h-401.067zM256 379.733v102.4h503.467v-102.4h-503.467zM759.467 584.533h-503.467v102.4h503.467v-102.4z" />
<glyph unicode="&#xe94e;" glyph-name="solunion" d="M759.467 870.4v-136.533h-601.6c0 0-128-341.333 106.667-341.333s469.333 0 469.333 0 34.133 0 34.133-34.133-8.533-98.133-8.533-98.133h-541.867c0 0-247.467 29.867-204.8 320 0 0 8.533 140.8 72.533 298.667 0 0 21.333-8.533 85.333-8.533h588.8zM853.333 25.6c64 0 85.333-8.533 85.333-8.533 64 153.6 72.533 298.667 72.533 298.667 42.667 290.133-204.8 320-204.8 320h-541.867c0 0-8.533-64-8.533-98.133s34.133-34.133 34.133-34.133 238.933 0 469.333 0 106.667-341.333 106.667-341.333h-601.6v-136.533h588.8z" />
<glyph unicode="&#xe94f;" glyph-name="stowaway" d="M1006.933 452.267l-260.267 106.667 29.867 29.867c4.267 4.267 4.267 12.8 4.267 17.067-4.267 4.267-8.533 8.533-12.8 8.533h-157.867c0 93.867 76.8 157.867 174.933 157.867 4.267 0 8.533 4.267 12.8 8.533s4.267 8.533 0 17.067l-81.067 153.6c-4.267 0-12.8 4.267-17.067 4.267-46.933 0-93.867-17.067-132.267-42.667-21.333-17.067-42.667-38.4-55.467-59.733-12.8 21.333-29.867 42.667-55.467 59.733-34.133 12.8-81.067 34.133-128 34.133-4.267 0-12.8-4.267-12.8-8.533l-85.333-153.6c-4.267-4.267-4.267-4.267 0-12.8 4.267-4.267 8.533-8.533 12.8-8.533 98.133 0 174.933-59.733 174.933-153.6v0h-140.8c-4.267 0-12.8-4.267-12.8-8.533-8.533-4.267-4.267-17.067 0-21.333l21.333-21.333-277.333-110.933c-8.533-8.533-12.8-12.8-8.533-21.333 0-8.533 8.533-12.8 17.067-12.8v0l98.133 4.267-81.067-85.333c0-4.267-4.267-8.533 0-12.8 0-4.267 4.267-8.533 8.533-8.533l85.333-34.133v-179.2c0-8.533 4.267-12.8 8.533-12.8l358.4-145.067h8.533l358.4 145.067c4.267 4.267 8.533 8.533 8.533 12.8v179.2l85.333 34.133c4.267 0 8.533 4.267 8.533 8.533s0 8.533-4.267 12.8l-68.267 98.133 102.4-4.267c8.533 0 12.8 4.267 17.067 12.8 8.533 0 4.267 4.267-4.267 12.8zM110.933 456.533l196.267 76.8 8.533-8.533-166.4-64-38.4-4.267zM153.6 285.867v0l-68.267 34.133 68.267 98.133 328.533-132.267-68.267-98.133-260.267 98.133zM490.667-29.867l-328.533 132.267v153.6l243.2-98.133h12.8c0 0 0 0 4.267 0v0c0 0 4.267 0 4.267 4.267l64 85.333c0-4.267 0-277.333 0-277.333zM490.667 324.267l-298.667 115.2 149.333 64 153.6-157.867v-17.067h-4.267zM529.067 337.067l157.867 157.867 140.8-55.467-298.667-115.2c0 0 0 12.8 0 12.8zM849.067 102.4l-328.533-132.267v281.6l64-85.333c0 0 0-4.267 4.267-4.267v0h17.067l243.2 98.133v-157.867zM938.667 324.267l-324.267-132.267-68.267 98.133 328.533 132.267 64-98.133zM870.4 460.8l-157.867 64 12.8 8.533 187.733-76.8-42.667 4.267z" />
<glyph unicode="&#xe950;" glyph-name="agency-term" d="M789.333 266.667c-55.467 0-102.4-46.933-102.4-102.4s46.933-102.4 102.4-102.4c55.467 0 102.4 46.933 102.4 102.4 0 59.733-46.933 102.4-102.4 102.4zM789.333 113.067c-29.867 0-51.2 21.333-51.2 51.2s21.333 51.2 51.2 51.2c29.867 0 51.2-21.333 51.2-51.2 0-25.6-25.6-51.2-51.2-51.2zM251.733 266.667c-55.467 0-102.4-46.933-102.4-102.4s46.933-102.4 102.4-102.4 102.4 46.933 102.4 102.4c0 59.733-46.933 102.4-102.4 102.4zM251.733 113.067c-29.867 0-51.2 21.333-51.2 51.2s21.333 51.2 51.2 51.2 51.2-21.333 51.2-51.2c0-25.6-25.6-51.2-51.2-51.2zM1006.933 539.733l-196.267 192c-12.8 12.8-29.867 17.067-46.933 17.067h-98.133v38.4c0 25.6-21.333 51.2-51.2 51.2h-563.2c-29.867 0-51.2-21.333-51.2-51.2v-554.667c0-29.867 25.6-51.2 51.2-51.2h68.267c8.533 64 64 115.2 132.267 115.2 64 0 123.733-51.2 132.267-115.2h268.8c8.533 64 64 115.2 132.267 115.2s128-51.2 136.533-115.2h51.2c29.867 0 51.2 25.6 51.2 51.2v260.267c0 17.067-8.533 34.133-17.067 46.933v0zM725.333 684.8c0 4.267 4.267 8.533 8.533 8.533h34.133c0 0 4.267 0 4.267-4.267l153.6-145.067c4.267 0 0-12.8-4.267-12.8h-187.733c-8.533 0-8.533 4.267-8.533 8.533v145.067zM509.013 556.373c0-113.92-92.16-206.080-206.080-206.080s-206.080 92.16-206.080 206.080 92.16 206.507 206.080 206.507 206.080-92.587 206.080-206.507zM342.613 494.080h-87.893l-15.36-40.107h-78.933l100.693 230.827h76.373l100.693-230.827h-80.213l-15.36 40.107zM321.28 550.4l-22.613 58.027-22.187-58.027h44.8z" />
<glyph unicode="&#xe951;" glyph-name="apps" d="M0 704h256v256h-256v-256zM384-64h256v256h-256v-256zM0-64h256v256h-256v-256zM0 320h256v256h-256v-256zM384 320h256v256h-256v-256zM768 960v-256h256v256h-256zM384 704h256v256h-256v-256zM768 320h256v256h-256v-256zM768-64h256v256h-256v-256z" />
<glyph unicode="&#xe952;" glyph-name="info" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512-230.4 512-512 512zM563.2 192h-102.4v307.2h102.4v-307.2zM563.2 601.6h-102.4v102.4h102.4v-102.4z" />

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 157 KiB

View File

@ -54,7 +54,6 @@
"You can't delete a confirmed order": "You can't delete a confirmed order",
"Value has an invalid format": "Value has an invalid format",
"The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one",
"Can't create stowaway for this ticket": "Can't create stowaway for this ticket",
"Swift / BIC can't be empty": "Swift / BIC can't be empty",
"Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}",
"Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
@ -70,7 +69,6 @@
"Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
"Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*",
"Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*",
"This ticket is not an stowaway anymore": "The ticket id [{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
@ -124,5 +122,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."
}

View File

@ -101,7 +101,6 @@
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
"You can't delete a confirmed order": "No puedes borrar un pedido confirmado",
"Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket",
"The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto",
"Invalid quantity": "Cantidad invalida",
"This postal code is not valid": "This postal code is not valid",
@ -138,7 +137,6 @@
"Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
"Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*",
"Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*",
"This ticket is not an stowaway anymore": "El ticket id [{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
@ -227,5 +225,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"
}

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethodCtx('importToNewRefundTicket', {
description: 'Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company',
description: 'Import lines of claimBeginning to new ticket with shipped, landed dates, agency and company',
accessType: 'WRITE',
accepts: [{
arg: 'id',

View File

@ -162,7 +162,7 @@
<td>{{::client.province | dashIfEmpty}}</td>
<td>{{::client.city | dashIfEmpty}}</td>
<td>{{::client.postcode | dashIfEmpty}}</td>
<td>{{::client.email | dashIfEmpty}}</td>
<td class="vn-w-xs" title="{{::client.email}}">{{::client.email | dashIfEmpty}}</td>
<td>{{::client.created | date:'dd/MM/yyyy'}}</td>
<td>{{::client.businessType | dashIfEmpty}}</td>
<td>{{::client.payMethod | dashIfEmpty}}</td>

View File

@ -63,7 +63,6 @@ module.exports = Self => {
stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT
i.*,
p.name AS producerName,

View File

@ -66,7 +66,9 @@ describe('InvoiceOut', () => {
controller.responseHandler('accept');
expect(controller.vnApp.showError).toHaveBeenCalledWith(`Invoice date and the max date should be filled`);
const expectedError = 'Invoice date and the max date should be filled';
expect(controller.vnApp.showError).toHaveBeenCalledWith(expectedError);
});
it('should throw an error when fromClientId or toClientId properties are not filled in', () => {

View File

@ -18,12 +18,5 @@
"isWithheld": {
"type": "number"
}
},
"relations": {
"taxType": {
"type": "belongsTo",
"model": "TaxType",
"foreignKey": "taxTypeFk"
}
}
}

View File

@ -117,6 +117,23 @@
value="{{tag.value}}">
</vn-label-value>
</vn-one>
<vn-one name="description" ng-if="$ctrl.summary.item.description">
<h4 ng-show="$ctrl.isBuyer">
<a
ui-sref="item.card.basicData({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Description</span>
</a>
</h4>
<h4
translate
ng-show="!$ctrl.isBuyer">
Description
</h4>
<p>
{{$ctrl.summary.item.description}}
</p>
</vn-one>
<vn-one name="tax">
<h4 ng-show="$ctrl.isBuyer || $ctrl.isAdministrative">
<a

View File

@ -1,48 +0,0 @@
module.exports = Self => {
Self.remoteMethod('canHaveStowaway', {
description: 'Returns if a ticket can have stowaway',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'ticket id',
http: {source: 'path'}
}],
returns: {
root: true
},
http: {
path: `/:id/canHaveStowaway`,
verb: 'GET'
}
});
Self.canHaveStowaway = async(id, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const ticket = await models.Ticket.findById(id, {
include: {
relation: 'ship',
scope: {
fields: ['id']
}
}
}, myOptions);
const warehouse = await models.Warehouse.findById(ticket.warehouseFk, null, myOptions);
const hasStowaway = ticket.ship() ? true : false;
const validStowaway = warehouse && warehouse.hasStowaway && !hasStowaway;
if (!ticket.isDeleted && validStowaway)
return true;
return false;
};
};

View File

@ -1,105 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('deleteStowaway', {
description: 'Deletes an stowaway',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The ticket id',
http: {source: 'path'}
}],
returns: {
root: true
},
http: {
path: `/:id/deleteStowaway`,
verb: 'POST'
}
});
Self.deleteStowaway = async(ctx, id, options) => {
const models = Self.app.models;
const $t = ctx.req.__; // $translate
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const ticket = await Self.findById(id, {
include: [{
relation: 'ship'
}, {
relation: 'stowaway'
}, {
relation: 'client',
scope: {
include: {
relation: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
}
}
}]
}, myOptions);
let stowawayFk;
let shipFk;
if (ticket.stowaway()) {
shipFk = ticket.stowaway().shipFk;
stowawayFk = ticket.stowaway().id;
} else if (ticket.ship()) {
shipFk = ticket.ship().shipFk;
stowawayFk = ticket.ship().id;
}
const stowaway = await models.Stowaway.findOne({
where: {
id: stowawayFk,
shipFk: shipFk
}
}, myOptions);
const result = await stowaway.destroy(myOptions);
const state = await models.State.findOne({
where: {
code: 'BOARDING'
}
}, myOptions);
const ticketTracking = await models.TicketTracking.findOne({
where: {
ticketFk: shipFk,
stateFk: state.id
}
}, myOptions);
await ticketTracking.destroy(myOptions);
const salesPerson = ticket.client().salesPersonUser();
if (salesPerson) {
const origin = ctx.req.headers.origin;
const message = $t('This ticket is not an stowaway anymore', {
ticketId: stowawayFk,
ticketUrl: `${origin}/#!/ticket/${stowawayFk}/sale`
});
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
}
if (tx) await tx.commit();
return result;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -200,22 +200,7 @@ module.exports = Self => {
return {'t.routeFk': {neq: null}};
return {'t.routeFk': null};
case 'pending':
if (value) {
return {and: [
{'st.alertLevel': 0},
{'st.code': {nin: [
'OK',
'BOARDING',
'PRINTED',
'PRINTED_AUTO',
'PICKER_DESIGNED'
]}}
]};
} else {
return {and: [
{'st.alertLevel': {gt: 0}}
]};
}
return {'st.isNotValidated': value};
case 'id':
case 'clientFk':
case 'agencyModeFk':

View File

@ -1,74 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('getPossibleStowaways', {
description: 'Returns a list of allowed tickets for a stowaway ticket',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'ticket id',
http: {source: 'path'}
}],
returns: {
root: true
},
http: {
path: `/:id/getPossibleStowaways`,
verb: 'GET'
}
});
Self.getPossibleStowaways = async(ticketFk, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const canHaveStowaway = await models.Ticket.canHaveStowaway(ticketFk, myOptions);
if (!canHaveStowaway)
throw new UserError(`Can't create stowaway for this ticket`);
const ship = await models.Ticket.findById(ticketFk, null, myOptions);
if (!ship || !ship.shipped)
return [];
const lowestDate = new Date(ship.shipped.getTime());
lowestDate.setHours(0, 0, -1, 0);
const highestDate = new Date(ship.shipped.getTime());
highestDate.setHours(23, 59, 59);
const possibleStowaways = await models.Ticket.find({
where: {
id: {neq: ticketFk},
clientFk: ship.clientFk,
addressFk: ship.addressFk,
agencyModeFk: ship.agencyModeFk,
warehouseFk: {neq: ship.warehouseFk},
shipped: {
between: [lowestDate.toJSON(), highestDate.toJSON()]
}
},
include: [
{relation: 'agencyMode'},
{relation: 'warehouse'},
{relation: 'ticketState',
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['id', 'name'],
}
},
},
]
}, myOptions);
return possibleStowaways;
};
};

View File

@ -107,28 +107,9 @@ module.exports = Self => {
}
}
}
}, {
relation: 'ship'
}, {
relation: 'stowaway'
}]
}, myOptions);
// Change state to "fixing" if contains an stowaway and remove the link between them
let otherTicketId;
if (ticket.stowaway())
otherTicketId = ticket.stowaway().shipFk;
else if (ticket.ship())
otherTicketId = ticket.ship().id;
if (otherTicketId) {
await models.Ticket.deleteStowaway(ctx, otherTicketId, myOptions);
await models.TicketTracking.changeState(ctx, {
ticketFk: otherTicketId,
code: 'FIXING'
}, myOptions);
}
// Send notification to salesPerson
const salesPersonUser = ticket.client().salesPersonUser();
if (salesPersonUser) {

View File

@ -1,39 +0,0 @@
const models = require('vn-loopback/server/server').models;
describe('ticket canHaveStowaway()', () => {
it('should return true if the ticket warehouse have hasStowaway equal 1', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 16;
const canStowaway = await models.Ticket.canHaveStowaway(ticketId, options);
expect(canStowaway).toBeTruthy();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return false if the ticket warehouse dont have hasStowaway equal 0', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 10;
const canStowaway = await models.Ticket.canHaveStowaway(ticketId, options);
expect(canStowaway).toBeFalsy();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -1,75 +0,0 @@
const models = require('vn-loopback/server/server').models;
describe('ticket deleteStowaway()', () => {
const shipId = 16;
const stowawayId = 17;
const ctx = {
req: {
accessToken: {userId: 18},
headers: {origin: 'http://localhost'}
}
};
ctx.req.__ = (value, params) => {
return params.nickname;
};
it(`should create an stowaway, delete it and see the states of both stowaway and ship go back to the last states`, async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
await models.Stowaway.rawSql(`
INSERT INTO stowaway (id, shipFk) VALUES (?, ?)
`, [stowawayId, shipId], options);
await models.Stowaway.rawSql(
`CALL ticketStateUpdate(?, ?)`, [shipId, 'BOARDING'], options);
await models.Stowaway.rawSql(
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'BOARDING'], options);
let createdStowaways = await models.Stowaway.count({id: stowawayId, shipFk: shipId}, options);
expect(createdStowaways).toEqual(1);
let shipState = await models.TicketLastState.findOne({
where: {
ticketFk: shipId
}
}, options);
let stowawayState = await models.TicketLastState.findOne({
where: {
ticketFk: stowawayId
}
}, options);
expect(shipState.name).toEqual('Embarcando');
expect(stowawayState.name).toEqual('Embarcando');
await models.Ticket.deleteStowaway(ctx, shipId, options);
await models.Ticket.deleteStowaway(ctx, stowawayId, options);
createdStowaways = await models.Stowaway.count({id: stowawayId, shipFk: shipId}, options);
expect(createdStowaways).toEqual(0);
shipState = await models.TicketLastState.findOne({
where: {
ticketFk: shipId
}
}, options);
stowawayState = await models.TicketLastState.findOne({
where: {
ticketFk: stowawayId
}
}, options);
expect(shipState.name).toEqual('OK');
expect(stowawayState.name).toEqual('Libre');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -153,7 +153,7 @@ describe('ticket filter()', () => {
const secondRow = result[1];
const thirdRow = result[2];
expect(result.length).toEqual(12);
expect(result.length).toEqual(17);
expect(firstRow.state).toEqual('Entregado');
expect(secondRow.state).toEqual('Entregado');
expect(thirdRow.state).toEqual('Entregado');

View File

@ -1,60 +0,0 @@
const models = require('vn-loopback/server/server').models;
let UserError = require('vn-loopback/util/user-error');
describe('ticket getPossibleStowaways()', () => {
it(`should throw an error if Can't create stowaway for this ticket`, async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const ticketId = 10;
await models.Ticket.getPossibleStowaways(ticketId, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toEqual(new UserError(`Can't create stowaway for this ticket`));
});
it('should return an empty list of tickets for a valid ticket', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 12;
const possibleStowaways = await models.Ticket.getPossibleStowaways(ticketId, options);
expect(possibleStowaways.length).toEqual(0);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return allowed list of tickets for a valid ticket', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 16;
const possibleStowaways = await models.Ticket.getPossibleStowaways(ticketId, options);
expect(possibleStowaways.length).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -98,92 +98,4 @@ describe('ticket setDeleted()', () => {
throw e;
}
});
it('should delete ticket, remove stowaway and itemshelving then change stowaway state to "FIXING" ', async() => {
pending('test excluded by task #3693');
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
const ctx = {
req: {
accessToken: {userId: employeeUser},
headers: {
origin: 'http://localhost:5000'
},
__: () => {}
}
};
const sampleTicket = await models.Ticket.findById(12);
const sampleStowaway = await models.Ticket.findById(13);
sampleTicket.id = undefined;
const shipTicket = await models.Ticket.create(sampleTicket, options);
sampleStowaway.id = undefined;
const stowawayTicket = await models.Ticket.create(sampleStowaway, options);
await models.Stowaway.rawSql(`
INSERT INTO vn.stowaway(id, shipFk)
VALUES (?, ?)`, [stowawayTicket.id, shipTicket.id], options);
const boardingState = await models.State.findOne({
where: {
code: 'BOARDING'
}
}, options);
await models.TicketTracking.create({
ticketFk: stowawayTicket.id,
stateFk: boardingState.id,
workerFk: ctx.req.accessToken.userId
}, options);
const okState = await models.State.findOne({
where: {
code: 'OK'
}
}, options);
await models.TicketTracking.create({
ticketFk: shipTicket.id,
stateFk: okState.id,
workerFk: ctx.req.accessToken.userId
}, options);
let stowawayTicketState = await models.TicketState.findOne({
where: {
ticketFk: stowawayTicket.id
}
}, options);
let stowaway = await models.Stowaway.findById(shipTicket.id, null, options);
expect(stowaway).toBeDefined();
expect(stowawayTicketState.code).toEqual('BOARDING');
await models.Ticket.setDeleted(ctx, shipTicket.id, options);
stowawayTicketState = await models.TicketState.findOne({
where: {
ticketFk: stowawayTicket.id
}
}, options);
stowaway = await models.Stowaway.findById(shipTicket.id, null, options);
expect(stowaway).toBeNull();
expect(stowawayTicketState.code).toEqual('FIXING');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -38,9 +38,6 @@
"State":{
"dataSource": "vn"
},
"Stowaway": {
"dataSource": "vn"
},
"Ticket": {
"dataSource": "vn"
},

View File

@ -1,24 +0,0 @@
const LoopBackContext = require('loopback-context');
const UserError = require('vn-loopback/util/user-error');
module.exports = function(Self) {
Self.observe('before save', async function(ctx) {
const models = Self.app.models;
const canHaveStowaway = await models.Ticket.canHaveStowaway(ctx.instance.shipFk);
if (!canHaveStowaway)
throw new UserError(`Can't create stowaway for this ticket`);
if (ctx.isNewInstance) {
let where = {
code: 'BOARDING'
};
let state = await models.State.findOne({where});
let params = {ticketFk: ctx.instance.shipFk, stateFk: state.id};
const loopBackContext = LoopBackContext.getCurrentContext();
let httpCtx = {req: loopBackContext.active};
await models.TicketTracking.changeState(httpCtx, params);
}
});
};

View File

@ -1,36 +0,0 @@
{
"name": "Stowaway",
"base": "VnModel",
"options": {
"mysql": {
"table": "stowaway"
}
},
"properties": {
"id": {
"id": true,
"type": "number",
"forceId": false
},
"shipFk": {
"type": "number",
"required": false
},
"created":{
"type": "date",
"required": false
}
},
"relations": {
"ship": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "shipFk"
},
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "id"
}
}
}

View File

@ -14,7 +14,6 @@ module.exports = Self => {
require('../methods/ticket/getSales')(Self);
require('../methods/ticket/getSalesPersonMana')(Self);
require('../methods/ticket/filter')(Self);
require('../methods/ticket/getPossibleStowaways')(Self);
require('../methods/ticket/canBeInvoiced')(Self);
require('../methods/ticket/makeInvoice')(Self);
require('../methods/ticket/updateEditableTicket')(Self);
@ -23,9 +22,7 @@ module.exports = Self => {
require('../methods/ticket/uploadFile')(Self);
require('../methods/ticket/addSale')(Self);
require('../methods/ticket/transferSales')(Self);
require('../methods/ticket/canHaveStowaway')(Self);
require('../methods/ticket/recalculateComponents')(Self);
require('../methods/ticket/deleteStowaway')(Self);
require('../methods/ticket/sendSms')(Self);
require('../methods/ticket/isLocked')(Self);
require('../methods/ticket/freightCost')(Self);

View File

@ -69,16 +69,6 @@
"model": "Client",
"foreignKey": "clientFk"
},
"ship": {
"type": "hasOne",
"model": "Stowaway",
"foreignKey": "shipFk"
},
"stowaway": {
"type": "hasOne",
"model": "Stowaway",
"foreignKey": "id"
},
"warehouse": {
"type": "belongsTo",
"model": "Warehouse",

View File

@ -6,18 +6,15 @@ class Controller extends ModuleCard {
let filter = {
include: [
{
relation: 'address'},
relation: 'address'
},
{
relation: 'ship'},
{
relation: 'stowaway'},
relation: 'zone'
},
{
relation: 'warehouse',
scope: {fields: ['name']}
},
{
relation: 'zone',
},
{
relation: 'invoiceOut',
scope: {fields: ['id']}
@ -47,7 +44,8 @@ class Controller extends ModuleCard {
}
},
},
}, {
},
{
relation: 'ticketState',
scope: {
fields: ['stateFk'],

View File

@ -103,20 +103,6 @@
translate>
SMS Minimum import
</vn-item>
<vn-item
ng-click="addStowaway.show()"
ng-show="$ctrl.canShowStowaway"
name="addStowaway"
translate>
Add stowaway
</vn-item>
<vn-item
ng-click="deleteStowaway.show()"
ng-show="$ctrl.canDeleteStowaway"
name="deleteStowaway"
translate>
Delete stowaway
</vn-item>
<vn-item
ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.isEditable"
@ -260,21 +246,6 @@
sms="$ctrl.newSMS">
</vn-ticket-sms>
<!-- Add stowaway dialog -->
<vn-add-stowaway
vn-id="addStowaway"
card-reload="$ctrl.reload()"
ticket="$ctrl.ticket">
</vn-add-stowaway>
<!-- Delete stowaway confirmation dialog -->
<vn-confirm
vn-id="deleteStowaway"
on-accept="$ctrl.deleteStowaway()"
question="Delete stowaway"
message="Are you sure you want to delete this stowaway?">
</vn-confirm>
<!-- Make invoice confirmation dialog -->
<vn-confirm
vn-id="makeInvoiceConfirmation"

View File

@ -52,7 +52,8 @@ class Controller extends Section {
const filter = {
include: [{
relation: 'address',
}, {
},
{
relation: 'client',
scope: {
fields: [
@ -74,15 +75,14 @@ class Controller extends Section {
}
}
},
{relation: 'ship'},
{relation: 'stowaway'},
{relation: 'invoiceOut'}]
{
relation: 'invoiceOut'
}]
};
return this.$http.get(`Tickets/${this.ticketId}`, {filter})
.then(res => this.ticket = res.data)
.then(() => {
this.canStowaway();
this.isTicketEditable();
this.hasDocuware();
});
@ -228,27 +228,6 @@ class Controller extends Section {
this.$.sms.open();
}
canStowaway() {
this.canShowStowaway = false;
if (!this.isTicketModule || !this.ticket) return;
this.$http.get(`Tickets/${this.id}/canHaveStowaway`)
.then(res => this.canShowStowaway = !!res.data);
}
get canDeleteStowaway() {
if (!this.ticket || !this.isTicketModule)
return false;
return this.ticket.stowaway || this.ticket.ship;
}
deleteStowaway() {
return this.$http.post(`Tickets/${this.id}/deleteStowaway`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
makeInvoice() {
const params = {ticketsIds: [this.id]};
return this.$http.post(`Tickets/makeInvoice`, params)

View File

@ -231,23 +231,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
});
});
describe('canStowaway()', () => {
it('should make a query and return if the ticket can be stowawayed', () => {
$httpBackend.expect('GET', `Tickets/${ticket.id}/canHaveStowaway`).respond(true);
controller.canStowaway();
$httpBackend.flush();
expect(controller.canShowStowaway).toBeTruthy();
});
it('should not make a query if is not on the ticket module', () => {
$state.getCurrentPath = () => [null, {state: {name: 'client'}}];
controller.canStowaway();
expect(controller.canShowStowaway).toBeFalsy();
});
});
describe('recalculateComponents()', () => {
it('should make a query and show a success message', () => {
jest.spyOn(controller, 'reload').mockReturnThis();

View File

@ -1,36 +0,0 @@
<vn-crud-model vn-id="model"
url="Tickets/{{$ctrl.ticket.id}}/getPossibleStowaways"
data="possibleStowaways">
</vn-crud-model>
<vn-dialog
vn-id="dialog"
class="modal-form"
on-open="model.refresh()"
message="Stowaways to add">
<tpl-body>
<vn-horizontal class="add-stowaway">
<vn-data-viewer model="model">
<vn-table model="model" auto-load="false">
<vn-thead>
<vn-tr>
<vn-th number>Ticket id</vn-th>
<vn-th>Shipped</vn-th>
<vn-th>Agency</vn-th>
<vn-th>Warehouse</vn-th>
<vn-th>State</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="ticket in possibleStowaways" class="clickable" ng-click="$ctrl.addStowaway(ticket)">
<vn-td number>{{ticket.id}}</vn-td>
<vn-td>{{ticket.landed | date: 'dd/MM/yyyy'}}</vn-td>
<vn-td>{{ticket.agencyMode.name}}</vn-td>
<vn-td>{{ticket.warehouse.name}}</vn-td>
<vn-td>{{ticket.ticketState.state.name}}</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-data-viewer>
</vn-horizontal>
</tpl-body>
</vn-dialog>

View File

@ -1,32 +0,0 @@
import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
addStowaway(stowaway) {
let params = {id: stowaway.id, shipFk: this.ticket.id};
this.$http.post(`Stowaways/`, params)
.then(() => this.cardReload())
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.$.dialog.hide();
});
}
show() {
this.$.dialog.show();
}
hide() {
this.$.dialog.hide();
}
}
ngModule.vnComponent('vnAddStowaway', {
template: require('./addStowaway.html'),
controller: Controller,
bindings: {
ticket: '<',
cardReload: '&?'
}
});

View File

@ -93,36 +93,6 @@
icon="icon-basketadd">
</vn-quick-link>
</div>
<div ng-transclude="btnFour">
<vn-quick-link
ng-if="$ctrl.ticket.stowaway"
tooltip="Ship stowaways"
state="['ticket.card.summary', {id: $ctrl.ticket.stowaway.shipFk}]"
icon="icon-stowaway">
</vn-quick-link>
</div>
<div ng-transclude="btnFour">
<vn-quick-link
ng-if="$ctrl.ticket.ship"
tooltip="Stowaway"
state="['ticket.card.summary', {id: $ctrl.ticket.ship.id}]"
icon="icon-stowaway">
</vn-quick-link>
</div>
</div>
<div style="text-align: center">
<vn-button-menu
ng-if="$ctrl.ticket.ship.length > 1"
vn-id="stowaways-button"
icon="icon-stowaway"
show-filter="false"
show-field="id"
value-field="id"
vn-tooltip="Ship stowaways"
tooltip-position="up"
data="$ctrl.ticket.ship"
ui-sref="ticket.card.sale({id: value})">
</vn-button-menu>
</div>
</slot-body>
</vn-descriptor-content>

View File

@ -1,12 +1,4 @@
Ship: Barco
Stowaway: Polizón
Cliente: Client
Ship stowaways: Polizones del barco
Stowaways to add: Polizones a añadir
Stowaways of the ticket: Polizones del ticket
Add stowaway: Añadir polizón
Delete stowaway: Eliminar polizón
Are you sure you want to delete this stowaway?: ¿Seguro que quieres eliminar este polizón?
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
Show pallet report: Ver hoja de pallet
Change shipped hour: Cambiar hora de envío

View File

@ -1,11 +1,5 @@
@import "variables";
.add-stowaway {
vn-data-viewer {
width: 640px
}
}
vn-dialog.modal-form {
section.header {
background-color: $color-main;

View File

@ -5,7 +5,6 @@ import './index/';
import './search-panel';
import './card';
import './descriptor';
import './descriptor/addStowaway';
import './descriptor-popover';
import './descriptor-menu';
import './create/card';

View File

@ -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;
};
};

View File

@ -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,190 +27,675 @@ describe('workerTimeControl add/delete timeEntry()', () => {
});
});
it('should fail to add a time entry if the target user is not a subordinate', async() => {
activeCtx.accessToken.userId = employeeId;
const workerId = 2;
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;
let error;
let error;
try {
ctx.args = {timed: new Date(), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) {
error = e;
}
try {
ctx.args = {timed: new Date(), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
expect(error.message).toBe(`You don't have enough privileges`);
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
expect(error.message).toBe(`You don't have enough privileges`);
});
it('should fail to add if the current and the target user are the same and is not team boss', async() => {
activeCtx.accessToken.userId = employeeId;
const workerId = employeeId;
let error;
try {
ctx.args = {timed: new Date(), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
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 himself', async() => {
activeCtx.accessToken.userId = teamBossId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const todayAtOne = new Date();
todayAtOne.setHours(1, 0, 0, 0);
ctx.args = {timed: todayAtOne, direction: 'in'};
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(createdTimeEntry.id).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should try but fail to delete his own time entry', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = salesBossId;
let error;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const todayAtOne = new Date();
todayAtOne.setHours(1, 0, 0, 0);
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);
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
expect(error.message).toBe(`You don't have enough privileges`);
});
it('should delete the created time entry for the team boss as himself', async() => {
activeCtx.accessToken.userId = teamBossId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const todayAtOne = new Date();
todayAtOne.setHours(1, 0, 0, 0);
ctx.args = {timed: todayAtOne, direction: 'in'};
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(createdTimeEntry.id).toBeDefined();
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options);
expect(deletedTimeEntry).toBeNull();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should delete the created time entry for the team boss as HHRR', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const todayAtOne = new Date();
todayAtOne.setHours(1, 0, 0, 0);
ctx.args = {timed: todayAtOne, direction: 'in'};
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(createdTimeEntry.id).toBeDefined();
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options);
expect(deletedTimeEntry).toBeNull();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should edit the created time entry for the team boss as HHRR', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const todayAtOne = new Date();
todayAtOne.setHours(1, 0, 0, 0);
ctx.args = {timed: todayAtOne, direction: 'in'};
const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(createdTimeEntry.id).toBeDefined();
ctx.args = {direction: 'out'};
const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options);
expect(updatedTimeEntry.direction).toEqual('out');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});
it('should fail to add if the current and the target user are the same and is not team boss', async() => {
activeCtx.accessToken.userId = employeeId;
const workerId = employeeId;
let error;
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;
try {
ctx.args = {timed: new Date(), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
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() => {
activeCtx.accessToken.userId = teamBossId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const tx = await models.WorkerTimeControl.beginTransaction({});
const options = {transaction: tx};
try {
ctx.args = {timed: date, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const todayAtSix = new Date();
todayAtSix.setHours(18, 30, 0, 0);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
ctx.args = {timed: todayAtSix, direction: 'in'};
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(error.message).toBe(`No está permitido trabajar`);
});
expect(createdTimeEntry.id).toBeDefined();
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;
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
ctx.args = {timed: date, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
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;
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
const calendar = await app.models.Calendar.findById(3);
expect(error.message).toBe(`No hay un contrato en vigor`);
});
try {
ctx.args = {timed: new Date(calendar.dated), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) {
error = e;
}
describe('direction errors', () => {
it('should throw an error when trying "in" direction twice', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = hankPymId;
expect(error.message).toBe(`The worker has a marked absence that day`);
});
let date = new Date();
date.setDate(date.getDate() - 21);
date = weekDay(date, monday);
let error;
it('should try but fail to delete his own time entry', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = salesBossId;
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);
let error;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
try {
date.setHours(10, 0, 0);
ctx.args = {timed: date, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const todayAtSeven = new Date();
todayAtSeven.setHours(19, 30, 0, 0);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
ctx.args = {timed: todayAtSeven, direction: 'in'};
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(error.message).toBe(`Dirección incorrecta`);
});
activeCtx.accessToken.userId = salesPersonId;
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
it('should throw an error when trying "in" direction after insert "in" and "middle"', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = hankPymId;
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
let date = new Date();
date.setDate(date.getDate() - 21);
date = weekDay(date, monday);
let error;
expect(error).toBeDefined();
expect(error.statusCode).toBe(400);
expect(error.message).toBe(`You don't have enough privileges`);
});
const tx = await models.WorkerTimeControl.beginTransaction({});
const options = {transaction: tx};
it('should delete the created time entry for the team boss as himself', async() => {
activeCtx.accessToken.userId = teamBossId;
const workerId = teamBossId;
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);
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
try {
date.setHours(10, 0, 0);
ctx.args = {timed: date, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const todayAtFive = new Date();
todayAtFive.setHours(17, 30, 0, 0);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
ctx.args = {timed: todayAtFive, direction: 'in'};
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
expect(error.message).toBe(`Dirección incorrecta`);
});
expect(createdTimeEntry.id).toBeDefined();
it('Should throw an error when trying "out" before closing a "middle" couple', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = hankPymId;
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
let date = new Date();
date.setDate(date.getDate() - 21);
date = weekDay(date, monday);
let error;
const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options);
const tx = await models.WorkerTimeControl.beginTransaction({});
const options = {transaction: tx};
expect(deletedTimeEntry).toBeNull();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
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);
it('should delete the created time entry for the team boss as HHRR', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
try {
date.setHours(10, 0, 0);
ctx.args = {timed: date, direction: 'out'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
const todayAtFive = new Date();
todayAtFive.setHours(17, 30, 0, 0);
expect(error.message).toBe(`Dirección incorrecta`);
});
ctx.args = {timed: todayAtFive, direction: 'in'};
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
it('should throw an error when trying "middle" after "out"', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = hankPymId;
expect(createdTimeEntry.id).toBeDefined();
let date = new Date();
date.setDate(date.getDate() - 21);
date = weekDay(date, monday);
let error;
await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options);
const tx = await models.WorkerTimeControl.beginTransaction({});
const options = {transaction: tx};
const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options);
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);
expect(deletedTimeEntry).toBeNull();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
try {
date.setHours(10, 0, 0);
ctx.args = {timed: date, direction: 'middle'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
it('should edit the created time entry for the team boss as HHRR', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
expect(error.message).toBe(`Dirección incorrecta`);
});
const todayAtFive = new Date();
todayAtFive.setHours(17, 30, 0, 0);
it('should throw an error when trying "out" direction twice', async() => {
activeCtx.accessToken.userId = salesBossId;
const workerId = hankPymId;
ctx.args = {timed: todayAtFive, direction: 'in'};
const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
let date = new Date();
date.setDate(date.getDate() - 21);
date = weekDay(date, monday);
let error;
expect(createdTimeEntry.id).toBeDefined();
const tx = await models.WorkerTimeControl.beginTransaction({});
const options = {transaction: tx};
ctx.args = {direction: 'out'};
const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options);
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);
expect(updatedTimeEntry.direction).toEqual('out');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
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(7, 59, 0);
ctx.args = {timed: date, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
try {
date.setHours(8, 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);
}
}

View File

@ -1,4 +1,4 @@
const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models;
describe('agency getLanded()', () => {
it('should return a landing date', async() => {
@ -9,12 +9,12 @@ describe('agency getLanded()', () => {
const agencyModeFk = 7;
const warehouseFk = 1;
const tx = await app.models.Zone.beginTransaction({});
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
const result = await app.models.Agency.getLanded(ctx, shipped, addressFk, agencyModeFk, warehouseFk, options);
const result = await models.Agency.getLanded(ctx, shipped, addressFk, agencyModeFk, warehouseFk, options);
expect(result.landed).toBeDefined();

View File

@ -141,9 +141,8 @@
</tr>
</tbody>
</table>
<div v-if="ticket.description || ticket.shipFk" class="text-area">
<div v-if="ticket.description class="text-area">
<p>{{ticket.description}}</p>
<p v-if="ticket.shipFk">{{$t('stowaway')}}: {{ticket.shipFk}}</p>
</div>
</div>
</div>

View File

@ -20,7 +20,6 @@ phone: Teléfono
warehouse: Almacén
salesPerson: Comercial
import: Importe
stowaway: Encajado dentro del ticket
route: Ruta
routeId: Ruta {0}
ticket: Ticket

View File

@ -17,7 +17,6 @@ SELECT
0 AS import,
am.name ticketAgency,
tob.description,
s.shipFk,
u.nickName salesPersonName,
ipkg.itemPackingTypes
FROM route r
@ -30,7 +29,6 @@ FROM route r
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN stowaway s ON s.id = t.id
LEFT JOIN (
SELECT t.id AS ticketFk,
GROUP_CONCAT(DISTINCT(i.itemPackingTypeFk)) AS itemPackingTypes