From ead09940326ca949d51bf26e85ba32daf1e29292 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 5 Nov 2020 10:33:02 +0100 Subject: [PATCH] timeControlCalculate procedure updated --- db/changes/10250-curfew/00-ACL.sql | 3 +- .../10250-curfew/00-timeControlCalculate.sql | 43 +++++++++++++++++++ db/changes/10250/00-ACL.sql | 2 - e2e/paths/05-ticket/05_tracking_state.spec.js | 2 +- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 db/changes/10250-curfew/00-timeControlCalculate.sql delete mode 100644 db/changes/10250/00-ACL.sql diff --git a/db/changes/10250-curfew/00-ACL.sql b/db/changes/10250-curfew/00-ACL.sql index c4987c405..90f673c67 100644 --- a/db/changes/10250-curfew/00-ACL.sql +++ b/db/changes/10250-curfew/00-ACL.sql @@ -1,3 +1,4 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Supplier', 'updateFiscalData', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Supplier', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Supplier', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierLog', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierContact', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file diff --git a/db/changes/10250-curfew/00-timeControlCalculate.sql b/db/changes/10250-curfew/00-timeControlCalculate.sql new file mode 100644 index 000000000..90d9acca9 --- /dev/null +++ b/db/changes/10250-curfew/00-timeControlCalculate.sql @@ -0,0 +1,43 @@ +DROP PROCEDURE IF EXISTS `vn`.`timeControl_calculate`; +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`timeControl_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + SET @vIsOdd := TRUE; + SET @vUser := NULL; + SET @vDated := NULL; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + + CREATE TEMPORARY TABLE tmp.timeControlCalculate + SELECT + userFk, + dated, + IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, + SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, + @timeWork / 3600 timeWorkDecimal, + timed + FROM (SELECT SUM(timeWork) timeWork, + userFk, + dated, + GROUP_CONCAT(DATE_FORMAT(sub.timed,"%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') timed + FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk), + IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE), + IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd), + IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed), + IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork, + IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated, + wtc.timed timed, + wtc.userFk, + direction + FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction + FROM workerTimeControl wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo + ORDER BY userFk, timed ASC + ) wtc + WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo + ) sub + GROUP BY userFk, dated + )sub2; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10250/00-ACL.sql b/db/changes/10250/00-ACL.sql deleted file mode 100644 index c9d8fd456..000000000 --- a/db/changes/10250/00-ACL.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('supplier', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierContact', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js index d66067da8..d5db750b8 100644 --- a/e2e/paths/05-ticket/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket/05_tracking_state.spec.js @@ -48,7 +48,7 @@ describe('Ticket Create new tracking state path', () => { }); it('should now access to the create state view by clicking the create floating button', async() => { - await page.waitFor('.vn-popup', {hidden: true}), + await page.waitFor('.vn-popup', {hidden: true}); await page.waitToClick(selectors.ticketTracking.createStateButton); await page.waitForState('ticket.card.tracking.edit'); });