diff --git a/.gitignore b/.gitignore index 3ef8c28fd..8cb76a829 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ coverage node_modules -dist/* +dist e2e/dms/*/ !e2e/dms/c4c !e2e/dms/c81 diff --git a/back/methods/chat/sendMessage.js b/back/methods/chat/sendMessage.js index f3510a098..2ab07af8c 100644 --- a/back/methods/chat/sendMessage.js +++ b/back/methods/chat/sendMessage.js @@ -28,8 +28,10 @@ module.exports = Self => { const models = Self.app.models; const accessToken = ctx.req.accessToken; const sender = await models.Account.findById(accessToken.userId); + const recipient = to.replace('@', ''); - return sendMessage(to, `@${sender.name}: ${message}`); + if (sender.name != recipient) + return sendMessage(to, `@${sender.name}: ${message}`); }; async function sendMessage(name, message) { @@ -70,6 +72,12 @@ module.exports = Self => { } function send(uri, body) { + if (process.env.NODE_ENV !== 'production') { + return new Promise(resolve => { + return resolve({statusCode: 200, message: 'Fake notification sent'}); + }); + } + const options = { method: 'POST', uri: uri, diff --git a/back/methods/chat/spec/send.spec.js b/back/methods/chat/spec/send.spec.js new file mode 100644 index 000000000..ebb62a0c8 --- /dev/null +++ b/back/methods/chat/spec/send.spec.js @@ -0,0 +1,18 @@ +const app = require('vn-loopback/server/server'); + +describe('chat sendMessage()', () => { + it('should return a "Fake notification sent" as response', async() => { + let ctx = {req: {accessToken: {userId: 1}}}; + let response = await app.models.Chat.sendMessage(ctx, '@salesPerson', 'I changed something'); + + expect(response.statusCode).toEqual(200); + expect(response.message).toEqual('Fake notification sent'); + }); + + it('should not return a response', async() => { + let ctx = {req: {accessToken: {userId: 18}}}; + let response = await app.models.Chat.sendMessage(ctx, '@salesPerson', 'I changed something'); + + expect(response).toBeUndefined(); + }); +}); diff --git a/back/models/account.js b/back/models/account.js index 9e6ecba45..00c583d31 100644 --- a/back/models/account.js +++ b/back/models/account.js @@ -62,7 +62,7 @@ module.exports = Self => { */ Self.hasRole = async function(userId, name) { let roles = await Self.getRoles(userId); - return roles.find(role => role == name); + return roles.some(role => role == name); }; /** diff --git a/db/changes/10100-AllSaints/00-zone.sql b/db/changes/10081-agency/00-zone.sql similarity index 71% rename from db/changes/10100-AllSaints/00-zone.sql rename to db/changes/10081-agency/00-zone.sql index 1fae52f4e..74e482c4c 100644 --- a/db/changes/10100-AllSaints/00-zone.sql +++ b/db/changes/10081-agency/00-zone.sql @@ -26,6 +26,12 @@ CREATE TABLE `vn`.`zoneEvent` ( CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8; +ALTER TABLE `vn`.`zoneEvent` + ADD COLUMN `type` ENUM('day', 'indefinitely', 'range') NOT NULL AFTER `zoneFk`, + ADD COLUMN `dated` DATE NULL DEFAULT NULL AFTER `type`, + CHANGE COLUMN `from` `started` DATE NULL DEFAULT NULL , + CHANGE COLUMN `to` `ended` DATE NULL DEFAULT NULL ; + CREATE TABLE `vn`.`zoneExclusion` ( `id` int(11) NOT NULL AUTO_INCREMENT, `zoneFk` int(11) NOT NULL, @@ -35,9 +41,16 @@ CREATE TABLE `vn`.`zoneExclusion` ( KEY `zoneFk` (`zoneFk`), CONSTRAINT `zoneExclusion_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; +ALTER TABLE `vn`.`zone` +DROP FOREIGN KEY `fk_zone_1`; +ALTER TABLE `vn`.`zone` +CHANGE COLUMN `warehouseFk` `warehouseFk` SMALLINT(6) UNSIGNED NULL DEFAULT NULL ; +ALTER TABLE `vn`.`zone` +ADD CONSTRAINT `fk_zone_1` + FOREIGN KEY (`warehouseFk`) + REFERENCES `vn`.`warehouse` (`id`) + ON DELETE NO ACTION + ON UPDATE CASCADE; -ALTER TABLE `vn`.`zone` - DROP FOREIGN KEY `fk_zone_1`; -ALTER TABLE `vn`.`zone` - DROP COLUMN `warehouseFk`, - DROP INDEX `fk_zone_1_idx`; +ALTER TABLE `vn`.`zoneExclusion` + CHANGE COLUMN `day` `dated` DATE NOT NULL ; diff --git a/db/changes/10081-agency/00-zone_getEvents.sql b/db/changes/10081-agency/00-zone_getEvents.sql index 199074a72..6e47bad22 100644 --- a/db/changes/10081-agency/00-zone_getEvents.sql +++ b/db/changes/10081-agency/00-zone_getEvents.sql @@ -1,10 +1,12 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getEvents`; -DROP PROCEDURE IF EXISTS `vn`.`zone_getEvents`; DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zone_getEvents`( - vAgencyModeFk INT, +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getEvents`( vProvinceFk INT, - vPostCode VARCHAR(255)) + vPostCode VARCHAR(255), + vAgencyModeFk INT) BEGIN /** * Returns available events for the passed province/postcode and agency. @@ -13,9 +15,9 @@ BEGIN * @param vProvinceFk The province id * @param vPostCode The postcode or %NULL to use the province */ - DECLARE vGeoFk INT; - - IF vPostCode IS NOT NULL THEN + DECLARE vGeoFk INT; + + IF vPostCode IS NOT NULL THEN SELECT p.geoFk INTO vGeoFk FROM postCode p JOIN town t ON t.id = p.townFk @@ -24,24 +26,27 @@ BEGIN ELSE SELECT geoFk INTO vGeoFk FROM province - WHERE id = vProvinceFk; - END IF; + WHERE id = vProvinceFk; + END IF; - CALL zone_getFromGeo(vGeoFk); - - DELETE t FROM tmp.zone t - JOIN zone z ON z.id = t.id - WHERE z.agencyModeFk != vAgencyModeFk; - - SELECT e.`from`, e.`to`, e.weekDays + CALL zone_getFromGeo(vGeoFk); + + IF vAgencyModeFk IS NOT NULL THEN + DELETE t FROM tmp.zone t + JOIN zone z ON z.id = t.id + WHERE z.agencyModeFk != vAgencyModeFk; + END IF; + + SELECT e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays FROM tmp.zone t JOIN zoneEvent e ON e.zoneFk = t.id; - - SELECT DISTINCT e.`day` + + SELECT DISTINCT e.dated FROM tmp.zone t JOIN zoneExclusion e ON e.zoneFk = t.id; DROP TEMPORARY TABLE tmp.zone; END$$ + DELIMITER ; diff --git a/db/changes/10081-agency/00-zone_getOptionsForDate.sql b/db/changes/10081-agency/00-zone_getOptionsForDate.sql deleted file mode 100644 index a71f85c1a..000000000 --- a/db/changes/10081-agency/00-zone_getOptionsForDate.sql +++ /dev/null @@ -1,79 +0,0 @@ - -DROP PROCEDURE IF EXISTS `vn`.`zone_getOptionsForLanding`; -DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zone_getOptionsForLanding`(vLanded DATE) -BEGIN -/** - * Gets computed options for the passed zones and delivery date. - * - * @table tmp.zones(id) The zones ids - * @param vLanded The delivery date - * @return tmp.zoneOption The computed options - */ - DECLARE vHour TIME DEFAULT TIME(NOW()); - - DROP TEMPORARY TABLE IF EXISTS tTemp; - CREATE TEMPORARY TABLE tTemp - ENGINE = MEMORY - SELECT t.id zoneFk, - TIME(e.`hour`) `hour`, - e.travelingDays, - e.price, - e.bonus, - CASE - WHEN e.`from` IS NULL AND e.`to` IS NULL - THEN 3 - WHEN e.`to` IS NULL - THEN 2 - ELSE 1 - END specificity - FROM tmp.zone t - JOIN zoneEvent e ON e.zoneFk = t.id - WHERE (e.`from` = vLanded AND e.`to` IS NULL) - OR ( - (e.`from` IS NULL OR vLanded BETWEEN e.`from` AND e.`to`) - AND e.weekDays & (1 << WEEKDAY(vLanded)) - ); - - -- XXX: Compatibility with the deprecated #zoneCalendar table - - INSERT INTO tTemp - SELECT t.id zoneFk, - NULL, - NULL, - c.price, - c.bonus, - 4 - FROM tmp.zone t - JOIN zoneCalendar c ON c.zoneFk = t.id - WHERE c.delivered = vLanded; - - DELETE t FROM tTemp t - JOIN zoneExclusion e - ON e.zoneFk = t.zoneFk AND e.`day` = vLanded; - - UPDATE tTemp t - JOIN zone z ON z.id = t.zoneFk - SET t.`hour` = IFNULL(t.`hour`, TIME(z.`hour`)), - t.travelingDays = IFNULL(t.travelingDays, z.travelingDays), - t.price = IFNULL(t.price, z.price), - t.bonus = IFNULL(t.bonus, z.bonus); - - DELETE FROM tTemp - WHERE (@shipped := TIMESTAMPADD(DAY, -travelingDays, vLanded)) < CURDATE() - OR @shipped = CURDATE() AND vHour > `hour`; - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; - CREATE TEMPORARY TABLE tmp.zoneOption - ENGINE = MEMORY - SELECT * - FROM ( - SELECT * FROM tTemp - ORDER BY zoneFk, specificity - ) t - GROUP BY zoneFk; - - DROP TEMPORARY TABLE tTemp; -END$$ -DELIMITER ; - diff --git a/db/changes/10100-AllSaints/01-zone_getAgency.sql b/db/changes/10081-agency/01-zone_getAgency.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getAgency.sql rename to db/changes/10081-agency/01-zone_getAgency.sql diff --git a/db/changes/10100-AllSaints/01-zone_getFirstShipped.sql b/db/changes/10081-agency/01-zone_getFirstShipped.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getFirstShipped.sql rename to db/changes/10081-agency/01-zone_getFirstShipped.sql diff --git a/db/changes/10100-AllSaints/01-zone_getLanded.sql b/db/changes/10081-agency/01-zone_getLanded.sql similarity index 96% rename from db/changes/10100-AllSaints/01-zone_getLanded.sql rename to db/changes/10081-agency/01-zone_getLanded.sql index fd3c6b6aa..a2bbe46a5 100644 --- a/db/changes/10100-AllSaints/01-zone_getLanded.sql +++ b/db/changes/10081-agency/01-zone_getLanded.sql @@ -28,7 +28,7 @@ BEGIN JOIN zone z ON z.id = zo.zoneFk JOIN zoneWarehouse zw ON zw.zoneFk = z.id WHERE agencyModeFk = vAgencyModeFk - AND warehouseFk = vWarehouseFk; + AND zw.warehouseFk = vWarehouseFk; DROP TEMPORARY TABLE tmp.zone, diff --git a/db/changes/10100-AllSaints/01-zone_getShippedWarehouse.sql b/db/changes/10081-agency/01-zone_getShippedWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getShippedWarehouse.sql rename to db/changes/10081-agency/01-zone_getShippedWarehouse.sql diff --git a/db/changes/10100-AllSaints/01-zone_getWarehouse.sql b/db/changes/10081-agency/01-zone_getWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getWarehouse.sql rename to db/changes/10081-agency/01-zone_getWarehouse.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetAgency.sql b/db/changes/10081-agency/02-zoneGetAgency.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetAgency.sql rename to db/changes/10081-agency/02-zoneGetAgency.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetFirstShipped__.sql b/db/changes/10081-agency/02-zoneGetFirstShipped__.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetFirstShipped__.sql rename to db/changes/10081-agency/02-zoneGetFirstShipped__.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetLanded.sql b/db/changes/10081-agency/02-zoneGetLanded.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetLanded.sql rename to db/changes/10081-agency/02-zoneGetLanded.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetShipped.sql b/db/changes/10081-agency/02-zoneGetShipped.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetShipped.sql rename to db/changes/10081-agency/02-zoneGetShipped.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetShippedWarehouse.sql b/db/changes/10081-agency/02-zoneGetShippedWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetShippedWarehouse.sql rename to db/changes/10081-agency/02-zoneGetShippedWarehouse.sql diff --git a/db/changes/10081-agency/04-zone_getOptionsForLanding.sql b/db/changes/10081-agency/04-zone_getOptionsForLanding.sql new file mode 100644 index 000000000..ae081f14b --- /dev/null +++ b/db/changes/10081-agency/04-zone_getOptionsForLanding.sql @@ -0,0 +1,67 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getOptionsForLanding`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE) +BEGIN +/** + * Gets computed options for the passed zones and delivery date. + * + * @table tmp.zones(id) The zones ids + * @param vLanded The delivery date + * @return tmp.zoneOption The computed options + */ + DECLARE vHour TIME DEFAULT TIME(NOW()); + + DROP TEMPORARY TABLE IF EXISTS tTemp; + CREATE TEMPORARY TABLE tTemp + ENGINE = MEMORY + SELECT t.id zoneFk, + IFNULL(TIME(e.`hour`), TIME(z.`hour`)) `hour`, + IFNULL(e.travelingDays, z.travelingDays) travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus, + CASE + WHEN e.`type` = 'day' + THEN 1 + WHEN e.`type` = 'range' + THEN 2 + ELSE 3 + END specificity + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + WHERE ( + e.`type` = 'day' + AND e.dated = vLanded + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(vLanded)) + AND (e.`started` IS NULL OR vLanded >= e.`started`) + AND (e.`ended` IS NULL OR vLanded <= e.`ended`) + ); + + DELETE t FROM tTemp t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; + + DELETE FROM tTemp + WHERE (@shipped := TIMESTAMPADD(DAY, -travelingDays, vLanded)) < CURDATE() + OR @shipped = CURDATE() AND vHour > `hour`; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT * + FROM ( + SELECT * FROM tTemp + ORDER BY zoneFk, specificity + ) t + GROUP BY zoneFk; + + DROP TEMPORARY TABLE tTemp; +END$$ + +DELIMITER ; + diff --git a/db/changes/10081-agency/04-zone_getOptionsForShipment.sql b/db/changes/10081-agency/04-zone_getOptionsForShipment.sql new file mode 100644 index 000000000..c631f8809 --- /dev/null +++ b/db/changes/10081-agency/04-zone_getOptionsForShipment.sql @@ -0,0 +1,76 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getOptionsForShipment`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE) +BEGIN +/** + * Gets computed options for the passed zones and shipping date. + * + * @table tmp.zones(id) The zones ids + * @param vShipped The shipping date + * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options + */ + DROP TEMPORARY TABLE IF EXISTS tLandings; + CREATE TEMPORARY TABLE tLandings + (INDEX (eventFk)) + ENGINE = MEMORY + SELECT e.id eventFk, + @travelingDays := IFNULL(e.travelingDays, z.travelingDays) travelingDays, + TIMESTAMPADD(DAY, @travelingDays, vShipped) landed + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id; + + DROP TEMPORARY TABLE IF EXISTS tTemp; + CREATE TEMPORARY TABLE tTemp + ENGINE = MEMORY + SELECT t.id zoneFk, + IFNULL(TIME(e.`hour`), TIME(z.`hour`)) `hour`, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus, + CASE + WHEN e.`type` = 'day' + THEN 1 + WHEN e.`type` = 'range' + THEN 2 + ELSE 3 + END specificity, + l.travelingDays, + l.landed + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + JOIN tLandings l ON l.eventFk = e.id + WHERE ( + e.`type` = 'day' + AND e.`dated` = l.landed + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(l.landed)) + AND (e.`started` IS NULL OR l.landed >= e.`started`) + AND (e.`ended` IS NULL OR l.landed <= e.`ended`) + ); + + DELETE t FROM tTemp t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT * + FROM ( + SELECT * FROM tTemp + ORDER BY zoneFk, specificity + ) t + GROUP BY zoneFk; + + DROP TEMPORARY TABLE + tTemp, + tLandings; +END$$ + +DELIMITER ; + diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForDated.sql b/db/changes/10100-AllSaints/04-zone_getOptionsForDated.sql deleted file mode 100644 index fce54e012..000000000 --- a/db/changes/10100-AllSaints/04-zone_getOptionsForDated.sql +++ /dev/null @@ -1,88 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketCreateWithUser`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( - vClientId INT - ,vShipped DATE - ,vWarehouseFk INT - ,vCompanyFk INT - ,vAddressFk INT - ,vAgencyModeFk INT - ,vRouteFk INT - ,vlanded DATE - ,vUserId INT - ,OUT vNewTicket INT) -BEGIN - - DECLARE vZoneFk INT; - - IF vClientId IS NULL THEN - CALL util.throw ('CLIENT_NOT_ESPECIFIED'); - END IF; - - IF NOT vAddressFk OR vAddressFk IS NULL THEN - SELECT id INTO vAddressFk - FROM address - WHERE clientFk = vClientId AND isDefaultAddress; - END IF; - - IF vAgencyModeFk IS NOT NULL THEN - - CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetShipped - WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; - - IF vZoneFk IS NULL OR vZoneFk = 0 THEN - CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); - END IF; - END IF; - INSERT INTO vn2008.Tickets ( - Id_Cliente, - Fecha, - Id_Consigna, - Id_Agencia, - Alias, - warehouse_id, - Id_Ruta, - empresa_id, - landing, - zoneFk - ) - SELECT - vClientId, - vShipped, - a.id, - vAgencyModeFk, - a.nickname, - vWarehouseFk, - IF(vRouteFk,vRouteFk,NULL), - vCompanyFk, - vlanded, - vZoneFk - FROM address a - JOIN agencyMode am ON am.id = a.agencyModeFk - WHERE a.id = vAddressFk; - - SET vNewTicket = LAST_INSERT_ID(); - - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vNewTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN address a ON a.id = ao.addressFk - WHERE a.id = vAddressFk; - - INSERT INTO vn.ticketLog - SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); - - IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vNewTicket, getWorker() - FROM state - WHERE `code` = 'DELIVERED'; - END IF; -END$$ - -DELIMITER ; diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForLandingsql b/db/changes/10100-AllSaints/04-zone_getOptionsForLandingsql deleted file mode 100644 index 116703831..000000000 --- a/db/changes/10100-AllSaints/04-zone_getOptionsForLandingsql +++ /dev/null @@ -1,83 +0,0 @@ - -USE `vn`; -DROP procedure IF EXISTS `vn`.`zone_getOptionsForLanding`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE) -BEGIN -/** - * Gets computed options for the passed zones and delivery date. - * - * @table tmp.zones(id) The zones ids - * @param vLanded The delivery date - * @return tmp.zoneOption The computed options - */ - DECLARE vHour TIME DEFAULT TIME(NOW()); - - DROP TEMPORARY TABLE IF EXISTS tTemp; - CREATE TEMPORARY TABLE tTemp - ENGINE = MEMORY - SELECT t.id zoneFk, - TIME(e.`hour`) `hour`, - e.travelingDays, - e.price, - e.bonus, - CASE - WHEN e.`from` IS NULL AND e.`to` IS NULL - THEN 3 - WHEN e.`to` IS NULL - THEN 2 - ELSE 1 - END specificity - FROM tmp.zone t - JOIN zoneEvent e ON e.zoneFk = t.id - WHERE (e.`from` = vLanded AND e.`to` IS NULL) - OR ( - (e.`from` IS NULL OR vLanded BETWEEN e.`from` AND e.`to`) - AND e.weekDays & (1 << WEEKDAY(vLanded)) - ); - - -- XXX: Compatibility with the deprecated #zoneCalendar table - - INSERT INTO tTemp - SELECT t.id zoneFk, - NULL, - NULL, - c.price, - c.bonus, - 4 - FROM tmp.zone t - JOIN zoneCalendar c ON c.zoneFk = t.id - WHERE c.delivered = vLanded; - - DELETE t FROM tTemp t - JOIN zoneExclusion e - ON e.zoneFk = t.zoneFk AND e.`day` = vLanded; - - UPDATE tTemp t - JOIN zone z ON z.id = t.zoneFk - SET t.`hour` = IFNULL(t.`hour`, TIME(z.`hour`)), - t.travelingDays = IFNULL(t.travelingDays, z.travelingDays), - t.price = IFNULL(t.price, z.price), - t.bonus = IFNULL(t.bonus, z.bonus); - - DELETE FROM tTemp - WHERE (@shipped := TIMESTAMPADD(DAY, -travelingDays, vLanded)) < CURDATE() - OR @shipped = CURDATE() AND vHour > `hour`; - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; - CREATE TEMPORARY TABLE tmp.zoneOption - ENGINE = MEMORY - SELECT * - FROM ( - SELECT * FROM tTemp - ORDER BY zoneFk, specificity - ) t - GROUP BY zoneFk; - - DROP TEMPORARY TABLE tTemp; -END$$ - -DELIMITER ; -; diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForShipment.sql b/db/changes/10100-AllSaints/04-zone_getOptionsForShipment.sql deleted file mode 100644 index 26a2101f7..000000000 --- a/db/changes/10100-AllSaints/04-zone_getOptionsForShipment.sql +++ /dev/null @@ -1,65 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `zone_getOptionsForShipment`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE) -BEGIN -/** - * Gets computed options for the passed zones and shipping date. - * - * @table tmp.zones(id) The zones ids - * @param vShipped The shipping date - * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options - */ - DECLARE vHour TIME DEFAULT TIME(NOW()); - - DROP TEMPORARY TABLE IF EXISTS tTemp; - CREATE TEMPORARY TABLE tTemp - ENGINE = MEMORY - SELECT t.id zoneFk, - TIME(e.`hour`) `hour`, - e.travelingDays, - e.price, - e.bonus, - CASE - WHEN e.`from` IS NULL AND e.`to` IS NULL - THEN 3 - WHEN e.`to` IS NULL - THEN 2 - ELSE 1 - END specificity - FROM tmp.zone t - JOIN zoneEvent e ON e.zoneFk = t.id - WHERE (e.`from` = TIMESTAMPADD(DAY, e.travelingDays, vShipped) AND e.`to` IS NULL) - OR ( - (e.`from` IS NULL OR TIMESTAMPADD(DAY, e.travelingDays, vShipped) BETWEEN e.`from` AND e.`to`) - AND e.weekDays & (1 << WEEKDAY(TIMESTAMPADD(DAY, e.travelingDays, vShipped))) - ); - - DELETE t FROM tTemp t - JOIN zoneExclusion e - ON e.zoneFk = t.zoneFk AND TIMESTAMPADD(DAY,-t.travelingDays, e.`day`) = vShipped; - - UPDATE tTemp t - JOIN zone z ON z.id = t.zoneFk - SET t.`hour` = IFNULL(t.`hour`, TIME(z.`hour`)), - t.travelingDays = IFNULL(t.travelingDays, z.travelingDays), - t.price = IFNULL(t.price, z.price), - t.bonus = IFNULL(t.bonus, z.bonus); - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; - CREATE TEMPORARY TABLE tmp.zoneOption - ENGINE = MEMORY - SELECT * - FROM ( - SELECT * FROM tTemp - ORDER BY zoneFk, specificity - ) t - GROUP BY zoneFk; - - DROP TEMPORARY TABLE tTemp; -END$$ - -DELIMITER ; - diff --git a/db/changes/10100-AllSaints/00-ACL.sql b/db/changes/10100-allSaints/00-ACL.sql similarity index 100% rename from db/changes/10100-AllSaints/00-ACL.sql rename to db/changes/10100-allSaints/00-ACL.sql diff --git a/db/changes/10100-AllSaints/00-travelLog.sql b/db/changes/10100-allSaints/00-travelLog.sql similarity index 100% rename from db/changes/10100-AllSaints/00-travelLog.sql rename to db/changes/10100-allSaints/00-travelLog.sql diff --git a/db/changes/10100-AllSaints/00-upperGap.sql b/db/changes/10100-allSaints/00-upperGap.sql similarity index 100% rename from db/changes/10100-AllSaints/00-upperGap.sql rename to db/changes/10100-allSaints/00-upperGap.sql diff --git a/db/changes/10100-AllSaints/00-userLog.sql b/db/changes/10100-allSaints/00-userLog.sql similarity index 100% rename from db/changes/10100-AllSaints/00-userLog.sql rename to db/changes/10100-allSaints/00-userLog.sql diff --git a/db/changes/10100-AllSaints/00-userPhoneType.sql b/db/changes/10100-allSaints/00-userPhoneType.sql similarity index 100% rename from db/changes/10100-AllSaints/00-userPhoneType.sql rename to db/changes/10100-allSaints/00-userPhoneType.sql diff --git a/db/changes/10100-AllSaints/01-userPhone.sql b/db/changes/10100-allSaints/01-userPhone.sql similarity index 100% rename from db/changes/10100-AllSaints/01-userPhone.sql rename to db/changes/10100-allSaints/01-userPhone.sql diff --git a/db/changes/10100-AllSaints/02-catalog_componentCalculate.sql b/db/changes/10100-allSaints/02-catalog_componentCalculate.sql similarity index 100% rename from db/changes/10100-AllSaints/02-catalog_componentCalculate.sql rename to db/changes/10100-allSaints/02-catalog_componentCalculate.sql diff --git a/db/changes/10100-AllSaints/02-ticketCalculate__.sql b/db/changes/10100-allSaints/02-ticketCalculate__.sql similarity index 100% rename from db/changes/10100-AllSaints/02-ticketCalculate__.sql rename to db/changes/10100-allSaints/02-ticketCalculate__.sql diff --git a/db/changes/10100-AllSaints/03-available_calc.sql b/db/changes/10100-allSaints/03-available_calc.sql similarity index 100% rename from db/changes/10100-AllSaints/03-available_calc.sql rename to db/changes/10100-allSaints/03-available_calc.sql diff --git a/db/changes/10100-AllSaints/03-catalog_calculate.sql b/db/changes/10100-allSaints/03-catalog_calculate.sql similarity index 100% rename from db/changes/10100-AllSaints/03-catalog_calculate.sql rename to db/changes/10100-allSaints/03-catalog_calculate.sql diff --git a/db/changes/10100-AllSaints/03-order_confirmWithUser.sql b/db/changes/10100-allSaints/03-order_confirmWithUser.sql similarity index 100% rename from db/changes/10100-AllSaints/03-order_confirmWithUser.sql rename to db/changes/10100-allSaints/03-order_confirmWithUser.sql diff --git a/db/changes/10100-AllSaints/03-ticketCalculateClon.sql b/db/changes/10100-allSaints/03-ticketCalculateClon.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCalculateClon.sql rename to db/changes/10100-allSaints/03-ticketCalculateClon.sql diff --git a/db/changes/10100-AllSaints/03-ticketComponentCalculate.sql b/db/changes/10100-allSaints/03-ticketComponentCalculate.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketComponentCalculate.sql rename to db/changes/10100-allSaints/03-ticketComponentCalculate.sql diff --git a/db/changes/10100-AllSaints/03-ticketCreateWithUser.sql b/db/changes/10100-allSaints/03-ticketCreateWithUser.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCreateWithUser.sql rename to db/changes/10100-allSaints/03-ticketCreateWithUser.sql diff --git a/db/changes/10100-AllSaints/03-ticketCreateWithoutZone.sql b/db/changes/10100-allSaints/03-ticketCreateWithoutZone.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCreateWithoutZone.sql rename to db/changes/10100-allSaints/03-ticketCreateWithoutZone.sql diff --git a/db/changes/10100-AllSaints/05-catalog_calcFromItem.sql b/db/changes/10100-allSaints/05-catalog_calcFromItem.sql similarity index 100% rename from db/changes/10100-AllSaints/05-catalog_calcFromItem.sql rename to db/changes/10100-allSaints/05-catalog_calcFromItem.sql diff --git a/db/changes/10110-postCampaign/00-country.sql b/db/changes/10110-postCampaign/00-country.sql new file mode 100644 index 000000000..dcc883ab8 --- /dev/null +++ b/db/changes/10110-postCampaign/00-country.sql @@ -0,0 +1,10 @@ +USE `vn`; + +UPDATE `vn`.`country` SET `ibanLength` = '24' WHERE (`id` = 1); +UPDATE `vn`.`country` SET `ibanLength` = '27' WHERE (`id` = 2); +UPDATE `vn`.`country` SET `ibanLength` = '22' WHERE (`id` = 3); +UPDATE `vn`.`country` SET `ibanLength` = '24' WHERE (`id` = 4); +UPDATE `vn`.`country` SET `ibanLength` = '18' WHERE (`id` = 5); +UPDATE `vn`.`country` SET `ibanLength` = '25' WHERE (`id` = 8); +UPDATE `vn`.`country` SET `ibanLength` = '27' WHERE (`id` = 19); +UPDATE `vn`.`country` SET `ibanLength` = '24' WHERE (`id` = 30); diff --git a/db/changes/10110-postCampaign/00-department_doCalc.sql b/db/changes/10110-postCampaign/00-department_doCalc.sql new file mode 100644 index 000000000..7adeb30f0 --- /dev/null +++ b/db/changes/10110-postCampaign/00-department_doCalc.sql @@ -0,0 +1,3 @@ +USE `vn`; + +CREATE DEFINER=`root`@`%` EVENT `department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.department_doCalc \ No newline at end of file diff --git a/db/changes/10110-postCampaign/00-sample.sql b/db/changes/10110-postCampaign/00-sample.sql new file mode 100644 index 000000000..68e9d1a0f --- /dev/null +++ b/db/changes/10110-postCampaign/00-sample.sql @@ -0,0 +1,8 @@ +USE `vn`; + +UPDATE `vn`.`sample` SET `description` = 'Bienvenida como nuevo cliente' WHERE (`id` = '12'); +UPDATE `vn`.`sample` SET `description` = 'Instalación y configuración de impresora de coronas' WHERE (`id` = '13'); +UPDATE `vn`.`sample` SET `description` = 'Solicitud de domiciliación bancaria' WHERE (`id` = '14'); +UPDATE `vn`.`sample` SET `description` = 'Aviso inicial por saldo deudor' WHERE (`id` = '15'); +UPDATE `vn`.`sample` SET `description` = 'Aviso reiterado por saldo deudor' WHERE (`id` = '16'); +UPDATE `vn`.`sample` SET `isVisible` = '0' WHERE (`id` = '17'); diff --git a/db/changes/10110-postCampaign/00-ticketClosure.sql b/db/changes/10110-postCampaign/00-ticketClosure.sql new file mode 100644 index 000000000..07c7ef812 --- /dev/null +++ b/db/changes/10110-postCampaign/00-ticketClosure.sql @@ -0,0 +1,116 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketClosure`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosure`() +BEGIN +/** + * Realiza el cierre de todos los + * tickets de la table ticketClosure. + */ + DECLARE vDone BOOL; + DECLARE vClientFk INT; + DECLARE vTicketFk INT; + DECLARE vIsTaxDataChecked BOOL; + DECLARE vCompanyFk INT; + DECLARE vShipped DATE; + DECLARE vPriority INT DEFAULT 1; + DECLARE vReportDeliveryNote INT DEFAULT 1; + DECLARE vNewInvoiceId INT; + DECLARE vHasDailyInvoice BOOL; + DECLARE vWithPackage BOOL; + + DECLARE cur CURSOR FOR + SELECT ticketFk FROM tmp.ticketClosure; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + RESIGNAL; + END; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2; + CREATE TEMPORARY TABLE tmp.ticketClosure2 + SELECT ticketFk FROM tmp.ticketClosure; + INSERT INTO tmp.ticketClosure + SELECT id FROM stowaway s + JOIN tmp.ticketClosure2 tc ON s.shipFk = tc.ticketFk; + OPEN cur; + + proc: LOOP + SET vDone = FALSE; + + FETCH cur INTO vTicketFk; + + IF vDone THEN + LEAVE proc; + END IF; + + -- ticketClosure start + SELECT + c.id, + c.isTaxDataChecked, + t.companyFk, + t.shipped, + co.hasDailyInvoice, + w.isManaged + INTO vClientFk, + vIsTaxDataChecked, + vCompanyFk, + vShipped, + vHasDailyInvoice, + vWithPackage + FROM ticket t + JOIN `client` c ON c.id = t.clientFk + JOIN province p ON p.id = c.provinceFk + JOIN country co ON co.id = p.countryFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.id = vTicketFk; + + INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) + (SELECT vTicketFk, p.id, COUNT(*) + FROM expedition e + JOIN packaging p ON p.itemFk = e.itemFk + WHERE e.ticketFk = vTicketFk AND p.isPackageReturnable + AND vWithPackage + GROUP BY p.itemFk); + + -- No retornables o no catalogados + INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) + (SELECT e.itemFk, vTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1 + FROM expedition e + JOIN item i ON i.id = e.itemFk + LEFT JOIN packaging p ON p.itemFk = i.id + WHERE e.ticketFk = vTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 + AND getSpecialPrice(e.itemFk, vClientFk) > 0 + GROUP BY e.itemFk); + + IF(vHasDailyInvoice) THEN + + -- Facturacion rapida + CALL ticketTrackingAdd(vTicketFk, 'DELIVERED', NULL); + -- Facturar si está contabilizado + IF vIsTaxDataChecked THEN + CALL invoiceOut_newFromClient( + vClientFk, + (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), + vShipped, + vCompanyFk, + NULL, + vNewInvoiceId); + END IF; + ELSE + -- Albaran_print + CALL ticketTrackingAdd(vTicketFk, (SELECT vn.getAlert3State(vTicketFk)), NULL); + END IF; + + -- ticketClosure end + END LOOP; + + CLOSE cur; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2; +END$$ + +DELIMITER ; + diff --git a/db/changes/10110-postCampaign/00-ticketRequest.sql b/db/changes/10110-postCampaign/00-ticketRequest.sql new file mode 100644 index 000000000..0b8a5d22d --- /dev/null +++ b/db/changes/10110-postCampaign/00-ticketRequest.sql @@ -0,0 +1,108 @@ +USE `vn`; + +ALTER TABLE `vn`.`ticketRequest` +DROP FOREIGN KEY `fgnAtender`; +ALTER TABLE `vn`.`ticketRequest` +CHANGE COLUMN `atenderFk` `attenderFk` INT(11) NULL DEFAULT NULL ; +ALTER TABLE `vn`.`ticketRequest` +ADD CONSTRAINT `fgnAtender` + FOREIGN KEY (`attenderFk`) + REFERENCES `vn`.`worker` (`id`) + ON UPDATE CASCADE; + +USE `vn2008`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn2008`.`Ordenes` AS + SELECT + `tr`.`id` AS `Id_ORDEN`, + `tr`.`description` AS `ORDEN`, + `tr`.`requesterFk` AS `requesterFk`, + `tr`.`attenderFk` AS `attenderFk`, + `tr`.`quantity` AS `CANTIDAD`, + `tr`.`itemFk` AS `Id_ARTICLE`, + `tr`.`price` AS `PRECIOMAX`, + `tr`.`isOk` AS `isOk`, + `tr`.`saleFk` AS `Id_Movimiento`, + `tr`.`ticketFk` AS `ticketFk`, + `tr`.`response` AS `COMENTARIO`, + `tr`.`created` AS `odbc_date`, + `tr`.`ordered` AS `datORDEN`, + `tr`.`shipped` AS `datTICKET`, + `tr`.`salesPersonCode` AS `CodVENDEDOR`, + `tr`.`buyerCode` AS `CodCOMPRADOR`, + `tr`.`price__` AS `PREU`, + `tr`.`clientFk` AS `Id_CLIENTE`, + `tr`.`ok__` AS `OK`, + `tr`.`total` AS `TOTAL`, + `tr`.`buyed` AS `datCOMPRA`, + `tr`.`ko__` AS `KO` + FROM + `vn`.`ticketRequest` `tr`; + +USE `vn`; + +DROP TRIGGER IF EXISTS `vn`.`ticketRequest_beforeInsert`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`ticketRequest_beforeInsert` BEFORE INSERT ON `ticketRequest` FOR EACH ROW +BEGIN + IF NEW.ticketFk IS NULL THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; + + IF NEW.requesterFk IS NULL THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.attenderFk IS NULL THEN + SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + END IF; +END$$ +DELIMITER ; + + +DROP TRIGGER IF EXISTS `vn`.`ticketRequest_beforeUpdate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`ticketRequest_beforeUpdate` BEFORE UPDATE ON `ticketRequest` FOR EACH ROW +BEGIN + IF NEW.saleFk <> OLD.saleFk THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; + + IF NEW.salesPersonCode <> OLD.salesPersonCode THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.buyerCode <> OLD.buyerCode THEN + SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + END IF; +END$$ +DELIMITER ; + +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`ticketRequest__` AS + SELECT + `t`.`Id_ORDEN` AS `id`, + `t`.`ORDEN` AS `description`, + `t`.`requesterFk` AS `requesterFk`, + `t`.`attenderFk` AS `attenderFk`, + `t`.`CANTIDAD` AS `quantity`, + `t`.`Id_ARTICLE` AS `itemFk`, + `t`.`PRECIOMAX` AS `price`, + `t`.`isOk` AS `isOk`, + `t`.`Id_Movimiento` AS `saleFk`, + `t`.`ticketFk` AS `ticketFk`, + `t`.`COMENTARIO` AS `response`, + `t`.`odbc_date` AS `created` + FROM + `vn2008`.`Ordenes` `t`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 1c464589f..d2c4050e2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -53,13 +53,14 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossF INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`) VALUES - (1, 'España', 0, 'ES', 1, 22), - (2, 'Italia', 1, 'IT', 1, 25), - (3, 'Alemania', 1, 'DE', 1, 20), - (4, 'Rumania', 1, 'RO', 1, 22), - (5, 'Holanda', 1, 'NL', 1, 16), - (19,'Francia', 1, 'FR', 1, 25), - (30,'Canarias', 1, 'IC', 1, 22); + (1, 'España', 0, 'ES', 1, 24), + (2, 'Italia', 1, 'IT', 1, 27), + (3, 'Alemania', 1, 'DE', 1, 22), + (4, 'Rumania', 1, 'RO', 1, 24), + (5, 'Holanda', 1, 'NL', 1, 18), + (8, 'Portugal', 1, 'PT', 1, 27), + (19,'Francia', 1, 'FR', 1, 27), + (30,'Canarias', 1, 'IC', 1, 24); INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`) VALUES @@ -195,9 +196,9 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city VALUES (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), - (103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), + (103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), - (105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), + (105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), (106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1), (107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), (108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), @@ -1467,7 +1468,7 @@ INSERT INTO `vn2008`.`workerTeam`(`id`, `team`, `user`) (5, 3, 103), (6, 3, 104); -INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) +INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) VALUES (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), @@ -1614,227 +1615,227 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) (8, 5, 0), (8, 1, 1); -INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `from`) +INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) VALUES - (1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), - (1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), - (1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), - (1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), - (1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), - (2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), - (2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), - (2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), - (2, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (3, CURDATE()), - (3, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (3, DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (4, CURDATE()), - (4, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (4, DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (5, CURDATE()), - (5, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (5, DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (6, CURDATE()), - (6, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (6, DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (7, CURDATE()), - (7, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (7, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (7, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (7, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (7, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (7, DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (8, CURDATE()), - (8, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (8, DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (8, DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (8, DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (8, DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (8, DATE_ADD(CURDATE(), INTERVAL +6 DAY)); + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), + (3, 'day', CURDATE()), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), + (3, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), + (4, 'day', CURDATE()), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), + (4, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), + (5, 'day', CURDATE()), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), + (5, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), + (6, 'day', CURDATE()), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), + (6, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), + (7, 'day', CURDATE()), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (7, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), + (8, 'day', CURDATE()), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), + (8, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)); -INSERT INTO `vn`.`workerTimeControl`(`userFk`,`timed`,`manual`) +INSERT INTO `vn`.`workerTimeControl`(`userFk`,`timed`,`manual`, `direction`) VALUES - (106, CONCAT(CURDATE(), ' 07:00'), TRUE), - (106, CONCAT(CURDATE(), ' 10:00'), TRUE), - (106, CONCAT(CURDATE(), ' 10:10'), TRUE), - (106, CONCAT(CURDATE(), ' 15:00'), TRUE); + (106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'), + (106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'), + (106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'), + (106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out'); INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`) VALUES @@ -1946,3 +1947,8 @@ INSERT INTO `vn`.`userPhone`(`id`, `userFk`, `typeFk`, `phone`) (65, 107, 'businessPhone', 700987987), (67, 106, 'businessPhone', 1111111112), (68, 106, 'personalPhone', 1111111113); + +INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`) + VALUES + (1, 43200, 129600, 734400, 43200, 50400); + diff --git a/db/tests/vn/buyUltimateFromInterval.spec.js b/db/tests/vn/buyUltimateFromInterval.spec.js index b416b5cb2..b5e6970f7 100644 --- a/db/tests/vn/buyUltimateFromInterval.spec.js +++ b/db/tests/vn/buyUltimateFromInterval.spec.js @@ -5,25 +5,14 @@ describe('buyUltimateFromInterval()', () => { let today; let future; beforeAll(() => { - let date = new Date(); - let month = `${date.getMonth() + 1}`; - let futureMonth = `${date.getMonth() + 2}`; - let day = date.getDate(); - let year = date.getFullYear(); - let futureYear = year; + let now = new Date(); + now.setHours(0, 0, 0, 0); + today = now; - if (month.toString().length < 2) month = '0' + month; - if (futureMonth.toString().length < 2) futureMonth = '0' + futureMonth; - if (futureMonth.toString() == '13') { - futureMonth = '01'; - futureYear + 1; - } - - - if (day.toString().length < 2) day = `0${day}`; - - today = [year, month, day].join('-'); - future = [futureYear, futureMonth, day].join('-'); + let futureDate = new Date(now); + let futureMonth = now.getMonth() + 1; + futureDate.setMonth(futureMonth); + future = futureDate; }); it(`should create a temporal table with it's data`, async() => { @@ -65,8 +54,8 @@ describe('buyUltimateFromInterval()', () => { expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3); expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5); - expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today)); - expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today)); + expect(buyUltimateFromIntervalTable[0].landed).toEqual(today); + expect(buyUltimateFromIntervalTable[1].landed).toEqual(today); }); it(`should create a temporal table with it's data in which started value is assigned to ended`, async() => { @@ -101,8 +90,8 @@ describe('buyUltimateFromInterval()', () => { expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3); expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5); - expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today)); - expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today)); + expect(buyUltimateFromIntervalTable[0].landed).toEqual(today); + expect(buyUltimateFromIntervalTable[1].landed).toEqual(today); }); it(`should create a temporal table with it's data in which ended value is a date in the future`, async() => { @@ -137,7 +126,7 @@ describe('buyUltimateFromInterval()', () => { expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3); expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5); - expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today)); - expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today)); + expect(buyUltimateFromIntervalTable[0].landed).toEqual(today); + expect(buyUltimateFromIntervalTable[1].landed).toEqual(today); }); }); diff --git a/db/tests/vn/orderConfirmWithUser.spec.js b/db/tests/vn/orderConfirmWithUser.spec.js new file mode 100644 index 000000000..f2a3d0c4e --- /dev/null +++ b/db/tests/vn/orderConfirmWithUser.spec.js @@ -0,0 +1,37 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +// #1885 +xdescribe('order_confirmWithUser()', () => { + it('should confirm an order', async() => { + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + let params = { + orderFk: 10, + userId: 9 + }; + // problema: la funcion order_confirmWithUser tiene una transacción, por tanto esta nunca hace rollback + stmt = new ParameterizedSQL('CALL hedera.order_confirmWithUser(?, ?)', [ + params.orderFk, + params.userId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('SELECT confirmed FROM hedera.order WHERE id = ?', [ + params.orderFk + ]); + let orderIndex = stmts.push(stmt) - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + savedDescription = result[orderIndex][0].confirmed; + + expect(savedDescription).toBeTruthy(); + }); +}); diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 13aeae436..4d6285603 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -7,8 +7,6 @@ import config from './config.js'; let currentUser; let actions = { - // Generic extensions - clickIfExists: async function(selector) { let exists = await this.exists(selector); if (exists) await this.click(selector); @@ -25,8 +23,6 @@ let actions = { }, selector); }, - // Salix specific extensions - changeLanguageToEnglish: async function() { let langSelector = '.user-popover vn-autocomplete[ng-model="$ctrl.lang"]'; @@ -49,14 +45,15 @@ let actions = { login: async function(userName) { if (currentUser !== userName) { - let logoutClicked = await this.clickIfExists('#logout'); + let accountClicked = await this.clickIfExists('#user'); - if (logoutClicked) { + if (accountClicked) { let buttonSelector = '.vn-dialog.shown button[response=accept]'; - await this.wait(buttonSelector => { - return document.querySelector(buttonSelector) != null - || location.hash == '#!/login'; - }, buttonSelector); + await this.waitToClick('#logout') + .wait(buttonSelector => { + return document.querySelector(buttonSelector) != null + || location.hash == '#!/login'; + }, buttonSelector); await this.clickIfExists(buttonSelector); } @@ -72,7 +69,7 @@ let actions = { currentUser = userName; } else - await this.waitToClick('vn-topbar a[ui-sref="home"]'); + await this.waitToClick('a[ui-sref=home]'); }, waitForLogin: async function(userName) { @@ -189,7 +186,7 @@ let actions = { let element = selectorMatches[0]; if (selectorMatches.length > 1) - throw new Error(`multiple matches of ${elementSelector} found`); + throw new Error(`Multiple matches of ${elementSelector} found`); let isVisible = false; if (element) { @@ -347,7 +344,7 @@ let actions = { .write('vn-searchbar input', searchValue) .click('vn-searchbar vn-icon[icon="search"]') .wait(100) - .waitForNumberOfElements('.searchResult', 1) + .waitForNumberOfElements('.search-result', 1) .evaluate(() => { return document.querySelector('ui-view vn-card vn-table') != null; }) @@ -362,15 +359,16 @@ let actions = { accessToSection: function(sectionRoute) { return this.wait(`vn-left-menu`) .evaluate(sectionRoute => { - return document.querySelector(`vn-left-menu ul li ul li > a[ui-sref="${sectionRoute}"]`) != null; + return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null; }, sectionRoute) .then(nested => { - if (!nested) - return this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`); + if (nested) { + this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]') + .wait('vn-left-menu .expanded'); + } - return this.waitToClick('vn-left-menu .collapsed') - .wait('vn-left-menu .expanded') - .waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`); + return this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`) + .waitForSpinnerLoad(); }); }, @@ -429,10 +427,7 @@ let actions = { }, waitForSpinnerLoad: function() { - return this.wait(() => { - const element = document.querySelector('vn-spinner > div'); - return element.style.display == 'none'; - }); + return this.waitUntilNotPresent('vn-topbar vn-spinner'); } }; diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index 6706b6dc4..01dcdd5d3 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -13,9 +13,7 @@ module.exports = function createNightmare(width = 1280, height = 720) { x: 0, y: 0, waitTimeout: 2000, - // openDevTools: { - // mode: 'detach' - // } + // openDevTools: {mode: 'detach'} }).viewport(width, height); nightmare.on('console', (type, message, ...args) => { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 838878b60..7b5b583f6 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -9,7 +9,7 @@ export default { invoiceOutButton: '.modules-menu > li[ui-sref="invoiceOut.index"]', claimsButton: '.modules-menu > li[ui-sref="claim.index"]', returnToModuleIndexButton: 'a[ui-sref="order.index"]', - userMenuButton: 'vn-topbar #user', + userMenuButton: '#user', userLocalWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.localWarehouseFk"]', userLocalBank: '.user-popover vn-autocomplete[ng-model="$ctrl.localBankFk"]', userLocalCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.localCompanyFk"]', @@ -23,7 +23,7 @@ export default { clientsIndex: { searchClientInput: `vn-textfield input`, searchButton: 'vn-searchbar vn-icon[icon="search"]', - searchResult: 'vn-client-index .vn-list-item', + searchResult: 'vn-client-index .vn-item', createClientButton: `vn-float-button`, othersButton: 'vn-left-menu li[name="Others"] > a' }, @@ -180,7 +180,7 @@ export default { acceptDeleteButton: '.vn-confirm.shown button[response="accept"]' }, itemsIndex: { - searchIcon: 'vn-item-index vn-searchbar vn-icon[icon="search"]', + searchIcon: 'vn-searchbar vn-icon[icon="search"]', createItemButton: `vn-float-button`, searchResult: 'vn-item-index a.vn-tr', searchResultPreviewButton: 'vn-item-index .buttons > [icon="desktop_windows"]', @@ -221,7 +221,7 @@ export default { moreMenuRegularizeButton: '.vn-drop-down.shown li[name="Regularize stock"]', regularizeQuantityInput: '.vn-dialog.shown tpl-body > div > vn-textfield input', regularizeWarehouseAutocomplete: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.warehouseFk"]', - editButton: 'vn-item-card vn-item-descriptor vn-float-button[icon="edit"]', + editButton: 'vn-item-descriptor vn-float-button[icon="edit"]', regularizeSaveButton: '.vn-dialog.shown tpl-buttons > button', inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', navigateBackToIndex: 'vn-item-descriptor vn-icon[icon="chevron_left"]' @@ -324,20 +324,20 @@ export default { setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button' }, ticketsIndex: { - openAdvancedSearchButton: 'vn-ticket-index vn-searchbar .append vn-icon[icon="arrow_drop_down"]', + openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"] input', newTicketButton: 'vn-ticket-index > a', searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)', - searchTicketInput: `vn-ticket-index vn-textfield input`, - searchWeeklyTicketInput: `vn-ticket-weekly-index vn-textfield input`, - searchWeeklyClearInput: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]', + searchTicketInput: `vn-searchbar input`, + searchWeeklyTicketInput: `vn-searchbar input`, + searchWeeklyClearInput: 'vn-searchbar vn-icon[icon=clear]', advancedSearchButton: 'vn-ticket-search-panel button[type=submit]', - searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]', - searchWeeklyButton: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon="search"]', + searchButton: 'vn-searchbar vn-icon[icon="search"]', + searchWeeklyButton: 'vn-searchbar vn-icon[icon="search"]', moreMenu: 'vn-ticket-index vn-icon-menu[icon=more_vert]', - moreMenuWeeklyTickets: '.vn-drop-down.shown li:nth-child(2)', + menuWeeklyTickets: 'vn-left-menu [ui-sref="ticket.weekly.index"]', sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[ng-model="weekly.weekDay"] input', weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr', firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', @@ -472,7 +472,7 @@ export default { zoneAutocomplete: 'vn-autocomplete[ng-model="$ctrl.zoneId"]', nextStepButton: 'vn-step-control .buttons > section:last-child vn-button', finalizeButton: 'vn-step-control .buttons > section:last-child button[type=submit]', - stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > form > vn-card > vn-horizontal > table > tfoot > tr > td:nth-child(4)', + stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two vn-tfoot > vn-tr > :nth-child(6)', chargesReasonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.ticket.option"]', }, ticketComponents: { @@ -516,9 +516,9 @@ export default { saveStateButton: `button[type=submit]` }, claimsIndex: { - searchClaimInput: `vn-claim-index vn-textfield input`, + searchClaimInput: `vn-searchbar input`, searchResult: 'vn-claim-index vn-card > vn-table > div > vn-tbody > a', - searchButton: 'vn-claim-index vn-searchbar vn-icon[icon="search"]' + searchButton: 'vn-searchbar vn-icon[icon="search"]' }, claimDescriptor: { moreMenu: 'vn-claim-descriptor vn-icon-menu[icon=more_vert]', @@ -584,7 +584,7 @@ export default { searchResultDate: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)', searchResultAddress: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)', searchOrderInput: `vn-order-index vn-textfield input`, - searchButton: 'vn-order-index vn-searchbar vn-icon[icon="search"]', + searchButton: 'vn-searchbar vn-icon[icon="search"]', createOrderButton: `vn-float-button`, }, orderDescriptor: { @@ -679,34 +679,35 @@ export default { 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', confirmButton: '.vn-dialog.shown tpl-buttons > button', - firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > span', - firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > span', - firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > span', - firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > span', - firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > span', - firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > span', - firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > span', - secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > span', - secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > span', - secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > span', - secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > span', - secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > span', - secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > span', - secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > span', - thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > span', - thirdEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > span', - thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > span', - thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > span', - thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > span', - thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > span', - thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > span', - fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > span', - fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > span', - fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > span', - fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > span', - fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > span', - fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > span', - fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > span', + firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > div', + firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > vn-chip > div', + firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > vn-chip > div', + firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > vn-chip > div', + firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > vn-chip > div', + firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > vn-chip > div', + firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > vn-chip > div', + secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > vn-chip > div', + secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > vn-chip > div', + secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > vn-chip > div', + secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > vn-chip > div', + secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > vn-chip > div', + secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > vn-chip > div', + secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > vn-chip > div', + thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > div', + 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', + thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > vn-chip > div', + thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > vn-chip > div', + thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > vn-chip > div', + thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > vn-chip > div', + thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > vn-chip > div', + fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > vn-chip > div', + fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > vn-chip > div', + fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > vn-chip > div', + fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > vn-chip > div', + fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > vn-chip > div', + fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > vn-chip > div', + fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > vn-chip > div', 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)', @@ -717,11 +718,12 @@ export default { 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]', secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number', - navigateBackToIndex: 'vn-worker-descriptor vn-icon[icon="chevron_left"]' + navigateBackToIndex: 'vn-worker-descriptor vn-icon[icon="chevron_left"]', + acceptDeleteDialog: '.vn-confirm.shown button[response="accept"]' }, invoiceOutIndex: { - searchInvoiceOutInput: `vn-invoice-out-index vn-textfield input`, - searchButton: 'vn-invoice-out-index vn-searchbar vn-icon[icon="search"]', + searchInvoiceOutInput: `vn-searchbar input`, + searchButton: 'vn-searchbar vn-icon[icon="search"]', searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr', }, invoiceOutDescriptor: { diff --git a/e2e/paths/01-login/01_login.spec.js b/e2e/paths/01-login/01_login.spec.js index 03acc98a8..f612ad23c 100644 --- a/e2e/paths/01-login/01_login.spec.js +++ b/e2e/paths/01-login/01_login.spec.js @@ -30,7 +30,7 @@ describe('Login path', () => { it('should log in', async() => { const url = await nightmare .doLogin('employee', null) - .wait('#logout') + .wait('#user') .parsedUrl(); expect(url.hash).toEqual('#!/'); diff --git a/e2e/paths/03-worker-module/02_time_control.spec.js b/e2e/paths/03-worker-module/02_time_control.spec.js index ce7316773..706fc2a74 100644 --- a/e2e/paths/03-worker-module/02_time_control.spec.js +++ b/e2e/paths/03-worker-module/02_time_control.spec.js @@ -35,8 +35,30 @@ describe('Worker time control path', () => { expect(result).toEqual(scanTime); }); - it(`should scan out Hank Pym and forget to scan in from the break`, async() => { - const scanTime = '15:00'; + it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => { + const scanTime = '18:00'; + const result = await nightmare + .waitToClick(selectors.workerTimeControl.mondayAddTimeButton) + .pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) + .waitToClick(selectors.workerTimeControl.confirmButton) + .waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); + + expect(result).toEqual(scanTime); + }); + + it(`should delete the wrong entry for Hank Pym`, async() => { + const wrongScanTime = '18:00'; + const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime) + .waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete) + .waitToClick(selectors.workerTimeControl.acceptDeleteDialog) + .waitForLastSnackbar(); + + expect(result).toEqual('Entry removed'); + }); + + it(`should scan out Hank Pym to leave early`, async() => { + const scanTime = '14:00'; const result = await nightmare .waitToClick(selectors.workerTimeControl.mondayAddTimeButton) .pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) @@ -54,7 +76,7 @@ describe('Worker time control path', () => { .waitToClick(selectors.workerTimeControl.confirmButton) .waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText'); - expect(result).toEqual('15:00'); + expect(result).toEqual('14:00'); }); it(`should the third entry be the scan in from break`, async() => { @@ -67,9 +89,10 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 hours`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '07:00 h.') .waitToGetProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText'); - expect(result).toEqual('08:00 h.'); + expect(result).toEqual('07:00 h.'); }); }); @@ -120,6 +143,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 happy hours`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.tuesdayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -173,6 +197,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 cheerfull hours`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.wednesdayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -226,6 +251,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 joyfull hours`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.thursdayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -279,6 +305,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 hours with a smile on his face`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.fridayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -319,6 +346,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 hours with all his will`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.saturdayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -350,6 +378,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym worked 8 glad hours`, async() => { const result = await nightmare + .waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '08:00 h.') .waitToGetProperty(selectors.workerTimeControl.sundayWorkedHours, 'innerText'); expect(result).toEqual('08:00 h.'); @@ -387,10 +416,10 @@ describe('Worker time control path', () => { it('should Hank Pym check his hours are alright', async() => { const wholeWeekHours = await nightmare - .waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '56:00 h.') + .waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '55:00 h.') .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); - expect(wholeWeekHours).toEqual('56:00 h.'); + expect(wholeWeekHours).toEqual('55:00 h.'); }); }); }); diff --git a/e2e/paths/04-item-module/01_summary.spec.js b/e2e/paths/04-item-module/01_summary.spec.js index bd06ebef4..8f493bfac 100644 --- a/e2e/paths/04-item-module/01_summary.spec.js +++ b/e2e/paths/04-item-module/01_summary.spec.js @@ -80,7 +80,7 @@ describe('Item summary path', () => { it('should search for other item', async() => { const result = await nightmare - .clearInput('vn-item-index vn-searchbar input') + .clearInput('vn-searchbar input') .waitToClick(selectors.itemsIndex.searchButton) .write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat fist 15cm') .waitToClick(selectors.itemsIndex.searchButton) diff --git a/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js index 8e4645051..ec9b16fa4 100644 --- a/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js @@ -7,7 +7,7 @@ describe('Ticket expeditions and log path', () => { beforeAll(() => { return nightmare .loginAndModule('production', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.expedition'); }); diff --git a/e2e/paths/05-ticket-module/04_packages.spec.js b/e2e/paths/05-ticket-module/04_packages.spec.js index 30324aec2..b51bb8b95 100644 --- a/e2e/paths/05-ticket-module/04_packages.spec.js +++ b/e2e/paths/05-ticket-module/04_packages.spec.js @@ -7,7 +7,7 @@ describe('Ticket Create packages path', () => { beforeAll(() => { return nightmare .loginAndModule('employee', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.package'); }); diff --git a/e2e/paths/05-ticket-module/05_tracking_state.spec.js b/e2e/paths/05-ticket-module/05_tracking_state.spec.js index 5797b6798..7c319f1c9 100644 --- a/e2e/paths/05-ticket-module/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket-module/05_tracking_state.spec.js @@ -8,7 +8,7 @@ describe('Ticket Create new tracking state path', () => { beforeAll(() => { return nightmare .loginAndModule('production', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.tracking.index'); }); @@ -44,7 +44,7 @@ describe('Ticket Create new tracking state path', () => { beforeAll(() => { return nightmare .loginAndModule('salesPerson', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.tracking.index'); }); diff --git a/e2e/paths/05-ticket-module/08_components.spec.js b/e2e/paths/05-ticket-module/08_components.spec.js index 4603650ac..501c2eaad 100644 --- a/e2e/paths/05-ticket-module/08_components.spec.js +++ b/e2e/paths/05-ticket-module/08_components.spec.js @@ -7,7 +7,7 @@ describe('Ticket List components path', () => { beforeAll(() => { return nightmare .loginAndModule('employee', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.components'); }); diff --git a/e2e/paths/05-ticket-module/09_weekly.spec.js b/e2e/paths/05-ticket-module/09_weekly.spec.js index a7a301d79..ad8a8020c 100644 --- a/e2e/paths/05-ticket-module/09_weekly.spec.js +++ b/e2e/paths/05-ticket-module/09_weekly.spec.js @@ -11,8 +11,7 @@ describe('Ticket descriptor path', () => { it('should count the amount of tickets in the turns section', async() => { const result = await nightmare - .waitToClick(selectors.ticketsIndex.moreMenu) - .waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets) + .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .wait(selectors.ticketsIndex.weeklyTicket) .countElement(selectors.ticketsIndex.weeklyTicket); @@ -72,8 +71,7 @@ describe('Ticket descriptor path', () => { it('should confirm the ticket 11 was added on thursday', async() => { const result = await nightmare - .waitToClick(selectors.ticketsIndex.moreMenu) - .waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets) + .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Thursday'); @@ -132,8 +130,7 @@ describe('Ticket descriptor path', () => { it('should confirm the ticket 11 was added on saturday', async() => { const result = await nightmare - .waitToClick(selectors.ticketsIndex.moreMenu) - .waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets) + .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Saturday'); @@ -160,7 +157,7 @@ describe('Ticket descriptor path', () => { it('should confirm the sixth weekly ticket was deleted', async() => { const result = await nightmare - .waitToClick('vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]') + .waitToClick('vn-searchbar vn-icon[icon=clear]') .waitToClick(selectors.ticketsIndex.searchWeeklyButton) .waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5) .countElement(selectors.ticketsIndex.searchWeeklyResult); diff --git a/e2e/paths/05-ticket-module/10_request.spec.js b/e2e/paths/05-ticket-module/10_request.spec.js index 0a31cb75a..44dc3e1af 100644 --- a/e2e/paths/05-ticket-module/10_request.spec.js +++ b/e2e/paths/05-ticket-module/10_request.spec.js @@ -7,7 +7,7 @@ describe('Ticket purchase request path', () => { beforeAll(() => { nightmare .loginAndModule('salesPerson', 'ticket') - .accessToSearchResult('id:16') + .accessToSearchResult('16') .accessToSection('ticket.card.request.index'); }); diff --git a/e2e/paths/05-ticket-module/11_diary.spec.js b/e2e/paths/05-ticket-module/11_diary.spec.js index aeec780e7..c64c0ba7b 100644 --- a/e2e/paths/05-ticket-module/11_diary.spec.js +++ b/e2e/paths/05-ticket-module/11_diary.spec.js @@ -1,5 +1,4 @@ import selectors from '../../helpers/selectors.js'; -import config from '../../helpers/config.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket diary path', () => { @@ -31,12 +30,9 @@ describe('Ticket diary path', () => { }); it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => { - const itemId = 2; const url = await nightmare .waitToClick(selectors.ticketSummary.firstSaleItemId) .waitToClick(selectors.ticketSummary.popoverDiaryButton) - .waitForLogin('employee') - .goto(`${config.url}#!/item/${itemId}/diary?warehouseFk=1&ticketFk=1`) .parsedUrl(); expect(url.hash).toContain('/diary'); diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index 81bb75bdb..9442f1be0 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -9,8 +9,7 @@ describe('Ticket descriptor path', () => { .loginAndModule('salesperson', 'ticket'); }); - // Excluded waiting for #1874 - xdescribe('Delete ticket', () => { + describe('Delete ticket', () => { it('should search for an specific ticket', async() => { const result = await nightmare .write(selectors.ticketsIndex.searchTicketInput, 18) diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket-module/13_services.spec.js index 775357bda..01da91f1b 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket-module/13_services.spec.js @@ -21,7 +21,7 @@ describe('Ticket services path', () => { .isDisabled(selectors.ticketService.firstAddDescriptionButton); expect(result).toBeTruthy(); - }); + }, 100000); it('should receive an error if you attempt to save a service without access rights', async() => { const result = await nightmare diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 9808fd667..e2c9b7ad4 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -208,11 +208,9 @@ export default class Autocomplete extends Field { onContainerKeyDown(event) { if (event.defaultPrevented) return; - switch (event.key) { case 'ArrowUp': case 'ArrowDown': - case 'Enter': this.showDropDown(); break; default: diff --git a/front/core/components/button-menu/index.js b/front/core/components/button-menu/index.js index 946e1fd7f..c19962b08 100644 --- a/front/core/components/button-menu/index.js +++ b/front/core/components/button-menu/index.js @@ -7,7 +7,7 @@ export default class ButtonMenu extends Button { constructor($element, $scope, $transclude) { super($element, $scope); this.$transclude = $transclude; - $element.on('click', e => this.onClick(e)); + $element.on('click', e => this.onButtonClick(e)); } get model() { @@ -41,8 +41,7 @@ export default class ButtonMenu extends Button { Object.assign(this.$.dropDown, props); } - onClick(event) { - if (this.disabled) return; + onButtonClick(event) { if (event.defaultPrevented) return; this.emit('open'); this.showDropDown(); diff --git a/front/core/components/button-menu/index.spec.js b/front/core/components/button-menu/index.spec.js index 1e8c048ff..87f677001 100644 --- a/front/core/components/button-menu/index.spec.js +++ b/front/core/components/button-menu/index.spec.js @@ -14,7 +14,7 @@ describe('Component vnButtonMenu', () => { $element.remove(); }); - describe('onClick(event)', () => { + describe('onButtonClick(event)', () => { it(`should emit the open event`, () => { spyOn(controller, 'emit'); @@ -23,7 +23,7 @@ describe('Component vnButtonMenu', () => { bubbles: true, cancelable: true }); - controller.onClick(event); + controller.onButtonClick(event); expect(controller.emit).toHaveBeenCalledWith('open'); }); diff --git a/front/core/components/button/style.scss b/front/core/components/button/style.scss index 74dcbcf9b..032c88cbb 100644 --- a/front/core/components/button/style.scss +++ b/front/core/components/button/style.scss @@ -39,19 +39,19 @@ } &.colored { color: white; - background-color: $color-main; + background-color: $color-button; box-shadow: 0 .15em .15em 0 rgba(0, 0, 0, .3); transition: background 200ms ease-in-out; &:not(.disabled) { &:hover, &:focus { - background-color: lighten($color-main, 10%); + background-color: lighten($color-button, 10%); } } } &.flat { - color: $color-main; + color: $color-button; background-color: transparent; box-shadow: none; transition: background 200ms ease-in-out; diff --git a/front/core/components/check/style.scss b/front/core/components/check/style.scss index 31715a2cd..b84b61ce5 100644 --- a/front/core/components/check/style.scss +++ b/front/core/components/check/style.scss @@ -19,7 +19,7 @@ } &.checked > .btn { border-color: transparent; - background-color: $color-main; + background-color: $color-button; & > .mark { top: 0; diff --git a/front/core/components/chip/style.scss b/front/core/components/chip/style.scss index 4476d089e..5840ecdf1 100644 --- a/front/core/components/chip/style.scss +++ b/front/core/components/chip/style.scss @@ -24,13 +24,12 @@ vn-chip { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; - line-height: 2em; & > vn-avatar { margin-left: -0.7em; margin-right: .3em; vertical-align: middle; - height: 1.9em; + height: 2em; width: 2em; } } diff --git a/front/core/components/date-picker/index.js b/front/core/components/date-picker/index.js index 17ce19406..24f8cf90f 100644 --- a/front/core/components/date-picker/index.js +++ b/front/core/components/date-picker/index.js @@ -14,7 +14,9 @@ class DatePicker extends Field { let value = this.input.value; if (value) { - date = new Date(value); + let ymd = value.split('-') + .map(e => parseInt(e)); + date = new Date(ymd[0], ymd[1] - 1, ymd[2]); if (this.field) { let orgDate = this.field instanceof Date diff --git a/front/core/components/date-picker/index.spec.js b/front/core/components/date-picker/index.spec.js index 411a92105..2dd419e07 100644 --- a/front/core/components/date-picker/index.spec.js +++ b/front/core/components/date-picker/index.spec.js @@ -3,6 +3,10 @@ describe('Component vnDatePicker', () => { let $element; let $ctrl; + let today; + today = new Date(); + today.setHours(0, 0, 0, 0); + beforeEach(ngModule('vnCore')); beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { @@ -18,14 +22,19 @@ describe('Component vnDatePicker', () => { describe('field() setter', () => { it(`should display the formated the date`, () => { - let today; - today = new Date(); - today.setHours(0, 0, 0, 0); - $ctrl.field = today; let displayed = $filter('date')(today, 'yyyy-MM-dd'); expect($ctrl.value).toEqual(displayed); }); }); + + describe('onValueUpdate()', () => { + it(`should change the picker value to selected date`, () => { + $ctrl.value = $filter('date')(today, 'yyyy-MM-dd'); + $ctrl.input.dispatchEvent(new Event('change')); + + expect($ctrl.field).toEqual(today); + }); + }); }); diff --git a/front/core/components/dialog/index.js b/front/core/components/dialog/index.js index 0891542a2..7a7cb5f9f 100644 --- a/front/core/components/dialog/index.js +++ b/front/core/components/dialog/index.js @@ -29,6 +29,10 @@ export default class Dialog extends Popup { * @return {Promise} A promise that will be resolved with response when dialog is closed */ show(data, responseHandler) { + if (this.shown) + return this.$q.reject(new Error('Dialog already shown')); + super.show(); + if (typeof data == 'function') { responseHandler = data; data = null; @@ -36,27 +40,27 @@ export default class Dialog extends Popup { this.data = data; this.showHandler = responseHandler; - super.show(); return this.$q(resolve => { this.resolve = resolve; }); } /** - * Hides the dialog. + * Hides the dialog resolving the promise returned by show(). * * @param {String} response The response */ hide(response) { if (!this.shown) return; - this.showHandler = null; super.hide(); + + this.showHandler = null; if (this.resolve) this.resolve(response); } /** - * Calls the response handler. + * Calls the response handlers. * * @param {String} response The response code * @return {Boolean} The response handler return diff --git a/front/core/components/dialog/index.spec.js b/front/core/components/dialog/index.spec.js index a898261fb..8c41bc060 100644 --- a/front/core/components/dialog/index.spec.js +++ b/front/core/components/dialog/index.spec.js @@ -28,14 +28,6 @@ describe('Component vnDialog', () => { expect(called).toBeTruthy(); }); - it(`should hide the dialog when response is given`, () => { - controller.show(); - spyOn(controller, 'hide'); - controller.respond('answer'); - - expect(controller.hide).toHaveBeenCalledWith('answer'); - }); - it(`should not hide the dialog when false is returned from response handler`, () => { controller.show(() => false); spyOn(controller, 'hide'); @@ -46,12 +38,13 @@ describe('Component vnDialog', () => { }); describe('hide()', () => { - it(`should do nothing if it's already hidden`, () => { - controller.onResponse = () => {}; - spyOn(controller, 'onResponse'); + it(`should resolve the promise returned by show`, () => { + let resolved = true; + controller.show().then(() => resolved = true); controller.hide(); + $scope.$apply(); - expect(controller.onResponse).not.toHaveBeenCalledWith(); + expect(resolved).toBeTruthy(); }); }); @@ -94,7 +87,7 @@ describe('Component vnDialog', () => { expect(controller.onAccept).toHaveBeenCalledWith({$response: 'accept'}); }); - it(`should resolve the promise returned by show() with response when hidden`, () => { + it(`should resolve the promise returned by show() with response`, () => { let response; controller.show().then(res => response = res); controller.respond('response'); diff --git a/front/core/components/dialog/style.scss b/front/core/components/dialog/style.scss index 9461a0063..2f3d9a028 100644 --- a/front/core/components/dialog/style.scss +++ b/front/core/components/dialog/style.scss @@ -36,7 +36,7 @@ background-color: transparent; border: none; border-radius: .1em; - color: $color-main; + color: $color-button; font-family: vn-font-bold; padding: .7em; margin: -0.7em; diff --git a/front/core/components/drop-down/index.js b/front/core/components/drop-down/index.js index 163553aeb..9f2dfe424 100644 --- a/front/core/components/drop-down/index.js +++ b/front/core/components/drop-down/index.js @@ -5,6 +5,7 @@ import template from './index.html'; import ArrayModel from '../array-model/array-model'; import CrudModel from '../crud-model/crud-model'; import {mergeWhere} from 'vn-loopback/util/filter'; +import focus from '../../lib/focus'; /** * @event select Thrown when model item is selected @@ -86,9 +87,11 @@ export default class DropDown extends Popover { * @param {String} search The initial search term or %null */ show(parent, search) { - this._activeOption = -1; + if (this.shown) return; super.show(parent); + this._activeOption = -1; + this.list = this.popup.querySelector('.list'); this.ul = this.popup.querySelector('ul'); @@ -102,21 +105,25 @@ export default class DropDown extends Popover { this.search = search; this.buildList(); - let input = this.popup.querySelector('input'); - setTimeout(() => input.focus()); + focus(this.popup.querySelector('input')); } - onClose() { + hide() { + if (!this.shown) return; + super.hide(); + this.document.removeEventListener('keydown', this.docKeyDownHandler); this.docKeyDownHandler = null; this.list.removeEventListener('scroll', this.listScrollHandler); this.listScrollHandler = null; + } + onClose() { + this.destroyList(); this.list = null; this.ul = null; - this.destroyList(); super.onClose(); } @@ -387,7 +394,7 @@ export default class DropDown extends Popover { let filter = { order, - limit: this.limit || 8 + limit: this.limit || 30 }; if (model instanceof CrudModel) { diff --git a/front/core/components/field/index.html b/front/core/components/field/index.html index 8d12ddd77..d614d157f 100644 --- a/front/core/components/field/index.html +++ b/front/core/components/field/index.html @@ -28,8 +28,7 @@ ng-transclude="append" class="append"> -