diff --git a/db/install/boot.sh b/db/install/boot.sh index ebfdae87f..eb91ed8ae 100755 --- a/db/install/boot.sh +++ b/db/install/boot.sh @@ -13,6 +13,12 @@ for file in changes/*.sql; do mysql -u root -fc < $file done +# Import changes for local db +for file in changes/only-local/*.sql; do + echo "[INFO] -> Imported ./$file" + mysql -u root -fc < $file +done + # Import fixtures echo "[INFO] -> Imported ./dump/dumpedFixtures.sql" mysql -u root -f < ./dump/dumpedFixtures.sql diff --git a/db/install/changes/00-routeLog.sql b/db/install/changes/00-routeLog.sql new file mode 100644 index 000000000..b6430fcb6 --- /dev/null +++ b/db/install/changes/00-routeLog.sql @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS `vn`.`routeLog`; + +CREATE TABLE `vn`.`routeLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(10) unsigned NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Rutas` (`Id_Ruta`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + diff --git a/db/install/changes/00-smsConfig.sql b/db/install/changes/00-smsConfig.sql new file mode 100644 index 000000000..7d2c6e1b7 --- /dev/null +++ b/db/install/changes/00-smsConfig.sql @@ -0,0 +1 @@ +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `user`, `password`, `title`) VALUES ('1', 'https://websms.xtratelecom.es/api_php/server.wsdl', 'FERRERTORIBIO', 'HERMANOS', 'Verdnatura'); diff --git a/db/install/changes/01-ACL.sql b/db/install/changes/only-local/00-ACL.sql similarity index 100% rename from db/install/changes/01-ACL.sql rename to db/install/changes/only-local/00-ACL.sql diff --git a/db/install/changes/absenceType.sql b/db/install/changes/only-local/00-absenceType.sql similarity index 100% rename from db/install/changes/absenceType.sql rename to db/install/changes/only-local/00-absenceType.sql diff --git a/db/install/changes/12-department.sql b/db/install/changes/only-local/00-department.sql similarity index 100% rename from db/install/changes/12-department.sql rename to db/install/changes/only-local/00-department.sql diff --git a/db/install/changes/holiday.sql b/db/install/changes/only-local/00-holiday.sql similarity index 100% rename from db/install/changes/holiday.sql rename to db/install/changes/only-local/00-holiday.sql diff --git a/db/install/changes/holidayDetail.sql b/db/install/changes/only-local/00-holidayDetail.sql similarity index 100% rename from db/install/changes/holidayDetail.sql rename to db/install/changes/only-local/00-holidayDetail.sql diff --git a/db/install/changes/holidayType.sql b/db/install/changes/only-local/00-holidayType.sql similarity index 100% rename from db/install/changes/holidayType.sql rename to db/install/changes/only-local/00-holidayType.sql diff --git a/db/install/changes/17-mailUser.sql b/db/install/changes/only-local/00-mailUser.sql similarity index 100% rename from db/install/changes/17-mailUser.sql rename to db/install/changes/only-local/00-mailUser.sql diff --git a/db/install/changes/13-nodeAdd.sql b/db/install/changes/only-local/00-nodeAdd.sql similarity index 100% rename from db/install/changes/13-nodeAdd.sql rename to db/install/changes/only-local/00-nodeAdd.sql diff --git a/db/install/changes/14-nodeRecalc.sql b/db/install/changes/only-local/00-nodeRecalc.sql similarity index 100% rename from db/install/changes/14-nodeRecalc.sql rename to db/install/changes/only-local/00-nodeRecalc.sql diff --git a/db/install/changes/11-ticketCalculateSale.sql b/db/install/changes/only-local/00-ticketCalculateSale.sql similarity index 100% rename from db/install/changes/11-ticketCalculateSale.sql rename to db/install/changes/only-local/00-ticketCalculateSale.sql diff --git a/db/install/changes/12-ticketGetProblems.sql b/db/install/changes/only-local/00-ticketGetProblems.sql similarity index 100% rename from db/install/changes/12-ticketGetProblems.sql rename to db/install/changes/only-local/00-ticketGetProblems.sql diff --git a/db/install/changes/ticketGetVisibleAvailable.sql b/db/install/changes/only-local/00-ticketGetVisibleAvailable.sql similarity index 100% rename from db/install/changes/ticketGetVisibleAvailable.sql rename to db/install/changes/only-local/00-ticketGetVisibleAvailable.sql diff --git a/db/install/changes/15-ticketLog.sql b/db/install/changes/only-local/00-ticketLog.sql similarity index 100% rename from db/install/changes/15-ticketLog.sql rename to db/install/changes/only-local/00-ticketLog.sql diff --git a/db/install/changes/workCenterHoliday.sql b/db/install/changes/only-local/00-workCenterHoliday.sql similarity index 100% rename from db/install/changes/workCenterHoliday.sql rename to db/install/changes/only-local/00-workCenterHoliday.sql diff --git a/db/install/changes/workerCalendar.sql b/db/install/changes/only-local/00-workerCalendar.sql similarity index 100% rename from db/install/changes/workerCalendar.sql rename to db/install/changes/only-local/00-workerCalendar.sql diff --git a/db/install/changes/workerLabour.sql b/db/install/changes/only-local/00-workerLabour.sql similarity index 100% rename from db/install/changes/workerLabour.sql rename to db/install/changes/only-local/00-workerLabour.sql diff --git a/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql index 8dae419b6..47328d3da 100644 --- a/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -574,16 +574,16 @@ INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) (05080000, 'Coral y materiales similares' , 2, 2), (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1); -INSERT INTO `vn`.`item`(`id`, `name`,`typeFk`,`size`,`inkFk`,`category`,`stems`,`originFk`,`description`,`producerFk`,`intrastatFk`,`isOnOffer`,`expenceFk`,`isBargain`,`comment`,`relevancy`,`image`,`taxClassFk`,`longName`,`subName`,`tag5`,`value5`,`tag6`,`value6`,`tag7`,`value7`,`tag8`,`value8`) +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `taxClassFk`, `subName`) VALUES - (1 , 'Object1 Gem1 5', 2, 70, 'AMA', 'EXT', 1 , 1, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 66540, 1, 'Object1 Gem1 5', NULL, 'Medida', '70', 'Color', 'Amarillo' , 'Categoria', 'EXT', 'Tallos', '1'), - (2 , 'Object2 Gem2 3', 2, 70, 'AZL', 'EXT', 1 , 2, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 65540, 1, 'Object2 Gem2 3', NULL, 'Medida', '70', 'Color', 'Azul' , 'Categoria', 'EXT', 'Tallos', '1'), - (3 , 'Object3 Armor 3', 1, 60, 'AMR', 'EXT', 1 , 3, 'Rhodeys armor', 1, 05080000, 0, 4751000000, 0, NULL, 0, 61692, 1, 'Object3 Armor 3', NULL, 'Medida', '60', 'Color', 'Rosa/Amarillo', 'Categoria', 'EXT', 'Tallos', '1'), - (4 , 'Object4 Armor2 2', 1, 60, 'AMR', 'EXT', 1 , 1, 'Iron Mans first armor', 1, 05080000, 1, 4751000000, 0, NULL, 0, 66090, 2, 'Object4 Armor2 2', NULL, 'Medida', '60', 'Color', 'Rosa/Amarillo', 'Categoria', 'EXT', 'Tallos', '1'), - (5 , 'Object5 Weapon 50', 3, 30, 'GRE', 'EXT', 1 , 2, 'Thors hammer!', 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, 'Object5 Weapon 50', NULL, 'Medida', '30', 'Color', 'Azul' , 'Categoria', 'EXT', 'Tallos', '1'), - (6 , 'Broken Box', 5, 30, 'GRE', 'EXT', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, 'Broken Box', NULL, 'Medida', '30', 'Color', 'Gris' , NULL, NULL, NULL, NULL), - (7 , 'Legendary Box', 5, 90, 'AZL', 'EXT', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, 'Legendary Box', NULL, 'Medida', '90', 'Color', 'Gris' , NULL, NULL, NULL, NULL), - (71, 'ShippingCost', 4, NULL, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, 'ShippingCost', NULL, NULL , NULL, NULL , NULL , NULL, NULL, NULL, NULL); + (1 , 2, 70, 'AMA', 1 , 1, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 66540, 1, NULL), + (2 , 2, 70, 'AZL', 1 , 2, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 65540, 1, NULL), + (3 , 1, 60, 'AMR', 1 , 3, 'Rhodeys armor', 1, 05080000, 0, 4751000000, 0, NULL, 0, 61692, 1, NULL), + (4 , 1, 60, 'AMR', 1 , 1, 'Iron Mans first armor', 1, 05080000, 1, 4751000000, 0, NULL, 0, 66090, 2, NULL), + (5 , 3, 30, 'GRE', 1 , 2, 'Thors hammer!', 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (6 , 5, 30, 'GRE', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (7 , 5, 90, 'AZL', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, NULL); INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`) VALUES @@ -608,30 +608,30 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) VALUES - (1, 1, 1, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (2, 2, 1, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 1, 1, 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (4, 4, 1, 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (5, 1, 2, 'Object1 Gem1 5', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), - (6, 1, 3, 'Object1 Gem1 5', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)), - (7, 2, 11, 'Object2 Gem2 3', 15, 1.46, 0, 0, 0, CURDATE()), - (8, 4, 11, 'Object4 Armor2 2', 10, 3.05, 0, 0, 0, CURDATE()), - (9, 1, 16, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, CURDATE()), - (10, 2, 16, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, CURDATE()), - (11, 1, 16, 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, CURDATE()), - (12, 4, 16, 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, CURDATE()), - (13, 2, 8, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (14, 1, 8, 'Object1 Gem1 5', 10, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (15, 1, 19, 'Object1 Gem1 5', 10, 1.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (16, 2, 20, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (17, 2, 22, 'Object2 Gem2 3', 30, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (18, 4, 22, 'Object4 Armor2 2', 20, 3.00, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (19, 1, 4, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY)), - (20, 1, 5, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)), - (21, 1, 6, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)), - (22, 1, 7, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)), - (23, 1, 9, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (24, 1, 10, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)); + (1, 1, 1, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (2, 2, 1, 'Melee weapon combat first 15cm', 10, 1.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (3, 1, 1, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (5, 1, 2, 'Ranged weapon longbow 2m', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), + (6, 1, 3, 'Ranged weapon longbow 2m', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)), + (7, 2, 11, 'Melee weapon combat first 15cm', 15, 1.46, 0, 0, 0, CURDATE()), + (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.05, 0, 0, 0, CURDATE()), + (9, 1, 16, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, CURDATE()), + (10, 2, 16, 'Melee weapon combat first 15cm', 10, 1.07, 0, 0, 0, CURDATE()), + (11, 1, 16, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, CURDATE()), + (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, CURDATE()), + (13, 2, 8, 'Melee weapon combat first 15cm', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (14, 1, 8, 'Ranged weapon longbow 2m', 10, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (15, 1, 19, 'Ranged weapon longbow 2m', 10, 1.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (16, 2, 20, 'Melee weapon combat first 15cm', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (17, 2, 22, 'Melee weapon combat first 15cm', 30, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 3.00, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (19, 1, 4, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY)), + (20, 1, 5, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)), + (21, 1, 6, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)), + (22, 1, 7, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)), + (23, 1, 9, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (24, 1, 10, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)); INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`) VALUES @@ -672,7 +672,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (7, 28, 5.6), (7, 29, -4.6), (7, 39, 0.01), - (8, 15, 0.0426), + (8, 15, 0.039), (8, 21, -0.003), (8, 28, 20.72), (8, 29, -19.72), @@ -803,41 +803,56 @@ INSERT INTO `vn`.`itemBotanical`(`itemFk`, `botanical`, `genusFk`, `specieFk`) INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) VALUES - (1 , 1, 56, 'Object1', 1), - (2 , 1, 58, 'Gem1' , 2), - (3 , 1, 27, '5' , 3), - (4 , 1, 36, 'Marvel1', 4), - (5 , 1, 1 , 'Yellow' , 5), - (6 , 1, 67 , 'A1' , 6), - (7 , 1, 23, '0' , 7), - (8 , 2, 56, 'Object2', 1), - (9 , 2, 58, 'Gem2' , 2), - (10, 2, 27 , '3' , 3), - (11, 2, 36, 'Marvel2', 4), - (12, 2, 1 , 'Red' , 5), - (13, 2, 67, 'A1' , 6), - (14, 2, 23, '0' , 7), - (15, 3, 56, 'Object3', 1), - (16, 3, 58, 'Armor' , 2), - (17, 3, 4, '3' , 3), - (18, 3, 36, 'Stark' , 4), - (19, 3, 1 , 'Green' , 5), - (20, 3, 67, 'EXT' , 6), - (21, 3, 23, '0' , 7), - (22, 4, 56, 'Object4', 1), - (23, 4, 58, 'Armor2' , 2), - (24, 4, 4, '2' , 3), - (25, 4, 36, 'Stark' , 4), - (26, 4, 1 , 'Blue' , 5), - (27, 4, 67, 'EXT' , 6), - (28, 4, 23, '1' , 7), - (29, 5, 56, 'Object5', 1), - (30, 5, 58, 'Weapon' , 2), - (31, 5, 27 , '50' , 3), - (32, 5, 36, 'Thor' , 4), - (33, 5, 1 , 'Grey' , 5), - (34, 5, 67, 'EXT' , 6), - (35, 5, 23, '1' , 7); + (1 , 1, 56, 'Ranged weapon', 1), + (2 , 1, 58, 'longbow', 2), + (3 , 1, 27, '2m', 3), + (4 , 1, 36, 'Stark Industries', 4), + (5 , 1, 1, 'Brown', 5), + (6 , 1, 67, 'precission', 6), + (7 , 1, 23, '1', 7), + (8 , 2, 56, 'Melee weapon', 1), + (9 , 2, 58, 'combat first', 2), + (10, 2, 27, '15cm', 3), + (11, 2, 36, 'Stark Industries', 4), + (12, 2, 1, 'Silver', 5), + (13, 2, 67, 'concussion', 6), + (14, 2, 23, '1', 7), + (15, 3, 56, 'Ranged weapon', 1), + (16, 3, 58, 'sniper rifle', 2), + (17, 3, 4, '300mm', 3), + (18, 3, 36, 'Stark Industries', 4), + (19, 3, 1, 'Green', 5), + (20, 3, 67, 'precission', 6), + (21, 3, 23, '1', 7), + (22, 4, 56, 'Melee weapon', 1), + (23, 4, 58, 'heavy shield', 2), + (24, 4, 4, '1x0.5m', 3), + (25, 4, 36, 'Stark Industries', 4), + (26, 4, 1, 'Black', 5), + (27, 4, 67, 'containtment', 6), + (28, 4, 23, '1', 7), + (29, 5, 56, 'Ranged weapon', 1), + (30, 5, 58, 'pistol', 2), + (31, 5, 27, '9mm', 3), + (32, 5, 36, 'Stark Industries', 4), + (33, 5, 1, 'Silver', 5), + (34, 5, 67, 'rapid fire', 6), + (35, 5, 23, '1', 7), + (36, 6, 56, 'Container', 1), + (37, 6, 58, 'ammo box', 2), + (38, 6, 27, '1m', 3), + (39, 6, 36, 'Stark Industries', 4), + (40, 6, 1, 'Green', 5), + (41, 6, 67, 'supply', 6), + (42, 6, 23, '1', 7), + (43, 7, 56, 'Container', 1), + (44, 7, 58, 'medical box', 2), + (45, 7, 27, '1m', 3), + (46, 7, 36, 'Stark Industries', 4), + (47, 7, 1, 'White', 5), + (48, 7, 67, 'supply', 6), + (49, 7, 23, '1', 7), + (50, 71, 92, 'Shipping cost', 2); INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) VALUES @@ -1182,10 +1197,10 @@ INSERT INTO `vn2008`.`workerTeam`(`id`, `team`, `user`) INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) VALUES - (1, 'Object1 Gem1 5', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (2, 'Object2 Gem2 3', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 'Object4 Armor2 2', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (4, 'Object2 Gem2 3', 18, 35, 15, 2, 1.30, NULL, NULL, 11, CURDATE()); + (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)), + (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (4, 'Melee weapon combat first 15cm', 18, 35, 15, 2, 1.30, NULL, NULL, 11, CURDATE()); INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`) VALUES diff --git a/e2e/paths/item-module/01_summary.spec.js b/e2e/paths/item-module/01_summary.spec.js index 1364aa00a..e4b27d127 100644 --- a/e2e/paths/item-module/01_summary.spec.js +++ b/e2e/paths/item-module/01_summary.spec.js @@ -11,7 +11,7 @@ describe('Item summary path', () => { it('should search for an item', async() => { const result = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object1 Gem1 5') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -21,7 +21,7 @@ describe('Item summary path', () => { it(`should click on the search result summary button to open the item summary popup`, async() => { const isVisibleBefore = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object1 Gem1 5') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon longbow 2m') .isVisible(selectors.itemSummary.basicData); const isVisibleAfter = await nightmare @@ -34,18 +34,18 @@ describe('Item summary path', () => { it(`should check the item summary preview shows fields from basic data`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object1 Gem1 5') + .waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object1 Gem1 5'); + expect(result).toContain('Ranged weapon longbow 2m'); }); it(`should check the item summary preview shows fields from tags`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Yellow') + .waitForTextInElement(selectors.itemSummary.tags, 'Brown') .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Yellow'); + expect(result).toContain('Brown'); }); it(`should check the item summary preview shows fields from niche`, async() => { @@ -84,7 +84,7 @@ describe('Item summary path', () => { const result = await nightmare .clearInput('vn-item-index vn-searchbar input') .waitToClick(selectors.itemsIndex.searchButton) - .write(selectors.itemsIndex.searchItemInput, 'Object2 Gem2 3') + .write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat first 15cm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -94,7 +94,7 @@ describe('Item summary path', () => { it(`should now click on the search result summary button to open the item summary popup`, async() => { const isVisibleBefore = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Melee weapon combat first 15cm') .isVisible(selectors.itemSummary.basicData); const isVisibleAfter = await nightmare @@ -108,18 +108,18 @@ describe('Item summary path', () => { it(`should now check the item summary preview shows fields from basic data`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat first 15cm') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object2 Gem2 3'); + expect(result).toContain('Melee weapon combat first 15cm'); }); it(`should now check the item summary preview shows fields from tags`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Red') + .waitForTextInElement(selectors.itemSummary.tags, 'Silver') .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Red'); + expect(result).toContain('Silver'); }); it(`should now check the item summary preview shows fields from niche`, async() => { @@ -172,17 +172,17 @@ describe('Item summary path', () => { it(`should check the item summary shows fields from basic data section`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat first 15cm') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object2 Gem2 3'); + expect(result).toContain('Melee weapon combat first 15cm'); }); it(`should check the item summary shows fields from tags section`, async() => { const result = await nightmare .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Red'); + expect(result).toContain('Silver'); }); it(`should check the item summary shows fields from niches section`, async() => { diff --git a/e2e/paths/item-module/02_basic_data.spec.js b/e2e/paths/item-module/02_basic_data.spec.js index 15cea353a..257b12e17 100644 --- a/e2e/paths/item-module/02_basic_data.spec.js +++ b/e2e/paths/item-module/02_basic_data.spec.js @@ -7,7 +7,7 @@ describe('Item Edit basic data path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object2 Gem2 3') + .accessToSearchResult('Melee weapon combat first 15cm') .accessToSection('item.card.data'); }); diff --git a/e2e/paths/item-module/03_tax.spec.js b/e2e/paths/item-module/03_tax.spec.js index c1c75f51f..5060a4f91 100644 --- a/e2e/paths/item-module/03_tax.spec.js +++ b/e2e/paths/item-module/03_tax.spec.js @@ -7,7 +7,7 @@ describe('Item edit tax path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.tax'); }); diff --git a/e2e/paths/item-module/04_tags.spec.js b/e2e/paths/item-module/04_tags.spec.js index ab4f833f4..b7412576d 100644 --- a/e2e/paths/item-module/04_tags.spec.js +++ b/e2e/paths/item-module/04_tags.spec.js @@ -7,7 +7,7 @@ describe('Item create tags path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.tags'); }); @@ -55,7 +55,7 @@ describe('Item create tags path', () => { .waitToGetProperty(selectors.itemTags.fifthRelevancyInput, 'value'); expect(tag).toEqual('Color'); - expect(value).toEqual('Yellow'); + expect(value).toEqual('Brown'); expect(relevancy).toEqual('5'); }); @@ -70,7 +70,7 @@ describe('Item create tags path', () => { .waitToGetProperty(selectors.itemTags.sixthRelevancyInput, 'value'); expect(tag).toEqual('Categoria'); - expect(value).toEqual('A1'); + expect(value).toEqual('precission'); expect(relevancy).toEqual('6'); }); }); diff --git a/e2e/paths/item-module/05_niche.spec.js b/e2e/paths/item-module/05_niche.spec.js index 6f0e624db..fcb3c69ef 100644 --- a/e2e/paths/item-module/05_niche.spec.js +++ b/e2e/paths/item-module/05_niche.spec.js @@ -7,7 +7,7 @@ describe('Item create niche path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.niche'); }); diff --git a/e2e/paths/item-module/06_botanical.spec.js b/e2e/paths/item-module/06_botanical.spec.js index c17a7adc7..864705056 100644 --- a/e2e/paths/item-module/06_botanical.spec.js +++ b/e2e/paths/item-module/06_botanical.spec.js @@ -7,7 +7,7 @@ describe('Item Create botanical path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object5 Weapon 50') + .accessToSearchResult('Ranged weapon pistol 9mm') .accessToSection('item.card.botanical'); }); diff --git a/e2e/paths/item-module/07_barcode.spec.js b/e2e/paths/item-module/07_barcode.spec.js index 268b2b7e9..db588cfe6 100644 --- a/e2e/paths/item-module/07_barcode.spec.js +++ b/e2e/paths/item-module/07_barcode.spec.js @@ -7,7 +7,7 @@ describe('Item Create barcodes path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.itemBarcode'); }); diff --git a/e2e/paths/item-module/09_regularize.spec.js b/e2e/paths/item-module/09_regularize.spec.js index 50d5d2f68..23d8904e4 100644 --- a/e2e/paths/item-module/09_regularize.spec.js +++ b/e2e/paths/item-module/09_regularize.spec.js @@ -29,7 +29,7 @@ xdescribe('Item regularize path', () => { it('should search for the item', async() => { const resultCount = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object5 Weapon 50') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -39,7 +39,7 @@ xdescribe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object5 Weapon 50') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); @@ -134,7 +134,7 @@ xdescribe('Item regularize path', () => { it('should search for the item once again', async() => { const resultCount = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object5 Weapon 50') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -144,7 +144,7 @@ xdescribe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object5 Weapon 50') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index 54d63e26a..b261cc612 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -15,7 +15,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSaleColour, 'innerText'); - expect(value).toContain('Yellow'); + expect(value).toContain('Silver'); }); it('should confirm the first ticket sale contains the lenght', async() => { @@ -29,7 +29,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText'); - expect(value).toContain('2.30'); + expect(value).toContain('1.30'); }); it('should confirm the first ticket sale contains the discount', async() => { @@ -43,7 +43,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); - expect(value).toContain('23'); + expect(value).toContain('19.50'); }); it('should navigate to the catalog by pressing the new item button', async() => { diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index 6576893a9..b800f9069 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -15,7 +15,7 @@ describe('Ticket Create packages path', () => { const result = await nightmare .waitToClick(selectors.ticketPackages.firstRemovePackageButton) .waitToClick(selectors.ticketPackages.addPackageButton) - .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box') + .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m') .waitToClick(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -54,7 +54,7 @@ describe('Ticket Create packages path', () => { it(`should create a new package with correct data`, async() => { const result = await nightmare - .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box') + .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m') .waitToClick(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -64,10 +64,10 @@ describe('Ticket Create packages path', () => { it(`should confirm the first select is the expected one`, async() => { const result = await nightmare .reloadSection('ticket.card.package.index') - .waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Legendary Box') + .waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Container medical box 1m') .waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value'); - expect(result).toEqual('7 : Legendary Box'); + expect(result).toEqual('7 : Container medical box 1m'); }); it(`should confirm the first quantity is the expected one`, async() => { diff --git a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js index d467a9f5e..1a51a9a60 100644 --- a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js +++ b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js @@ -73,7 +73,7 @@ describe('Ticket Edit basic data path', () => { .wait(1900) .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); - expect(result).toContain('-€204.25'); + expect(result).toContain('-€202.25'); }); it(`should then click next to move on to step three`, async() => { diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index 0edba8750..f339f6a57 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -311,7 +311,7 @@ xdescribe('Ticket Edit sale path', () => { .wait(selectors.ticketSales.firstSaleText) .waitToGetProperty(selectors.ticketSales.firstSaleText, 'innerText'); - expect(result).toContain(`Object4 Armor2 2`); + expect(result).toContain(`Melee weapon heavy shield 1x0.5m`); }); it('should go back to the original ticket sales section', async() => { diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js new file mode 100644 index 000000000..539b6e546 --- /dev/null +++ b/modules/client/back/methods/sms/send.js @@ -0,0 +1,80 @@ +const soap = require('soap'); +const xmlParser = require('xml2js').parseString; +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('send', { + description: 'Sends SMS to a destination phone', + accepts: [{ + arg: 'recipientFk', + type: 'Integer' + }, + { + arg: 'recipient', + type: 'String', + required: true, + }, + { + arg: 'message', + type: 'String', + required: true, + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/send`, + verb: 'POST' + } + }); + + Self.send = async(ctx, recipientFk, recipient, message) => { + const userId = ctx.req.accessToken.userId; + const smsConfig = await Self.app.models.SmsConfig.findOne(); + const soapClient = await soap.createClientAsync(smsConfig.uri); + const params = { + user: smsConfig.user, + pass: smsConfig.password, + src: smsConfig.title, + dst: recipient, + msg: message + }; + + let xmlResponse; + let xmlResult; + let xmlParsed; + let status; + + try { + [xmlResponse] = await soapClient.sendSMSAsync(params); + xmlResult = xmlResponse.result.$value; + xmlParsed = await new Promise((resolve, reject) => { + xmlParser(xmlResult, (err, result) => { + if (err) + reject(err); + resolve(result); + }); + }); + [status] = xmlParsed['xtratelecom-sms-response'].sms; + } catch (e) { + console.error(e); + } + + const newSms = { + senderFk: userId, + destinationFk: recipientFk || null, + destination: recipient, + message: message, + statusCode: status.codigo, + status: status.descripcion + }; + + const sms = Self.create(newSms); + + if (status.codigo != 200) + throw new UserError(`We weren't able to send this SMS`); + + return sms; + }; +}; diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index c64db145f..76d60abca 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -74,6 +74,12 @@ "ClientSample": { "dataSource": "vn" }, + "Sms": { + "dataSource": "vn" + }, + "SmsConfig": { + "dataSource": "vn" + }, "TpvError": { "dataSource": "vn" }, diff --git a/modules/client/back/models/sms-config.json b/modules/client/back/models/sms-config.json new file mode 100644 index 000000000..3134f8674 --- /dev/null +++ b/modules/client/back/models/sms-config.json @@ -0,0 +1,29 @@ +{ + "name": "SmsConfig", + "description": "Sms configuration", + "base": "VnModel", + "options": { + "mysql": { + "table": "smsConfig" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "uri": { + "type": "String" + }, + "user": { + "type": "String" + }, + "password": { + "type": "String" + }, + "title": { + "type": "String" + } + } +} diff --git a/modules/client/back/models/sms.js b/modules/client/back/models/sms.js new file mode 100644 index 000000000..a823d864a --- /dev/null +++ b/modules/client/back/models/sms.js @@ -0,0 +1,4 @@ +module.exports = Self => { + // Methods + require('../methods/sms/send')(Self); +}; diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json new file mode 100644 index 000000000..ec458e73d --- /dev/null +++ b/modules/client/back/models/sms.json @@ -0,0 +1,51 @@ +{ + "name": "Sms", + "description": "Sms sent to client", + "base": "VnModel", + "options": { + "mysql": { + "table": "sms" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "sender": { + "type": "String", + "required": true + }, + "destination": { + "type": "String", + "required": true + }, + "message": { + "type": "String", + "required": true + }, + "statusCode": { + "type": "Number", + "required": true + }, + "status": { + "type": "String" + }, + "created": { + "type": "Date" + } + }, + "relations": { + "sender": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "senderFk" + }, + "recipient": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "destinationFk" + } + } +} diff --git a/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js b/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js index e1bfdb4c1..272367327 100644 --- a/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js +++ b/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js @@ -1,9 +1,9 @@ const app = require('vn-loopback/server/server'); describe('item filterItemTags()', () => { - it('should filter ItemTags table', async () => { + it('should filter ItemTags table', async() => { let [result] = await app.models.ItemTag.filterItemTags(1, {}); - expect(result.value).toEqual('Blue'); + expect(result.value).toEqual('Black'); }); }); diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index e21031f70..ecaa7aabe 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -6,12 +6,12 @@ describe('item filter()', () => { order: 'isActive ASC, name', limit: 8 }; - let tags = [{value: 'Gem2', tagFk: 58}]; + let tags = [{value: 'combat first', tagFk: 58}]; let result = await app.models.Item.filter({args: {filter: filter, typeFk: 2, tags: tags}}); expect(result.length).toEqual(1); expect(result[0].id).toEqual(2); - expect(result[0].name).toEqual('Object2 Gem2 3'); + expect(result[0].name).toEqual('Melee weapon combat first 15cm'); expect(result[0].type).toEqual('Anthurium'); }); }); diff --git a/modules/order/back/methods/order/specs/catalogFilter.spec.js b/modules/order/back/methods/order/specs/catalogFilter.spec.js index f36f9457b..5a1ed6274 100644 --- a/modules/order/back/methods/order/specs/catalogFilter.spec.js +++ b/modules/order/back/methods/order/specs/catalogFilter.spec.js @@ -14,10 +14,10 @@ describe('order catalogFilter()', () => { let firstItemId = result[0].id; expect(result.length).toEqual(2); - expect(firstItemId).toEqual(2); + expect(firstItemId).toEqual(1); }); - it('should return an array of items based on tag filter', async() => { + it('should now return an array of items based on tag filter', async() => { let filter = { where: { categoryFk: 1, @@ -25,7 +25,7 @@ describe('order catalogFilter()', () => { } }; - let tags = [{tagFk: 56, value: 'Object2'}]; + let tags = [{tagFk: 56, value: 'Melee weapon'}]; let orderFk = 11; let orderBy = {field: 'relevancy DESC, name', way: 'DESC'}; let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags); diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 6e667134a..e326c57df 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -4,5 +4,8 @@ }, "Vehicle": { "dataSource": "vn" + }, + "RouteLog": { + "dataSource": "vn" } } diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json new file mode 100644 index 000000000..abaeeb722 --- /dev/null +++ b/modules/route/back/models/route-log.json @@ -0,0 +1,58 @@ +{ + "name": "RouteLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "routeLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "originFk": { + "type": "Number", + "required": true + }, + "userFk": { + "type": "Number" + }, + "action": { + "type": "String", + "required": true + }, + "changedModel": { + "type": "String" + }, + "oldInstance": { + "type": "Object" + }, + "newInstance": { + "type": "Object" + }, + "creationDate": { + "type": "Date" + }, + "changedModelId": { + "type": "Number" + }, + "changedModelValue": { + "type": "String" + }, + "description": { + "type": "String" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index 8930d314c..f3e4dc946 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -1,6 +1,9 @@ { "name": "Route", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"RouteLog" + }, "options": { "mysql": { "table": "route" diff --git a/modules/route/front/index.js b/modules/route/front/index.js index 33df6dfca..af8a0b69b 100644 --- a/modules/route/front/index.js +++ b/modules/route/front/index.js @@ -7,3 +7,4 @@ import './summary'; import './card'; import './create'; import './basic-data'; +import './log'; diff --git a/modules/route/front/log/index.html b/modules/route/front/log/index.html new file mode 100644 index 000000000..925ea1d14 --- /dev/null +++ b/modules/route/front/log/index.html @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/modules/route/front/log/index.js b/modules/route/front/log/index.js new file mode 100644 index 000000000..85358bd72 --- /dev/null +++ b/modules/route/front/log/index.js @@ -0,0 +1,53 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $stateParams) { + this.$scope = $scope; + this.$stateParams = $stateParams; + this.filter = { + include: [{ + relation: 'user', + scope: { + fields: ['name'], + }, + }], + }; + } + + get logs() { + return this._logs; + } + + set logs(value) { + this._logs = value; + + if (this.logs) { + this.logs.forEach(log => { + log.oldProperties = this.getInstance(log.oldInstance); + log.newProperties = this.getInstance(log.newInstance); + }); + } + } + + getInstance(instance) { + let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/; + const properties = []; + if (typeof instance == 'object' && instance != null) { + Object.keys(instance).forEach(property => { + if (validDate.test(instance[property])) + instance[property] = new Date(instance[property]).toLocaleString('es-ES'); + + properties.push({key: property, value: instance[property]}); + }); + return properties; + } + return null; + } +} + +Controller.$inject = ['$scope', '$stateParams']; + +ngModule.component('vnRouteLog', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/route/front/log/index.spec.js b/modules/route/front/log/index.spec.js new file mode 100644 index 000000000..f8b6f8272 --- /dev/null +++ b/modules/route/front/log/index.spec.js @@ -0,0 +1,37 @@ +import './index'; + +describe('Route', () => { + describe('Component vnRouteLog', () => { + let $componentController; + let $scope; + let controller; + + beforeEach(ngModule('route')); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope) => { + $componentController = _$componentController_; + $scope = $rootScope.$new(); + controller = $componentController('vnRouteLog', {$scope: $scope}); + controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]}; + })); + + describe('logs setter', () => { + it('should call the function getInstance() twice', () => { + spyOn(controller, 'getInstance'); + controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}]; + + expect(controller.getInstance.calls.count()).toBe(2); + expect(controller.getInstance).toHaveBeenCalledWith({id: 1}); + expect(controller.getInstance).toHaveBeenCalledWith({id: 2}); + }); + }); + + describe('getInstance(instance)', () => { + it('should transform the object given in to an array', () => { + let newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance); + + expect(newInstance).toEqual([{key: 'id', value: 1}]); + }); + }); + }); +}); diff --git a/modules/route/front/routes.json b/modules/route/front/routes.json index 521ccd9be..9aae910e3 100644 --- a/modules/route/front/routes.json +++ b/modules/route/front/routes.json @@ -5,7 +5,9 @@ "validations" : true, "dependencies": ["client", "worker", "ticket"], "menu": [ - {"state": "route.card.basicData", "icon": "settings"}], + {"state": "route.card.basicData", "icon": "settings"}, + {"state": "route.card.log", "icon": "history"} + ], "routes": [ { "url": "/route", @@ -51,6 +53,12 @@ "route": "$ctrl.route" }, "acl": ["delivery"] - } + }, { + "url" : "/log", + "state": "route.card.log", + "component": "vn-route-log", + "description": "Log", + "acl": ["delivery"] + } ] } \ No newline at end of file diff --git a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js index 40ee40fb0..048d16c04 100644 --- a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js +++ b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js @@ -1,12 +1,12 @@ const app = require('vn-loopback/server/server'); describe('ticket listPackaging()', () => { - it('should call the listPackaging method and return the response', async () => { + it('should call the listPackaging method and return the response', async() => { let filter = {where: {packagingFk: 1}}; let response = await app.models.Packaging.listPackaging(filter); expect(response[0].name).toBeDefined(); - expect(response[0].name).toEqual('Broken Box'); + expect(response[0].name).toEqual('Container ammo box 1m'); }); }); diff --git a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js index eb8ea615c..0d9937f89 100644 --- a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js +++ b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js @@ -5,7 +5,7 @@ describe('ticket listSaleTracking()', () => { let filter = {where: {ticketFk: 1}}; let result = await app.models.SaleTracking.listSaleTracking(filter); - expect(result[0].concept).toEqual('Object1 Gem1 5'); + expect(result[0].concept).toEqual('Ranged weapon longbow 2m'); }); it(`should call the listSaleTracking method and return zero if doesn't have lines`, async() => { diff --git a/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js b/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js index 7fed64ba2..b12c22084 100644 --- a/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js +++ b/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js @@ -4,7 +4,7 @@ describe('sale getClaimableFromTicket()', () => { it('should return the claimable sales of a given ticket', async() => { let claimableFromTicket = await app.models.Sale.getClaimableFromTicket(16); - expect(claimableFromTicket[0].concept).toBe('Object1 Gem1 5'); + expect(claimableFromTicket[0].concept).toBe('Ranged weapon longbow 2m'); expect(claimableFromTicket.length).toBe(3); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js index a2ea4de3f..cefa9ff4d 100644 --- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js @@ -9,6 +9,6 @@ describe('ticket getSales()', () => { expect(sales[1].tags).toBeDefined(); expect(sales[2].tags).toBeDefined(); expect(sales[3].tags).toBeDefined(); - expect(sales[2].claim).toBeDefined(); + expect(sales[0].claim).toBeDefined(); }); }); diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 8e9ca5433..65678297c 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -1,6 +1,9 @@ { "name": "Ticket", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"TicketLog" + }, "options": { "mysql": { "table": "ticket" diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 8bff26233..249baf815 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -55,13 +55,13 @@ diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index f9c14600d..9176f1490 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -2,8 +2,9 @@ import ngModule from '../module'; import './style.scss'; export default class Controller { - constructor($scope, $state, $stateParams) { + constructor($scope, $state, $stateParams, $translate) { this.$ = $scope; + this.$translate = $translate; this.$stateParams = $stateParams; this.$state = $state; this.selectedTicket = null; @@ -41,9 +42,9 @@ export default class Controller { } goToLines(event, ticketFk) { - event.preventDefault(); - event.stopImmediatePropagation(); - this.$state.go('ticket.card.sale', {id: ticketFk}); + this.preventDefault(event); + let url = this.$state.href('ticket.card.sale', {id: ticketFk}, {absolute: true}); + window.open(url, '_blank'); } goToTurns() { @@ -85,30 +86,32 @@ export default class Controller { } showClientDescriptor(event, clientFk) { - event.preventDefault(); - event.stopImmediatePropagation(); + this.preventDefault(event); this.$.clientDescriptor.clientFk = clientFk; this.$.clientDescriptor.parent = event.target; this.$.clientDescriptor.show(); } showWorkerDescriptor(event, userId) { - event.preventDefault(); - event.stopImmediatePropagation(); + this.preventDefault(event); this.selectedWorker = userId; this.$.workerDescriptor.parent = event.target; this.$.workerDescriptor.show(); } preview(event, ticket) { - event.preventDefault(); - event.stopImmediatePropagation(); + this.preventDefault(event); this.selectedTicket = ticket; this.$.summary.show(); } + + preventDefault(event) { + event.preventDefault(); + event.stopImmediatePropagation(); + } } -Controller.$inject = ['$scope', '$state', '$stateParams']; +Controller.$inject = ['$scope', '$state', '$stateParams', '$translate']; ngModule.component('vnTicketIndex', { template: require('./index.html'), diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml index bb8624797..293ef9fdc 100644 --- a/modules/ticket/front/index/locale/es.yml +++ b/modules/ticket/front/index/locale/es.yml @@ -1,2 +1,3 @@ Turns: Turnos -Go to lines: Ir a lineas \ No newline at end of file +Go to lines: Ir a lineas +Not available: No disponible \ No newline at end of file diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 1cb9713d5..5a37cc959 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -1,5 +1,5 @@ -
{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - {{$ctrl.summary.nickname}} +
Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}} =2.9.0", + "sax": ">=0.6", + "serve-static": "^1.11.1", + "strip-bom": "~0.3.1", + "uuid": "^3.1.0", + "xml-crypto": "~0.8.0" + } + }, "socket.io": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", @@ -14263,6 +14306,15 @@ "ansi-regex": "^2.0.0" } }, + "strip-bom": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-0.3.1.tgz", + "integrity": "sha1-noo57/RW/5q8LwWfXyIluw8/fKU=", + "requires": { + "first-chunk-stream": "^0.1.0", + "is-utf8": "^0.2.0" + } + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -15172,8 +15224,7 @@ "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "uglify-js": { "version": "3.4.9", @@ -16668,6 +16719,22 @@ "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", "dev": true }, + "xml-crypto": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/xml-crypto/-/xml-crypto-0.8.5.tgz", + "integrity": "sha1-K7z7PrM/OoKiGLgiv2craxwg5Tg=", + "requires": { + "xmldom": "=0.1.19", + "xpath.js": ">=0.0.3" + }, + "dependencies": { + "xmldom": { + "version": "0.1.19", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.19.tgz", + "integrity": "sha1-Yx/Ad3bv2EEYvyUXGzftTQdaCrw=" + } + } + }, "xml2js": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", @@ -16679,7 +16746,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xmlcreate": { @@ -16699,6 +16766,11 @@ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, + "xpath.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xpath.js/-/xpath.js-1.1.0.tgz", + "integrity": "sha512-jg+qkfS4K8E7965sqaUl8mRngXiKb3WZGfONgE18pr03FUQiuSV6G+Ej4tS55B+rIQSFEIw3phdVAQ4pPqNWfQ==" + }, "xregexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", diff --git a/package.json b/package.json index 5a2ae2a94..fa63013f7 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,11 @@ "request": "^2.88.0", "request-promise-native": "^1.0.7", "require-yaml": "0.0.1", + "soap": "^0.26.0", "strong-error-handler": "^2.3.2", "uuid": "^3.3.2", - "vn-loopback": "file:./loopback" + "vn-loopback": "file:./loopback", + "xml2js": "^0.4.19" }, "devDependencies": { "@babel/core": "^7.3.3",