From 1d95c17a0b520a0a8b6387022408610066efc8c1 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 09:23:59 +0100 Subject: [PATCH 001/136] refs #5858 feat: remove row from bs.nightTask --- db/changes/234901/04-remove-procedure-bs_nightTask.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/changes/234901/04-remove-procedure-bs_nightTask.sql diff --git a/db/changes/234901/04-remove-procedure-bs_nightTask.sql b/db/changes/234901/04-remove-procedure-bs_nightTask.sql new file mode 100644 index 000000000..530dc6ef5 --- /dev/null +++ b/db/changes/234901/04-remove-procedure-bs_nightTask.sql @@ -0,0 +1,2 @@ +DELETE FROM bs.nightTask + WHERE `procedure` ='zone_getCollisions'; From 50cb7964d9ad12d877ae6c0cd233788d9d84e313 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 09:24:45 +0100 Subject: [PATCH 002/136] ref #5858 feat: drp zone_getCollisions procedure --- db/changes/234901/05-drop-procedure-zone_getCollisions.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/changes/234901/05-drop-procedure-zone_getCollisions.sql diff --git a/db/changes/234901/05-drop-procedure-zone_getCollisions.sql b/db/changes/234901/05-drop-procedure-zone_getCollisions.sql new file mode 100644 index 000000000..9d0db5465 --- /dev/null +++ b/db/changes/234901/05-drop-procedure-zone_getCollisions.sql @@ -0,0 +1 @@ +DROP PROCEDURE vn.zone_getCollisions; From 1b60cd33d5bf137e762480776cb14a0cfaab29b3 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 09:25:35 +0100 Subject: [PATCH 003/136] ref #5858 feat: notification template --- .../email/zone-included/assets/css/import.js | 11 ++++++++ .../email/zone-included/locale/es.yml | 2 ++ .../email/zone-included/sql/zoneIncluded.sql | 5 ++++ .../email/zone-included/zone-included.html | 8 ++++++ .../email/zone-included/zone-included.js | 27 +++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 print/templates/email/zone-included/assets/css/import.js create mode 100644 print/templates/email/zone-included/locale/es.yml create mode 100644 print/templates/email/zone-included/sql/zoneIncluded.sql create mode 100644 print/templates/email/zone-included/zone-included.html create mode 100755 print/templates/email/zone-included/zone-included.js diff --git a/print/templates/email/zone-included/assets/css/import.js b/print/templates/email/zone-included/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/zone-included/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml new file mode 100644 index 000000000..2e954840d --- /dev/null +++ b/print/templates/email/zone-included/locale/es.yml @@ -0,0 +1,2 @@ +subject: Colisión de zona detectada +title: "La zona {0} ha sido registrada en más de un sitio" diff --git a/print/templates/email/zone-included/sql/zoneIncluded.sql b/print/templates/email/zone-included/sql/zoneIncluded.sql new file mode 100644 index 000000000..eaf331232 --- /dev/null +++ b/print/templates/email/zone-included/sql/zoneIncluded.sql @@ -0,0 +1,5 @@ +SELECT + z.name +FROM vn.zoneIncluded zI + LEFT JOIN vn.zone z ON z.Id = zI.zoneFk +WHERE zI.id = ?; diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html new file mode 100644 index 000000000..fbb58334a --- /dev/null +++ b/print/templates/email/zone-included/zone-included.html @@ -0,0 +1,8 @@ + +
+
+

{{ $t('subject') }}

+

{{ $t('title', [this.zoneIncluded.name]) }}

+
+
+
diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js new file mode 100755 index 000000000..821d7c42a --- /dev/null +++ b/print/templates/email/zone-included/zone-included.js @@ -0,0 +1,27 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'zone-included', + async serverPrefetch() { + this.zoneIncluded = await this.fetchZoneIncluded(this.id); + }, + methods: { + fetchZoneIncluded(id) { + return this.findOneFromDef('zoneIncluded', [id]); + }, + }, + components: { + 'email-body': emailBody.build(), + }, + props: { + id: { + type: Number, + required: true + }, + url: { + type: String, + required: true + } + } +}; From f00b264daa9ee57d233d74d328cf7712c0c7a701 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 09:27:08 +0100 Subject: [PATCH 004/136] ref #5858 feat: dispatchers_after[Insert|Update|Delete] --- db/changes/234901/00-zoneIncluded_trigger.sql | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 db/changes/234901/00-zoneIncluded_trigger.sql diff --git a/db/changes/234901/00-zoneIncluded_trigger.sql b/db/changes/234901/00-zoneIncluded_trigger.sql new file mode 100644 index 000000000..b482d1747 --- /dev/null +++ b/db/changes/234901/00-zoneIncluded_trigger.sql @@ -0,0 +1,47 @@ +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` + AFTER INSERT ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'insert', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` + AFTER UPDATE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'update', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; + +-- DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; +-- USE `vn`; + +-- DELIMITER $$ +-- CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` +-- AFTER DELETE ON `zoneIncluded` +-- FOR EACH ROW +-- BEGIN +-- INSERT INTO zoneLog +-- SET `action` = 'delete', +-- `changedModel` = 'zoneIncluded', +-- `changedModelId` = OLD.zoneFk, +-- `userFk` = account.myUser_getId(); +-- END$$ +-- DELIMITER ; From f4a9e7b74e4e05d5f5ec7c993bd3143a628e9188 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 09:31:09 +0100 Subject: [PATCH 005/136] ref #5858 feat: create table zoneIncludedCheck --- .../234901/01-zoneIncluded_table_zoneincludedCheck.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql diff --git a/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql new file mode 100644 index 000000000..0fd19d4bf --- /dev/null +++ b/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql @@ -0,0 +1,7 @@ +CREATE TABLE `vn`.`zoneIncludedCheck` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `zoneFK` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY (`inclusion_FK`,`zoneFK`), + CONSTRAINT `inclusion_FK` FOREIGN KEY (`zoneFK`) REFERENCES `zoneIncluded` (`id`) ON UPDATE CASCADE, +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From b453abdb3a615c11ea630f6930e5784024ebc67a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 22 Nov 2023 12:48:43 +0100 Subject: [PATCH 006/136] refs #5858 feat: new event in vn --- db/changes/234901/02-zoneIncluded_event_checkCollisions.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/changes/234901/02-zoneIncluded_event_checkCollisions.sql diff --git a/db/changes/234901/02-zoneIncluded_event_checkCollisions.sql b/db/changes/234901/02-zoneIncluded_event_checkCollisions.sql new file mode 100644 index 000000000..3a6dd32b8 --- /dev/null +++ b/db/changes/234901/02-zoneIncluded_event_checkCollisions.sql @@ -0,0 +1,5 @@ +USE vn; +CREATE EVENT zoneCollisionsCheck +ON SCHEDULE AT CURRENT_TIMESTAMP +DISABLE ON SLAVE +DO SELECT vn.zoneIncluded_checkCollisions; From a2329e12765d05040289c3fade90d9465bc11e88 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 23 Nov 2023 15:17:40 +0100 Subject: [PATCH 007/136] refs #5858 feat: update template notification --- print/templates/email/zone-included/locale/es.yml | 4 ++-- print/templates/email/zone-included/zone-included.html | 4 ++-- print/templates/email/zone-included/zone-included.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml index 2e954840d..5cf617ba3 100644 --- a/print/templates/email/zone-included/locale/es.yml +++ b/print/templates/email/zone-included/locale/es.yml @@ -1,2 +1,2 @@ -subject: Colisión de zona detectada -title: "La zona {0} ha sido registrada en más de un sitio" +subject: Colisión de zona {0} detectada +title: "La localización {0} ha sido registrada en más de un sitio" diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index fbb58334a..eafa6513f 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,8 +1,8 @@
-

{{ $t('subject') }}

-

{{ $t('title', [this.zoneIncluded.name]) }}

+

{{ $t('subject', [zoneSelected]) }}

+

{{ $t('title', [geoSelected]) }}

diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index 821d7c42a..caac6cfd6 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -15,11 +15,11 @@ module.exports = { 'email-body': emailBody.build(), }, props: { - id: { - type: Number, + zoneSelected: { + type: String, required: true }, - url: { + geoSelected: { type: String, required: true } From 5d156e81ca87b155911cfd55752ddebaa3d80aed Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 23 Nov 2023 15:18:09 +0100 Subject: [PATCH 008/136] refs #5858 perf: move files to current version folder --- db/changes/234801/00-zoneIncluded_trigger.sql | 72 +++++++++++++++++++ ...1-zoneIncluded_table_zoneincludedCheck.sql | 14 ++++ .../02-zoneIncluded_event_checkCollisions.sql | 0 ...zoneIncluded_procedure_checkCollisions.sql | 30 ++++++++ .../04-remove-procedure-bs_nightTask.sql | 0 .../05-drop-procedure-zone_getCollisions.sql | 0 db/changes/234901/00-zoneIncluded_trigger.sql | 47 ------------ ...1-zoneIncluded_table_zoneincludedCheck.sql | 7 -- ...zoneIncluded_procedure_checkCollisions.sql | 14 ++++ 9 files changed, 130 insertions(+), 54 deletions(-) create mode 100644 db/changes/234801/00-zoneIncluded_trigger.sql create mode 100644 db/changes/234801/01-zoneIncluded_table_zoneincludedCheck.sql rename db/changes/{234901 => 234801}/02-zoneIncluded_event_checkCollisions.sql (100%) create mode 100644 db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql rename db/changes/{234901 => 234801}/04-remove-procedure-bs_nightTask.sql (100%) rename db/changes/{234901 => 234801}/05-drop-procedure-zone_getCollisions.sql (100%) delete mode 100644 db/changes/234901/00-zoneIncluded_trigger.sql delete mode 100644 db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql create mode 100644 db/dump/03-zoneIncluded_procedure_checkCollisions.sql diff --git a/db/changes/234801/00-zoneIncluded_trigger.sql b/db/changes/234801/00-zoneIncluded_trigger.sql new file mode 100644 index 000000000..521ca2601 --- /dev/null +++ b/db/changes/234801/00-zoneIncluded_trigger.sql @@ -0,0 +1,72 @@ +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` + AFTER INSERT ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'insert', + `changedModel` = 'zoneIncluded', + `changedModelId` = NEW.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'insert', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + CALL `vn`.`zoneIncluded_checkCollisions`(); +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` + AFTER UPDATE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'update', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'update', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + + CALL `vn`.`zoneIncluded_checkCollisions`(); + + +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` + AFTER DELETE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'delete', + `zoneFk` = OLD.zoneFk, + `geoFk` = OLD.geoFk, + `userFk` = account.myUser_getId(); + + CALL `vn`.`zoneIncluded_checkCollisions`(); +END$$ +DELIMITER ; diff --git a/db/changes/234801/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234801/01-zoneIncluded_table_zoneincludedCheck.sql new file mode 100644 index 000000000..ba52f76b0 --- /dev/null +++ b/db/changes/234801/01-zoneIncluded_table_zoneincludedCheck.sql @@ -0,0 +1,14 @@ +CREATE TABLE `vn`.`zoneIncludedCheck` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `zoneFK` int(11) NOT NULL, + `geoFK` int(11) NOT NULL, + `userFK` int(10) unsigned NOT NULL, + `action`set('insert','update','delete') NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `user_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `zone_FK` FOREIGN KEY (`zoneFK`) REFERENCES `vn`.`zone` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `geo_FK` FOREIGN KEY (`geoFK`) REFERENCES `vn`.`zoneGeo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + UNIQUE INDEX (`zoneFK`, `geoFK`, `userFK`, `action`) +) + +comment 'Table to save temporarily zone changes'; diff --git a/db/changes/234901/02-zoneIncluded_event_checkCollisions.sql b/db/changes/234801/02-zoneIncluded_event_checkCollisions.sql similarity index 100% rename from db/changes/234901/02-zoneIncluded_event_checkCollisions.sql rename to db/changes/234801/02-zoneIncluded_event_checkCollisions.sql diff --git a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql new file mode 100644 index 000000000..84d0e363f --- /dev/null +++ b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql @@ -0,0 +1,30 @@ +-- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT) +BEGIN +DECLARE done INT DEFAULT 0; +DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; +DECLARE z_name VARCHAR(255); +DECLARE g_name VARCHAR(255); + +DECLARE my_cur CURSOR FOR + SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + +OPEN my_cur; + my_cur_loop: + LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ; + IF done = 1 THEN + select concat('NO REDCORDS' ) AS '** DEBUG:'; + LEAVE my_cur_loop; + END IF; + SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; + DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; + SELECT util.notification_send('zone-included', + JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), + account.myUser_getId() + ); + END LOOP my_cur_loop; +CLOSE my_cur; + + +END diff --git a/db/changes/234901/04-remove-procedure-bs_nightTask.sql b/db/changes/234801/04-remove-procedure-bs_nightTask.sql similarity index 100% rename from db/changes/234901/04-remove-procedure-bs_nightTask.sql rename to db/changes/234801/04-remove-procedure-bs_nightTask.sql diff --git a/db/changes/234901/05-drop-procedure-zone_getCollisions.sql b/db/changes/234801/05-drop-procedure-zone_getCollisions.sql similarity index 100% rename from db/changes/234901/05-drop-procedure-zone_getCollisions.sql rename to db/changes/234801/05-drop-procedure-zone_getCollisions.sql diff --git a/db/changes/234901/00-zoneIncluded_trigger.sql b/db/changes/234901/00-zoneIncluded_trigger.sql deleted file mode 100644 index b482d1747..000000000 --- a/db/changes/234901/00-zoneIncluded_trigger.sql +++ /dev/null @@ -1,47 +0,0 @@ -DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; -USE `vn`; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` - AFTER INSERT ON `zoneIncluded` - FOR EACH ROW -BEGIN - INSERT INTO zoneLog - SET `action` = 'insert', - `changedModel` = 'zoneIncluded', - `changedModelId` = OLD.zoneFk, - `userFk` = account.myUser_getId(); -END$$ -DELIMITER ; - -DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; -USE `vn`; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` - AFTER UPDATE ON `zoneIncluded` - FOR EACH ROW -BEGIN - INSERT INTO zoneLog - SET `action` = 'update', - `changedModel` = 'zoneIncluded', - `changedModelId` = OLD.zoneFk, - `userFk` = account.myUser_getId(); -END$$ -DELIMITER ; - --- DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; --- USE `vn`; - --- DELIMITER $$ --- CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` --- AFTER DELETE ON `zoneIncluded` --- FOR EACH ROW --- BEGIN --- INSERT INTO zoneLog --- SET `action` = 'delete', --- `changedModel` = 'zoneIncluded', --- `changedModelId` = OLD.zoneFk, --- `userFk` = account.myUser_getId(); --- END$$ --- DELIMITER ; diff --git a/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql deleted file mode 100644 index 0fd19d4bf..000000000 --- a/db/changes/234901/01-zoneIncluded_table_zoneincludedCheck.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE `vn`.`zoneIncludedCheck` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `zoneFK` int(11) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY (`inclusion_FK`,`zoneFK`), - CONSTRAINT `inclusion_FK` FOREIGN KEY (`zoneFK`) REFERENCES `zoneIncluded` (`id`) ON UPDATE CASCADE, -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/dump/03-zoneIncluded_procedure_checkCollisions.sql b/db/dump/03-zoneIncluded_procedure_checkCollisions.sql new file mode 100644 index 000000000..540bec5ee --- /dev/null +++ b/db/dump/03-zoneIncluded_procedure_checkCollisions.sql @@ -0,0 +1,14 @@ +DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() +BEGIN + -- DROP TEMPORARY TABLE IF EXISTS tmp.toCheck; + DECLARE vZonesToCheck INT; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vZoneFk INT; + DECLARE vCounter INT; + +END$$ +DELIMITER ; From 4383ebd7f1ad7f0430488f92ba4cd131a0e61e8f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 24 Nov 2023 12:30:44 +0100 Subject: [PATCH 009/136] refs #5858 feat: email notification --- db/changes/234801/00-zoneIncluded_trigger.sql | 7 ++++--- .../03-zoneIncluded_procedure_checkCollisions.sql | 9 ++++++--- db/changes/234801/06-zoneincluded_notification.sql | 11 +++++++++++ .../methods/zone/specs/toggleIsIncluded.spec.js | 13 +++++++++++-- print/templates/email/zone-included/locale/es.yml | 4 ++-- .../email/zone-included/zone-included.html | 4 ++-- .../templates/email/zone-included/zone-included.js | 8 -------- 7 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 db/changes/234801/06-zoneincluded_notification.sql diff --git a/db/changes/234801/00-zoneIncluded_trigger.sql b/db/changes/234801/00-zoneIncluded_trigger.sql index 521ca2601..4de0416b7 100644 --- a/db/changes/234801/00-zoneIncluded_trigger.sql +++ b/db/changes/234801/00-zoneIncluded_trigger.sql @@ -17,7 +17,8 @@ BEGIN `zoneFk` = NEW.zoneFk, `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); + END$$ DELIMITER ; @@ -41,7 +42,7 @@ BEGIN `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ @@ -67,6 +68,6 @@ BEGIN `geoFk` = OLD.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ DELIMITER ; diff --git a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql index 84d0e363f..ccfb8f3b8 100644 --- a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql +++ b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql @@ -1,5 +1,7 @@ --- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT) +DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +DELIMITER $$ + +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN zi_zone INT, IN zi_geo INT) BEGIN DECLARE done INT DEFAULT 0; DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; @@ -27,4 +29,5 @@ OPEN my_cur; CLOSE my_cur; -END +END$$ +DELIMITER ; diff --git a/db/changes/234801/06-zoneincluded_notification.sql b/db/changes/234801/06-zoneincluded_notification.sql new file mode 100644 index 000000000..53b2a9189 --- /dev/null +++ b/db/changes/234801/06-zoneincluded_notification.sql @@ -0,0 +1,11 @@ +-- Auto-generated SQL script #202311241021 +INSERT INTO util.notification (name,description) + VALUES ('zone-included','An email to notify zoneCollisions'); + +-- Auto-generated SQL script #202311241051 +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, account.role FROM util.notification WHERE name= "zone-included" diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 746a2d0bd..3e72408cf 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,8 +1,9 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); - +let conn = null; describe('zone toggleIsIncluded()', () => { beforeAll(async() => { + conn = await models.Item.dataSource.connector; const activeCtx = { accessToken: {userId: 9}, http: { @@ -16,15 +17,23 @@ describe('zone toggleIsIncluded()', () => { }); }); - it('should return the created location with isIncluded true', async() => { + fit('should return the created location with isIncluded true', async() => { const tx = await models.Zone.beginTransaction({}); try { + let toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); + + expect(toCheck.length).toEqual(0); const options = {transaction: tx}; let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); + toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); + + expect(toCheck.length).not.toEqual(1); + + await conn.executeStmt({sql: 'CALL vn.zoneIncluded_checkCollisions(?, ? )', params: [0, 0]}); await tx.rollback(); } catch (e) { diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml index 5cf617ba3..57d257663 100644 --- a/print/templates/email/zone-included/locale/es.yml +++ b/print/templates/email/zone-included/locale/es.yml @@ -1,2 +1,2 @@ -subject: Colisión de zona {0} detectada -title: "La localización {0} ha sido registrada en más de un sitio" +subject: Colisión de zona detectada +title: "La zona {0} y localización {1} ha sido registrada en más de un sitio" diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index eafa6513f..76f59e9f9 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,8 +1,8 @@
-

{{ $t('subject', [zoneSelected]) }}

-

{{ $t('title', [geoSelected]) }}

+

{{ $t('subject') }}

+

{{ $t('title', [zoneSelected,geoSelected]) }}

diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index caac6cfd6..6ed8964b1 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -3,14 +3,6 @@ const emailBody = new Component('email-body'); module.exports = { name: 'zone-included', - async serverPrefetch() { - this.zoneIncluded = await this.fetchZoneIncluded(this.id); - }, - methods: { - fetchZoneIncluded(id) { - return this.findOneFromDef('zoneIncluded', [id]); - }, - }, components: { 'email-body': emailBody.build(), }, From c40dc134f811cebef8a51ad16cb6928eeb423d66 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 29 Nov 2023 12:15:38 +0100 Subject: [PATCH 010/136] refs #5858 feat: sql files for new version --- .../234801/06-zoneincluded_notification.sql | 6 +- db/changes/234802/00-zoneIncluded_trigger.sql | 73 +++++++++++++++++++ ...1-zoneIncluded_table_zoneincludedCheck.sql | 14 ++++ .../02-zoneIncluded_event_checkCollisions.sql | 5 ++ ...zoneIncluded_procedure_checkCollisions.sql | 33 +++++++++ .../04-remove-procedure-bs_nightTask.sql | 2 + .../05-drop-procedure-zone_getCollisions.sql | 1 + .../234802/06-zoneincluded_notification.sql | 11 +++ .../email/zone-included/zone-included.html | 29 +++++++- .../email/zone-included/zone-included.js | 6 ++ 10 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 db/changes/234802/00-zoneIncluded_trigger.sql create mode 100644 db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql create mode 100644 db/changes/234802/02-zoneIncluded_event_checkCollisions.sql create mode 100644 db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql create mode 100644 db/changes/234802/04-remove-procedure-bs_nightTask.sql create mode 100644 db/changes/234802/05-drop-procedure-zone_getCollisions.sql create mode 100644 db/changes/234802/06-zoneincluded_notification.sql diff --git a/db/changes/234801/06-zoneincluded_notification.sql b/db/changes/234801/06-zoneincluded_notification.sql index 53b2a9189..3de713884 100644 --- a/db/changes/234801/06-zoneincluded_notification.sql +++ b/db/changes/234801/06-zoneincluded_notification.sql @@ -1,11 +1,9 @@ --- Auto-generated SQL script #202311241021 INSERT INTO util.notification (name,description) VALUES ('zone-included','An email to notify zoneCollisions'); --- Auto-generated SQL script #202311241051 INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, account.role FROM util.notification WHERE name= "zone-included" + SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/changes/234802/00-zoneIncluded_trigger.sql b/db/changes/234802/00-zoneIncluded_trigger.sql new file mode 100644 index 000000000..4de0416b7 --- /dev/null +++ b/db/changes/234802/00-zoneIncluded_trigger.sql @@ -0,0 +1,73 @@ +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` + AFTER INSERT ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'insert', + `changedModel` = 'zoneIncluded', + `changedModelId` = NEW.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'insert', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); + +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` + AFTER UPDATE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'update', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'update', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + + -- CALL `vn`.`zoneIncluded_checkCollisions`(); + + +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` + AFTER DELETE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'delete', + `zoneFk` = OLD.zoneFk, + `geoFk` = OLD.geoFk, + `userFk` = account.myUser_getId(); + + -- CALL `vn`.`zoneIncluded_checkCollisions`(); +END$$ +DELIMITER ; diff --git a/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql new file mode 100644 index 000000000..ba52f76b0 --- /dev/null +++ b/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql @@ -0,0 +1,14 @@ +CREATE TABLE `vn`.`zoneIncludedCheck` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `zoneFK` int(11) NOT NULL, + `geoFK` int(11) NOT NULL, + `userFK` int(10) unsigned NOT NULL, + `action`set('insert','update','delete') NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `user_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `zone_FK` FOREIGN KEY (`zoneFK`) REFERENCES `vn`.`zone` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `geo_FK` FOREIGN KEY (`geoFK`) REFERENCES `vn`.`zoneGeo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + UNIQUE INDEX (`zoneFK`, `geoFK`, `userFK`, `action`) +) + +comment 'Table to save temporarily zone changes'; diff --git a/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql b/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql new file mode 100644 index 000000000..3a6dd32b8 --- /dev/null +++ b/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql @@ -0,0 +1,5 @@ +USE vn; +CREATE EVENT zoneCollisionsCheck +ON SCHEDULE AT CURRENT_TIMESTAMP +DISABLE ON SLAVE +DO SELECT vn.zoneIncluded_checkCollisions; diff --git a/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql new file mode 100644 index 000000000..8959b3945 --- /dev/null +++ b/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql @@ -0,0 +1,33 @@ +DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +DELIMITER $$ + +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() +BEGIN +DECLARE done INT DEFAULT 0; +DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; +DECLARE z_name VARCHAR(255); +DECLARE g_name VARCHAR(255); + +DECLARE my_cur CURSOR FOR + SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + +OPEN my_cur; + my_cur_loop: + LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ; + IF done = 1 THEN + select concat('NO REDCORDS' ) AS '** DEBUG:'; + LEAVE my_cur_loop; + END IF; + SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; + DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; + SELECT util.notification_send('zone-included', + JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), + account.myUser_getId() + ); + END LOOP my_cur_loop; +CLOSE my_cur; + + +END$$ +DELIMITER ; diff --git a/db/changes/234802/04-remove-procedure-bs_nightTask.sql b/db/changes/234802/04-remove-procedure-bs_nightTask.sql new file mode 100644 index 000000000..530dc6ef5 --- /dev/null +++ b/db/changes/234802/04-remove-procedure-bs_nightTask.sql @@ -0,0 +1,2 @@ +DELETE FROM bs.nightTask + WHERE `procedure` ='zone_getCollisions'; diff --git a/db/changes/234802/05-drop-procedure-zone_getCollisions.sql b/db/changes/234802/05-drop-procedure-zone_getCollisions.sql new file mode 100644 index 000000000..9d0db5465 --- /dev/null +++ b/db/changes/234802/05-drop-procedure-zone_getCollisions.sql @@ -0,0 +1 @@ +DROP PROCEDURE vn.zone_getCollisions; diff --git a/db/changes/234802/06-zoneincluded_notification.sql b/db/changes/234802/06-zoneincluded_notification.sql new file mode 100644 index 000000000..53b2a9189 --- /dev/null +++ b/db/changes/234802/06-zoneincluded_notification.sql @@ -0,0 +1,11 @@ +-- Auto-generated SQL script #202311241021 +INSERT INTO util.notification (name,description) + VALUES ('zone-included','An email to notify zoneCollisions'); + +-- Auto-generated SQL script #202311241051 +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, account.role FROM util.notification WHERE name= "zone-included" diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index 76f59e9f9..95f43b570 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,8 +1,33 @@
-

{{ $t('subject') }}

-

{{ $t('title', [zoneSelected,geoSelected]) }}

+ + + + + + + + + + + + + + + + + +
C.PostalNúmero de zonaPrecioZonaAlmacénSalix
{{ zn.name }}{{ zoneFk }}{{ z.price }}{{ z.name }}{{ w.name }}' + 'https://salix.verdnatura.es/#!/zone/', + zoneFk, + '/location?q=%7B%22search%22:%22', + zn.name, + '%22%7D
diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index 6ed8964b1..7fb60fb63 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -5,6 +5,12 @@ module.exports = { name: 'zone-included', components: { 'email-body': emailBody.build(), + }, + computed: { + + }, + methods: { + }, props: { zoneSelected: { From 60fbb1d56ee4f2e4af9c9ccfbeccd0374803d3cc Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 1 Dec 2023 09:39:21 +0100 Subject: [PATCH 011/136] refs #5858 feat: update procedure zoneIncluded_getCollisions --- ...zoneIncluded_procedure_checkCollisions.sql | 83 ++++++++++++------- db/changes/234802/00-zoneIncluded_trigger.sql | 73 ---------------- ...1-zoneIncluded_table_zoneincludedCheck.sql | 14 ---- .../02-zoneIncluded_event_checkCollisions.sql | 5 -- ...zoneIncluded_procedure_checkCollisions.sql | 33 -------- .../04-remove-procedure-bs_nightTask.sql | 2 - .../05-drop-procedure-zone_getCollisions.sql | 1 - .../234802/06-zoneincluded_notification.sql | 11 --- 8 files changed, 55 insertions(+), 167 deletions(-) delete mode 100644 db/changes/234802/00-zoneIncluded_trigger.sql delete mode 100644 db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql delete mode 100644 db/changes/234802/02-zoneIncluded_event_checkCollisions.sql delete mode 100644 db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql delete mode 100644 db/changes/234802/04-remove-procedure-bs_nightTask.sql delete mode 100644 db/changes/234802/05-drop-procedure-zone_getCollisions.sql delete mode 100644 db/changes/234802/06-zoneincluded_notification.sql diff --git a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql index ccfb8f3b8..f3649466b 100644 --- a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql +++ b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql @@ -1,33 +1,60 @@ -DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +DROP PROCEDURE IF EXISTS vn.zoneIncluded_checkCollisions; + DELIMITER $$ - -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN zi_zone INT, IN zi_geo INT) +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() BEGIN -DECLARE done INT DEFAULT 0; -DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; -DECLARE z_name VARCHAR(255); -DECLARE g_name VARCHAR(255); - -DECLARE my_cur CURSOR FOR - SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ; -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; - -OPEN my_cur; - my_cur_loop: - LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ; - IF done = 1 THEN - select concat('NO REDCORDS' ) AS '** DEBUG:'; - LEAVE my_cur_loop; - END IF; - SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; - DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; - SELECT util.notification_send('zone-included', - JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), - account.myUser_getId() - ); - END LOOP my_cur_loop; -CLOSE my_cur; + DECLARE zic_id, zic_zone, zic_geoFk, zic_action, zic_zoneFk, zic_userFk INT; + DECLARE zic2_geoFk, zic2_zoneFk INT; + DECLARE z_name VARCHAR(255); + DECLARE g_name VARCHAR(255); + DECLARE vDone boolean; -END$$ + DECLARE cur CURSOR FOR + SELECT zic.id, z.name , zg.name ,zic.zoneFK, zic.geoFk ,zic.`action` , zic.userFK + FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg + WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id and zic.action ='insert'; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SET vDone := FALSE; + OPEN cur; + LOOP1: LOOP + SET vDone := FALSE; + FETCH cur INTO zic_id, z_name, g_name, zic_zoneFk, zic_geoFk, zic_action, zic_userFk ; + IF vDone THEN + select concat('NO RECORDS LOOP 1' ) AS '** DEBUG:'; + CLOSE cur; + LEAVE LOOP1; + END IF; + -- SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_zoneFk,'**',zic_geoFk,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; + DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; + + BLOCK2: BEGIN + DECLARE vDone2 boolean; + DECLARE cur2 CURSOR FOR + SELECT zi.zoneFk,zi.geoFk + FROM vn.zoneIncluded zi, vn.zone z + where z.id = zi.zoneFk and zi.zoneFk=zic_zoneFk and zi.geoFk=zic_geoFk and zi.isIncluded = 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone2 = TRUE; + SET vDone2 := FALSE; + OPEN cur2; + LOOP2: LOOP + FETCH cur2 INTO zic2_zoneFk, zic2_geoFk ; + IF vDone2 THEN + select concat('NO RECORDS LOOP 2' ) AS '** DEBUG:'; + CLOSE cur2; + LEAVE LOOP2; + END IF; + SELECT concat('COLLISION DETECTED', zic2_zoneFk, zic2_geoFk ) AS '** DEBUG:'; + + SELECT util.notification_send('zone-included', + JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), + account.myUser_getId() + ); + END LOOP LOOP2; + END BLOCK2; + END LOOP LOOP1; +END +$$ DELIMITER ; diff --git a/db/changes/234802/00-zoneIncluded_trigger.sql b/db/changes/234802/00-zoneIncluded_trigger.sql deleted file mode 100644 index 4de0416b7..000000000 --- a/db/changes/234802/00-zoneIncluded_trigger.sql +++ /dev/null @@ -1,73 +0,0 @@ -DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; -USE `vn`; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` - AFTER INSERT ON `zoneIncluded` - FOR EACH ROW -BEGIN - INSERT INTO zoneLog - SET `action` = 'insert', - `changedModel` = 'zoneIncluded', - `changedModelId` = NEW.zoneFk, - `userFk` = account.myUser_getId(); - INSERT INTO zoneIncludedCheck - SET - `action`= 'insert', - `zoneFk` = NEW.zoneFk, - `geoFk` = NEW.geoFk, - `userFk` = account.myUser_getId(); - -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); - -END$$ -DELIMITER ; - -DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; -USE `vn`; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` - AFTER UPDATE ON `zoneIncluded` - FOR EACH ROW -BEGIN - INSERT INTO zoneLog - SET `action` = 'update', - `changedModel` = 'zoneIncluded', - `changedModelId` = OLD.zoneFk, - `userFk` = account.myUser_getId(); - INSERT INTO zoneIncludedCheck - SET - `action`= 'update', - `zoneFk` = NEW.zoneFk, - `geoFk` = NEW.geoFk, - `userFk` = account.myUser_getId(); - - -- CALL `vn`.`zoneIncluded_checkCollisions`(); - - -END$$ -DELIMITER ; - -DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; -USE `vn`; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` - AFTER DELETE ON `zoneIncluded` - FOR EACH ROW -BEGIN - INSERT INTO zoneLog - SET `action` = 'delete', - `changedModel` = 'zoneIncluded', - `changedModelId` = OLD.zoneFk, - `userFk` = account.myUser_getId(); - INSERT INTO zoneIncludedCheck - SET - `action`= 'delete', - `zoneFk` = OLD.zoneFk, - `geoFk` = OLD.geoFk, - `userFk` = account.myUser_getId(); - - -- CALL `vn`.`zoneIncluded_checkCollisions`(); -END$$ -DELIMITER ; diff --git a/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql deleted file mode 100644 index ba52f76b0..000000000 --- a/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE `vn`.`zoneIncludedCheck` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `zoneFK` int(11) NOT NULL, - `geoFK` int(11) NOT NULL, - `userFK` int(10) unsigned NOT NULL, - `action`set('insert','update','delete') NOT NULL, - PRIMARY KEY (`id`), - CONSTRAINT `user_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `zone_FK` FOREIGN KEY (`zoneFK`) REFERENCES `vn`.`zone` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `geo_FK` FOREIGN KEY (`geoFK`) REFERENCES `vn`.`zoneGeo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - UNIQUE INDEX (`zoneFK`, `geoFK`, `userFK`, `action`) -) - -comment 'Table to save temporarily zone changes'; diff --git a/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql b/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql deleted file mode 100644 index 3a6dd32b8..000000000 --- a/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql +++ /dev/null @@ -1,5 +0,0 @@ -USE vn; -CREATE EVENT zoneCollisionsCheck -ON SCHEDULE AT CURRENT_TIMESTAMP -DISABLE ON SLAVE -DO SELECT vn.zoneIncluded_checkCollisions; diff --git a/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql deleted file mode 100644 index 8959b3945..000000000 --- a/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql +++ /dev/null @@ -1,33 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; -DELIMITER $$ - -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() -BEGIN -DECLARE done INT DEFAULT 0; -DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; -DECLARE z_name VARCHAR(255); -DECLARE g_name VARCHAR(255); - -DECLARE my_cur CURSOR FOR - SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ; -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; - -OPEN my_cur; - my_cur_loop: - LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ; - IF done = 1 THEN - select concat('NO REDCORDS' ) AS '** DEBUG:'; - LEAVE my_cur_loop; - END IF; - SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; - DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; - SELECT util.notification_send('zone-included', - JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), - account.myUser_getId() - ); - END LOOP my_cur_loop; -CLOSE my_cur; - - -END$$ -DELIMITER ; diff --git a/db/changes/234802/04-remove-procedure-bs_nightTask.sql b/db/changes/234802/04-remove-procedure-bs_nightTask.sql deleted file mode 100644 index 530dc6ef5..000000000 --- a/db/changes/234802/04-remove-procedure-bs_nightTask.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM bs.nightTask - WHERE `procedure` ='zone_getCollisions'; diff --git a/db/changes/234802/05-drop-procedure-zone_getCollisions.sql b/db/changes/234802/05-drop-procedure-zone_getCollisions.sql deleted file mode 100644 index 9d0db5465..000000000 --- a/db/changes/234802/05-drop-procedure-zone_getCollisions.sql +++ /dev/null @@ -1 +0,0 @@ -DROP PROCEDURE vn.zone_getCollisions; diff --git a/db/changes/234802/06-zoneincluded_notification.sql b/db/changes/234802/06-zoneincluded_notification.sql deleted file mode 100644 index 53b2a9189..000000000 --- a/db/changes/234802/06-zoneincluded_notification.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Auto-generated SQL script #202311241021 -INSERT INTO util.notification (name,description) - VALUES ('zone-included','An email to notify zoneCollisions'); - --- Auto-generated SQL script #202311241051 -INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" - - -INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, account.role FROM util.notification WHERE name= "zone-included" From e3379b42a1c40ea05196f2901a285ff6adc4a04d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 1 Dec 2023 14:06:28 +0100 Subject: [PATCH 012/136] refs #5858 test: bad test calls --- .../zone/back/methods/zone/specs/toggleIsIncluded.spec.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 3e72408cf..241b0d0cc 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -21,19 +21,11 @@ describe('zone toggleIsIncluded()', () => { const tx = await models.Zone.beginTransaction({}); try { - let toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); - - expect(toCheck.length).toEqual(0); const options = {transaction: tx}; let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); - toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); - - expect(toCheck.length).not.toEqual(1); - - await conn.executeStmt({sql: 'CALL vn.zoneIncluded_checkCollisions(?, ? )', params: [0, 0]}); await tx.rollback(); } catch (e) { From 15936ddc552e6f86907735f584d5503caa6ef12a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 07:53:47 +0100 Subject: [PATCH 013/136] refs #5858 other: rename files --- ...dure-bs_nightTask.sql => 04-remove_procedure_bs_nightTask.sql} | 0 ...getCollisions.sql => 05-drop_procedure_zone_getCollisions.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/234801/{04-remove-procedure-bs_nightTask.sql => 04-remove_procedure_bs_nightTask.sql} (100%) rename db/changes/234801/{05-drop-procedure-zone_getCollisions.sql => 05-drop_procedure_zone_getCollisions.sql} (100%) diff --git a/db/changes/234801/04-remove-procedure-bs_nightTask.sql b/db/changes/234801/04-remove_procedure_bs_nightTask.sql similarity index 100% rename from db/changes/234801/04-remove-procedure-bs_nightTask.sql rename to db/changes/234801/04-remove_procedure_bs_nightTask.sql diff --git a/db/changes/234801/05-drop-procedure-zone_getCollisions.sql b/db/changes/234801/05-drop_procedure_zone_getCollisions.sql similarity index 100% rename from db/changes/234801/05-drop-procedure-zone_getCollisions.sql rename to db/changes/234801/05-drop_procedure_zone_getCollisions.sql From cc88fcbd9d88623917db080f17b5cfbbe6a9f9ea Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 07:54:12 +0100 Subject: [PATCH 014/136] refs #5858 feat: update notification template --- .../email/zone-included/locale/es.yml | 5 +++ .../email/zone-included/zone-included.html | 41 ++++++++++--------- .../email/zone-included/zone-included.js | 26 ++++++++---- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml index 57d257663..974253ddc 100644 --- a/print/templates/email/zone-included/locale/es.yml +++ b/print/templates/email/zone-included/locale/es.yml @@ -1,2 +1,7 @@ subject: Colisión de zona detectada title: "La zona {0} y localización {1} ha sido registrada en más de un sitio" +postalCode: C. Postal +zoneFk: Número de zona +price: Precio +zone: Zona +warehouse: Almacén diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index 95f43b570..0381cc8c4 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -3,28 +3,29 @@
- - - - - + + + + + - - - - - - - + + + + + +
C.PostalNúmero de zonaPrecioZonaAlmacén{{ $t('postalCode') }}{{ $t('zoneFk') }}{{ $t('price') }}{{ $t('zone') }}{{ $t('warehouse') }} Salix
{{ zn.name }}{{ zoneFk }}{{ z.price }}{{ z.name }}{{ w.name }}' - 'https://salix.verdnatura.es/#!/zone/', - zoneFk, - '/location?q=%7B%22search%22:%22', - zn.name, +
{{ zone.zn.name }}{{ zone.zoneFk }}{{ zone.z.price }}{{ zone.z.name }}{{ zone.w.name }} + + 'https://salix.verdnatura.es/#!/zone/'+ + {{zone.zoneFk}}+ + '/location?q=%7B%22search%22:%22'+ + {{zone.zn.name}}+ '%22%7D
diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index 7fb60fb63..c42e2c34e 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -6,6 +6,7 @@ module.exports = { components: { 'email-body': emailBody.build(), }, + computed: { }, @@ -13,13 +14,22 @@ module.exports = { }, props: { - zoneSelected: { - type: String, - required: true - }, - geoSelected: { - type: String, - required: true - } + zoneCollisions: {type: Array, required: true} + // zoneFk: { + // type: String, + // required: true + // }, + // z: { + // type: Object, + // required: true + // }, + // zn: { + // type: Object, + // required: true + // }, + // w: { + // type: Object, + // required: true + // } } }; From 5b6112720fdb8022e88b6b96b1f00d49de78fb2a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 07:54:29 +0100 Subject: [PATCH 015/136] refs #5858 feat: new fixture --- db/dump/fixtures.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index af181fd3b..85d5873fd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3010,3 +3010,9 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`) (1, 'Error in VAT calculation'), (2, 'Error in sales details'), (3, 'Error in customer data'); + + +-- Auto-generated SQL script #202312181416 +UPDATE salix.ACL + SET principalId='employee' + WHERE id=391; From a31b689ae2d597f9ed19374bb6d29c600fd2a79b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 07:54:49 +0100 Subject: [PATCH 016/136] refs #5858 perf: update db/changes --- ...zoneIncluded_procedure_checkCollisions.sql | 145 ++++++++++++------ .../234801/06-zoneincluded_notification.sql | 5 +- 2 files changed, 99 insertions(+), 51 deletions(-) diff --git a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql index f3649466b..99cab6746 100644 --- a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql +++ b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql @@ -1,60 +1,107 @@ DROP PROCEDURE IF EXISTS vn.zoneIncluded_checkCollisions; DELIMITER $$ -$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() BEGIN - DECLARE zic_id, zic_zone, zic_geoFk, zic_action, zic_zoneFk, zic_userFk INT; - DECLARE zic2_geoFk, zic2_zoneFk INT; - DECLARE z_name VARCHAR(255); - DECLARE g_name VARCHAR(255); - DECLARE vDone boolean; +/** + * Calcula si para un mismo codigo postal y dia + * hay mas de una zona configurada y manda correo + * + */ + DECLARE vGeoFk INT DEFAULT NULL; + DECLARE vZoneFk INT; + DECLARE vIsDone INT DEFAULT FALSE; + DECLARE vTableCollisions TEXT; + DECLARE json_data JSON; + DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - DECLARE cur CURSOR FOR - SELECT zic.id, z.name , zg.name ,zic.zoneFK, zic.geoFk ,zic.`action` , zic.userFK - FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg - WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id and zic.action ='insert'; + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + SELECT z.id + FROM zone z + JOIN agencyMode am ON am.id = z.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY','DELIVERY'); - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - SET vDone := FALSE; - OPEN cur; - LOOP1: LOOP - SET vDone := FALSE; - FETCH cur INTO zic_id, z_name, g_name, zic_zoneFk, zic_geoFk, zic_action, zic_userFk ; - IF vDone THEN - select concat('NO RECORDS LOOP 1' ) AS '** DEBUG:'; - CLOSE cur; - LEAVE LOOP1; - END IF; - -- SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_zoneFk,'**',zic_geoFk,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; - DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; + CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE); - BLOCK2: BEGIN - DECLARE vDone2 boolean; - DECLARE cur2 CURSOR FOR - SELECT zi.zoneFk,zi.geoFk - FROM vn.zoneIncluded zi, vn.zone z - where z.id = zi.zoneFk and zi.zoneFk=zic_zoneFk and zi.geoFk=zic_geoFk and zi.isIncluded = 1; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone2 = TRUE; - SET vDone2 := FALSE; - OPEN cur2; - LOOP2: LOOP - FETCH cur2 INTO zic2_zoneFk, zic2_geoFk ; - IF vDone2 THEN - select concat('NO RECORDS LOOP 2' ) AS '** DEBUG:'; - CLOSE cur2; - LEAVE LOOP2; - END IF; - SELECT concat('COLLISION DETECTED', zic2_zoneFk, zic2_geoFk ) AS '** DEBUG:'; + DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes; + CREATE TEMPORARY TABLE tmp.zoneNodes ( + geoFk INT, + name VARCHAR(100), + parentFk INT, + sons INT, + isChecked BOOL DEFAULT 0, + zoneFk INT, + PRIMARY KEY zoneFkk (zoneFk, geoFk), + INDEX(geoFk)) + ENGINE = MyISAM; - SELECT util.notification_send('zone-included', - JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), - account.myUser_getId() - ); - END LOOP LOOP2; - END BLOCK2; - END LOOP LOOP1; -END -$$ + OPEN cur1; + cur1Loop: LOOP + SET vIsDone = FALSE; + FETCH cur1 INTO vZoneFk; + IF vIsDone THEN + LEAVE cur1Loop; + END IF; + + CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE); + + myLoop: LOOP + SET vGeoFk = NULL; + SELECT geoFk INTO vGeoFk + FROM tmp.zoneNodes zn + WHERE NOT isChecked + LIMIT 1; + + IF vGeoFk IS NULL THEN + LEAVE myLoop; + END IF; + + CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE); + UPDATE tmp.zoneNodes + SET isChecked = TRUE + WHERE geoFk = vGeoFk; + END LOOP; + + END LOOP; + CLOSE cur1; + DELETE FROM tmp.zoneNodes + WHERE sons > 0; + + DROP TEMPORARY TABLE IF EXISTS geoCollision; + CREATE TEMPORARY TABLE geoCollision + SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk + FROM tmp.zoneNodes zn + JOIN zone z ON z.id = zn.zoneFk + JOIN zoneWarehouse zw ON z.id = zw.zoneFk + GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk + HAVING count(*) > 1; + + SELECT JSON_ARRAYAGG( + JSON_OBJECT( + 'zoneFk', zoneFk, + 'zn', JSON_OBJECT('name', zn.name), + 'z', JSON_OBJECT('name', z.name,'price', z.price), + 'w', JSON_OBJECT('name', w.name) + ) + ) FROM tmp.zoneNodes zn + JOIN zone z ON z.id = zn.zoneFk + JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk + JOIN warehouse w ON w.id = gc.warehouseFk + INTO json_data; + + SELECT util.notification_send( + 'zone-included', + JSON_OBJECT('zoneCollisions',json_data), + account.myUser_getId() + ); + + DROP TEMPORARY TABLE + geoCollision, + tmp.zone, + tmp.zoneNodes; +END ;; DELIMITER ; diff --git a/db/changes/234801/06-zoneincluded_notification.sql b/db/changes/234801/06-zoneincluded_notification.sql index 3de713884..d05902461 100644 --- a/db/changes/234801/06-zoneincluded_notification.sql +++ b/db/changes/234801/06-zoneincluded_notification.sql @@ -1,5 +1,6 @@ -INSERT INTO util.notification (name,description) - VALUES ('zone-included','An email to notify zoneCollisions'); +INSERT INTO util.notification (id, name,description) + VALUES ( +(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); INSERT INTO util.notificationSubscription (notificationFk,userFk) SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; From dbc3fc800781a6fb300aeebaa21cadbe9b4bcb55 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 08:02:38 +0100 Subject: [PATCH 017/136] refs #5858 perf: remove bad comments --- db/changes/234801/00-zoneIncluded_trigger.sql | 3 --- ...03-zoneIncluded_procedure_checkCollisions.sql | 14 -------------- db/dump/fixtures.sql | 3 +-- .../methods/zone/specs/toggleIsIncluded.spec.js | 4 +--- .../email/zone-included/sql/zoneIncluded.sql | 5 ----- .../email/zone-included/zone-included.js | 16 ---------------- 6 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 db/dump/03-zoneIncluded_procedure_checkCollisions.sql diff --git a/db/changes/234801/00-zoneIncluded_trigger.sql b/db/changes/234801/00-zoneIncluded_trigger.sql index 4de0416b7..7684e7787 100644 --- a/db/changes/234801/00-zoneIncluded_trigger.sql +++ b/db/changes/234801/00-zoneIncluded_trigger.sql @@ -17,7 +17,6 @@ BEGIN `zoneFk` = NEW.zoneFk, `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); END$$ DELIMITER ; @@ -42,7 +41,6 @@ BEGIN `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ @@ -68,6 +66,5 @@ BEGIN `geoFk` = OLD.geoFk, `userFk` = account.myUser_getId(); - -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ DELIMITER ; diff --git a/db/dump/03-zoneIncluded_procedure_checkCollisions.sql b/db/dump/03-zoneIncluded_procedure_checkCollisions.sql deleted file mode 100644 index 540bec5ee..000000000 --- a/db/dump/03-zoneIncluded_procedure_checkCollisions.sql +++ /dev/null @@ -1,14 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() -BEGIN - -- DROP TEMPORARY TABLE IF EXISTS tmp.toCheck; - DECLARE vZonesToCheck INT; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vZoneFk INT; - DECLARE vCounter INT; - -END$$ -DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 85d5873fd..e934ee12e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3012,7 +3012,6 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`) (3, 'Error in customer data'); --- Auto-generated SQL script #202312181416 UPDATE salix.ACL SET principalId='employee' - WHERE id=391; + WHERE model ="Notification"; diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 241b0d0cc..86c04f844 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,9 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -let conn = null; describe('zone toggleIsIncluded()', () => { beforeAll(async() => { - conn = await models.Item.dataSource.connector; const activeCtx = { accessToken: {userId: 9}, http: { @@ -17,7 +15,7 @@ describe('zone toggleIsIncluded()', () => { }); }); - fit('should return the created location with isIncluded true', async() => { + it('should return the created location with isIncluded true', async() => { const tx = await models.Zone.beginTransaction({}); try { diff --git a/print/templates/email/zone-included/sql/zoneIncluded.sql b/print/templates/email/zone-included/sql/zoneIncluded.sql index eaf331232..e69de29bb 100644 --- a/print/templates/email/zone-included/sql/zoneIncluded.sql +++ b/print/templates/email/zone-included/sql/zoneIncluded.sql @@ -1,5 +0,0 @@ -SELECT - z.name -FROM vn.zoneIncluded zI - LEFT JOIN vn.zone z ON z.Id = zI.zoneFk -WHERE zI.id = ?; diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index c42e2c34e..cddebe612 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -15,21 +15,5 @@ module.exports = { }, props: { zoneCollisions: {type: Array, required: true} - // zoneFk: { - // type: String, - // required: true - // }, - // z: { - // type: Object, - // required: true - // }, - // zn: { - // type: Object, - // required: true - // }, - // w: { - // type: Object, - // required: true - // } } }; From 2d4fb9d2f8c2a460ff5e8c1c782e0e8a551173ee Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 08:04:11 +0100 Subject: [PATCH 018/136] refs #5858 perf: remove unused methods --- print/templates/email/zone-included/zone-included.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index cddebe612..7e23ee2f0 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -6,13 +6,6 @@ module.exports = { components: { 'email-body': emailBody.build(), }, - - computed: { - - }, - methods: { - - }, props: { zoneCollisions: {type: Array, required: true} } From 243319b11325be0eb659e33a6388c1330d0ca520 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 12:55:27 +0100 Subject: [PATCH 019/136] refs #5858 feat zoneIncludedCheck model --- modules/zone/back/model-config.json | 3 ++ .../zone/back/models/zone-included-check.json | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 modules/zone/back/models/zone-included-check.json diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 261a89902..72c755978 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -32,6 +32,9 @@ "ZoneIncluded": { "dataSource": "vn" }, + "ZoneIncludedCheck": { + "dataSource": "vn" + }, "ZoneWarehouse": { "dataSource": "vn" }, diff --git a/modules/zone/back/models/zone-included-check.json b/modules/zone/back/models/zone-included-check.json new file mode 100644 index 000000000..8affee92c --- /dev/null +++ b/modules/zone/back/models/zone-included-check.json @@ -0,0 +1,44 @@ +{ + "name": "ZoneIncludedCheck", + "base": "Loggable", + "options": { + "mysql": { + "table": "zoneIncludedCheck" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "zoneFk": { + "type": "int" + }, + "geoFk": { + "type": "int" + }, + "userFk": { + "type": "int" + }, + "action": { + "type": "string" + } + }, + "relations": { + "zone": { + "type": "belongsTo", + "model": "Zone", + "foreignKey": "zoneFk" + }, + "geo": { + "type": "belongsTo", + "model": "ZoneGeo", + "foreignKey": "geoFk" + }, + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + } +} From 38a5337f680428b31ee63a6afb3276d01b28bd43 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Dec 2023 12:57:10 +0100 Subject: [PATCH 020/136] refs #5858 test: execute test --- .../methods/zone/specs/deleteZone.spec.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 968685fec..b5cdbba52 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -30,11 +30,59 @@ describe('zone deletezone()', () => { } }); + it('should NOT delete a zone if is included', async() => { + const tx = await models.Zone.beginTransaction({}); + let isIncluded = false; + try { + const options = {transaction: tx}; + const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}); + isIncluded = zoneIncluded.length > 0; + await models.Zone.deleteZone(ctx, zoneId, options); + } catch (e) { + expect(isIncluded).toBeTrue(); + expect(e).not.toBeNull(); + await tx.rollback(); + } + }); + + it('should NOT delete a zone if is included check', async() => { + const tx = await models.Zone.beginTransaction({}); + let isIncluded = false; + try { + const options = {transaction: tx}; + const zoneIncludedCheck = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}); + isIncluded = zoneIncludedCheck.length > 0; + await models.Zone.deleteZone(ctx, zoneId, options); + } catch (e) { + expect(isIncluded).toBeTrue(); + expect(e).not.toBeNull(); + await tx.rollback(); + } + }); + it('should delete a zone and update their tickets', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; + const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); + await models.ZoneIncluded.destroyById(zoneIncluded[0].id, options); + + const zoneIncludedDeleted = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); + + expect(zoneIncludedDeleted.length).toEqual(0); + const zoneIncludedCheck = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}, options); + + expect(zoneIncludedCheck.length).toEqual(2); + // Insert + await models.ZoneIncludedCheck.destroyById(zoneIncludedCheck[0].id, options); + // Delete + await models.ZoneIncludedCheck.destroyById(zoneIncludedCheck[1].id, options); + + const zoneIncludedCheckDeleted = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}, options); + + expect(zoneIncludedCheckDeleted.length).toEqual(0); + await models.Zone.deleteZone(ctx, zoneId, options); const updatedZone = await models.Zone.findById(zoneId, null, options); From c8b156771d39f9893ca84093f547464f60adcd1b Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 9 Feb 2024 14:00:16 +0100 Subject: [PATCH 021/136] feat: refs #6395 Added buyerFk in buy --- db/routines/vn/triggers/buy_beforeInsert.sql | 1 + db/routines/vn/triggers/buy_beforeUpdate.sql | 4 ++++ db/versions/10880-salmonHydrangea/00-firstScript.sql | 1 + 3 files changed, 6 insertions(+) create mode 100644 db/versions/10880-salmonHydrangea/00-firstScript.sql diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index c88bef05a..c698e23e6 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -19,6 +19,7 @@ trig: BEGIN END IF; SET NEW.editorFk = account.myUser_getId(); + SET NEW.buyerFk = NEW.editorFk; CALL buy_checkGrouping(NEW.`grouping`); diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index fc03c456f..b41418bcc 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -65,6 +65,10 @@ trig:BEGIN SET NEW.isIgnored = TRUE; END IF; + IF NOT (NEW.itemFk <=> OLD.itemFk) THEN + SET NEW.buyerFk = NEW.editorFk; + END IF; + IF NOT (NEW.itemFk <=> OLD.itemFk) OR NOT (OLD.entryFk <=> NEW.entryFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck diff --git a/db/versions/10880-salmonHydrangea/00-firstScript.sql b/db/versions/10880-salmonHydrangea/00-firstScript.sql new file mode 100644 index 000000000..934fc2020 --- /dev/null +++ b/db/versions/10880-salmonHydrangea/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.buy ADD buyerFk int(10) unsigned DEFAULT NULL NULL; From 995a99c66131127021c96f3a3fe5ca1c96423e0a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 08:53:55 +0100 Subject: [PATCH 022/136] refs #5858 feat: removeZoneIncludedCheck --- .../methods/zone/specs/deleteZone.spec.js | 15 ------- modules/zone/back/model-config.json | 7 +-- .../zone/back/models/zone-included-check.json | 44 ------------------- 3 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 modules/zone/back/models/zone-included-check.json diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index b5cdbba52..e105bb296 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -47,14 +47,10 @@ describe('zone deletezone()', () => { it('should NOT delete a zone if is included check', async() => { const tx = await models.Zone.beginTransaction({}); - let isIncluded = false; try { const options = {transaction: tx}; - const zoneIncludedCheck = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}); - isIncluded = zoneIncludedCheck.length > 0; await models.Zone.deleteZone(ctx, zoneId, options); } catch (e) { - expect(isIncluded).toBeTrue(); expect(e).not.toBeNull(); await tx.rollback(); } @@ -71,17 +67,6 @@ describe('zone deletezone()', () => { const zoneIncludedDeleted = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); expect(zoneIncludedDeleted.length).toEqual(0); - const zoneIncludedCheck = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}, options); - - expect(zoneIncludedCheck.length).toEqual(2); - // Insert - await models.ZoneIncludedCheck.destroyById(zoneIncludedCheck[0].id, options); - // Delete - await models.ZoneIncludedCheck.destroyById(zoneIncludedCheck[1].id, options); - - const zoneIncludedCheckDeleted = await models.ZoneIncludedCheck.find({where: {zoneFk: zoneId}}, options); - - expect(zoneIncludedCheckDeleted.length).toEqual(0); await models.Zone.deleteZone(ctx, zoneId, options); diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 72c755978..3bbbe0d1b 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -3,10 +3,10 @@ "dataSource": "vn" }, "AgencyMode": { - "dataSource": "vn" + "dataSource": "vn" }, "DeliveryMethod": { - "dataSource": "vn" + "dataSource": "vn" }, "Zone": { "dataSource": "vn" @@ -32,9 +32,6 @@ "ZoneIncluded": { "dataSource": "vn" }, - "ZoneIncludedCheck": { - "dataSource": "vn" - }, "ZoneWarehouse": { "dataSource": "vn" }, diff --git a/modules/zone/back/models/zone-included-check.json b/modules/zone/back/models/zone-included-check.json deleted file mode 100644 index 8affee92c..000000000 --- a/modules/zone/back/models/zone-included-check.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "ZoneIncludedCheck", - "base": "Loggable", - "options": { - "mysql": { - "table": "zoneIncludedCheck" - } - }, - "properties": { - "id": { - "id": true, - "type": "number" - }, - "zoneFk": { - "type": "int" - }, - "geoFk": { - "type": "int" - }, - "userFk": { - "type": "int" - }, - "action": { - "type": "string" - } - }, - "relations": { - "zone": { - "type": "belongsTo", - "model": "Zone", - "foreignKey": "zoneFk" - }, - "geo": { - "type": "belongsTo", - "model": "ZoneGeo", - "foreignKey": "geoFk" - }, - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - } -} From 4799151565b3488e255e41e9def118b97757d759 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:12:17 +0100 Subject: [PATCH 023/136] refs #5858 feat: fixtures.before.sql --- db/dump/fixtures.before.sql | 9397 ++++++++++------------------------- 1 file changed, 2654 insertions(+), 6743 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index be288588e..8a6bd85fd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -7,7152 +7,3063 @@ SET foreign_key_checks = 0; DROP ROLE 'salix'; - CREATE ROLE 'salix'; - -GRANT 'salix' TO 'root' @'%'; - -SET DEFAULT ROLE 'salix' FOR 'root' @'%'; +GRANT 'salix' TO 'root'@'%'; +SET DEFAULT ROLE 'salix' FOR 'root'@'%'; CREATE SCHEMA IF NOT EXISTS `vn2008`; - CREATE SCHEMA IF NOT EXISTS `tmp`; -UPDATE `util`.`config` SET `environment` = 'development'; +UPDATE `util`.`config` + SET `environment`= 'development'; -- FOR MOCK vn.time DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`; DELIMITER $$ - $$ - -CREATE DEFINER =`root`@`localhost` PROCEDURE `vn`.`mockVnTime` -() +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mockVnTime`() BEGIN -DECLARE - vDate DATE; + + DECLARE vDate DATE; SET vDate = '2000-01-01'; - WHILE (YEAR(vDate) < = 2002) DO - INSERT IGNORE INTO - vn.`time` ( - dated, period, `month`, `year`, `day`, week, yearMonth, salesYear - ) - VALUES ( - vDate, CONCAT( - YEAR(vDate), (WEEK(vDate) + 1) - ), MONTH(vDate), YEAR(vDate), DAY(vDate), WEEK(vDate) + 1, CONCAT(YEAR(vDate), MONTH(vDate)), YEAR(vDate) - ); - SET vDate = DATE_ADD(vDate, INTERVAL 1 DAY); -END - WHILE; + + WHILE ( YEAR(vDate) <= 2002 ) DO + INSERT IGNORE INTO vn.`time` (dated, period, `month`, `year`, `day`, week, yearMonth, salesYear) + VALUES (vDate, CONCAT(YEAR(vDate), (WEEK(vDate)+1)), MONTH(vDate), YEAR(vDate), DAY(vDate), WEEK(vDate)+1, CONCAT(YEAR(vDate), MONTH(vDate)), YEAR(vDate)); + + SET vDate = DATE_ADD(vDate, INTERVAL 1 DAY); + END WHILE; + END$$ +DELIMITER ; -DELIMITER; - -CALL `vn`.`mockVnTime` (); - +CALL `vn`.`mockVnTime`(); DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`; -- END MOCK vn.time ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; - ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; - ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; - ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; -INSERT INTO - `salix`.`AccessToken` ( - `id`, `ttl`, `created`, `userId` - ) -VALUES ( - 'DEFAULT_TOKEN', '1209600', CURDATE(), 66 - ); +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES + ('DEFAULT_TOKEN', '1209600', CURDATE(), 66); -INSERT INTO - `salix`.`printConfig` ( - `id`, `itRecipient`, `incidencesEmail` - ) -VALUES ( - 1, 'it@gotamcity.com', 'incidences@gotamcity.com' - ); +INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) + VALUES + (1, 'it@gotamcity.com', 'incidences@gotamcity.com'); -INSERT INTO - `vn`.`ticketConfig` (`id`, `scopeDays`) -VALUES ('1', '6'); +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) + VALUES + ('1', '6'); -INSERT INTO - `vn`.`bionicConfig` ( - `generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox` - ) -VALUES (1.30, 167.00, 138000, 71); +INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) + VALUES + (1.30, 167.00, 138000, 71); -INSERT INTO - `vn`.`chatConfig` (`host`, `api`) -VALUES ( - 'https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1' - ); +INSERT INTO `vn`.`chatConfig` (`host`, `api`) + VALUES + ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); -INSERT IGNORE INTO - `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) -VALUES ('1', '11'); +INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) + VALUES + ('1', '11'); UPDATE `account`.`role` SET id = 100 WHERE id = 0; -INSERT INTO - `account`.`roleConfig` ( - `id`, `mysqlPassword`, `rolePrefix`, `userPrefix`, `userHost`, `tplUser` - ) -VALUES ( - 1, 'mysqlPassword', '$', '!', '%', 'any' - ); +INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPrefix`, `userHost`, `tplUser`) + VALUES + (1, 'mysqlPassword', '$', '!', '%', 'any'); CALL `account`.`role_sync`; -INSERT INTO - `account`.`user` ( - `id`, `name`, `nickname`, `role`, `active`, `email`, `lang`, `image`, `password` - ) -SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' -FROM `account`.`role` -ORDER BY id; +INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `role`,`active`,`email`, `lang`, `image`, `password`) + SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' + FROM `account`.`role` + ORDER BY id; -INSERT INTO - `account`.`account` (`id`) -SELECT `u`.`id` -FROM `account`.`user` `u` - JOIN `account`.`role` `r` ON `u`.`role` = `r`.`id` -WHERE - `r`.`name` <> 'customer'; +INSERT INTO `account`.`account`(`id`) + SELECT `u`.`id` + FROM `account`.`user` `u` + JOIN `account`.`role` `r` ON `u`.`role` = `r`.`id` + WHERE `r`.`name` <> 'customer'; -INSERT INTO - `vn`.`educationLevel` (`id`, `name`) -VALUES ( - 1, 'ESTUDIOS PRIMARIOS COMPLETOS' - ), - ( - 2, 'ENSEÑANZAS DE BACHILLERATO' - ); +INSERT INTO `vn`.`educationLevel` (`id`, `name`) + VALUES + (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), + (2, 'ENSEÑANZAS DE BACHILLERATO'); -INSERT INTO - `vn`.`worker` ( - `id`, `code`, `firstName`, `lastName`, `bossFk` - ) -SELECT id, UPPER(LPAD(role, 3, '0')), name, name, NULL -FROM `account`.`user` -WHERE - `id` = 9; +INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`) + SELECT id,UPPER(LPAD(role, 3, '0')), name, name, NULL + FROM `account`.`user` + WHERE `id` = 9; -INSERT INTO - `vn`.`worker` ( - `id`, `code`, `firstName`, `lastName`, `bossFk` - ) -SELECT id, UPPER(LPAD(role, 3, '0')), name, name, 9 -FROM `account`.`user` -WHERE - `id` <> 9; +INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`) + SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9 + FROM `account`.`user` + WHERE `id` <> 9; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; - UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; - UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18; -DELETE FROM `vn`.`worker` WHERE firstName = 'customer'; +DELETE FROM `vn`.`worker` WHERE firstName ='customer'; -INSERT INTO - `hedera`.`tpvConfig` ( - `id`, `currency`, `terminal`, `transactionType`, `maxAmount`, `employeeFk`, `testUrl` - ) -VALUES (1, 978, 1, 0, 2000, 9, 0); +INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`, `maxAmount`, `employeeFk`, `testUrl`) + VALUES + (1, 978, 1, 0, 2000, 9, 0); -INSERT INTO - `account`.`user` ( - `id`, `name`, `nickname`, `password`, `role`, `active`, `email`, `lang`, `image` - ) -VALUES ( - 1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29' - ), - ( - 1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL - ), - ( - 1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL - ), - ( - 1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL - ); +INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) + VALUES + (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL), + (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL), + (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL); UPDATE account.`user` -SET - passExpired = DATE_SUB( - util.VN_CURDATE (), INTERVAL 1 YEAR - ) -WHERE - name = 'maintenance'; + SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR) + WHERE name = 'maintenance'; -INSERT INTO - `account`.`mailAlias` ( - `id`, `alias`, `description`, `isPublic` - ) -VALUES ( - 1, 'general', 'General mailing list', FALSE - ), - ( - 2, 'it', 'IT department', TRUE - ), - ( - 3, 'sales', 'Sales department', TRUE - ); +INSERT INTO `account`.`mailAlias`(`id`, `alias`, `description`, `isPublic`) + VALUES + (1, 'general', 'General mailing list', FALSE), + (2, 'it' , 'IT department' , TRUE), + (3, 'sales' , 'Sales department' , TRUE); -INSERT INTO - `account`.`mailAliasAccount` (`mailAlias`, `account`) -VALUES (1, 1), - (1, 18), - (3, 18), - (1, 9), - (2, 9); +INSERT INTO `account`.`mailAliasAccount`(`mailAlias`, `account`) + VALUES + (1, 1), + (1, 18), + (3, 18), + (1, 9), + (2, 9); -INSERT INTO - `account`.`mailForward` (`account`, `forwardTo`) -VALUES (1, 'employee@domain.local'); +INSERT INTO `account`.`mailForward`(`account`, `forwardTo`) + VALUES + (1, 'employee@domain.local'); -INSERT INTO - `vn`.`currency` (`id`, `code`, `name`, `ratio`) -VALUES (1, 'EUR', 'Euro', 1), - (2, 'USD', 'Dollar USA', 1.4), - (3, 'GBP', 'Libra', 1), - (4, 'JPY', 'Yen Japones', 1); -INSERT INTO - `vn`.`country` ( - `id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE` - ) -VALUES ( - 1, 'España', 1, 'ES', 1, 24, 4, 0, 1 - ), - ( - 2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1 - ), - ( - 3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1 - ), - ( - 4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1 - ), - ( - 5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1 - ), - ( - 8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1 - ), - ( - 13, 'Ecuador', 0, 'EC', 1, 24, 2, 1, 2 - ), - ( - 19, 'Francia', 1, 'FR', 1, 27, 4, 0, 1 - ), - ( - 30, 'Canarias', 1, 'IC', 1, 24, 4, 1, 2 - ); -INSERT INTO - `vn`.`warehouse` ( - `id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny` - ) -VALUES ( - 1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ), - ( - 2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0 - ), - ( - 3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0 - ), - ( - 4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1 - ), - ( - 5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0 - ), - ( - 13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0 - ), - ( - 60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0 - ); +INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) + VALUES + (1, 'EUR', 'Euro', 1), + (2, 'USD', 'Dollar USA', 1.4), + (3, 'GBP', 'Libra', 1), + (4, 'JPY', 'Yen Japones', 1); -INSERT INTO `vn`.`sectorType` (`id`, `code`) VALUES (1, 'normal'); +INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) + VALUES + (1, 'España', 1, 'ES', 1, 24, 4, 0, 1), + (2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1), + (3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1), + (4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1), + (5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1), + (8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1), + (13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2), + (19,'Francia', 1, 'FR', 1, 27, 4, 0, 1), + (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2); -INSERT INTO - `vn`.`sector` ( - `id`, `description`, `warehouseFk`, `code`, `typeFk` - ) -VALUES ( - 1, 'First sector', 1, 'FIRST', 1 - ), - ( - 2, 'Second sector', 2, 'SECOND', 1 - ); +INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`) + VALUES + (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), + (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0), + (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), + (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), + (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), + (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), + (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); -INSERT INTO - `vn`.`printer` ( - `id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress` - ) -VALUES ( - 1, 'printer1', 'path1', 0, 1, NULL - ), - ( - 2, 'printer2', 'path2', 1, 1, NULL - ), - ( - 4, 'printer4', 'path4', 0, NULL, '10.1.10.4' - ); +INSERT INTO `vn`.`sectorType` (`id`, `code`) + VALUES (1,'normal'); + +INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`, `typeFk`) + VALUES + (1, 'First sector', 1, 'FIRST', 1), + (2, 'Second sector', 2, 'SECOND',1); + +INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`) + VALUES + (1, 'printer1', 'path1', 0, 1 , NULL), + (2, 'printer2', 'path2', 1, 1 , NULL), + (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; -INSERT INTO - `vn`.`worker` ( - `id`, `code`, `firstName`, `lastName`, `bossFk`, `phone` - ) -VALUES ( - 1106, 'LGN', 'David Charles', 'Haller', 19, 432978106 - ), - ( - 1107, 'ANT', 'Hank', 'Pym', 19, 432978107 - ), - ( - 1108, 'DCX', 'Charles', 'Xavier', 19, 432978108 - ), - ( - 1109, 'HLK', 'Bruce', 'Banner', 19, 432978109 - ), - ( - 1110, 'JJJ', 'Jessica', 'Jones', 19, 432978110 - ); -INSERT INTO - `vn`.`parking` ( - `id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder` - ) -VALUES ( - '1', 700, '01', 1, '700-01', 70001 - ), - ( - '2', 700, '02', 2, '700-02', 70002 - ), - ( - '3', 100, '01', 1, '100-01', 1 - ), - ( - 32397, 100, '02', 1, 'A-47-1', 1165 - ), - ( - 34831, 200, '01', 1, 'K-26-2', 20220 - ), - ( - 34965, 200, '02', 2, 'L-08-4', 21800 - ), - ( - 39096, 200, '03', 2, 'LR-02-3', 99999 - ); +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) + VALUES + (1106, 'LGN', 'David Charles', 'Haller', 19, 432978106), + (1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107), + (1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108), + (1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109), + (1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110); -INSERT INTO - `vn`.`shelving` ( - `code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable` - ) -VALUES ('AA6', 34965, 1, 0, NULL, 0), - ('AA7', 34965, 1, 0, NULL, 0), - ('AA8', 34965, 1, 0, NULL, 0), - ('AA9', NULL, 1, 0, NULL, 0), - ('AAA', NULL, 0, 0, 1109, 1), - ('AAB', NULL, 0, 0, 1109, 1), - ('AAC', NULL, 1, 99, 1109, 1), - ('AAD', NULL, 0, 0, 1109, 1), - ('AAE', 39096, 1, 0, 1109, 1), - ('AAF', 34831, 1, 0, 1109, 1), - ('GVC', 1, 0, 1, 1106, 1), - ('HEJ', 2, 0, 1, 1106, 1), - ('UXN', 1, 0, 1, 1106, 1); +INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES + ('1', 700, '01', 1, '700-01', 70001), + ('2', 700, '02', 2, '700-02', 70002), + ('3', 100, '01', 1, '100-01', 1), + (32397, 100, '02', 1, 'A-47-1', 1165), + (34831, 200, '01', 1, 'K-26-2', 20220), + (34965, 200, '02', 2, 'L-08-4', 21800), + (39096, 200, '03', 2, 'LR-02-3', 99999); -INSERT INTO - `vn`.`accountingType` ( - `id`, `description`, `receiptDescription`, `code`, `maxAmount`, `daysInFuture` - ) -VALUES ( - 1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1 - ), - ( - 2, 'Cash', 'Cash', 'cash', 1000, 0 - ), - ( - 3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0 - ), - ( - 4, 'Finalcial lines', NULL, NULL, NULL, 0 - ), - ( - 5, 'Other products', NULL, NULL, NULL, 0 - ), - ( - 6, 'Loans', NULL, NULL, NULL, 0 - ), - ( - 7, 'Leasing', NULL, NULL, NULL, 0 - ), - ( - 8, 'Compensations', 'Compensations', 'compensation', NULL, 0 - ); +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) + VALUES + ('AA6', 34965, 1, 0, NULL, 0), + ('AA7', 34965, 1, 0, NULL, 0), + ('AA8', 34965, 1, 0, NULL, 0), + ('AA9', NULL, 1, 0, NULL, 0), + ('AAA', NULL, 0, 0, 1109, 1), + ('AAB', NULL, 0, 0, 1109, 1), + ('AAC', NULL, 1, 99, 1109, 1), + ('AAD', NULL, 0, 0, 1109, 1), + ('AAE', 39096, 1, 0, 1109, 1), + ('AAF', 34831, 1, 0, 1109, 1), + ('GVC', 1, 0, 1, 1106, 1), + ('HEJ', 2, 0, 1, 1106, 1), + ('UXN', 1, 0, 1, 1106, 1); -INSERT INTO - `vn`.`bankEntity` ( - `id`, `countryFk`, `name`, `bic` - ) -VALUES ( - 128, 1, 'The Best Bank', 'BBKKESMMMMMM' - ), - ( - 2100, 1, 'Caixa Bank', 'CAIXESBB' - ); +INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) + VALUES + (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), + (2, 'Cash', 'Cash', 'cash', 1000, 0), + (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), + (4, 'Finalcial lines', NULL, NULL, NULL, 0), + (5, 'Other products', NULL, NULL, NULL, 0), + (6, 'Loans', NULL, NULL, NULL, 0), + (7, 'Leasing', NULL, NULL, NULL, 0), + (8, 'Compensations', 'Compensations', 'compensation', NULL, 0); -INSERT INTO - `vn`.`accounting` ( - `id`, `bank`, `account`, `accountingTypeFk`, `entityFk`, `isActive`, `currencyFk`, `code` - ) -VALUES ( - 1, 'Pay on receipt', '5720000001', 3, 128, 1, 1, 'payOnReceipt' - ), - ( - 2, 'Cash', '5700000001', 2, 128, 1, 1, 'cash' - ), - ( - 3, 'Compensation', '4000000000', 8, 128, 1, 1, 'compensation' - ), - ( - 4, 'Transfers', '4000000001', 1, 128, 1, 1, 'transfers' - ), - ( - 3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 2100, 1, 1, 'cra' - ); +INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) + VALUES + (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), + (2100, 1, 'Caixa Bank', 'CAIXESBB'); -INSERT INTO - `vn`.`deliveryMethod` (`id`, `code`, `description`) -VALUES (1, 'AGENCY', 'Agencia'), - (2, 'DELIVERY', 'Reparto'), - (3, 'PICKUP', 'Recogida'), - (4, 'OTHER', 'Otros'); +INSERT INTO `vn`.`accounting`(`id`, `bank`, `account`, `accountingTypeFk`, `entityFk`, `isActive`, `currencyFk`, `code`) + VALUES + (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1, 'payOnReceipt'), + (2, 'Cash', '5700000001', 2, 128, 1, 1, 'cash'), + (3, 'Compensation', '4000000000', 8, 128, 1, 1, 'compensation'), + (4, 'Transfers', '4000000001', 1, 128, 1, 1, 'transfers'), + (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 2100, 1, 1, 'cra'); -INSERT INTO - `vn`.`agency` (`id`, `name`, `warehouseFk`) -VALUES (1, 'inhouse pickup', 1), - (2, 'Super-Man delivery', 1), - (3, 'Teleportation device', 1), - (4, 'Entanglement', 1), - (5, 'Quantum break device', 1), - (6, 'Walking', 1), - (7, 'Gotham247', 1), - (8, 'Gotham247Expensive', 1), - (9, 'Refund', 1), - (10, 'Other agency', 1); +INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`) + VALUES + (1, 'AGENCY', 'Agencia'), + (2, 'DELIVERY', 'Reparto'), + (3, 'PICKUP', 'Recogida'), + (4, 'OTHER', 'Otros'); -UPDATE `vn`.`agencyMode` -SET - `id` = 1 -WHERE - `name` = 'inhouse pickup'; - -UPDATE `vn`.`agencyMode` -SET - `id` = 2 -WHERE - `name` = 'Super-Man delivery'; - -UPDATE `vn`.`agencyMode` -SET - `id` = 3 -WHERE - `name` = 'Teleportation device'; +INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`) + VALUES + (1, 'inhouse pickup' , 1), + (2, 'Super-Man delivery' , 1), + (3, 'Teleportation device' , 1), + (4, 'Entanglement' , 1), + (5, 'Quantum break device' , 1), + (6, 'Walking' , 1), + (7, 'Gotham247' , 1), + (8, 'Gotham247Expensive' , 1), + (9, 'Refund' , 1), + (10, 'Other agency' , 1); +UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup'; +UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery'; +UPDATE `vn`.`agencyMode` SET `id` = 3 WHERE `name` = 'Teleportation device'; UPDATE `vn`.`agencyMode` SET `id` = 4 WHERE `name` = 'Entanglement'; - -UPDATE `vn`.`agencyMode` -SET - `id` = 5 -WHERE - `name` = 'Quantum break device'; - +UPDATE `vn`.`agencyMode` SET `id` = 5 WHERE `name` = 'Quantum break device'; UPDATE `vn`.`agencyMode` SET `id` = 6 WHERE `name` = 'Walking'; - UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Gotham247'; - -UPDATE `vn`.`agencyMode` -SET - `id` = 8 -WHERE - `name` = 'Gotham247Expensive'; - +UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Gotham247Expensive'; UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'Refund'; - UPDATE `vn`.`agencyMode` SET `id` = 10 WHERE `name` = 'Other agency'; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 3 WHERE `id` = 1; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 2; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 2 WHERE `id` = 3; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 4; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 5; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 2 WHERE `id` = 6; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 7; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23; - UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10; -UPDATE `vn`.`agencyMode` -SET - `web` = 1, - `reportMail` = 'no-reply@gothamcity.com'; +UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'; -UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; +UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; -INSERT INTO - `vn`.`payMethod` ( - `id`, `code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified` - ) -VALUES ( - 1, NULL, 'PayMethod one', 0, 001, 0, 0, 0 - ), - ( - 2, NULL, 'PayMethod two', 10, 001, 0, 0, 1 - ), - ( - 3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0 - ), - ( - 4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0, 0 - ), - ( - 5, NULL, 'PayMethod five', 10, 001, 0, 0, 0 - ), - ( - 8, 'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0 - ); +INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) + VALUES + (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), + (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), + (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), + (4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0, 0), + (5, NULL, 'PayMethod five', 10, 001, 0, 0, 0), + (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); -INSERT INTO - `vn`.`payDem` (`id`, `payDem`) -VALUES (1, 10), - (2, 20), - (7, 0); +INSERT INTO `vn`.`payDem`(`id`, `payDem`) + VALUES + (1, 10), + (2, 20), + (7, 0); -INSERT INTO - `vn`.`autonomy` (`id`, `name`, `countryFk`) -VALUES (1, 'Autonomy one', 1), - (2, 'Autonomy two', 1), - (3, 'Autonomy three', 2), - (4, 'Autonomy four', 13); +INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`) + VALUES + (1, 'Autonomy one', 1), + (2, 'Autonomy two', 1), + (3, 'Autonomy three', 2), + (4, 'Autonomy four', 13); -INSERT INTO - `vn`.`province` ( - `id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk` - ) -VALUES (1, 'Province one', 1, 1, NULL), - (2, 'Province two', 1, 1, NULL), - ( - 3, 'Province three', 30, 2, NULL - ), - ( - 4, 'Province four', 2, 3, NULL - ), - ( - 5, 'Province five', 13, 4, NULL - ); -INSERT INTO - `vn`.`town` (`id`, `name`, `provinceFk`) -VALUES (1, 'Valencia', 1), - (2, 'Gotham', 1), - (3, 'Algemesi', 1), - (4, 'Alzira', 1), - (5, 'Quito', 5); +INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk`) + VALUES + (1, 'Province one', 1, 1, NULL), + (2, 'Province two', 1, 1, NULL), + (3, 'Province three', 30, 2, NULL), + (4, 'Province four', 2, 3, NULL), + (5, 'Province five', 13, 4, NULL); -INSERT INTO - `vn`.`postCode` (`code`, `townFk`, `geoFk`) -VALUES ('46000', 1, 6), - ('46460', 2, 6), - ('46680', 3, 6), - ('46600', 4, 7), - ('EC170150', 5, 8); +INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) + VALUES + (1, 'Valencia', 1), + (2, 'Gotham', 1), + (3, 'Algemesi', 1), + (4, 'Alzira', 1), + (5, 'Quito', 5); -INSERT INTO - `vn`.`clientType` (`id`, `code`, `type`) -VALUES (1, 'normal', 'Normal'), - ( - 2, 'internalUse', 'Autoconsumo' - ), - (3, 'handMaking', 'Confección'), - (4, 'loses', 'Mermas'); +INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) + VALUES + ('46000', 1, 6), + ('46460', 2, 6), + ('46680', 3, 6), + ('46600', 4, 7), + ('EC170150', 5, 8); -INSERT INTO - `vn`.`cplusTerIdNif` (`id`, `description`) -VALUES (1, 'NIF'); +INSERT INTO `vn`.`clientType`(`id`, `code`, `type`) + VALUES + (1, 'normal', 'Normal'), + (2, 'internalUse', 'Autoconsumo'), + (3, 'handMaking', 'Confección'), + (4, 'loses', 'Mermas'); -INSERT INTO - `vn`.`contactChannel` (`id`, `name`) -VALUES (1, 'Rumors on the streets'), - (2, 'Metropolis newspaper'), - (3, 'Daily Bugle'), - (4, 'GCN Channel'), - (5, 'The Newspaper'); +INSERT INTO `vn`.`cplusTerIdNif`(`id`, `description`) + VALUES + (1, 'NIF'); -INSERT INTO - `vn`.`client` ( - `id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `phone`, `mobile`, `isRelevant`, `email`, `iban`, `dueDay`, `accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`, `created`, `isToBeMailed`, `contactChannelFk`, `hasSepaVnl`, `hasCoreVnl`, `hasCoreVnh`, `riskCalculated`, `clientTypeFk`, `hasToInvoiceByAddress`, `isTaxDataChecked`, `isFreezed`, `creditInsurance`, `isCreatedAsServed`, `hasInvoiceSimplified`, `salesPersonFk`, `isVies`, `eypbc`, `businessTypeFk`, `typeFk` - ) -VALUES ( - 1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist', 'normal' - ), - ( - 1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist', 'normal' - ), - ( - 1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist', 'normal' - ), - ( - 1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist', 'normal' - ), - ( - 1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist', 'normal' - ), - ( - 1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist', 'normal' - ), - ( - 1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist', 'normal' - ), - ( - 1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist', 'normal' - ), - ( - 1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist', 'normal' - ), - ( - 1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist', 'normal' - ), - ( - 1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others', 'loses' - ), - ( - 1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE (), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others', 'loses' - ); +INSERT INTO `vn`.`contactChannel`(`id`, `name`) + VALUES + (1, 'Rumors on the streets'), + (2, 'Metropolis newspaper'), + (3, 'Daily Bugle'), + (4, 'GCN Channel'), + (5, 'The Newspaper'); -INSERT INTO - `vn`.`client` ( - `id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`, `dueDay`, `accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`, `created`, `isTaxDataChecked` - ) -SELECT - id, - name, - CONCAT( - RPAD(CONCAT(id, 9), 8, id), 'A' - ), - CONCAT(name, 'Social'), - CONCAT(name, 'Contact'), - CONCAT(name, 'Street'), - 'GOTHAM', - 46460, - 1, - CONCAT(name, '@mydomain.com'), - NULL, - 0, - 1234567890, - 0, - 1, - 1, - 300, - 1, - 1, - NULL, - 10, - 5, - util.VN_CURDATE (), - 1 -FROM `account`.`role` `r` -WHERE - `r`.`hasLogin` = 1; +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`) + VALUES + (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'), + (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'), + (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'), + (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'); -INSERT INTO - `vn`.`clientManaCache` (`clientFk`, `mana`, `dated`) -VALUES ( - 1101, 50, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 1102, 100, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 1103, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 1104, -30, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ); +INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 + FROM `account`.`role` `r` + WHERE `r`.`hasLogin` = 1; -INSERT INTO - `vn`.`mandateType` (`id`, `name`) -VALUES (1, 'B2B'), - (2, 'CORE'), - (3, 'LCR'); +INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) + VALUES + (1101, 50, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1102, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); -INSERT INTO - `vn`.`clientConfig` ( - `id`, `riskTolerance`, `maxCreditRows`, `maxPriceIncreasingRatio`, `riskScope`, `defaultPayMethodFk`, `defaultDueDay`, `defaultCredit`, `defaultIsTaxDataChecked`, `defaultHasCoreVnl`, `defaultMandateTypeFk` - ) -VALUES ( - 1, 200, 10, 0.25, 2, 4, 5, 300.00, 1, 1, 2 - ); +INSERT INTO `vn`.`mandateType`(`id`, `name`) + VALUES + (1, 'B2B'), + (2, 'CORE'), + (3, 'LCR'); -INSERT INTO - `vn`.`address` ( - `id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress` - ) -VALUES ( - 1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1 - ), - ( - 2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1 - ), - ( - 3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1 - ), - ( - 4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1 - ), - ( - 5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1 - ), - ( - 6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1 - ), - ( - 7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1 - ), - ( - 8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1 - ), - ( - 9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1 - ), - ( - 10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1 - ), - ( - 11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1 - ), - ( - 12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1 - ), - ( - 101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0 - ), - ( - 121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0 - ), - ( - 122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0 - ), - ( - 123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0 - ), - ( - 124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0 - ), - ( - 125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0 - ), - ( - 126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0 - ), - ( - 127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0 - ), - ( - 128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0 - ), - ( - 129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0 - ), - ( - 130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0 - ); +INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPriceIncreasingRatio`, `riskScope`, `defaultPayMethodFk`, `defaultDueDay`, `defaultCredit`, `defaultIsTaxDataChecked`, `defaultHasCoreVnl`, `defaultMandateTypeFk`) + VALUES + (1, 200, 10, 0.25, 2, 4, 5, 300.00, 1, 1, 2); -INSERT INTO - `vn`.`address` ( - `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress` - ) -SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1 -FROM `account`.`role` `r` -WHERE - `r`.`hasLogin` = 1; + +INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) + VALUES + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), + (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), + (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1), + (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), + (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), + (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), + (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1), + (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1), + (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1), + (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1), + (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1), + (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), + (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), + (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), + (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), + (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), + (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), + (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0), + (128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0), + (129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0), + (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0); + +INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`) + SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1 + FROM `account`.`role` `r` + WHERE `r`.`hasLogin` = 1; UPDATE `vn`.`client` SET defaultAddressFk = 1 WHERE id = 1101; - UPDATE `vn`.`client` SET defaultAddressFk = 2 WHERE id = 1102; - UPDATE `vn`.`client` SET defaultAddressFk = 3 WHERE id = 1103; - UPDATE `vn`.`client` SET defaultAddressFk = 4 WHERE id = 1104; - UPDATE `vn`.`client` SET defaultAddressFk = 5 WHERE id = 1105; - UPDATE `vn`.`client` SET defaultAddressFk = 6 WHERE id = 1106; - UPDATE `vn`.`client` SET defaultAddressFk = 7 WHERE id = 1107; - UPDATE `vn`.`client` SET defaultAddressFk = 8 WHERE id = 1108; - UPDATE `vn`.`client` SET defaultAddressFk = 9 WHERE id = 1109; - UPDATE `vn`.`client` SET defaultAddressFk = 10 WHERE id = 1110; - UPDATE `vn`.`client` SET defaultAddressFk = 11 WHERE id = 200; - UPDATE `vn`.`client` SET defaultAddressFk = 12 WHERE id = 400; DROP TEMPORARY TABLE IF EXISTS tmp.address; -CREATE TEMPORARY TABLE tmp.address SELECT * FROM `vn`.`address`; - -UPDATE `vn`.`client` `c` -JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id` -SET - `c`.`defaultAddressFk` = `a`.`id` -WHERE - `defaultAddressFk` IS NULL; +CREATE TEMPORARY TABLE tmp.address + SELECT * FROM `vn`.`address`; + UPDATE `vn`.`client` `c` + JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id` + SET `c`.`defaultAddressFk` = `a`.`id` + WHERE `defaultAddressFk` IS NULL; DROP TEMPORARY TABLE tmp.address; -INSERT INTO - `vn`.`clientCredit` ( - `clientFk`, `workerFk`, `amount`, `created` - ) -VALUES ( - 1101, 5, 300, DATE_ADD( - util.VN_CURDATE (), INTERVAL -11 MONTH - ) - ), - ( - 1101, 5, 900, DATE_ADD( - util.VN_CURDATE (), INTERVAL -10 MONTH - ) - ), - ( - 1101, 5, 800, DATE_ADD( - util.VN_CURDATE (), INTERVAL -9 MONTH - ) - ), - ( - 1101, 5, 700, DATE_ADD( - util.VN_CURDATE (), INTERVAL -8 MONTH - ) - ), - ( - 1101, 5, 600, DATE_ADD( - util.VN_CURDATE (), INTERVAL -7 MONTH - ) - ), - ( - 1101, 5, 500, DATE_ADD( - util.VN_CURDATE (), INTERVAL -6 MONTH - ) - ), - ( - 1101, 5, 400, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 MONTH - ) - ), - ( - 1101, 9, 300, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ) - ), - ( - 1101, 9, 200, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ) - ), - ( - 1101, 9, 100, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ) - ), - ( - 1101, 9, 50, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 1102, 9, 800, util.VN_CURDATE () - ), - ( - 1104, 9, 90, util.VN_CURDATE () - ), - ( - 1105, 9, 90, util.VN_CURDATE () - ); +INSERT INTO `vn`.`clientCredit`(`clientFk`, `workerFk`, `amount`, `created`) + VALUES + (1101, 5, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 MONTH)), + (1101, 5, 900, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 MONTH)), + (1101, 5, 800, DATE_ADD(util.VN_CURDATE(), INTERVAL -9 MONTH)), + (1101, 5, 700, DATE_ADD(util.VN_CURDATE(), INTERVAL -8 MONTH)), + (1101, 5, 600, DATE_ADD(util.VN_CURDATE(), INTERVAL -7 MONTH)), + (1101, 5, 500, DATE_ADD(util.VN_CURDATE(), INTERVAL -6 MONTH)), + (1101, 5, 400, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 MONTH)), + (1101, 9, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (1101, 9, 200, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (1101, 9, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (1101, 9, 50 , DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1102, 9, 800, util.VN_CURDATE()), + (1104, 9, 90 , util.VN_CURDATE()), + (1105, 9, 90 , util.VN_CURDATE()); -INSERT INTO - `vn`.`roleCreditLimit` (`id`, `maxAmount`, `roleFk`) -VALUES (1, 9999999, 20), - (2, 10000, 21), - (3, 600, 13); +INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`) + VALUES + (1, 9999999, 20), + (2, 10000, 21), + (3, 600, 13); -INSERT INTO - `vn`.`clientObservation` ( - `id`, `clientFk`, `workerFk`, `text`, `created` - ) -VALUES ( - 1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE () - ), - ( - 2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE () - ), - ( - 3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE () - ), - ( - 4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE () - ), - ( - 5, 1105, 5, 'They do understand. Our mutant powers make us superior', util.VN_CURDATE () - ), - ( - 6, 1106, 5, 'My name is Legion, for we are many!', util.VN_CURDATE () - ), - ( - 7, 1107, 9, 'I think our first move should be calling the Avengers..', util.VN_CURDATE () - ), - ( - 8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', util.VN_CURDATE () - ), - ( - 9, 1109, 18, 'HULK SMASH! ...', util.VN_CURDATE () - ), - ( - 10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', util.VN_CURDATE () - ); +INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`) + VALUES + (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE()), + (2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE()), + (3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE()), + (4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE()), + (5, 1105, 5, 'They do understand. Our mutant powers make us superior', util.VN_CURDATE()), + (6, 1106, 5, 'My name is Legion, for we are many!', util.VN_CURDATE()), + (7, 1107, 9, 'I think our first move should be calling the Avengers..', util.VN_CURDATE()), + (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', util.VN_CURDATE()), + (9, 1109, 18, 'HULK SMASH! ...', util.VN_CURDATE()), + (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', util.VN_CURDATE()); -INSERT INTO - `vn`.`observationType` (`id`, `description`, `code`) -VALUES (1, 'ItemPicker', 'itemPicker'), - (2, 'Packager', 'packager'), - (3, 'Delivery', 'delivery'), - ( - 4, 'SalesPerson', 'salesPerson' - ), - ( - 5, 'Administrative', 'administrative' - ), - (6, 'Weight', 'weight'), - (7, 'InvoiceOut', 'invoiceOut'); +INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) + VALUES + (1, 'ItemPicker', 'itemPicker'), + (2, 'Packager', 'packager'), + (3, 'Delivery', 'delivery'), + (4, 'SalesPerson', 'salesPerson'), + (5, 'Administrative', 'administrative'), + (6, 'Weight', 'weight'), + (7, 'InvoiceOut', 'invoiceOut'); -INSERT INTO - `vn`.`addressObservation` ( - `id`, `addressFk`, `observationTypeFk`, `description` - ) -VALUES (1, 121, 1, 'under the floor'), - ( - 2, 121, 2, 'wears leather and goes out at night' - ), - ( - 3, 121, 3, 'care with the dog' - ), - ( - 5, 122, 5, 'Delivery after 10am' - ); +INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) + VALUES + (1, 121, 1, 'under the floor'), + (2, 121, 2, 'wears leather and goes out at night'), + (3, 121, 3, 'care with the dog'), + (5, 122, 5, 'Delivery after 10am'); -INSERT INTO - `vn`.`creditClassification` ( - `id`, `client`, `dateStart`, `dateEnd` - ) -VALUES ( - 1, 1101, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 2, 1102, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 3, 1103, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 4, 1104, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 5, 1105, util.VN_CURDATE (), util.VN_CURDATE () - ); +INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`) + VALUES + (1, 1101, util.VN_CURDATE(), util.VN_CURDATE()), + (2, 1102, util.VN_CURDATE(), util.VN_CURDATE()), + (3, 1103, util.VN_CURDATE(), util.VN_CURDATE()), + (4, 1104, util.VN_CURDATE(), util.VN_CURDATE()), + (5, 1105, util.VN_CURDATE(), util.VN_CURDATE()); -INSERT INTO - `vn`.`creditInsurance` ( - `id`, `creditClassificationFk`, `credit`, `creationDate`, `grade` - ) -VALUES ( - 1, 1, 3000, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), NULL - ), - ( - 2, 2, 6000, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), NULL - ), - ( - 3, 3, 10000, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), NULL - ); +INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassificationFk`, `credit`, `creationDate`, `grade`) + VALUES + (1, 1, 3000, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL), + (2, 2, 6000, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL), + (3, 3, 10000, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL); -INSERT INTO - `vn`.`companyGroup` (`id`, `code`) -VALUES (1, 'wayneIndustries'), - (2, 'verdnatura'); +INSERT INTO `vn`.`companyGroup`(`id`, `code`) + VALUES + (1, 'wayneIndustries'), + (2, 'verdnatura'); -INSERT INTO - `vn`.`supplierActivity` (`code`, `name`) -VALUES ( - 'animals', 'Food and complements for pets' - ), - ( - 'complements', 'Other complements' - ), - ( - 'flowerPlants', 'Wholesale of flowers and plants' - ), - ( - 'vegetablesFruits', 'Fruit and vegetable trade' - ); +INSERT INTO `vn`.`supplierActivity`(`code`, `name`) + VALUES + ('animals', 'Food and complements for pets'), + ('complements', 'Other complements'), + ('flowerPlants', 'Wholesale of flowers and plants'), + ('vegetablesFruits', 'Fruit and vegetable trade'); -INSERT INTO - `vn`.`supplier` ( - `id`, `name`, `nickname`, `account`, `countryFk`, `nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister` - ) -VALUES ( - 1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE (), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V' - ), - ( - 2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE (), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V' - ), - ( - 69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE (), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V' - ), - ( - 442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE (), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V' - ), - ( - 567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE (), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V' - ), - ( - 791, 'BROS SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE (), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V' - ), - ( - 1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE (), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V' - ); +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) + VALUES + (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), + (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (791, 'BROS SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), + (1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); -INSERT INTO - `vn`.`supplierAddress` ( - `id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile` - ) -VALUES ( - 1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222' - ), - ( - 2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222' - ), - ( - 3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222' - ), - ( - 4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222' - ), - ( - 5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222' - ), - ( - 6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222' - ); +INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`) + VALUES + (1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'), + (2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'), + (3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'), + (4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'), + (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'), + (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'); -INSERT INTO - `vn`.`supplierContact` ( - `id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name` - ) -VALUES ( - 1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss' - ), - ( - 2, 1, 987456132, NULL, NULL, NULL, 'the salesperson' - ), - ( - 3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL - ), - ( - 4, 442, 321654987, NULL, NULL, 'observation442', NULL - ); +INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) + VALUES + (1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'), + (2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'), + (3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL), + (4, 442, 321654987, NULL, NULL, 'observation442', NULL); -INSERT INTO - `vn`.`supplierAccount` ( - `id`, `supplierFk`, `iban`, `bankEntityFk` - ) -VALUES ( - 241, 442, 'ES111122333344111122221111', 128 - ); +INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`) + VALUES + (241, 442, 'ES111122333344111122221111', 128); -INSERT INTO - `vn`.`company` ( - `id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary`, `clientFk` - ) -VALUES ( - 69, 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL, NULL - ), - ( - 442, 'VNL', 241, 30, 2, 1, NULL, 2, 'VNL Company - Plant passport', 1101 - ), - ( - 567, 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport', NULL - ), - ( - 791, 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL, NULL - ), - ( - 1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport', NULL - ); +INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`) + VALUES + (69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL), + (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101), + (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL), + (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL), + (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL); -INSERT INTO - `vn`.`taxArea` ( - `code`, `claveOperacionFactura`, `CodigoTransaccion` - ) -VALUES ('CEE', 1, 10), - ('EQU', 0, 1), - ('NATIONAL', 0, 1), - ('WORLD', 2, 15); +INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) + VALUES + ('CEE', 1, 10), + ('EQU', 0, 1), + ('NATIONAL', 0, 1), + ('WORLD', 2, 15); -INSERT INTO vn.invoiceOutConfig SET parallelism = 8; +INSERT INTO vn.invoiceOutConfig + SET parallelism = 8; -INSERT INTO - `vn`.`invoiceOutSerial` ( - `code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type` - ) -VALUES ( - 'A', 'Global nacional', 1, 'NATIONAL', 0, 'global' - ), - ( - 'T', 'Española rapida', 1, 'NATIONAL', 0, 'quick' - ), - ( - 'V', 'Intracomunitaria global', 0, 'CEE', 1, 'global' - ), - ( - 'M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick' - ), - ( - 'R', 'Rectificativa', 1, 'NATIONAL', 0, NULL - ), - ( - 'E', 'Exportación rápida', 0, 'WORLD', 0, 'quick' - ); +INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) + VALUES + ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'), + ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'), + ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'), + ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), + ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); -INSERT INTO - `vn`.`invoiceOut` ( - `id`, `serial`, `amount`, `issued`, `clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf` - ) -VALUES ( - 1, 'T', 1026.24, util.VN_CURDATE (), 1101, util.VN_CURDATE (), 442, util.VN_CURDATE (), util.VN_CURDATE (), 1, 0 - ), - ( - 2, 'T', 121.36, util.VN_CURDATE (), 1102, util.VN_CURDATE (), 442, util.VN_CURDATE (), util.VN_CURDATE (), 1, 0 - ), - ( - 3, 'T', 8.88, util.VN_CURDATE (), 1103, util.VN_CURDATE (), 442, util.VN_CURDATE (), util.VN_CURDATE (), 1, 0 - ), - ( - 4, 'T', 8.88, util.VN_CURDATE (), 1104, util.VN_CURDATE (), 442, util.VN_CURDATE (), util.VN_CURDATE (), 1, 0 - ), - ( - 5, 'A', 8.88, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1103, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 442, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 0 - ); +INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) + VALUES + (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; - UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; - UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3; - UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; - UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; -INSERT INTO - `vn`.`invoiceOutTax` ( - `invoiceOutFk`, `taxableBase`, `vat`, `pgcFk` - ) -VALUES (1, 895.76, 89.58, 4722000010), - (1, 33.80, 7.10, 4722000021), - (2, 110.33, 11.03, 4770000010), - (3, 8.07, 0.81, 4770000010), - (4, 8.07, 0.81, 4770000010), - (5, 8.07, 0.81, 4770000010); +INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) + VALUES + (1, 895.76, 89.58, 4722000010), + (1, 33.80, 7.10, 4722000021), + (2, 110.33, 11.03, 4770000010), + (3, 8.07, 0.81, 4770000010), + (4, 8.07, 0.81, 4770000010), + (5, 8.07, 0.81, 4770000010); -INSERT INTO - `vn`.`expense` (`id`, `name`, `isWithheld`) -VALUES ( - 2000000000, 'Inmovilizado pendiente', 0 - ), - ( - 2000000001, 'Compra de bienes de inmovilizado', 0 - ), - (4751000000, 'Retenciones', 1), - (4751000001, 'Retencion', 0), - (6210000567, 'Alquiler VNH', 0), - ( - 6240000000, 'Transportes de ventas rutas', 0 - ), - (7001000000, 'Mercaderia', 0), - ( - 7050000000, 'Prestacion de servicios', 1 - ); +INSERT INTO `vn`.`expense`(`id`, `name`, `isWithheld`) + VALUES + (2000000000, 'Inmovilizado pendiente', 0), + (2000000001, 'Compra de bienes de inmovilizado', 0), + (4751000000, 'Retenciones', 1), + (4751000001, 'Retencion', 0), + (6210000567, 'Alquiler VNH', 0), + (6240000000, 'Transportes de ventas rutas', 0), + (7001000000, 'Mercaderia', 0), + (7050000000, 'Prestacion de servicios', 1); -INSERT INTO - `vn`.`invoiceOutExpense` ( - `id`, `invoiceOutFk`, `amount`, `expenseFk`, `created` - ) -VALUES ( - 1, 1, 813.06, 2000000000, util.VN_CURDATE () - ), - ( - 2, 1, 33.80, 4751000000, util.VN_CURDATE () - ), - ( - 3, 1, 70.70, 6210000567, util.VN_CURDATE () - ), - ( - 4, 2, 110.33, 2000000000, util.VN_CURDATE () - ), - ( - 5, 3, 8.07, 2000000000, util.VN_CURDATE () - ), - ( - 6, 4, 8.07, 2000000000, util.VN_CURDATE () - ), - ( - 7, 5, 8.07, 2000000000, util.VN_CURDATE () - ); -INSERT INTO - `vn`.`zone` ( - `id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize` - ) -VALUES ( - 1, 'Zone pickup A', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 1, 0, 1, 0, 100 - ), - ( - 2, 'Zone pickup B', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 1, 0, 1, 0, 100 - ), - ( - 3, 'Zone 247 A', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 7, 1, 2, 0, 100 - ), - ( - 4, 'Zone 247 B', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 7, 1, 2, 0, 100 - ), - ( - 5, 'Zone expensive A', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 8, 1, 1000, 0, 100 - ), - ( - 6, 'Zone expensive B', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 8, 1, 1000, 0, 100 - ), - ( - 7, 'Zone refund', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 23, 0, 1, 0, 100 - ), - ( - 8, 'Zone others', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 10, 0, 1, 0, 100 - ), - ( - 9, 'Zone superMan', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 2, 0, 1, 0, 100 - ), - ( - 10, 'Zone teleportation', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 3, 0, 1, 0, 100 - ), - ( - 11, 'Zone pickup C', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 1, 0, 1, 0, 100 - ), - ( - 12, 'Zone entanglement', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 4, 0, 1, 0, 100 - ), - ( - 13, 'Zone quantum break', CONCAT( - util.VN_CURDATE (), ' ', TIME('23:59') - ), 5, 0, 1, 0, 100 - ); +INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`) + VALUES + (1, 1, 813.06, 2000000000, util.VN_CURDATE()), + (2, 1, 33.80, 4751000000, util.VN_CURDATE()), + (3, 1, 70.70, 6210000567, util.VN_CURDATE()), + (4, 2, 110.33, 2000000000, util.VN_CURDATE()), + (5, 3, 8.07, 2000000000, util.VN_CURDATE()), + (6, 4, 8.07, 2000000000, util.VN_CURDATE()), + (7, 5, 8.07, 2000000000, util.VN_CURDATE()); -INSERT INTO - `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) -VALUES (1, 1, 1), - (2, 2, 2), - (3, 3, 1), - (4, 4, 2), - (5, 5, 1), - (6, 6, 2), - (7, 7, 1), - (8, 8, 1), - (9, 9, 1), - (10, 10, 3), - (11, 11, 5), - (12, 12, 4), - (13, 13, 5); +INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) + VALUES + (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100), + (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100), + (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (4, 'Zone 247 B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (5, 'Zone expensive A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (6, 'Zone expensive B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 1, 0, 100), + (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 1, 0, 100), + (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 1, 0, 100), + (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 1, 0, 100), + (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 1, 0, 100), + (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 1, 0, 100), + (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 1, 0, 100); -INSERT INTO - `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) -VALUES ( - 1, util.VN_CURDATE (), '23:59' - ), - ( - 2, util.VN_CURDATE (), '23:59' - ), - ( - 3, util.VN_CURDATE (), '23:59' - ), - ( - 4, util.VN_CURDATE (), '23:59' - ), - ( - 5, util.VN_CURDATE (), '23:59' - ), - ( - 6, util.VN_CURDATE (), '23:59' - ), - ( - 7, util.VN_CURDATE (), '23:59' - ), - ( - 8, util.VN_CURDATE (), '23:59' - ), - ( - 9, util.VN_CURDATE (), '23:59' - ), - ( - 10, util.VN_CURDATE (), '23:59' - ), - ( - 11, util.VN_CURDATE (), '23:59' - ), - ( - 12, util.VN_CURDATE (), '23:59' - ), - ( - 13, util.VN_CURDATE (), '23:59' - ); + +INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) + VALUES + (1, 1, 1), + (2, 2, 2), + (3, 3, 1), + (4, 4, 2), + (5, 5, 1), + (6, 6, 2), + (7, 7, 1), + (8, 8, 1), + (9, 9, 1), + (10, 10, 3), + (11, 11, 5), + (12, 12, 4), + (13, 13, 5); + +INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) + VALUES + (1, util.VN_CURDATE(), '23:59'), + (2, util.VN_CURDATE(), '23:59'), + (3, util.VN_CURDATE(), '23:59'), + (4, util.VN_CURDATE(), '23:59'), + (5, util.VN_CURDATE(), '23:59'), + (6, util.VN_CURDATE(), '23:59'), + (7, util.VN_CURDATE(), '23:59'), + (8, util.VN_CURDATE(), '23:59'), + (9, util.VN_CURDATE(), '23:59'), + (10, util.VN_CURDATE(), '23:59'), + (11, util.VN_CURDATE(), '23:59'), + (12, util.VN_CURDATE(), '23:59'), + (13, util.VN_CURDATE(), '23:59'); INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); -INSERT INTO - `vn`.`route` ( - `id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk` - ) -VALUES ( - 1, '1899-12-30 12:15:00', 56, util.VN_CURDATE (), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1 - ), - ( - 2, '1899-12-30 13:20:00', 56, util.VN_CURDATE (), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 9 - ), - ( - 3, '1899-12-30 14:30:00', 56, util.VN_CURDATE (), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 10 - ), - ( - 4, '1899-12-30 15:45:00', 56, util.VN_CURDATE (), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 12 - ), - ( - 5, '1899-12-30 16:00:00', 56, util.VN_CURDATE (), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 13 - ), - ( - 6, NULL, 57, util.VN_CURDATE (), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 3 - ), - ( - 7, NULL, 57, util.VN_CURDATE (), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 5 - ); +INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) + VALUES + (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1), + (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9), + (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10), + (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12), + (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13), + (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), + (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); -INSERT INTO - `vn`.`ticket` ( - `id`, `priority`, `agencyModeFk`, `warehouseFk`, `routeFk`, `shipped`, `landed`, `clientFk`, `nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight` - ) -VALUES ( - 1, 3, 1, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1 - ), - ( - 2, 1, 1, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2 - ), - ( - 3, 1, 7, 1, 6, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), INTERVAL + 1 DAY - ), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), NULL - ), - ( - 4, 3, 2, 1, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), INTERVAL + 1 DAY - ), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), NULL - ), - ( - 5, 3, 3, 3, 3, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), INTERVAL + 1 DAY - ), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), NULL - ), - ( - 6, 1, 3, 3, 3, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), NULL - ), - ( - 7, NULL, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 8, NULL, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 9, NULL, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 10, 1, 1, 5, 1, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 11, 1, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 12, 1, 8, 1, 1, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 13, 1, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 14, 1, 2, 1, NULL, util.VN_CURDATE (), util.VN_CURDATE (), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 15, 1, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 16, 1, 7, 1, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 17, 1, 7, 2, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 18, 1, 4, 4, 4, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 12 HOUR - ), NULL - ), - ( - 19, 1, 5, 5, NULL, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 20, 1, 5, 5, 3, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), NULL - ), - ( - 21, NULL, 5, 5, 5, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), NULL - ), - ( - 22, NULL, 5, 5, 5, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), NULL - ), - ( - 23, NULL, 8, 1, 7, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 24, NULL, 8, 1, 7, util.VN_CURDATE (), util.VN_CURDATE (), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 25, NULL, 8, 1, NULL, util.VN_CURDATE (), util.VN_CURDATE (), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 26, NULL, 8, 1, NULL, util.VN_CURDATE (), util.VN_CURDATE (), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 27, NULL, 8, 1, NULL, util.VN_CURDATE (), util.VN_CURDATE (), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 28, 1, 8, 1, 1, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 29, 1, 8, 1, 1, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 30, 1, 8, 1, 1, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 31, 1, 8, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ), - ( - 32, 1, 8, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE (), NULL - ); +INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`) + VALUES + (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2), + (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL), + (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL), + (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL), + (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL), + (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL), + (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL), + (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL), + (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL), + (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL), + (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL), + (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL), + (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL), + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL); -INSERT INTO - `vn`.`ticketObservation` ( - `id`, `ticketFk`, `observationTypeFk`, `description` - ) -VALUES (1, 11, 1, 'ready'), - (2, 2, 2, 'do it fast please'), - ( - 3, 3, 5, 'Faster faster fasteeeeeer!!!' - ), - (4, 4, 5, 'Deliver before 8am'), - ( - 5, 13, 5, 'You can run from the disappointments you are trying to forget. But its only when you embrace your past that you truly move forward. Maybe I never get to go home again, but I found my way there. And I am glad I did.' - ), - ( - 6, 14, 5, 'Careful, armed warhead' - ), - (7, 23, 1, 'under the floor'), - ( - 8, 23, 2, 'wears leather and goes out at night' - ), - (9, 23, 5, 'care with the dog'), - ( - 10, 23, 4, 'Reclama ticket: 8' - ), - ( - 11, 24, 4, 'Reclama ticket: 7' - ), - ( - 12, 11, 3, 'Delivery after 10am' - ), - ( - 13, 1, 7, 'observation of ticket one' - ), - ( - 14, 2, 7, 'observation of ticket two' - ); +INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) + VALUES + (1, 11, 1, 'ready'), + (2, 2, 2, 'do it fast please'), + (3, 3, 5, 'Faster faster fasteeeeeer!!!'), + (4, 4, 5, 'Deliver before 8am'), + (5, 13, 5, 'You can run from the disappointments you are trying to forget. But its only when you embrace your past that you truly move forward. Maybe I never get to go home again, but I found my way there. And I am glad I did.'), + (6, 14, 5, 'Careful, armed warhead'), + (7, 23, 1, 'under the floor'), + (8, 23, 2, 'wears leather and goes out at night'), + (9, 23, 5, 'care with the dog'), + (10, 23, 4, 'Reclama ticket: 8'), + (11, 24, 4, 'Reclama ticket: 7'), + (12, 11, 3, 'Delivery after 10am'), + (13, 1, 7, 'observation of ticket one'), + (14, 2, 7, 'observation of ticket two'); -- FIX for state hours on local, inter_afterInsert -- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); -INSERT INTO - `vn`.`ticketTracking` ( - `ticketFk`, `stateFk`, `userFk`, `created` - ) -VALUES ( - 1, 16, 5, DATE_ADD( - util.VN_NOW (), INTERVAL -1 MONTH - ) - ), - ( - 2, 16, 5, DATE_ADD( - util.VN_NOW (), INTERVAL -1 MONTH - ) - ), - ( - 3, 16, 5, DATE_ADD( - util.VN_NOW (), INTERVAL -2 MONTH - ) - ), - ( - 4, 16, 5, DATE_ADD( - util.VN_NOW (), INTERVAL -3 MONTH - ) - ), - ( - 5, 16, 18, DATE_ADD( - util.VN_NOW (), INTERVAL -4 MONTH - ) - ), - ( - 6, 16, 18, DATE_ADD( - util.VN_NOW (), INTERVAL -1 MONTH - ) - ), - (7, 10, 18, util.VN_NOW ()), - (8, 5, 19, util.VN_NOW ()), - (9, 5, 19, util.VN_NOW ()), - (10, 5, 19, util.VN_NOW ()), - (11, 3, 19, util.VN_NOW ()), - (12, 3, 19, util.VN_NOW ()), - (13, 3, 19, util.VN_NOW ()), - (14, 3, 19, util.VN_NOW ()), - (15, 2, 19, util.VN_NOW ()), - (16, 3, 19, util.VN_NOW ()), - (17, 2, 19, util.VN_NOW ()), - (18, 2, 19, util.VN_NOW ()), - (19, 2, 19, util.VN_NOW ()), - ( - 20, 1, 19, DATE_ADD( - util.VN_NOW (), INTERVAL + 1 MONTH - ) - ), - ( - 21, 1, 19, DATE_ADD( - util.VN_NOW (), INTERVAL + 1 MONTH - ) - ), - ( - 22, 1, 19, DATE_ADD( - util.VN_NOW (), INTERVAL + 1 MONTH - ) - ), - (23, 16, 21, util.VN_NOW ()), - (24, 16, 21, util.VN_NOW ()); +INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`) + VALUES + (1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (3, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -2 MONTH)), + (4, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -3 MONTH)), + (5, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -4 MONTH)), + (6, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (7, 10, 18, util.VN_NOW()), + (8, 5, 19, util.VN_NOW()), + (9, 5, 19, util.VN_NOW()), + (10, 5, 19, util.VN_NOW()), + (11, 3, 19, util.VN_NOW()), + (12, 3, 19, util.VN_NOW()), + (13, 3, 19, util.VN_NOW()), + (14, 3, 19, util.VN_NOW()), + (15, 2, 19, util.VN_NOW()), + (16, 3, 19, util.VN_NOW()), + (17, 2, 19, util.VN_NOW()), + (18, 2, 19, util.VN_NOW()), + (19, 2, 19, util.VN_NOW()), + (20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (23, 16, 21, util.VN_NOW()), + (24, 16, 21, util.VN_NOW()); -INSERT INTO - `vn`.`deliveryPoint` (`id`, `name`, `ubication`) -VALUES ( - 1, 'Gotham', '1007 Mountain Drive, Gotham' - ); +INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`) + VALUES + (1, 'Gotham','1007 Mountain Drive, Gotham'); -INSERT INTO - `vn`.`vehicle` ( - `id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk` - ) -VALUES ( - 1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1 - ), - ( - 2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1 - ), - ( - 3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1 - ), - ( - 4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1 - ), - ( - 5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1 - ), - ( - 6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1 - ); +INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`) + VALUES + (1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1), + (2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1), + (3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1), + (4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1), + (5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1), + (6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1); -INSERT INTO - `vn`.`config` ( - `id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried` - ) -VALUES ( - 1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ); +INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`) + VALUES + (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH)); -INSERT INTO - `vn`.`greugeType` (`id`, `name`, `code`) -VALUES (1, 'Diff', 'diff'), - (2, 'Recover', 'recover'), - (3, 'Mana', 'mana'), - (4, 'Reclaim', 'reclaim'), - (5, 'Heritage', 'heritage'), - ( - 6, 'Miscellaneous', 'miscellaneous' - ), - ( - 7, 'Freight Pickup', 'freightPickUp' - ); -INSERT INTO - `vn`.`greuge` ( - `id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk` - ) -VALUES ( - 1, 1101, 'some diff charges', -19.99, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 1, 1 - ), - ( - 2, 1101, 'more diff charges', 60, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 2, 1 - ), - ( - 3, 1101, 'even more! diff charges', -9.99, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 3, 1 - ), - ( - 4, 1101, 'insane diff charges', 60, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 4, 1 - ), - ( - 5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 5, 1 - ), - ( - 6, 1101, 'diff charges', 88.30, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 6, 1 - ), - ( - 7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 1, 1 - ), - ( - 8, 1101, 'some recovery charges', 29.35, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 2, 1 - ), - ( - 9, 1101, 'some manna charges', -9.99, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 3, 1 - ), - ( - 10, 1101, 'some claim charges', 13.13, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 4, 1 - ), - ( - 11, 1101, 'some heritage charges', -15.99, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 5, 1 - ), - ( - 12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), util.VN_CURDATE (), 6, 1 - ); +INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) + VALUES + (1, 'Diff', 'diff'), + (2, 'Recover', 'recover'), + (3, 'Mana', 'mana'), + (4, 'Reclaim', 'reclaim'), + (5, 'Heritage', 'heritage'), + (6, 'Miscellaneous', 'miscellaneous'), + (7, 'Freight Pickup', 'freightPickUp'); -INSERT INTO - `vn`.`mandate` ( - `id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk` - ) -VALUES ( - 1, 1102, 442, '1-1', util.VN_CURDATE (), 2 - ); +INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk`) + VALUES + (1, 1101, 'some diff charges', -19.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1), + (2, 1101, 'more diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1), + (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1), + (4, 1101, 'insane diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1), + (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1), + (6, 1101, 'diff charges', 88.30, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1), + (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1), + (8, 1101, 'some recovery charges', 29.35, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1), + (9, 1101, 'some manna charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1), + (10, 1101, 'some claim charges', 13.13, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1), + (11, 1101, 'some heritage charges', -15.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1), + (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1); -INSERT INTO - `vn`.`itemCategory` ( - `id`, `name`, `display`, `color`, `icon`, `code` - ) -VALUES ( - 1, 'Plant', 1, 'B92A26', 'icon-plant', 'plant' - ), - ( - 2, 'Flower', 2, 'dcf711', 'icon-flower', 'flower' - ), - ( - 3, 'Logistic', 0, 'b9f711', NULL, 'logistical' - ), - ( - 4, 'Handmade', 1, NULL, 'icon-handmade', 'handmade' - ), - ( - 5, 'Artificial', 1, NULL, 'icon-artificial', 'artificial' - ), - ( - 6, 'Green', 1, NULL, 'icon-greenery', 'greenery' - ), - ( - 7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory' - ), - ( - 8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit' - ); +INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`) + VALUES + (1, 1102, 442, '1-1', util.VN_CURDATE(), 2); -INSERT INTO - `vn`.`temperature` (`code`, `name`, `description`) -VALUES ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); +INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`) + VALUES + (1, 'Plant', 1, 'B92A26', 'icon-plant', 'plant'), + (2, 'Flower', 2, 'dcf711', 'icon-flower', 'flower'), + (3, 'Logistic', 0, 'b9f711', NULL, 'logistical'), + (4, 'Handmade', 1, NULL, 'icon-handmade', 'handmade'), + (5, 'Artificial', 1, NULL, 'icon-artificial', 'artificial'), + (6, 'Green', 1, NULL, 'icon-greenery', 'greenery'), + (7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'), + (8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit'); -INSERT INTO - `vn`.`itemType` ( - `id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`, `isFragile` - ) -VALUES ( - 1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool', 0 - ), - ( - 2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool', 1 - ), - ( - 3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool', 0 - ), - ( - 4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm', 0 - ), - ( - 5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0 - ), - ( - 6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1 - ); +INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) + VALUES + ('warm', 'Warm', 'Warm'), + ('cool', 'Cool', 'Cool'); -INSERT INTO - `vn`.`ink` ( - `id`, `name`, `picture`, `showOrder`, `hex` - ) -VALUES ( - 'YEL', 'Yellow', 1, 1, 'F4D03F' - ), - ('BLU', 'Blue', 1, 2, '5DADE2'), - ('RED', 'Red', 1, 3, 'EC7063'), - ( - 'SLV', 'Silver', 1, 4, 'CACFD2' - ), - ( - 'BRW', 'Brown', 1, 5, 'DC7633' - ), - ( - 'BLK', 'Black', 1, 6, '000000' - ), - ( - 'BAS', 'Blue/Silver', 1, 7, '5DADE2' - ), - ( - 'GRN', 'Green', 1, 8, '28A745' - ), - ( - 'WHT', 'White', 1, 9, 'FFFFFF' - ); +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`, `isFragile`) + VALUES + (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool', 0), + (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool', 1), + (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool', 0), + (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm', 0), + (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0), + (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1); -INSERT INTO - `vn`.`origin` (`id`, `code`, `name`) -VALUES (1, 'SPA', 'Spain'), - (2, 'HOL', 'Holand'), - (3, 'VLC', 'Valencia'); +INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) + VALUES + ('YEL', 'Yellow', 1, 1, 'F4D03F'), + ('BLU', 'Blue', 1, 2, '5DADE2'), + ('RED', 'Red', 1, 3, 'EC7063'), + ('SLV', 'Silver', 1, 4, 'CACFD2'), + ('BRW', 'Brown', 1, 5, 'DC7633'), + ('BLK', 'Black', 1, 6, '000000'), + ('BAS', 'Blue/Silver', 1, 7, '5DADE2'), + ('GRN', 'Green', 1, 8, '28A745'), + ('WHT', 'White', 1, 9, 'FFFFFF'); -INSERT INTO - `vn`.`producer` (`id`, `name`) -VALUES (1, 'Marvel Studios'), - (2, 'Nordic Mythology'); +INSERT INTO `vn`.`origin`(`id`,`code`, `name`) + VALUES + (1, 'SPA', 'Spain'), + (2, 'HOL', 'Holand'), + (3, 'VLC', 'Valencia'); -INSERT INTO - `vn`.`taxType` ( - `id`, `nickname`, `isAccrued`, `serial`, `TIPOOPE`, `description`, `countryFk` - ) -VALUES ( - 1, 'National', 1, 'R', 'I', 'national VAT', 1 - ), - ( - 2, 'European', 0, 'E', 'I', 'europe VAT', 1 - ); +INSERT INTO `vn`.`producer`(`id`, `name`) + VALUES + (1, 'Marvel Studios'), + (2, 'Nordic Mythology'); -INSERT INTO - `vn`.`taxCode` ( - `id`, `dated`, `code`, `taxTypeFk`, `rate`, `equalizationTax`, `type`, `link`, `isActive`, `updated`, `transactionCode` - ) -VALUES ( - 1, util.VN_CURDATE (), '1111111111', 1, 7.0, 0.0, 'R', 1, 1, util.VN_CURDATE (), 1 - ), - ( - 2, util.VN_CURDATE (), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, util.VN_CURDATE (), 1 - ), - ( - 21, util.VN_CURDATE (), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, util.VN_CURDATE (), 1 - ), - ( - 108, util.VN_CURDATE (), '4444444444', 2, 8.0, 0.0, 'R', 4, 1, util.VN_CURDATE (), 1 - ); +INSERT INTO `vn`.`taxType`(`id`, `nickname`, `isAccrued`, `serial`, `TIPOOPE`, `description`, `countryFk`) + VALUES + (1, 'National', 1, 'R', 'I', 'national VAT', 1), + (2, 'European', 0, 'E', 'I', 'europe VAT', 1); -INSERT INTO - `vn`.`taxClass` (`id`, `description`, `code`) -VALUES (1, 'Reduced VAT', 'R'), - (2, 'General VAT', 'G'); +INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equalizationTax`, `type`, `link`, `isActive`, `updated`, `transactionCode`) + VALUES + (1 , util.VN_CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, util.VN_CURDATE(), 1), + (2 , util.VN_CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, util.VN_CURDATE(), 1), + (21 , util.VN_CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, util.VN_CURDATE(), 1), + (108, util.VN_CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, util.VN_CURDATE(), 1); -INSERT INTO - `vn`.`taxClassCode` ( - `taxClassFk`, `effectived`, `taxCodeFk` - ) -VALUES (1, util.VN_CURDATE (), 1), - (1, util.VN_CURDATE (), 21), - (2, util.VN_CURDATE (), 2); +INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) + VALUES + (1, 'Reduced VAT', 'R'), + (2, 'General VAT', 'G'); -INSERT INTO - `vn`.`intrastat` ( - `id`, `description`, `taxClassFk`, `taxCodeFk` - ) -VALUES ( - 05080000, 'Coral y materiales similares', 2, 2 - ), - ( - 06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1 - ); +INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) + VALUES + (1, util.VN_CURDATE(), 1), + (1, util.VN_CURDATE(), 21), + (2, util.VN_CURDATE(), 2); -INSERT INTO - `vn`.`itemFamily` (`code`, `description`) -VALUES ('EMB', 'Packagings'), - ('SER', 'Services'), - ('VT', 'Sales'); +INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) + VALUES + (05080000, 'Coral y materiales similares', 2, 2), + (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1); -INSERT INTO - `vn`.`item` ( - `id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece` - ) -VALUES ( - 1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3 - ), - ( - 2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2 - ), - ( - 3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5 - ), - ( - 4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL - ), - ( - 10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ), - ( - 13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL - ), - ( - 14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL - ), - ( - 15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL - ), - ( - 16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL - ), - ( - 71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL - ); +INSERT INTO `vn`.`itemFamily`(`code`, `description`) + VALUES + ('EMB', 'Packagings'), + ('SER', 'Services'), + ('VT', 'Sales'); + +INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`) + VALUES + (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3), + (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2), + (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5), + (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), + (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL), + (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), + (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL); -- Update the taxClass after insert of the items -UPDATE `vn`.`itemTaxCountry` -SET - `taxClassFk` = 2 -WHERE - `itemFk` IN ( - 4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 71 - ); +UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 + WHERE `itemFk` IN(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 71); -INSERT INTO - `vn`.`priceFixed` ( - `id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created` - ) -VALUES ( - 1, 1, 0, 0, 2.5, 2, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 0, 1, util.VN_CURDATE () - ), - ( - 2, 3, 10, 10, 10, 10, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 0, 1, util.VN_CURDATE () - ), - ( - 3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 1, 2, util.VN_CURDATE () - ); +INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`) + VALUES + (1, 1, 0, 0, 2.5, 2, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()), + (2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()), + (3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE()); -INSERT INTO - `vn`.`expeditionBoxVol` (`boxFk`, `m3`, `ratio`) -VALUES (71, 0.141, 1); +INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`) + VALUES + (71,0.141,1); -INSERT INTO - `vn`.`packaging` ( - `id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price` - ) -VALUES ( - 1, 0.00, 10, 10, 0, 1, util.VN_CURDATE (), 6, 1.50 - ), - ( - 2, 100.00, 20, 20, 0, 1, util.VN_CURDATE (), 7, 1.00 - ), - ( - 3, 14000.00, 0, 0, 0, 1, util.VN_CURDATE (), NULL, 0 - ), - ( - 4, 218000.00, 0, 0, 0, 0, util.VN_CURDATE (), NULL, 0 - ), - ( - 5, 292000.00, 0, 0, 0, 0, util.VN_CURDATE (), NULL, 0 - ), - ( - 94, 140875.00, 49.00, 115.00, 25.00, 0, util.VN_CURDATE (), 71, 0.00 - ), - ( - 'cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE (), 15, 90.00 - ), - ( - 'pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE (), 16, 0.00 - ); +INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`) + VALUES + (1, 0.00, 10, 10, 0, 1, util.VN_CURDATE(), 6, 1.50), + (2, 100.00, 20, 20, 0, 1, util.VN_CURDATE(), 7, 1.00), + (3, 14000.00, 0, 0, 0, 1, util.VN_CURDATE(), NULL, 0), + (4, 218000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0), + (5, 292000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0), + (94, 140875.00, 49.00, 115.00, 25.00, 0, util.VN_CURDATE(), 71, 0.00), + ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00), + ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00); -INSERT INTO - `vn`.`packagingConfig` ( - `upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk` - ) -VALUES ('10', 1, 'pallet 100'); +INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`) + VALUES + ('10', 1, 'pallet 100'); -INSERT INTO - `vn`.`expeditionStateType` (`id`, `description`, `code`) -VALUES ( - 1, 'En reparto', 'ON DELIVERY' - ), - (2, 'Entregada', 'DELIVERED'), - (3, 'Perdida', 'LOST'); +INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) + VALUES + (1, 'En reparto', 'ON DELIVERY'), + (2, 'Entregada', 'DELIVERED'), + (3, 'Perdida', 'LOST'); -INSERT INTO - `vn`.`expedition` ( - `id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk` - ) -VALUES ( - 1, 1, 1, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 18, 'UR9000006041', 94, 1, 'pc1' - ), - ( - 2, 1, 1, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2, 18, 'UR9000006041', 94, 1, NULL - ), - ( - 3, 1, 1, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 3, 18, 'UR9000006041', 94, 2, NULL - ), - ( - 4, 1, 1, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 4, 18, 'UR9000006041', 94, 2, NULL - ), - ( - 5, 1, 2, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 18, NULL, 94, 3, NULL - ), - ( - 6, 7, 3, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), 1, 18, NULL, 94, 3, NULL - ), - ( - 7, 2, 4, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), 1, 18, NULL, 94, NULL, NULL - ), - ( - 8, 3, 5, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), 1, 18, NULL, 94, 1, NULL - ), - ( - 9, 3, 6, 71, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 18, NULL, 94, 2, NULL - ), - ( - 10, 7, 7, 71, util.VN_NOW (), 1, 18, NULL, 94, 3, NULL - ), - ( - 11, 7, 8, 71, util.VN_NOW (), 1, 18, NULL, 94, 3, NULL - ), - ( - 12, 7, 9, 71, util.VN_NOW (), 1, 18, NULL, 94, 3, NULL - ), - ( - 13, 1, 10, 71, util.VN_NOW (), 1, 18, NULL, 94, 3, NULL - ); -INSERT INTO - `vn`.`expeditionState` ( - `id`, `created`, `expeditionFk`, `typeFk`, `userFk` - ) -VALUES ( - 1, util.VN_CURDATE (), 1, 1, 1 - ), - ( - 2, util.VN_CURDATE (), 2, 1, 1 - ), - ( - 3, util.VN_CURDATE (), 3, 1, 1 - ), - ( - 4, util.VN_CURDATE (), 3, 2, 1106 - ), - ( - 5, util.VN_CURDATE (), 5, 1, 1106 - ), - ( - 6, util.VN_CURDATE (), 5, 3, 1106 - ); +INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`) + VALUES + (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'), + (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL), + (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL), + (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL), + (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL), + (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL), + (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL), + (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL), + (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL), + (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL); -INSERT INTO - `vn`.`ticketPackaging` ( - `id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp` - ) -VALUES ( - 1, 1, 2, 2, util.VN_CURDATE (), NULL - ), - ( - 2, 2, 2, 1, util.VN_CURDATE (), NULL - ), - ( - 3, 3, 2, 4, util.VN_CURDATE (), NULL - ); -INSERT INTO - `vn`.`sale` ( - `id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created` - ) -VALUES ( - 1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ) - ), - ( - 7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE () - ), - ( - 8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE () - ), - ( - 9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE () - ), - ( - 10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE () - ), - ( - 11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE () - ), - ( - 12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE () - ), - ( - 13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE () - ), - ( - 14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE () - ), - ( - 15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE () - ), - ( - 16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE () - ), - ( - 17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ), - ( - 18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ), - ( - 19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ) - ), - ( - 20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ) - ), - ( - 21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE () - ), - ( - 23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE () - ), - ( - 24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE () - ), - ( - 25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE () - ), - ( - 32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE () - ), - ( - 33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE () - ), - ( - 34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE () - ), - ( - 38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ), - ( - 39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE () - ); +INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) + VALUES + (1, util.VN_CURDATE(), 1, 1, 1), + (2, util.VN_CURDATE(), 2, 1, 1), + (3, util.VN_CURDATE(), 3, 1, 1), + (4, util.VN_CURDATE(), 3, 2, 1106), + (5, util.VN_CURDATE(), 5, 1, 1106), + (6, util.VN_CURDATE(), 5, 3, 1106); -INSERT INTO - `vn`.`saleComponent` ( - `saleFk`, `componentFk`, `value` - ) -VALUES (1, 28, 50), - (1, 29, 49.4), - (1, 39, 0.994), - (2, 28, 5), - (2, 29, 2), - (2, 39, 0.07), - (3, 28, 50), - (3, 29, 49.4), - (3, 39, 0.994), - (4, 28, 1.25), - (4, 29, 0.42), - (4, 39, 0.017), - (5, 17, 9.94), - (5, 28, 50), - (5, 29, 49.4), - (5, 39, 0.994), - (6, 17, 9.94), - (6, 28, 50), - (6, 29, 49.4), - (6, 39, 0.994), - (7, 15, 0.0199), - (7, 17, 0.35), - (7, 28, 5), - (7, 29, 2), - (7, 39, 0.07), - (8, 15, 0.0199), - (8, 17, 0.084), - (8, 28, 1.25), - (8, 29, 0.42), - (8, 39, 0.017), - (9, 15, 3.0949), - (9, 21, 0.001), - (9, 28, 53), - (9, 29, 46.4), - (9, 39, 0.994), - (10, 15, 0.0199), - (10, 28, 7), - (10, 29, 0), - (10, 39, 0.07), - (11, 15, 3.0949), - (11, 21, 0.001), - (11, 28, 53), - (11, 29, 46.4), - (11, 39, 0.994), - (12, 15, 0.0199), - (12, 21, 0.003), - (12, 28, 2.25), - (12, 29, -0.58), - (12, 39, 0.017), - (13, 15, 0.114), - (13, 28, 5), - (13, 29, 2), - (13, 39, 0.07), - (14, 15, 3.0949), - (14, 28, 50), - (14, 29, 49.4), - (14, 39, 0.994), - (15, 15, 3.0949), - (15, 28, 50), - (15, 29, 49.4), - (15, 39, 0.994), - (16, 28, 5), - (16, 29, 2), - (16, 39, 0.07), - (17, 28, 5), - (17, 29, 2), - (17, 39, 0.07), - (18, 28, 1.25), - (18, 29, 0.42), - (18, 39, 0.017), - (19, 17, 0.7), - (19, 22, 0.3), - (19, 28, 5), - (19, 29, 2), - (19, 39, 0.02), - (20, 17, 0.7), - (20, 22, 0.3), - (20, 28, 5), - (20, 29, 2), - (20, 39, 0.02), - (21, 17, 0.7), - (21, 22, 0.3), - (21, 28, 5), - (21, 29, 2), - (21, 39, 0.02), - (22, 17, 0.7), - (22, 22, 0.3), - (22, 28, 5), - (22, 29, 2), - (22, 39, 0.02), - (23, 17, 0.7), - (23, 22, 0.3), - (23, 28, 5), - (23, 29, 2), - (23, 39, 0.02), - (24, 17, 0.7), - (24, 22, 0.3), - (24, 28, 5), - (24, 29, 2), - (24, 39, 0.02), - (25, 17, 0.033), - (25, 28, 1.25), - (25, 29, 0.42), - (25, 39, 0.017), - (26, 17, 0.033), - (26, 28, 1.25), - (26, 29, 0.42), - (26, 39, 0.017), - (27, 17, 0.033), - (27, 28, 1.25), - (27, 29, 0.42), - (27, 39, 0.017), - (28, 17, 0.033), - (28, 28, 1.25), - (28, 29, 0.42), - (28, 39, 0.017), - (29, 17, 0.033), - (29, 28, 1.25), - (29, 29, 0.42), - (29, 39, 0.017), - (30, 17, 0.033), - (30, 28, 1.25), - (30, 29, 0.42), - (30, 39, 0.017), - (31, 28, 5), - (31, 29, 2), - (31, 36, 0.01), - (31, 39, 0.07), - (32, 28, 50), - (32, 29, 49.4), - (32, 36, -92.324), - (32, 39, 0.994); +INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) + VALUES + (1, 1, 2, 2, util.VN_CURDATE(), NULL), + (2, 2, 2, 1, util.VN_CURDATE(), NULL), + (3, 3, 2, 4, util.VN_CURDATE(), NULL); -INSERT INTO - `vn`.`itemShelving` ( - `itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk` - ) -VALUES (2, 'GVC', 1, 1, 1, 1106), - (4, 'HEJ', 1, 1, 1, 1106), - (1, 'UXN', 2, 12, 12, 1106); +INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) + VALUES + (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()), + (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()), + (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()), + (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()), + (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), + (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()), + (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()), + (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()); -INSERT INTO - `vn`.`itemShelvingSale` ( - `itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk` - ) -VALUES ( - '1', '1', '1', util.VN_CURDATE (), '1106' - ), - ( - '2', '2', '5', util.VN_CURDATE (), '1106' - ), - ( - '1', '7', '1', util.VN_CURDATE (), '1106' - ), - ( - '2', '8', '5', util.VN_CURDATE (), '1106' - ); +INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) + VALUES + (1, 28, 50), + (1, 29, 49.4), + (1, 39, 0.994), + (2, 28, 5), + (2, 29, 2), + (2, 39, 0.07), + (3, 28, 50), + (3, 29, 49.4), + (3, 39, 0.994), + (4, 28, 1.25), + (4, 29, 0.42), + (4, 39, 0.017), + (5, 17, 9.94), + (5, 28, 50), + (5, 29, 49.4), + (5, 39, 0.994), + (6, 17, 9.94), + (6, 28, 50), + (6, 29, 49.4), + (6, 39, 0.994), + (7, 15, 0.0199), + (7, 17, 0.35), + (7, 28, 5), + (7, 29, 2), + (7, 39, 0.07), + (8, 15, 0.0199), + (8, 17, 0.084), + (8, 28, 1.25), + (8, 29, 0.42), + (8, 39, 0.017), + (9, 15, 3.0949), + (9, 21, 0.001), + (9, 28, 53), + (9, 29, 46.4), + (9, 39, 0.994), + (10, 15, 0.0199), + (10, 28, 7), + (10, 29, 0), + (10, 39, 0.07), + (11, 15, 3.0949), + (11, 21, 0.001), + (11, 28, 53), + (11, 29, 46.4), + (11, 39, 0.994), + (12, 15, 0.0199), + (12, 21, 0.003), + (12, 28, 2.25), + (12, 29, -0.58), + (12, 39, 0.017), + (13, 15, 0.114), + (13, 28, 5), + (13, 29, 2), + (13, 39, 0.07), + (14, 15, 3.0949), + (14, 28, 50), + (14, 29, 49.4), + (14, 39, 0.994), + (15, 15, 3.0949), + (15, 28, 50), + (15, 29, 49.4), + (15, 39, 0.994), + (16, 28, 5), + (16, 29, 2), + (16, 39, 0.07), + (17, 28, 5), + (17, 29, 2), + (17, 39, 0.07), + (18, 28, 1.25), + (18, 29, 0.42), + (18, 39, 0.017), + (19, 17, 0.7), + (19, 22, 0.3), + (19, 28, 5), + (19, 29, 2), + (19, 39, 0.02), + (20, 17, 0.7), + (20, 22, 0.3), + (20, 28, 5), + (20, 29, 2), + (20, 39, 0.02), + (21, 17, 0.7), + (21, 22, 0.3), + (21, 28, 5), + (21, 29, 2), + (21, 39, 0.02), + (22, 17, 0.7), + (22, 22, 0.3), + (22, 28, 5), + (22, 29, 2), + (22, 39, 0.02), + (23, 17, 0.7), + (23, 22, 0.3), + (23, 28, 5), + (23, 29, 2), + (23, 39, 0.02), + (24, 17, 0.7), + (24, 22, 0.3), + (24, 28, 5), + (24, 29, 2), + (24, 39, 0.02), + (25, 17, 0.033), + (25, 28, 1.25), + (25, 29, 0.42), + (25, 39, 0.017), + (26, 17, 0.033), + (26, 28, 1.25), + (26, 29, 0.42), + (26, 39, 0.017), + (27, 17, 0.033), + (27, 28, 1.25), + (27, 29, 0.42), + (27, 39, 0.017), + (28, 17, 0.033), + (28, 28, 1.25), + (28, 29, 0.42), + (28, 39, 0.017), + (29, 17, 0.033), + (29, 28, 1.25), + (29, 29, 0.42), + (29, 39, 0.017), + (30, 17, 0.033), + (30, 28, 1.25), + (30, 29, 0.42), + (30, 39, 0.017), + (31, 28, 5), + (31, 29, 2), + (31, 36, 0.01), + (31, 39, 0.07), + (32, 28, 50), + (32, 29, 49.4), + (32, 36, -92.324), + (32, 39, 0.994); -INSERT INTO - `vn`.`saleTracking` ( - `saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `id`, `stateFk` - ) -VALUES ( - 1, 0, util.VN_CURDATE (), 5, 55, 1, 14 - ), - ( - 1, 1, util.VN_CURDATE (), 5, 54, 2, 8 - ), - ( - 2, 1, util.VN_CURDATE (), 10, 40, 3, 8 - ), - ( - 3, 1, util.VN_CURDATE (), 2, 40, 4, 8 - ), - ( - 31, 1, util.VN_CURDATE (), -5, 40, 5, 8 - ); +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`) + VALUES + (2, 'GVC', 1, 1, 1, 1106), + (4, 'HEJ', 1, 1, 1, 1106), + (1, 'UXN', 2, 12, 12, 1106); -INSERT INTO - `vn`.`itemBarcode` (`id`, `itemFk`, `code`) -VALUES (1, 1, 1111111111), - (2, 1, 2222222222), - (3, 1, 3333333333), - (4, 2, 4444444444); +INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) + VALUES + ('1', '1', '1', util.VN_CURDATE(), '1106'), + ('2', '2', '5', util.VN_CURDATE(), '1106'), + ('1', '7', '1', util.VN_CURDATE(), '1106'), + ('2', '8', '5', util.VN_CURDATE(), '1106'); -INSERT INTO - `vn`.`train` (`id`, `name`) -VALUES (1, 'Train1'), - (2, 'Train2'); +INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `id`, `stateFk`) + VALUES + (1, 0, util.VN_CURDATE(), 5, 55, 1, 14), + (1, 1, util.VN_CURDATE(), 5, 54, 2, 8), + (2, 1, util.VN_CURDATE(), 10, 40, 3, 8), + (3, 1, util.VN_CURDATE(), 2, 40, 4, 8), + (31, 1, util.VN_CURDATE(), -5, 40, 5, 8); -INSERT INTO - `vn`.`operator` ( - `workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk` - ) -VALUES ( - '1106', '1', '1', 'H', '1', '1', '1' - ), - ( - '1107', '1', '1', 'V', '1', '1', '1' - ); +INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`) + VALUES + (1, 1, 1111111111), + (2, 1, 2222222222), + (3, 1, 3333333333), + (4, 2, 4444444444); -INSERT INTO - `vn`.`collection` ( - `id`, `workerFk`, `stateFk`, `created`, `trainFk` - ) -VALUES ( - 1, 1106, 5, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1 - ), - ( - 2, 1106, 14, util.VN_CURDATE (), 1 - ); +INSERT INTO `vn`.`train`(`id`, `name`) + VALUES + (1, 'Train1'), + (2, 'Train2'); -INSERT INTO - `vn`.`ticketCollection` ( - `ticketFk`, `collectionFk`, `level` - ) -VALUES (1, 1, 1), - (2, 1, NULL), - (3, 2, NULL), - (23, 1, NULL); +INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`) + VALUES + ('1106', '1', '1', 'H', '1', '1', '1'), + ('1107', '1', '1', 'V', '1', '1', '1'); -INSERT INTO - `vn`.`genus` (`id`, `name`) -VALUES (1, 'Abelia'), - (2, 'Abies'), - (3, 'Abutilon'); +INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`) + VALUES + (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1), + (2, 1106, 14, util.VN_CURDATE(), 1); -INSERT INTO - `vn`.`specie` (`id`, `name`) -VALUES (1, 'grandiflora'), - (2, 'procera'), - (3, 'decurrens'), - (4, 'dealbata'); +INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) + VALUES + (1, 1, 1), + (2, 1, NULL), + (3, 2, NULL), + (23, 1, NULL); -INSERT INTO - `vn`.`itemBotanical` ( - `itemFk`, `genusFk`, `specieFk` - ) -VALUES (1, 1, 1), - (2, 2, 2), - (3, 2, NULL), - (4, 2, 1); +INSERT INTO `vn`.`genus`(`id`, `name`) + VALUES + (1, 'Abelia'), + (2, 'Abies'), + (3, 'Abutilon'); -INSERT INTO - `vn`.`tag` ( - `id`, `code`, `name`, `isFree`, `isQuantitatif`, `sourceTable`, `unit`, `ediTypeFk`, `overwrite` - ) -VALUES ( - 1, 'color', 'Color', 0, 0, 'ink', NULL, NULL, 'inkFk' - ), - ( - 2, NULL, 'Forma', 1, 0, NULL, NULL, NULL, NULL - ), - ( - 3, NULL, 'Material', 1, 0, NULL, NULL, NULL, NULL - ), - ( - 4, NULL, 'Longitud', 1, 1, NULL, 'mm', NULL, 'size' - ), - ( - 5, NULL, 'Diámetro', 1, 1, NULL, 'mm', NULL, 'diameter' - ), - ( - 7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm', NULL, NULL - ), - ( - 23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems' - ), - ( - 27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, 'size' - ), - ( - 36, 'producer', 'Proveedor', 1, 0, NULL, NULL, NULL, 'producer' - ), - ( - 56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL - ), - ( - 58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL - ), - ( - 67, 'category', 'Categoria', 1, 0, NULL, NULL, NULL, NULL - ), - ( - 92, NULL, 'Nombre temporal', 1, 0, NULL, NULL, NULL, NULL - ); +INSERT INTO `vn`.`specie`(`id`, `name`) + VALUES + (1, 'grandiflora'), + (2, 'procera'), + (3, 'decurrens'), + (4, 'dealbata'); -INSERT INTO - `vn`.`itemTag` ( - `id`, `itemFk`, `tagFk`, `value`, `priority` - ) -VALUES (1, 1, 56, 'Ranged weapon', 1), - (2, 1, 58, 'longbow', 2), - (3, 1, 27, '200cm', 3), - ( - 4, 1, 36, 'Stark Industries', 4 - ), - (5, 1, 1, 'Brown', 5), - (6, 1, 67, '+1 precission', 6), - (7, 1, 23, '1', 7), - (8, 2, 56, 'Melee weapon', 1), - (9, 2, 58, 'combat fist', 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, '2', 7), - (15, 3, 56, 'Ranged weapon', 1), - (16, 3, 58, 'sniper rifle', 2), - (17, 3, 4, '113cm', 3), - ( - 18, 3, 36, 'Stark Industries', 4 - ), - (19, 3, 1, 'Green', 5), - (20, 3, 67, 'precission', 6), - (21, 3, 23, '3', 7), - (22, 4, 56, 'Melee weapon', 1), - (23, 4, 58, 'heavy shield', 2), - (24, 4, 4, '100cm', 3), - ( - 25, 4, 36, 'Stark Industries', 4 - ), - (26, 4, 1, 'Black', 5), - (27, 4, 67, 'containtment', 6), - (28, 4, 23, '4', 7), - (29, 5, 56, 'Ranged weapon', 1), - (30, 5, 58, 'pistol', 2), - (31, 5, 67, '9mm', 3), - ( - 32, 5, 36, 'Stark Industries', 4 - ), - (33, 5, 1, 'Silver', 5), - (34, 5, 27, '15cm', 6), - (35, 5, 23, '5', 7), - (36, 6, 56, 'Container', 1), - (37, 6, 58, 'ammo box', 2), - (38, 6, 27, '100cm', 3), - ( - 39, 6, 36, 'Stark Industries', 4 - ), - (40, 6, 1, 'Green', 5), - (41, 6, 67, 'supply', 6), - (42, 6, 23, '6', 7), - (43, 7, 56, 'Container', 1), - (44, 7, 58, 'medical box', 2), - (45, 7, 27, '100cm', 3), - ( - 46, 7, 36, 'Stark Industries', 4 - ), - (47, 7, 1, 'White', 5), - (48, 7, 67, 'supply', 6), - (49, 7, 23, '7', 7), - ( - 50, 8, 56, 'Ranged Reinforced weapon', 1 - ), - (51, 8, 58, '+1 longbow', 2), - (52, 8, 27, '200cm', 3), - ( - 53, 8, 36, 'Stark Industries', 4 - ), - (54, 8, 1, 'Brown', 5), - (55, 8, 67, 'precission', 6), - (56, 8, 23, '8', 7), - ( - 57, 9, 56, 'Melee Reinforced weapon', 1 - ), - (58, 9, 58, 'combat fist', 2), - (59, 9, 27, '15cm', 3), - ( - 60, 9, 36, 'Stark Industries', 4 - ), - (61, 9, 1, 'Silver', 5), - (62, 9, 67, 'Concussion', 6), - (63, 9, 23, '9', 7), - ( - 64, 10, 56, 'Ranged Reinforced weapon', 1 - ), - (65, 10, 58, 'sniper rifle', 2), - (66, 10, 67, '700mm', 3), - ( - 67, 10, 36, 'Stark Industries', 4 - ), - (68, 10, 1, 'Green', 5), - (69, 10, 27, '130cm', 6), - (70, 10, 23, '10', 7), - ( - 71, 11, 56, 'Melee Reinforced weapon', 1 - ), - (72, 11, 58, 'heavy shield', 2), - (73, 11, 4, '120cm', 3), - ( - 74, 11, 36, 'Stark Industries', 4 - ), - (75, 11, 1, 'Black', 5), - (76, 11, 67, 'containtment', 6), - (77, 11, 23, '11', 7), - ( - 78, 12, 56, 'Ranged Reinforced weapon', 1 - ), - (79, 12, 58, 'pistol', 2), - (80, 12, 27, '9mm', 3), - ( - 81, 12, 36, 'Stark Industries', 4 - ), - (82, 12, 1, 'Silver', 5), - (83, 12, 67, '23cm', 6), - (84, 12, 23, '12', 7), - (85, 13, 56, 'Chest', 1), - (86, 13, 58, 'ammo box', 2), - (87, 13, 27, '100cm', 3), - ( - 88, 13, 36, 'Stark Industries', 4 - ), - (89, 13, 1, 'Green', 5), - (90, 13, 67, 'supply', 6), - (91, 13, 23, '13', 7), - (92, 14, 56, 'Chest', 1), - (93, 14, 58, 'medical box', 2), - (94, 14, 27, '100cm', 3), - ( - 95, 14, 36, 'Stark Industries', 4 - ), - (96, 14, 1, 'White', 5), - (97, 14, 67, 'supply', 6), - (98, 14, 23, '1', 7), - (99, 15, 92, 'Trolley', 2), - (100, 16, 92, 'Pallet', 2), - ( - 101, 71, 92, 'Shipping cost', 2 - ); +INSERT INTO `vn`.`itemBotanical`(`itemFk`, `genusFk`, `specieFk`) + VALUES + (1, 1, 1), + (2, 2, 2), + (3, 2, NULL), + (4, 2, 1); -INSERT INTO - `vn`.`itemTypeTag` ( - `id`, `itemTypeFk`, `tagFk`, `priority` - ) -VALUES (1, 1, 1, 0), - (2, 2, 2, 0), - (3, 3, 3, 0), - (4, 1, 4, 4), - (5, 1, 5, 5); +INSERT INTO `vn`.`tag`(`id`, `code`, `name`, `isFree`, `isQuantitatif`, `sourceTable`, `unit`, `ediTypeFk`, `overwrite`) + VALUES + (1, 'color', 'Color', 0, 0, 'ink', NULL, NULL, 'inkFk'), + (2, NULL, 'Forma', 1, 0, NULL, NULL,NULL, NULL), + (3, NULL, 'Material', 1, 0, NULL, NULL,NULL, NULL), + (4, NULL, 'Longitud', 1, 1, NULL, 'mm', NULL, 'size'), + (5, NULL, 'Diámetro', 1, 1, NULL, 'mm',NULL, 'diameter'), + (7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm',NULL, NULL), + (23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems'), + (27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, 'size'), + (36, 'producer', 'Proveedor', 1, 0, NULL, NULL, NULL, 'producer'), + (56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL), + (58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL), + (67, 'category', 'Categoria', 1, 0, NULL, NULL, NULL, NULL), + (92, NULL, 'Nombre temporal', 1, 0, NULL, NULL, NULL, NULL); -CALL `vn`.`itemRefreshTags` (NULL); +INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) + VALUES + (1, 1, 56, 'Ranged weapon', 1), + (2, 1, 58, 'longbow', 2), + (3, 1, 27, '200cm', 3), + (4, 1, 36, 'Stark Industries', 4), + (5, 1, 1, 'Brown', 5), + (6, 1, 67, '+1 precission', 6), + (7, 1, 23, '1', 7), + (8, 2, 56, 'Melee weapon', 1), + (9, 2, 58, 'combat fist', 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, '2', 7), + (15, 3, 56, 'Ranged weapon', 1), + (16, 3, 58, 'sniper rifle', 2), + (17, 3, 4, '113cm', 3), + (18, 3, 36, 'Stark Industries', 4), + (19, 3, 1, 'Green', 5), + (20, 3, 67, 'precission', 6), + (21, 3, 23, '3', 7), + (22, 4, 56, 'Melee weapon', 1), + (23, 4, 58, 'heavy shield', 2), + (24, 4, 4, '100cm', 3), + (25, 4, 36, 'Stark Industries', 4), + (26, 4, 1, 'Black', 5), + (27, 4, 67, 'containtment', 6), + (28, 4, 23, '4', 7), + (29, 5, 56, 'Ranged weapon', 1), + (30, 5, 58, 'pistol', 2), + (31, 5, 67, '9mm', 3), + (32, 5, 36, 'Stark Industries', 4), + (33, 5, 1, 'Silver', 5), + (34, 5, 27, '15cm', 6), + (35, 5, 23, '5', 7), + (36, 6, 56, 'Container', 1), + (37, 6, 58, 'ammo box', 2), + (38, 6, 27, '100cm', 3), + (39, 6, 36, 'Stark Industries', 4), + (40, 6, 1, 'Green', 5), + (41, 6, 67, 'supply', 6), + (42, 6, 23, '6', 7), + (43, 7, 56, 'Container', 1), + (44, 7, 58, 'medical box', 2), + (45, 7, 27, '100cm', 3), + (46, 7, 36, 'Stark Industries', 4), + (47, 7, 1, 'White', 5), + (48, 7, 67, 'supply', 6), + (49, 7, 23, '7', 7), + (50, 8, 56, 'Ranged Reinforced weapon', 1), + (51, 8, 58, '+1 longbow', 2), + (52, 8, 27, '200cm', 3), + (53, 8, 36, 'Stark Industries', 4), + (54, 8, 1, 'Brown', 5), + (55, 8, 67, 'precission', 6), + (56, 8, 23, '8', 7), + (57, 9, 56, 'Melee Reinforced weapon', 1), + (58, 9, 58, 'combat fist', 2), + (59, 9, 27, '15cm', 3), + (60, 9, 36, 'Stark Industries', 4), + (61, 9, 1, 'Silver', 5), + (62, 9, 67, 'Concussion', 6), + (63, 9, 23, '9', 7), + (64, 10, 56, 'Ranged Reinforced weapon', 1), + (65, 10, 58, 'sniper rifle', 2), + (66, 10, 67, '700mm', 3), + (67, 10, 36, 'Stark Industries', 4), + (68, 10, 1, 'Green', 5), + (69, 10, 27, '130cm', 6), + (70, 10, 23, '10', 7), + (71, 11, 56, 'Melee Reinforced weapon', 1), + (72, 11, 58, 'heavy shield', 2), + (73, 11, 4, '120cm', 3), + (74, 11, 36, 'Stark Industries', 4), + (75, 11, 1, 'Black', 5), + (76, 11, 67, 'containtment', 6), + (77, 11, 23, '11', 7), + (78, 12, 56, 'Ranged Reinforced weapon', 1), + (79, 12, 58, 'pistol', 2), + (80, 12, 27, '9mm', 3), + (81, 12, 36, 'Stark Industries', 4), + (82, 12, 1, 'Silver', 5), + (83, 12, 67, '23cm', 6), + (84, 12, 23, '12', 7), + (85, 13, 56, 'Chest', 1), + (86, 13, 58, 'ammo box', 2), + (87, 13, 27, '100cm', 3), + (88, 13, 36, 'Stark Industries', 4), + (89, 13, 1, 'Green', 5), + (90, 13, 67, 'supply', 6), + (91, 13, 23, '13', 7), + (92, 14, 56, 'Chest', 1), + (93, 14, 58, 'medical box', 2), + (94, 14, 27, '100cm', 3), + (95, 14, 36, 'Stark Industries', 4), + (96, 14, 1, 'White', 5), + (97, 14, 67, 'supply', 6), + (98, 14, 23, '1', 7), + (99, 15, 92, 'Trolley', 2), + (100, 16, 92, 'Pallet', 2), + (101, 71, 92, 'Shipping cost', 2); -INSERT INTO - `vn`.`itemLog` ( - `id`, `originFk`, `userFk`, `action`, `description`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`, `changedModelValue` - ) -VALUES ( - '1', '1', '1', 'insert', 'We made a change!', 'Item', '{}', '{}', 1, '1' - ); +INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) + VALUES + (1, 1, 1, 0), + (2, 2, 2, 0), + (3, 3, 3, 0), + (4, 1, 4, 4), + (5, 1, 5, 5); -INSERT INTO - `vn`.`recovery` ( - `id`, `clientFk`, `started`, `finished`, `amount`, `period` - ) -VALUES ( - 1, 1101, DATE_ADD( - util.VN_CURDATE (), INTERVAL -7 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), 50, 7 - ), - ( - 2, 1102, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 MONTH - ), util.VN_CURDATE (), 100, 1 - ), - ( - 3, 1102, util.VN_CURDATE (), DATE_ADD( - util.VN_CURDATE (), INTERVAL 1 MONTH - ), 50, 7 - ), - ( - 4, 1103, util.VN_CURDATE (), NULL, 50, 7 - ); +CALL `vn`.`itemRefreshTags`(NULL); -INSERT INTO - `bs`.`clientAnnualConsumption` (`clientFk`, `invoiced`) -VALUES (1101, 1500), - (1102, 100), - (1103, 1000), - (1104, 500), - (1105, 5000); +INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`, `changedModelValue`) + VALUES + ('1', '1', '1', 'insert', 'We made a change!', 'Item', '{}', '{}', 1, '1'); -INSERT INTO - `cache`.`cache_calc` ( - `id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id` - ) -VALUES ( - 1, 2, 'available', CONCAT_WS('/', 1, util.VN_CURDATE ()), util.VN_NOW (), DATE_ADD( - util.VN_NOW (), INTERVAL 15 MINUTE - ), util.VN_CURDATE (), NULL - ), - ( - 2, 4, 'last_buy', CONCAT_WS('/', 1, util.VN_CURDATE ()), util.VN_NOW (), DATE_ADD( - util.VN_NOW (), INTERVAL 15 MINUTE - ), util.VN_CURDATE (), NULL - ), - ( - 3, 8, 'visible', CONCAT_WS('/', 1, util.VN_CURDATE ()), util.VN_NOW (), DATE_ADD( - util.VN_NOW (), INTERVAL 15 MINUTE - ), util.VN_CURDATE (), NULL - ); +INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) + VALUES + (1, 1101, DATE_ADD(util.VN_CURDATE(),INTERVAL -7 MONTH), DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), 50, 7), + (2, 1102, DATE_ADD(util.VN_CURDATE(),INTERVAL -5 MONTH), util.VN_CURDATE(), 100, 1), + (3, 1102, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(),INTERVAL 1 MONTH), 50, 7), + (4, 1103, util.VN_CURDATE(), NULL, 50, 7); -INSERT INTO - `vn`.`ticketWeekly` (`ticketFk`, `weekDay`) -VALUES (2, 1), - (3, 2), - (5, 6), - (15, 6); +INSERT INTO `bs`.`clientAnnualConsumption`(`clientFk`, `invoiced`) + VALUES + (1101, 1500), + (1102, 100), + (1103, 1000), + (1104, 500), + (1105, 5000); -INSERT INTO - `vn`.`awb` ( - id, code, package, weight, created, amount, transitoryFk, taxFk - ) -VALUES ( - 1, '07546501420', 67, 671, util.VN_CURDATE (), 1761, 1, 1 - ), - ( - 2, '07546491421', 252, 2769, util.VN_CURDATE (), 5231, 1, 1 - ), - ( - 3, '07546500823', 102, 1495, util.VN_CURDATE (), 3221, 1, 1 - ), - ( - 4, '99610288821', 252, 2777, util.VN_CURDATE (), 3641, 1, 1 - ), - ( - 5, '07546500834', 229, 3292, util.VN_CURDATE (), 6601, 2, 1 - ), - ( - 6, '22101929561', 37, 458, util.VN_CURDATE (), 441, 2, 1 - ), - ( - 7, '07546491432', 258, 3034, util.VN_CURDATE (), 6441, 2, 1 - ), - ( - 8, '99610288644', 476, 4461, util.VN_CURDATE (), 5751, 442, 1 - ), - ( - 9, '99610289193', 302, 2972, util.VN_CURDATE (), 3871, 442, 1 - ), - ( - 10, '07546500856', 185, 2364, util.VN_CURDATE (), 5321, 442, 1 - ); +INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) + VALUES + (1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL), + (2, 4, 'last_buy', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL), + (3, 8, 'visible', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL); -INSERT INTO - `vn`.`travel` ( - `id`, `shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`, `ref`, `totalEntries`, `cargoSupplierFk`, `awbFK` - ) -VALUES ( - 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1 - ), - ( - 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2 - ), - ( - 3, util.VN_CURDATE (), util.VN_CURDATE (), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3 - ), - ( - 4, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4 - ), - ( - 5, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5 - ), - ( - 6, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6 - ), - ( - 7, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7 - ), - ( - 8, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10 - ); +INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) + VALUES + (2, 1), + (3, 2), + (5, 6), + (15, 6); -INSERT INTO - `vn`.`entry` ( - `id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes` - ) -VALUES ( - 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, '' - ), - ( - 2, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two' - ), - ( - 3, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three' - ), - ( - 4, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four' - ), - ( - 5, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five' - ), - ( - 6, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six' - ), - ( - 7, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven' - ), - ( - 8, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '' - ); +INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) + VALUES + (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), + (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), + (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), + (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1), + (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1), + (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1), + (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1), + (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1), + (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), + (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO - `bs`.`waste` ( - `buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate` - ) -VALUES ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Carnation', 1, 1, '1062', '51', '4.8' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Carnation Colombia', 2, 1, '35074', '687', '2.0' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Carnation Mini', 3, 1, '1777', '13', '0.7' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Carnation Short', 4, 1, '3182', '59', '0.6' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Crisantemo', 5, 1, '1747', '13', '0.7' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Lilium Oriental', 6, 1, '7182', '59', '0.6' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Alstroemeria', 7, 1, '1777', '13', '0.7' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Cymbidium', 1, 1, '4181', '59', '0.6' - ), - ( - 'CharlesXavier', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Cymbidium', 2, 1, '7268', '59', '0.6' - ), - ( - 'DavidCharlesHaller', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Containers', 2, 1, '-74', '0', '0.0' - ), - ( - 'DavidCharlesHaller', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Packagings', 3, 1, '-7', '0', '0.0' - ), - ( - 'DavidCharlesHaller', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Freight', 4, 1, '1100', '0', '0.0' - ), - ( - 'HankPym', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1' - ), - ( - 'HankPym', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0' - ), - ( - 'HankPym', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ) - ), WEEK( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 WEEK - ), 1 - ), 'Adhesives', 7, 1, '277', '0', '0.0' - ); +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`) + VALUES + (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), + (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), + (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), + (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10); -INSERT INTO - `vn`.`buy` ( - `id`, `entryFk`, `itemFk`, `buyingValue`, `quantity`, `packagingFk`, `stickers`, `freightValue`, `packageValue`, `comissionValue`, `packing`, `grouping`, `groupingMode`, `location`, `price1`, `price2`, `price3`, `printedStickers`, `isChecked`, `isIgnored`, `weight`, `created` - ) -VALUES ( - 1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ) - ), - ( - 2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE () - ), - ( - 4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE () - ), - ( - 5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE () - ), - ( - 6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE () - ), - ( - 7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE () - ), - ( - 8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE () - ), - ( - 9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE () - ), - ( - 15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE () - ); +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) + VALUES + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, ''), + (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two'), + (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three'), + (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four'), + (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'), + (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'), + (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'), + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''); -INSERT INTO - `hedera`.`order` ( - `id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`, `total`, `date_make`, `first_row_stamp`, `confirm_date` - ) -VALUES ( - 1, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1101, 3, 1, 121, 442, NULL, 'TPV', 1, '155.89', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 2, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1104, 3, 1, 124, 442, NULL, 'WEB', 1, '100.10', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 3, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), INTERVAL + 1 DAY - ), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1, '107.25', DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ) - ), - ( - 4, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), INTERVAL + 1 DAY - ), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1, '10.01', DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ) - ), - ( - 5, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), INTERVAL + 1 DAY - ), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1, '10.01', DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ) - ), - ( - 6, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), INTERVAL + 1 DAY - ), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1, '10.01', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ) - ), - ( - 7, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0, '10.01', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 8, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0, '123.53', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 9, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0, '10.01', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 10, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0, '10.01', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 11, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0, '60.90', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 12, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 13, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 14, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 15, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 16, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0, '155.89', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 17, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 18, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0, '72.60', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 19, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0, '16.50', util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 20, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0, '21.45', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ), - ( - 21, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0, '0.00', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ), - ( - 22, DATE_ADD( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), INTERVAL + 1 DAY - ), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0, '148.50', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ) - ); +INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) + VALUES + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); -INSERT INTO - `hedera`.`orderRow` ( - `id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk` - ) -VALUES ( - 1, 1, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 5, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1 - ), - ( - 2, 1, 2, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 10, 1.07, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2 - ), - ( - 3, 1, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 3 - ), - ( - 4, 1, 4, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 20, 3.06, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 4 - ), - ( - 5, 2, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 10, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 5 - ), - ( - 6, 3, 1, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), 15, 6.50, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 MONTH - ), 6 - ), - ( - 7, 11, 2, 1, util.VN_CURDATE (), 15, 1.30, 0, util.VN_CURDATE (), 7 - ), - ( - 8, 11, 4, 1, util.VN_CURDATE (), 10, 3.26, 0, util.VN_CURDATE (), 8 - ), - ( - 9, 16, 1, 1, util.VN_CURDATE (), 5, 9.10, 0, util.VN_CURDATE (), 9 - ), - ( - 10, 16, 2, 1, util.VN_CURDATE (), 10, 1.07, 0, util.VN_CURDATE (), 10 - ), - ( - 11, 16, 1, 1, util.VN_CURDATE (), 2, 9.10, 0, util.VN_CURDATE (), 11 - ), - ( - 12, 16, 4, 1, util.VN_CURDATE (), 20, 3.06, 0, util.VN_CURDATE (), 12 - ), - ( - 13, 8, 2, 1, util.VN_CURDATE (), 15, 1.30, 0, util.VN_CURDATE (), 13 - ), - ( - 14, 8, 1, 1, util.VN_CURDATE (), 10, 9.28, 0, util.VN_CURDATE (), 14 - ), - ( - 15, 19, 1, 1, util.VN_CURDATE (), 10, 1.50, 0, util.VN_CURDATE (), 15 - ), - ( - 16, 20, 2, 1, util.VN_CURDATE (), 15, 1.30, 0, util.VN_CURDATE (), 16 - ), - ( - 17, 22, 2, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 30, 2.30, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 17 - ), - ( - 18, 22, 4, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 20, 3.00, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 MONTH - ), 18 - ), - ( - 19, 4, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), 1, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 MONTH - ), 19 - ), - ( - 20, 5, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), 1, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -4 MONTH - ), 20 - ), - ( - 21, 6, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 9.10, 0, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 21 - ), - ( - 22, 7, 1, 1, util.VN_CURDATE (), 1, 9.10, 0, util.VN_CURDATE (), 22 - ), - ( - 23, 9, 1, 1, util.VN_CURDATE (), 1, 9.10, 0, util.VN_CURDATE (), 23 - ), - ( - 24, 10, 1, 1, util.VN_CURDATE (), 1, 9.10, 0, util.VN_CURDATE (), 24 - ), - ( - 25, 12, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 25 - ), - ( - 26, 13, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 26 - ), - ( - 27, 14, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 27 - ), - ( - 28, 15, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 28 - ), - ( - 29, 17, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 29 - ), - ( - 30, 18, 4, 1, util.VN_CURDATE (), 20, 3.00, 0, util.VN_CURDATE (), 30 - ); +INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) + VALUES + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); -INSERT INTO - `hedera`.`orderRowComponent` ( - `rowFk`, `componentFk`, `price` - ) -VALUES (1, 15, 0.58), - (1, 23, 6.5), - (1, 28, 20.72), - (1, 29, -18.72), - (1, 39, 0.02), - (2, 15, 0.058), - (2, 21, 0.002), - (2, 28, 5.6), - (2, 29, -4.6), - (2, 39, 0.01), - (3, 15, 0.58), - (3, 23, 6.5), - (3, 28, 20.72), - (3, 29, -18.72), - (3, 39, 0.02), - (4, 15, 0.051), - (4, 21, -0.001), - (4, 28, 20.72), - (4, 29, -19.72), - (4, 37, 2), - (4, 39, 0.01), - (5, 15, 0.58), - (5, 23, 6.5), - (5, 28, 20.72), - (5, 29, -18.72), - (5, 39, 0.02), - (6, 23, 6.5), - (7, 15, 0.0114), - (7, 28, 5.6), - (7, 29, -4.6), - (7, 39, 0.01), - (8, 15, 0.0016), - (8, 28, 20.72), - (8, 29, -19.72), - (8, 37, 2), - (8, 39, 0.01), - (9, 15, 0.58), - (9, 23, 6.5), - (9, 28, 20.72), - (9, 29, -18.72), - (9, 39, 0.02), - (10, 15, 0.058), - (10, 21, 0.002), - (10, 28, 5.6), - (10, 29, -4.6), - (10, 39, 0.01), - (11, 15, 0.58), - (11, 23, 6.5), - (11, 28, 20.72), - (11, 29, -18.72), - (11, 39, 0.02), - (12, 15, 0.051), - (12, 22, -0.001), - (12, 28, 20.72), - (12, 29, -19.72), - (12, 37, 2), - (12, 39, 0.01), - (13, 15, 0.2899), - (13, 28, 5.6), - (13, 29, -4.6), - (13, 39, 0.01), - (14, 15, 0.58), - (14, 23, 6.5), - (14, 28, 20.72), - (14, 29, -18.72), - (14, 39, 0.02), - (15, 15, 0.58), - (15, 23, 6.5), - (15, 28, 20.72), - (15, 29, -18.72), - (15, 39, 0.02), - (16, 15, 0.058), - (16, 21, 0.002), - (16, 28, 5.6), - (16, 29, -4.6), - (16, 39, 0.01), - (17, 15, 0.058), - (17, 21, 0.002), - (17, 28, 5.6), - (17, 29, -4.6), - (17, 39, 0.01), - (18, 15, 0.051), - (18, 22, -0.001), - (18, 28, 20.72), - (18, 29, -19.72), - (18, 37, 2), - (18, 39, 0.01), - (19, 15, 0.58), - (19, 23, 6.5), - (19, 28, 20.72), - (19, 29, -18.72), - (19, 39, 0.02), - (20, 15, 0.58), - (20, 23, 6.5), - (20, 28, 20.72), - (20, 29, -18.72), - (20, 39, 0.02), - (21, 15, 0.58), - (21, 23, 6.5), - (21, 28, 20.72), - (21, 29, -18.72), - (21, 39, 0.02), - (22, 15, 0.58), - (22, 23, 6.5), - (22, 28, 20.72), - (22, 29, -18.72), - (22, 39, 0.02), - (23, 15, 0.58), - (23, 23, 6.5), - (23, 28, 20.72), - (23, 29, -18.72), - (23, 39, 0.02), - (24, 15, 0.58), - (24, 23, 6.5), - (24, 28, 20.72), - (24, 29, -18.72), - (24, 39, 0.02), - (25, 15, 0.051), - (25, 22, -0.001), - (25, 28, 20.72), - (25, 29, -19.72), - (25, 37, 2), - (25, 39, 0.01), - (26, 15, 0.051), - (26, 22, -0.001), - (26, 28, 20.72), - (26, 29, -19.72), - (26, 37, 2), - (26, 39, 0.01), - (27, 15, 0.051), - (27, 22, -0.001), - (27, 28, 20.72), - (27, 29, -19.72), - (27, 37, 2), - (27, 39, 0.01), - (28, 15, 0.051), - (28, 22, -0.001), - (28, 28, 20.72), - (28, 29, -19.72), - (28, 37, 2), - (28, 39, 0.01), - (29, 15, 0.051), - (29, 22, -0.001), - (29, 28, 20.72), - (29, 29, -19.72), - (29, 37, 2), - (29, 39, 0.01), - (30, 15, 0.051), - (30, 22, -0.001), - (30, 28, 20.72), - (30, 29, -19.72), - (30, 37, 2), - (30, 39, 0.01); +INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) + VALUES + (1, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (2, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (4, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (5, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (6, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (9, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (11, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (12, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (13, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (14, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (15, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (16, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (17, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (18, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (19, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (20, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (21, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (22, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)); -INSERT INTO - `hedera`.`visit` (`id`, `firstAgentFk`) -VALUES (1, NULL), - (2, NULL), - (3, NULL), - (4, NULL), - (5, NULL), - (6, NULL), - (7, NULL), - (8, NULL), - (9, NULL), - (10, NULL), - (11, NULL); +INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`) + VALUES + (1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1), + (2, 1, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2), + (3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3), + (4, 1, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4), + (5, 2, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5), + (6, 3, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 6), + (7, 11, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 7), + (8, 11, 4, 1, util.VN_CURDATE(), 10, 3.26, 0, util.VN_CURDATE(), 8), + (9, 16, 1, 1, util.VN_CURDATE(), 5, 9.10, 0, util.VN_CURDATE(), 9), + (10, 16, 2, 1, util.VN_CURDATE(), 10, 1.07, 0, util.VN_CURDATE(), 10), + (11, 16, 1, 1, util.VN_CURDATE(), 2, 9.10, 0, util.VN_CURDATE(), 11), + (12, 16, 4, 1, util.VN_CURDATE(), 20, 3.06, 0, util.VN_CURDATE(), 12), + (13, 8, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 13), + (14, 8, 1, 1, util.VN_CURDATE(), 10, 9.28, 0, util.VN_CURDATE(), 14), + (15, 19, 1, 1, util.VN_CURDATE(), 10, 1.50, 0, util.VN_CURDATE(), 15), + (16, 20, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 16), + (17, 22, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 17), + (18, 22, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 18), + (19, 4, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 19), + (20, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 20), + (21, 6, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 21), + (22, 7, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 22), + (23, 9, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 23), + (24, 10, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 24), + (25, 12, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 25), + (26, 13, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 26), + (27, 14, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 27), + (28, 15, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 28), + (29, 17, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 29), + (30, 18, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 30); -INSERT INTO - `hedera`.`visitAgent` (`id`, `visitFk`) -VALUES (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11); +INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) + VALUES + (1, 15, 0.58), + (1, 23, 6.5), + (1, 28, 20.72), + (1, 29, -18.72), + (1, 39, 0.02), + (2, 15, 0.058), + (2, 21, 0.002), + (2, 28, 5.6), + (2, 29, -4.6), + (2, 39, 0.01), + (3, 15, 0.58), + (3, 23, 6.5), + (3, 28, 20.72), + (3, 29, -18.72), + (3, 39, 0.02), + (4, 15, 0.051), + (4, 21, -0.001), + (4, 28, 20.72), + (4, 29, -19.72), + (4, 37, 2), + (4, 39, 0.01), + (5, 15, 0.58), + (5, 23, 6.5), + (5, 28, 20.72), + (5, 29, -18.72), + (5, 39, 0.02), + (6, 23, 6.5), + (7, 15, 0.0114), + (7, 28, 5.6), + (7, 29, -4.6), + (7, 39, 0.01), + (8, 15, 0.0016), + (8, 28, 20.72), + (8, 29, -19.72), + (8, 37, 2), + (8, 39, 0.01), + (9, 15, 0.58), + (9, 23, 6.5), + (9, 28, 20.72), + (9, 29, -18.72), + (9, 39, 0.02), + (10, 15, 0.058), + (10, 21, 0.002), + (10, 28, 5.6), + (10, 29, -4.6), + (10, 39, 0.01), + (11, 15, 0.58), + (11, 23, 6.5), + (11, 28, 20.72), + (11, 29, -18.72), + (11, 39, 0.02), + (12, 15, 0.051), + (12, 22, -0.001), + (12, 28, 20.72), + (12, 29, -19.72), + (12, 37, 2), + (12, 39, 0.01), + (13, 15, 0.2899), + (13, 28, 5.6), + (13, 29, -4.6), + (13, 39, 0.01), + (14, 15, 0.58), + (14, 23, 6.5), + (14, 28, 20.72), + (14, 29, -18.72), + (14, 39, 0.02), + (15, 15, 0.58), + (15, 23, 6.5), + (15, 28, 20.72), + (15, 29, -18.72), + (15, 39, 0.02), + (16, 15, 0.058), + (16, 21, 0.002), + (16, 28, 5.6), + (16, 29, -4.6), + (16, 39, 0.01), + (17, 15, 0.058), + (17, 21, 0.002), + (17, 28, 5.6), + (17, 29, -4.6), + (17, 39, 0.01), + (18, 15, 0.051), + (18, 22, -0.001), + (18, 28, 20.72), + (18, 29, -19.72), + (18, 37, 2), + (18, 39, 0.01), + (19, 15, 0.58), + (19, 23, 6.5), + (19, 28, 20.72), + (19, 29, -18.72), + (19, 39, 0.02), + (20, 15, 0.58), + (20, 23, 6.5), + (20, 28, 20.72), + (20, 29, -18.72), + (20, 39, 0.02), + (21, 15, 0.58), + (21, 23, 6.5), + (21, 28, 20.72), + (21, 29, -18.72), + (21, 39, 0.02), + (22, 15, 0.58), + (22, 23, 6.5), + (22, 28, 20.72), + (22, 29, -18.72), + (22, 39, 0.02), + (23, 15, 0.58), + (23, 23, 6.5), + (23, 28, 20.72), + (23, 29, -18.72), + (23, 39, 0.02), + (24, 15, 0.58), + (24, 23, 6.5), + (24, 28, 20.72), + (24, 29, -18.72), + (24, 39, 0.02), + (25, 15, 0.051), + (25, 22, -0.001), + (25, 28, 20.72), + (25, 29, -19.72), + (25, 37, 2), + (25, 39, 0.01), + (26, 15, 0.051), + (26, 22, -0.001), + (26, 28, 20.72), + (26, 29, -19.72), + (26, 37, 2), + (26, 39, 0.01), + (27, 15, 0.051), + (27, 22, -0.001), + (27, 28, 20.72), + (27, 29, -19.72), + (27, 37, 2), + (27, 39, 0.01), + (28, 15, 0.051), + (28, 22, -0.001), + (28, 28, 20.72), + (28, 29, -19.72), + (28, 37, 2), + (28, 39, 0.01), + (29, 15, 0.051), + (29, 22, -0.001), + (29, 28, 20.72), + (29, 29, -19.72), + (29, 37, 2), + (29, 39, 0.01), + (30, 15, 0.051), + (30, 22, -0.001), + (30, 28, 20.72), + (30, 29, -19.72), + (30, 37, 2), + (30, 39, 0.01); -INSERT INTO - `hedera`.`visitAccess` (`id`, `agentFk`, `stamp`) -VALUES (1, 1, util.VN_CURDATE ()), - (2, 2, util.VN_CURDATE ()), - (3, 3, util.VN_CURDATE ()), - (4, 4, util.VN_CURDATE ()), - (5, 5, util.VN_CURDATE ()), - (6, 6, util.VN_CURDATE ()), - (7, 7, util.VN_CURDATE ()), - (8, 8, util.VN_CURDATE ()), - (9, 9, util.VN_CURDATE ()), - (10, 10, util.VN_CURDATE ()), - (11, 11, util.VN_CURDATE ()); +INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`) + VALUES + (1, NULL), + (2, NULL), + (3, NULL), + (4, NULL), + (5, NULL), + (6, NULL), + (7, NULL), + (8, NULL), + (9, NULL), + (10, NULL), + (11, NULL); -INSERT INTO - `hedera`.`visitUser` ( - `id`, `accessFk`, `userFk`, `stamp` - ) -VALUES ( - 1, 1, 1101, util.VN_CURDATE () - ), - ( - 2, 2, 1101, util.VN_CURDATE () - ), - ( - 3, 3, 1101, util.VN_CURDATE () - ), - ( - 4, 4, 1102, util.VN_CURDATE () - ), - ( - 5, 5, 1102, util.VN_CURDATE () - ), - ( - 6, 6, 1102, util.VN_CURDATE () - ), - ( - 7, 7, 1103, util.VN_CURDATE () - ), - ( - 8, 8, 1103, util.VN_CURDATE () - ), - ( - 9, 9, 1103, util.VN_CURDATE () - ), - ( - 10, 10, 1102, DATE_SUB( - util.VN_CURDATE (), INTERVAL 1 DAY - ) - ), - ( - 11, 11, 1103, DATE_SUB( - util.VN_CURDATE (), INTERVAL 1 DAY - ) - ); +INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`) + VALUES + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11); -INSERT INTO - `hedera`.`userSession` ( - `created`, `lastUpdate`, `ssid`, `data`, `userVisitFk` - ) -VALUES ( - util.VN_CURDATE (), util.VN_CURDATE (), '121', 'data', 1 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '122', 'data', 2 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '123', 'data', 3 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '124', 'data', 4 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '125', 'data', 5 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '126', 'data', 6 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '127', 'data', 7 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '128', 'data', 8 - ), - ( - util.VN_CURDATE (), util.VN_CURDATE (), '129', 'data', 9 - ); +INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`) + VALUES + (1, 1, util.VN_CURDATE()), + (2, 2, util.VN_CURDATE()), + (3, 3, util.VN_CURDATE()), + (4, 4, util.VN_CURDATE()), + (5, 5, util.VN_CURDATE()), + (6, 6, util.VN_CURDATE()), + (7, 7, util.VN_CURDATE()), + (8, 8, util.VN_CURDATE()), + (9, 9, util.VN_CURDATE()), + (10, 10, util.VN_CURDATE()), + (11, 11, util.VN_CURDATE()); -INSERT INTO - `vn`.`clientContact` ( - `id`, `clientFk`, `name`, `phone` - ) -VALUES ( - 1, 1101, 'contact 1', 666777888 - ), - ( - 2, 1101, 'contact 2', 111222333 - ), - ( - 3, 1101, 'contact 3', 222333444 - ), - ( - 4, 1102, 'contact 1', 876543219 - ); +INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`) + VALUES + (1, 1, 1101, util.VN_CURDATE()), + (2, 2, 1101, util.VN_CURDATE()), + (3, 3, 1101, util.VN_CURDATE()), + (4, 4, 1102, util.VN_CURDATE()), + (5, 5, 1102, util.VN_CURDATE()), + (6, 6, 1102, util.VN_CURDATE()), + (7, 7, 1103, util.VN_CURDATE()), + (8, 8, 1103, util.VN_CURDATE()), + (9, 9, 1103, util.VN_CURDATE()), + (10, 10, 1102, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)), + (11, 11, 1103, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)); -INSERT INTO - `vn`.`workerManaExcluded` (`workerFk`) -VALUES (9); +INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`) + VALUES + (util.VN_CURDATE(), util.VN_CURDATE(), '121', 'data', 1), + (util.VN_CURDATE(), util.VN_CURDATE(), '122', 'data', 2), + (util.VN_CURDATE(), util.VN_CURDATE(), '123', 'data', 3), + (util.VN_CURDATE(), util.VN_CURDATE(), '124', 'data', 4), + (util.VN_CURDATE(), util.VN_CURDATE(), '125', 'data', 5), + (util.VN_CURDATE(), util.VN_CURDATE(), '126', 'data', 6), + (util.VN_CURDATE(), util.VN_CURDATE(), '127', 'data', 7), + (util.VN_CURDATE(), util.VN_CURDATE(), '128', 'data', 8), + (util.VN_CURDATE(), util.VN_CURDATE(), '129', 'data', 9); +INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`) + VALUES + (1, 1101, 'contact 1', 666777888), + (2, 1101, 'contact 2', 111222333), + (3, 1101, 'contact 3', 222333444), + (4, 1102, 'contact 1', 876543219); + +INSERT INTO `vn`.`workerManaExcluded`(`workerFk`) + VALUES + (9); /* -el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes, -pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto -La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets + el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes, + pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto + + La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets */ -call vn.manaSpellersRequery (19); +call vn.manaSpellersRequery(19); +call vn.manaSpellersRequery(18); -call vn.manaSpellersRequery (18); +INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) + VALUES + (1, 1101, 1, util.VN_CURDATE(), 18, 18, 442), + (2, 1101, 1, util.VN_CURDATE(), 18, 18, 442), + (3, 1101, 2, util.VN_CURDATE(), 18, 18, 442), + (4, 1102, 2, util.VN_CURDATE(), 18, 18, 567), + (5, 1102, 3, util.VN_CURDATE(), 19, 19, 567); -INSERT INTO - `vn`.`clientSample` ( - `id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk` - ) -VALUES ( - 1, 1101, 1, util.VN_CURDATE (), 18, 18, 442 - ), - ( - 2, 1101, 1, util.VN_CURDATE (), 18, 18, 442 - ), - ( - 3, 1101, 2, util.VN_CURDATE (), 18, 18, 442 - ), - ( - 4, 1102, 2, util.VN_CURDATE (), 18, 18, 567 - ), - ( - 5, 1102, 3, util.VN_CURDATE (), 19, 19, 567 - ); +INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`) + VALUES + ( 1, 'pending', 'Pendiente', 1, 1, 0), + ( 2, 'managed', 'Gestionado', 72, 5, 0), + ( 3, 'resolved', 'Resuelto', 72, 7, 0), + ( 4, 'canceled', 'Anulado', 72, 6, 1), + ( 5, 'incomplete', 'Incompleta', 1, 3, 1), + ( 6, 'mana', 'Mana', 72, 4, 0), + ( 7, 'lack', 'Faltas', 72, 2, 0); -INSERT INTO - `vn`.`claimState` ( - `id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify` - ) -VALUES ( - 1, 'pending', 'Pendiente', 1, 1, 0 - ), - ( - 2, 'managed', 'Gestionado', 72, 5, 0 - ), - ( - 3, 'resolved', 'Resuelto', 72, 7, 0 - ), - ( - 4, 'canceled', 'Anulado', 72, 6, 1 - ), - ( - 5, 'incomplete', 'Incompleta', 1, 3, 1 - ), - (6, 'mana', 'Mana', 72, 4, 0), - (7, 'lack', 'Faltas', 72, 2, 0); +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`, `ticketFk`) + VALUES + (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183', 11), + (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL, 16), + (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL, 7), + (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL, 8); -INSERT INTO - `vn`.`claim` ( - `id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`, `ticketFk` - ) -VALUES ( - 1, util.VN_CURDATE (), 1, 1101, 18, 3, 0, util.VN_CURDATE (), 0, '02676A049183', 11 - ), - ( - 2, util.VN_CURDATE (), 2, 1101, 18, 3, 0, util.VN_CURDATE (), 1, NULL, 16 - ), - ( - 3, util.VN_CURDATE (), 3, 1101, 18, 1, 1, util.VN_CURDATE (), 5, NULL, 7 - ), - ( - 4, util.VN_CURDATE (), 3, 1104, 18, 5, 0, util.VN_CURDATE (), 10, NULL, 8 - ); +INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) + VALUES + (1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE()), + (2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE()), + (3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE()), + (4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE()); -INSERT INTO - `vn`.`claimObservation` ( - `claimFk`, `workerFk`, `text`, `created` - ) -VALUES ( - 1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE () - ), - ( - 2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE () - ), - ( - 3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE () - ), - ( - 4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE () - ); +INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`) + VALUES + (1, 1, 7, 5), + (2, 2, 10, 10), + (3, 3, 22, 1), + (4, 4, 13, 5); -INSERT INTO - `vn`.`claimBeginning` ( - `id`, `claimFk`, `saleFk`, `quantity` - ) -VALUES (1, 1, 7, 5), - (2, 2, 10, 10), - (3, 3, 22, 1), - (4, 4, 13, 5); +INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) + VALUES + (1, 'Bueno', NULL), + (2, 'Basura/Perd.', 12), + (3, 'Confeccion', NULL), + (4, 'Reclam.PRAG', 12), + (5, 'Corregido', 11); -INSERT INTO - `vn`.`claimDestination` ( - `id`, `description`, `addressFk` - ) -VALUES (1, 'Bueno', NULL), - (2, 'Basura/Perd.', 12), - (3, 'Confeccion', NULL), - (4, 'Reclam.PRAG', 12), - (5, 'Corregido', 11); +INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) + VALUES + (1, 1, 1, 21, 1, 1, 2, 5), + (2, 1, 2, 21, 7, 2, 2, 5), + (3, 2, 7, 21, 9, 3, 2, 5), + (4, 3, 7, 21, 15, 8, 2, 5), + (5, 4, 7, 21, 7, 8, 2, 5); -INSERT INTO - `vn`.`claimDevelopment` ( - `id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk` - ) -VALUES (1, 1, 1, 21, 1, 1, 2, 5), - (2, 1, 2, 21, 7, 2, 2, 5), - (3, 2, 7, 21, 9, 3, 2, 5), - (4, 3, 7, 21, 15, 8, 2, 5), - (5, 4, 7, 21, 7, 8, 2, 5); +INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestinationFk`) + VALUES + (1, 31, 4, 21, 2), + (2, 32, 3, 21, 3); -INSERT INTO - `vn`.`claimEnd` ( - `id`, `saleFk`, `claimFk`, `workerFk`, `claimDestinationFk` - ) -VALUES (1, 31, 4, 21, 2), - (2, 32, 3, 21, 3); +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) + VALUES + (1, 50), + (2, 30); -INSERT INTO - `vn`.`claimConfig` (`id`, `maxResponsibility`) -VALUES (1, 50), - (2, 30); +INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) + VALUES + (1101, 500, NULL, 0.00, 0.00, 1.00), + (1102, 1000, 2.00, 0.01, 0.05, 1.00), + (1103, 2000, 0.00, 0.00, 0.02, 1.00), + (1104, 2500, 150.00, 0.02, 0.10, 1.00); -INSERT INTO - `vn`.`claimRatio` ( - `clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate` - ) -VALUES ( - 1101, 500, NULL, 0.00, 0.00, 1.00 - ), - ( - 1102, 1000, 2.00, 0.01, 0.05, 1.00 - ), - ( - 1103, 2000, 0.00, 0.00, 0.02, 1.00 - ), - ( - 1104, 2500, 150.00, 0.02, 0.10, 1.00 - ); +INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`) + VALUES + (1, '02676A049183', DEFAULT, 1106), + (2, '02676A049183', DEFAULT, 1106), + (3, '02676A049183', DEFAULT, 1107), + (4, '02676A049183', DEFAULT, 1107), + (5, '01837B023653', DEFAULT, 1106); -INSERT INTO - vn.claimRma ( - `id`, `code`, `created`, `workerFk` - ) -VALUES ( - 1, '02676A049183', DEFAULT, 1106 - ), - ( - 2, '02676A049183', DEFAULT, 1106 - ), - ( - 3, '02676A049183', DEFAULT, 1107 - ), - ( - 4, '02676A049183', DEFAULT, 1107 - ), - ( - 5, '01837B023653', DEFAULT, 1106 - ); +INSERT INTO `vn`.`claimLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`) + VALUES + (1, 18, 'update', 'Claim', '{"hasToPickUp":false}', '{"hasToPickUp":true}', 1, NULL), + (1, 18, 'update', 'ClaimObservation', '{}', '{"claimFk":1,"text":"Waiting for customer"}', 1, NULL), + (1, 18, 'insert', 'ClaimBeginning', '{}', '{"claimFk":1,"saleFk":1,"quantity":10}', 1, NULL), + (1, 18, 'insert', 'ClaimDms', '{}', '{"claimFk":1,"dmsFk":1}', 1, NULL); -INSERT INTO - `vn`.`claimLog` ( - `originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description` - ) -VALUES ( - 1, 18, 'update', 'Claim', '{"hasToPickUp":false}', '{"hasToPickUp":true}', 1, NULL - ), - ( - 1, 18, 'update', 'ClaimObservation', '{}', '{"claimFk":1,"text":"Waiting for customer"}', 1, NULL - ), - ( - 1, 18, 'insert', 'ClaimBeginning', '{}', '{"claimFk":1,"saleFk":1,"quantity":10}', 1, NULL - ), - ( - 1, 18, 'insert', 'ClaimDms', '{}', '{"claimFk":1,"dmsFk":1}', 1, NULL - ); +INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`) + VALUES + (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), + (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad'); -INSERT INTO - `hedera`.`tpvMerchant` ( - `id`, `description`, `companyFk`, `bankFk`, `secretKey` - ) -VALUES ( - 1, 'Arkham Bank', 442, 1, 'h12387193H10238' - ), - ( - 2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad' - ); +INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) + VALUES + (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), + (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), + (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), + (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', util.VN_CURDATE()), + (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', util.VN_CURDATE()), + (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', util.VN_CURDATE()); -INSERT INTO - `hedera`.`tpvTransaction` ( - `id`, `merchantFk`, `clientFk`, `receiptFk`, `amount`, `response`, `errorCode`, `status`, `created` - ) -VALUES ( - 1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE () - ), - ( - 2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE () - ), - ( - 3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE () - ), - ( - 4, 2, 1101, NULL, 4698, NULL, NULL, 'started', util.VN_CURDATE () - ), - ( - 5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', util.VN_CURDATE () - ), - ( - 6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', util.VN_CURDATE () - ); +INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) + VALUES + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11), + (12, 12), + (13, 13), + (14, 14), + (15, 15), + (16, 16), + (17, 17), + (18, 18), + (19, 19), + (20, 20), + (21, 21), + (22, 22); -INSERT INTO - `vn`.`orderTicket` (`orderFk`, `ticketFk`) -VALUES (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11), - (12, 12), - (13, 13), - (14, 14), - (15, 15), - (16, 16), - (17, 17), - (18, 18), - (19, 19), - (20, 20), - (21, 21), - (22, 22); +INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) + VALUES + (1, 1, 69), + (5, 1, 442), + (9, 1, 442), + (18, 3, 567); -INSERT INTO - `vn`.`userConfig` ( - `userFk`, `warehouseFk`, `companyFk` - ) -VALUES (1, 1, 69), - (5, 1, 442), - (9, 1, 442), - (18, 3, 567); +INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) + VALUES + (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), + (2, 'Cobro web', 200.50, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 442, 1), + (3, 'Cobro en efectivo', 300.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 442, 0), + (4, 'Cobro en efectivo', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0), + (5, 'Compensación', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 3, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0); -INSERT INTO - `vn`.`receipt` ( - `id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate` - ) -VALUES ( - 1, 'Cobro web', 100.50, util.VN_CURDATE (), 9, 1, 1101, util.VN_CURDATE (), 442, 1 - ), - ( - 2, 'Cobro web', 200.50, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ), 9, 1, 1101, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ), 442, 1 - ), - ( - 3, 'Cobro en efectivo', 300.00, DATE_ADD( - util.VN_CURDATE (), INTERVAL -10 DAY - ), 9, 1, 1102, DATE_ADD( - util.VN_CURDATE (), INTERVAL -10 DAY - ), 442, 0 - ), - ( - 4, 'Cobro en efectivo', 400.00, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ), 9, 1, 1103, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ), 442, 0 - ), - ( - 5, 'Compensación', 400.00, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ), 9, 3, 1103, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ), 442, 0 - ); +INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`) + VALUES + (1, 1, 9), + (2, 2, 18), + (3, 2, 19), + (4, 3, 1101), + (5, 3, 1102), + (6, 4, 1103), + (7, 4, 1104); -INSERT INTO - `vn`.`workerTeam` (`id`, `team`, `workerFk`) -VALUES (1, 1, 9), - (2, 2, 18), - (3, 2, 19), - (4, 3, 1101), - (5, 3, 1102), - (6, 4, 1103), - (7, 4, 1104); +INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) + VALUES + (1, 'Ranged weapon longbow 200cm', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)), + (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)), + (3, 'Melee weapon heavy shield 100cm', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()), + (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()), + (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE()); -INSERT INTO - `vn`.`ticketRequest` ( - `id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created` - ) -VALUES ( - 1, 'Ranged weapon longbow 200cm', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ) - ), - ( - 2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL -15 DAY - ) - ), - ( - 3, 'Melee weapon heavy shield 100cm', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE () - ), - ( - 4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE () - ), - ( - 5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE () - ); +INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenseFk`) + VALUES + (1, 'Porte Agencia', 7001000000), + (2, 'Portes Retorno', 7001000000), + (3, 'Porte Carry', 7001000000), + (4, 'Cargo FITOSANITARIO', 4751000000), + (5, 'Documentos', 2000000000); -INSERT INTO - `vn`.`ticketServiceType` (`id`, `name`, `expenseFk`) -VALUES ( - 1, 'Porte Agencia', 7001000000 - ), - ( - 2, 'Portes Retorno', 7001000000 - ), - (3, 'Porte Carry', 7001000000), - ( - 4, 'Cargo FITOSANITARIO', 4751000000 - ), - (5, 'Documentos', 2000000000); +INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`, `ticketServiceTypeFk`) + VALUES + (1, 'Documentos', 1, 2.00, 1, 1, 1), + (2, 'Porte Agencia', 1, 10.00, 1, 2, 1), + (3, 'Documentos', 1, 5.50, 1, 11, 1), + (4, 'Documentos', 1, 2.00, 1, 9, 1), + (5, 'Documentos', 1, 2.00, 1, 8, 1); -INSERT INTO - `vn`.`ticketService` ( - `id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`, `ticketServiceTypeFk` - ) -VALUES ( - 1, 'Documentos', 1, 2.00, 1, 1, 1 - ), - ( - 2, 'Porte Agencia', 1, 10.00, 1, 2, 1 - ), - ( - 3, 'Documentos', 1, 5.50, 1, 11, 1 - ), - ( - 4, 'Documentos', 1, 2.00, 1, 9, 1 - ), - ( - 5, 'Documentos', 1, 2.00, 1, 8, 1 - ); +INSERT INTO `pbx`.`sip`(`user_id`, `extension`) + VALUES + (1, 1010), + (3, 1101), + (5, 1102), + (9, 1201); -INSERT INTO - `pbx`.`sip` (`user_id`, `extension`) -VALUES (1, 1010), - (3, 1101), - (5, 1102), - (9, 1201); +INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`) + VALUES + (1, 'employee', NULL, NULL), + (2, 'florist', NULL, NULL); -INSERT INTO - `vn`.`professionalCategory` ( - `id`, `name`, `level`, `dayBreak` - ) -VALUES (1, 'employee', NULL, NULL), - (2, 'florist', NULL, NULL); +INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`) + VALUES + (1, 'General schedule', 40, 0); -INSERT INTO - `vn`.`calendarType` ( - `id`, `description`, `hoursWeek`, `isPartial` - ) -VALUES (1, 'General schedule', 40, 0); - -INSERT INTO - `vn`.`workerBusinessAgreement` ( - `id`, `name`, `monthHolidays`, `yearHours`, `started`, `ended` - ) -VALUES ( - 1, 'flowers', 2.5, 1830, '2001-01-01', NULL - ); +INSERT INTO `vn`.`workerBusinessAgreement` (`id`, `name`, `monthHolidays`, `yearHours`, `started`, `ended`) + VALUES(1, 'flowers', 2.5, 1830, '2001-01-01', NULL); DROP TEMPORARY TABLE IF EXISTS tmp.worker; +CREATE TEMPORARY TABLE tmp.worker + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-12-25') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + FROM `vn`.`worker` `w`; -CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY -SELECT - w.id, - w.id as `workerFk`, - 'VNL', - CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-12-25' - ) as started, - CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 YEAR - ) - ), '-12-25' - ) as ended, - CONCAT( - 'E-46-', RPAD(CONCAT(w.id, 9), 8, w.id) - ), - NULL as `notes`, - NULL as `departmentFk`, - 23, - 1 as `workerBusinessProfessionalCategoryFk`, - 1 as `calendarTypeFk`, - 1 as `isHourlyLabor`, - 1 as `workerBusinessAgreementFk`, - 1 as `workcenterFk` -FROM `vn`.`worker` `w`; - -INSERT INTO - `vn`.`business` ( - `id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk` - ) -SELECT * -FROM tmp.worker; +INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) + SELECT * FROM tmp.worker; DROP TEMPORARY TABLE IF EXISTS tmp.worker; +CREATE TEMPORARY TABLE tmp.worker + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + FROM `vn`.`worker` `w` + WHERE `w`.`id` = 1109; -CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY -SELECT - '1111' as 'id', - w.id as `workerFk`, - 'VNL', - CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 YEAR - ) - ), '-12-25' - ) as started, - CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-12-24' - ) as ended, - CONCAT( - 'E-46-', RPAD(CONCAT(w.id, 9), 8, w.id) - ), - NULL as `notes`, - NULL as `departmentFk`, - 23, - 1 as `workerBusinessProfessionalCategoryFk`, - 1 as `calendarTypeFk`, - 1 as `isHourlyLabor`, - 1 as `workerBusinessAgreementFk`, - 1 as `workcenterFk` -FROM `vn`.`worker` `w` -WHERE - `w`.`id` = 1109; - -INSERT INTO - `vn`.`business` ( - `id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk` - ) -SELECT * -FROM tmp.worker; +INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) + SELECT * FROM tmp.worker; DROP TEMPORARY TABLE IF EXISTS tmp.worker; UPDATE `vn`.`business` -SET - `payedHolidays` = 8 -WHERE - `id` = 1106; + SET `payedHolidays`= 8 + WHERE `id`= 1106; UPDATE `vn`.`business` b -SET - b.`workerBusinessProfessionalCategoryFk` = 2 -WHERE - b.`workerFk` = 1110; + SET b.`workerBusinessProfessionalCategoryFk` = 2 + WHERE b.`workerFk` = 1110; UPDATE `vn`.`business` b -SET - b.`departmentFk` = 43 -WHERE - b.id IN (18, 19); + SET b.`departmentFk` = 43 + WHERE b.id IN(18, 19); UPDATE `vn`.`business` b -SET - b.`started` = b.`started` - INTERVAL 100 DAY -WHERE - b.id = 1107; + SET b.`started` = b.`started` - INTERVAL 100 DAY + WHERE b.id = 1107; -INSERT INTO - `vn`.`workCenterHoliday` ( - `workCenterFk`, `days`, `year` - ) -VALUES ( - '1', '27.5', YEAR(util.VN_CURDATE ()) - ), - ( - '5', '22', YEAR(util.VN_CURDATE ()) - ), - ( - '1', '24.5', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ) - ), - ( - '5', '23', YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ) - ); +INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) + VALUES + ('1', '27.5', YEAR(util.VN_CURDATE())), + ('5', '22', YEAR(util.VN_CURDATE())), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); -INSERT INTO - `vn`.`workerBusinessType` ( - `id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement` - ) -VALUES ( - 1, 'CONTRATO HOLANDA', 1, 0, 1 - ), - ( - 100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1 - ), - ( - 109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1 - ); +INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`) + VALUES + (1, 'CONTRATO HOLANDA', 1, 0, 1), + (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), + (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); UPDATE `vn`.`business` b -SET - `rate` = 7, - `workerBusinessTypeFk` = 100, - `amount` = 900.50 -WHERE - b.id = 1; + SET `rate` = 7, + `workerBusinessTypeFk` = 100, + `amount` = 900.50 + WHERE b.id = 1; UPDATE `vn`.`business` b -SET - `rate` = 7, - `workerBusinessTypeFk` = 100, - `amount` = 1263.03 -WHERE - b.id = 1106; + SET `rate` = 7, + `workerBusinessTypeFk` = 100, + `amount` = 1263.03 + WHERE b.id = 1106; UPDATE `vn`.`business` b -SET - `rate` = 7, - `workerBusinessTypeFk` = 100, - `amount` = 2000 -WHERE - b.id = 1107; + SET `rate` = 7, + `workerBusinessTypeFk` = 100, + `amount` = 2000 + WHERE b.id = 1107; UPDATE `vn`.`business` b -SET - `rate` = 7, - `workerBusinessTypeFk` = 100, - `amount` = 1500 -WHERE - b.id = 1108; + SET `rate` = 7, + `workerBusinessTypeFk` = 100, + `amount` = 1500 + WHERE b.id = 1108; -INSERT INTO - `vn`.`absenceType` ( - `id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate` - ) -VALUES ( - 1, 'Holidays', '#FF4444', 'holiday', 0, 0 - ), - ( - 2, 'Leave of absence', '#C71585', 'absence', 0, 1 - ), - ( - 6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5 - ), - ( - 15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1 - ), - ( - 20, 'Furlough', '#97B92F', 'furlough', 1, 1 - ), - ( - 21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1 - ); +INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) + VALUES + (1, 'Holidays', '#FF4444', 'holiday', 0, 0), + (2, 'Leave of absence', '#C71585', 'absence', 0, 1), + (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5), + (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), + (20, 'Furlough', '#97B92F', 'furlough', 1, 1), + (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); -INSERT INTO - `vn`.`calendar` ( - `businessFk`, `dayOffTypeFk`, `dated` - ) -VALUES ( - 1, 6, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 10 DAY, util.VN_CURDATE () + INTERVAL 10 DAY - ) - ), - ( - 1106, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 10 DAY, util.VN_CURDATE () + INTERVAL 10 DAY - ) - ), - ( - 1106, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 11 DAY, util.VN_CURDATE () + INTERVAL 11 DAY - ) - ), - ( - 1106, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 12 DAY, util.VN_CURDATE () + INTERVAL 12 DAY - ) - ), - ( - 1106, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 20 DAY, util.VN_CURDATE () + INTERVAL 20 DAY - ) - ), - ( - 1106, 2, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 13 DAY, util.VN_CURDATE () + INTERVAL 8 DAY - ) - ), - ( - 1106, 1, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 14 DAY, util.VN_CURDATE () + INTERVAL 9 DAY - ) - ), - ( - 1106, 2, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 15 DAY, util.VN_CURDATE () + INTERVAL 7 DAY - ) - ), - ( - 1107, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 10 DAY, util.VN_CURDATE () + INTERVAL 10 DAY - ) - ), - ( - 1107, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 11 DAY, util.VN_CURDATE () + INTERVAL 11 DAY - ) - ), - ( - 1107, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 12 DAY, util.VN_CURDATE () + INTERVAL 12 DAY - ) - ), - ( - 1107, 1, IF( - MONTH(util.VN_CURDATE ()) = 12 - AND DAY(util.VN_CURDATE ()) > 10, util.VN_CURDATE () - INTERVAL 20 DAY, util.VN_CURDATE () + INTERVAL 20 DAY - ) - ), - ( - 1107, 2, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 13 DAY, util.VN_CURDATE () + INTERVAL 8 DAY - ) - ), - ( - 1107, 1, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 14 DAY, util.VN_CURDATE () + INTERVAL 9 DAY - ) - ), - ( - 1107, 2, IF( - MONTH(util.VN_CURDATE ()) >= 1 - AND DAY(util.VN_CURDATE ()) > 20, util.VN_CURDATE () - INTERVAL 15 DAY, util.VN_CURDATE () + INTERVAL 7 DAY - ) - ), - ( - 1107, 2, util.VN_CURDATE () - INTERVAL 16 DAY - ); +INSERT INTO `vn`.`calendar` (`businessFk`, `dayOffTypeFk`, `dated`) + VALUES + (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)), + (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)), + (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)), + (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 10 DAY, util.VN_CURDATE() + INTERVAL 10 DAY)), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 11 DAY, util.VN_CURDATE() + INTERVAL 11 DAY)), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 12 DAY, util.VN_CURDATE() + INTERVAL 12 DAY)), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, util.VN_CURDATE() - INTERVAL 20 DAY, util.VN_CURDATE() + INTERVAL 20 DAY)), + (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 13 DAY, util.VN_CURDATE() + INTERVAL 8 DAY)), + (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 14 DAY, util.VN_CURDATE() + INTERVAL 9 DAY)), + (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, util.VN_CURDATE() - INTERVAL 15 DAY, util.VN_CURDATE() + INTERVAL 7 DAY)), + (1107, 2, util.VN_CURDATE() - INTERVAL 16 DAY); -INSERT INTO - `vn`.`smsConfig` ( - `id`, `uri`, `title`, `apiKey` - ) -VALUES ( - '1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523' - ); +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) + VALUES + ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523'); -INSERT INTO - `vn`.`sharingClient` ( - `id`, `workerFk`, `started`, `ended`, `clientFk` - ) -VALUES ( - 1, 19, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ), 1101 - ), - ( - 2, 18, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ), 1106 - ); +INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) + VALUES + (1, 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1101), + (2, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1106); -INSERT INTO - `vn`.`sharingCart` ( - `id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created` - ) -VALUES ( - 1, 18, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ), 19, DATE_ADD( - util.VN_CURDATE (), INTERVAL -5 DAY - ) - ); +INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`) + VALUES + (1, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY)); -CALL `vn`.zoneGeo_calcTree (); --- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons -INSERT INTO - `vn`.`zoneIncluded` ( - `zoneFk`, `geoFk`, `isIncluded` - ) -VALUES (1, 3, 0), - (1, 4, 0), - (1, 5, 0), - (1, 1, 1), - (2, 3, 0), - (2, 4, 0), - (2, 5, 0), - (2, 1, 1), - (3, 3, 0), - (3, 4, 0), - (3, 5, 0), - (3, 1, 1), - (4, 3, 0), - (4, 4, 0), - (4, 5, 0), - (4, 1, 1), - (5, 3, 1), - (5, 4, 0), - (5, 5, 1), - (5, 1, 1), - (6, 3, 1), - (6, 4, 0), - (6, 5, 1), - (6, 1, 1), - (7, 3, 0), - (7, 4, 0), - (7, 5, 0), - (7, 1, 1), - (8, 3, 0), - (8, 4, 0), - (8, 5, 0), - (8, 1, 1), - (9, 7, 1), - (10, 14, 1); +CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons -INSERT INTO - `vn`.`zoneEvent` (`zoneFk`, `type`, `dated`) -VALUES ( - 1, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 2, 2, 9 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 1, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 3, 3, 10 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 1, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 4, 4, 11 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 1, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 5, 5, 12 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 1, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 6, 6, 13 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 2, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 2, 2, 9 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 2, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 3, 3, 10 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 2, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 4, 4, 11 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 2, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 5, 5, 12 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - ( - 2, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 6, 6, 13 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ) - ), - (3, 'day', util.VN_CURDATE ()), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 3 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 4 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 5 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 6 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 7 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 8 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 9 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 10 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 11 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 12 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 13 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 14 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 16 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 17 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 18 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 19 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 20 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 21 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 22 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 23 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 24 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 25 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 26 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 27 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 28 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 29 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 30 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 31 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 32 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 33 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 34 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 35 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 36 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 37 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 38 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 39 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 40 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 41 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 42 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 43 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 44 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 45 DAY - ) - ), - ( - 3, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 46 DAY - ) - ), - (4, 'day', util.VN_CURDATE ()), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 3 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 4 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 5 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 6 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 7 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 8 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 9 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 10 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 11 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 12 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 13 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 14 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 16 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 17 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 18 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 19 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 20 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 21 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 22 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 23 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 24 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 25 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 26 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 27 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 28 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 29 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 30 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 31 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 32 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 33 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 34 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 35 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 36 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 37 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 38 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 39 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 40 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 41 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 42 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 43 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 44 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 45 DAY - ) - ), - ( - 4, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 46 DAY - ) - ), - (5, 'day', util.VN_CURDATE ()), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 3 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 4 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 5 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 6 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 7 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 8 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 9 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 10 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 11 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 12 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 13 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 14 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 16 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 17 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 18 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 19 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 20 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 21 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 22 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 23 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 24 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 25 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 26 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 27 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 28 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 29 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 30 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 31 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 32 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 33 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 34 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 35 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 36 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 37 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 38 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 39 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 40 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 41 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 42 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 43 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 44 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 45 DAY - ) - ), - ( - 5, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 46 DAY - ) - ), - (6, 'day', util.VN_CURDATE ()), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 3 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 4 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 5 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 6 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 7 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 8 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 9 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 10 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 11 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 12 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 13 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 14 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 15 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 16 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 17 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 18 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 19 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 20 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 21 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 22 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 23 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 24 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 25 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 26 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 27 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 28 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 29 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 30 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 31 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 32 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 33 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 34 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 35 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 36 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 37 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 38 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 39 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 40 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 41 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 42 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 43 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 44 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 45 DAY - ) - ), - ( - 6, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 46 DAY - ) - ), - (7, 'day', util.VN_CURDATE ()), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 2 DAY - ) - ), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 3 DAY - ) - ), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 4 DAY - ) - ), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 5 DAY - ) - ), - ( - 7, 'day', DATE_ADD( - util.VN_CURDATE (), INTERVAL + 6 DAY - ) - ); +INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) + VALUES + (1, 3, 0), + (1, 4, 0), + (1, 5, 0), + (1, 1, 1), + (2, 3, 0), + (2, 4, 0), + (2, 5, 0), + (2, 1, 1), + (3, 3, 0), + (3, 4, 0), + (3, 5, 0), + (3, 1, 1), + (4, 3, 0), + (4, 4, 0), + (4, 5, 0), + (4, 1, 1), + (5, 3, 1), + (5, 4, 0), + (5, 5, 1), + (5, 1, 1), + (6, 3, 1), + (6, 4, 0), + (6, 5, 1), + (6, 1, 1), + (7, 3, 0), + (7, 4, 0), + (7, 5, 0), + (7, 1, 1), + (8, 3, 0), + (8, 4, 0), + (8, 5, 0), + (8, 1, 1), + (9, 7, 1), + (10, 14, 1); -INSERT INTO - `vn`.`zoneEvent` (`zoneFk`, `type`, `weekDays`) -VALUES ( - 8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun' - ), - ( - 10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun' - ); +INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) + VALUES + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (3, 'day', util.VN_CURDATE()), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (4, 'day', util.VN_CURDATE()), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (5, 'day', util.VN_CURDATE()), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (6, 'day', util.VN_CURDATE()), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (7, 'day', util.VN_CURDATE()), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); -INSERT INTO - `vn`.`zoneEvent` ( - `zoneFk`, `type`, `started`, `ended`, `weekDays` - ) -VALUES ( - 9, 'range', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 YEAR - ), 'mon' - ), - ( - 9, 'range', util.VN_CURDATE (), NULL, 'tue' - ), - ( - 9, 'range', NULL, util.VN_CURDATE (), 'wed' - ); +INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) + VALUES + (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), + (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); -INSERT INTO - `vn`.`workerTimeControl` ( - `userFk`, `timed`, `manual`, `direction`, `isSendMail` - ) -VALUES ( - 1106, CONCAT(util.VN_CURDATE (), ' 07:00'), TRUE, 'in', 0 - ), - ( - 1106, CONCAT(util.VN_CURDATE (), ' 10:00'), TRUE, 'middle', 0 - ), - ( - 1106, CONCAT(util.VN_CURDATE (), ' 10:20'), TRUE, 'middle', 0 - ), - ( - 1106, CONCAT(util.VN_CURDATE (), ' 14:50'), TRUE, 'out', 0 - ), - ( - 1107, CONCAT(util.VN_CURDATE (), ' 07:00'), TRUE, 'in', 1 - ), - ( - 1107, CONCAT(util.VN_CURDATE (), ' 10:00'), TRUE, 'middle', 1 - ), - ( - 1107, CONCAT(util.VN_CURDATE (), ' 10:20'), TRUE, 'middle', 1 - ), - ( - 1107, CONCAT(util.VN_CURDATE (), ' 14:50'), TRUE, 'out', 1 - ); +INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`, `weekDays`) + VALUES + (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR), 'mon'), + (9, 'range', util.VN_CURDATE(), NULL, 'tue'), + (9, 'range', NULL, util.VN_CURDATE(), 'wed'); -INSERT INTO - `vn`.`dmsType` ( - `id`, `name`, `readRoleFk`, `writeRoleFk`, `code` - ) -VALUES ( - 1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn' - ), - ( - 2, 'Doc oficial', NULL, NULL, 'officialDoc' - ), - ( - 3, 'Laboral', 37, 37, 'hhrrData' - ), - ( - 4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote' - ), - ( - 5, 'Otros', 1, 1, 'miscellaneous' - ), - ( - 6, 'Pruebas', NULL, NULL, 'tests' - ), - ( - 7, 'IAE Clientes', 1, 1, 'economicActivitiesTax' - ), - ( - 8, 'Fiscal', NULL, NULL, 'fiscal' - ), - ( - 9, 'Vehiculos', NULL, NULL, 'vehicles' - ), - ( - 10, 'Plantillas', NULL, NULL, 'templates' - ), - ( - 11, 'Contratos', NULL, NULL, 'contracts' - ), - ( - 12, 'ley de pagos', 1, 1, 'paymentsLaw' - ), - (13, 'Basura', 1, 1, 'trash'), - (14, 'Ticket', 1, 1, 'ticket'), - ( - 15, 'Presupuestos', NULL, NULL, 'budgets' - ), - ( - 16, 'Logistica', NULL, NULL, 'logistics' - ), - (17, 'cmr', NULL, NULL, 'cmr'), - (18, 'dua', NULL, NULL, 'dua'), - ( - 19, 'inmovilizado', NULL, NULL, 'fixedAssets' - ), - ( - 20, 'Reclamación', 1, 1, 'claim' - ); +INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `isSendMail`) + VALUES + (1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in', 0), + (1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle', 0), + (1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 0), + (1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 0), + (1107, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in', 1), + (1107, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle', 1), + (1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1), + (1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1); -INSERT INTO - `vn`.`dms` ( - `id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created` - ) -VALUES ( - 1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', util.VN_CURDATE () - ), - ( - 2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE () - ), - ( - 3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE () - ), - ( - 4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE () - ), - ( - 5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE () - ), - ( - 6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE () - ), - ( - 7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE () - ), - ( - 8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE () - ); +INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) + VALUES + (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'), + (2, 'Doc oficial', NULL, NULL, 'officialDoc'), + (3, 'Laboral', 37, 37, 'hhrrData'), + (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'), + (5, 'Otros', 1, 1, 'miscellaneous'), + (6, 'Pruebas', NULL, NULL, 'tests'), + (7, 'IAE Clientes', 1, 1, 'economicActivitiesTax'), + (8, 'Fiscal', NULL, NULL, 'fiscal'), + (9, 'Vehiculos', NULL, NULL, 'vehicles'), + (10, 'Plantillas', NULL, NULL, 'templates'), + (11, 'Contratos', NULL, NULL, 'contracts'), + (12, 'ley de pagos', 1, 1, 'paymentsLaw'), + (13, 'Basura', 1, 1, 'trash'), + (14, 'Ticket', 1, 1, 'ticket'), + (15, 'Presupuestos', NULL, NULL, 'budgets'), + (16, 'Logistica', NULL, NULL, 'logistics'), + (17, 'cmr', NULL, NULL, 'cmr'), + (18, 'dua', NULL, NULL, 'dua'), + (19, 'inmovilizado', NULL, NULL, 'fixedAssets'), + (20, 'Reclamación', 1, 1, 'claim'); -INSERT INTO - `vn`.`claimDms` (`claimFk`, `dmsFk`) -VALUES (1, 7), - (1, 8); +INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) + VALUES + (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', util.VN_CURDATE()), + (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()), + (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()), + (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()), + (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()), + (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()), + (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), + (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()); -INSERT INTO - `vn`.`ticketDms` (`ticketFk`, `dmsFk`) -VALUES (11, 1); +INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`) + VALUES + (1, 7), + (1, 8); -INSERT INTO - `vn`.`clientDms` (`clientFk`, `dmsFk`) -VALUES (1104, 2), - (1104, 3); +INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`) + VALUES + (11, 1); -INSERT INTO - `vn`.`workerDocument` ( - `id`, `worker`, `document`, `isReadableByWorker` - ) -VALUES (1, 1106, 4, TRUE), - (2, 1107, 3, FALSE); +INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`) + VALUES + (1104, 2), + (1104, 3); -INSERT INTO - `vn`.`device` (`sn`, `model`, `userFk`) -VALUES ('aaa', 'android', '9'); +INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`) + VALUES + (1, 1106, 4, TRUE), + (2, 1107, 3, FALSE); -INSERT INTO - `vn`.`queuePriority` (`id`, `priority`, `code`) -VALUES (1, 'Alta', 'high'), - (2, 'Normal', 'normal'), - (3, 'Baja', 'low'); +INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) + VALUES + ('aaa', 'android', '9'); -INSERT INTO - `vn`.`workerTimeControlParams` ( - `id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut` - ) -VALUES ( - 1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000 - ); +INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`) + VALUES + (1, 'Alta', 'high'), + (2, 'Normal', 'normal'), + (3, 'Baja', 'low'); -INSERT IGNORE INTO - `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) -VALUES ('1', '11'); +INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`) + VALUES + (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); -INSERT INTO - `vn`.`thermograph` (`id`, `model`) -VALUES ('TMM190901395', 'TEMPMATE'), - ('TL.BBA85422', 'TL30'), - ('TZ1905012010', 'DISPOSABLE'), - ('138350-0', 'DISPOSABLE'); +INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); -INSERT INTO - `vn`.`travelThermograph` ( - `thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk` - ) -VALUES ( - 'TMM190901395', util.VN_CURDATE (), 1, 1, 'WARM', 'Ok', NULL - ), - ( - 'TL.BBA85422', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 2, 2, 'COOL', 'Ok', NULL - ), - ( - 'TL.BBA85422', util.VN_CURDATE (), 2, 1, 'COOL', 'can not read the temperature', NULL - ), - ( - 'TZ1905012010', util.VN_CURDATE (), 1, 1, 'WARM', 'Temperature in range', 5 - ), - ( - '138350-0', DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1, 1, 'WARM', NULL, 5 - ), - ( - '138350-0', util.VN_CURDATE (), 1, NULL, 'COOL', NULL, NULL - ); +INSERT INTO `vn`.`thermograph`(`id`, `model`) + VALUES + ('TMM190901395', 'TEMPMATE'), + ('TL.BBA85422', 'TL30'), + ('TZ1905012010', 'DISPOSABLE'), + ('138350-0', 'DISPOSABLE'); -REPLACE INTO - `vn`.`incoterms` (`code`, `name`) -VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO - `vn`.`customsAgent` ( - `id`, `fiscalName`, `street`, `nif`, `phone`, `email` - ) -VALUES ( - 1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com' - ), - ( - 2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com' - ); +INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`) + VALUES + ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL), + ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL), + ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL), + ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5), + ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), + ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); -INSERT INTO - `vn`.`tablet` ( - `uuid`, `name`, `place`, `macwifi` - ) -VALUES ( - '1', 'TEST', 'ON THE FIXTURES', '0' - ), - ( - '2', 'DEV', 'OTHER TABLET', '0' - ); +REPLACE INTO `vn`.`incoterms`(`code`, `name`) + VALUES + ('FAS', 'Free Alongside Ship'); -INSERT INTO - `vn`.`tabletDepartment` (`tabletFk`, `departmentFk`) -VALUES (1, 23), - (2, 1); +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) + VALUES + (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), + (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); -INSERT INTO - `vn`.`campaign` (`code`, `dated`) -VALUES ( - 'valentinesDay', CONCAT( - YEAR(util.VN_CURDATE ()), '-02-14' - ) - ), - ( - 'valentinesDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-02-14' - ) - ), - ( - 'valentinesDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 YEAR - ) - ), '-02-14' - ) - ), - ( - 'valentinesDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 YEAR - ) - ), '-02-14' - ) - ), - ( - 'mothersDay', CONCAT( - YEAR(util.VN_CURDATE ()), '-05-05' - ) - ), - ( - 'mothersDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-05-05' - ) - ), - ( - 'mothersDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 YEAR - ) - ), '-05-05' - ) - ), - ( - 'mothersDay', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 YEAR - ) - ), '-05-05' - ) - ), - ( - 'allSaints', CONCAT( - YEAR(util.VN_CURDATE ()), '-11-01' - ) - ), - ( - 'allSaints', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-11-01' - ) - ), - ( - 'allSaints', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -2 YEAR - ) - ), '-11-01' - ) - ), - ( - 'allSaints', CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -3 YEAR - ) - ), '-11-01' - ) - ); +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES + ('1', 'TEST', 'ON THE FIXTURES', '0'), + ('2', 'DEV', 'OTHER TABLET', '0'); -INSERT INTO - `hedera`.`imageCollectionSize` ( - `id`, `collectionFk`, `width`, `height` - ) -VALUES (1, 4, 160, 160); +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) + VALUES + (1, 23), + (2, 1); -INSERT INTO - `vn`.`rateConfig` ( - `rate0`, `rate1`, `rate2`, `rate3` - ) -VALUES (36, 31, 25, 21); +INSERT INTO `vn`.`campaign`(`code`, `dated`) + VALUES + ('valentinesDay', CONCAT(YEAR(util.VN_CURDATE()), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-02-14')), + ('mothersDay', CONCAT(YEAR(util.VN_CURDATE()), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-05-05')), + ('allSaints', CONCAT(YEAR(util.VN_CURDATE()), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-11-01')); -INSERT INTO - `vn`.`rate` ( - `dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3` - ) -VALUES ( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ), 1, 10, 15, 20, 25 - ), - ( - util.VN_CURDATE (), 1, 12, 17, 22, 27 - ); +INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`) + VALUES + (1, 4, 160, 160); -INSERT INTO - `vn`.`dua` ( - id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk - ) -VALUES ( - 1, '19ES0028013A481523', 1, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 1, 11276.95, 442 - ), - ( - 2, '21ES00280136115760', 2, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 1376.20, 442 - ), - ( - 3, '19ES00280131956004', 3, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 3, 14268.50, 442 - ), - ( - 4, '19ES00280131955995', 4, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 1, 8242.50, 442 - ), - ( - 5, '19ES00280132022070', 5, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 10012.49, 442 - ), - ( - 6, '19ES00280132032308', 6, util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 19914.25, 442 - ), - ( - 7, '19ES00280132025489', 7, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 1934.06, 442 - ), - ( - 8, '19ES00280132025490', 8, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 3618.52, 442 - ), - ( - 9, '19ES00280132025491', 9, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 7126.23, 442 - ), - ( - 10, '19ES00280132025492', 10, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), util.VN_CURDATE (), util.VN_CURDATE (), util.VN_CURDATE (), 2, 4631.45, 442 - ); +INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`) + VALUES + (36, 31, 25, 21); -INSERT INTO - `vn`.`duaEntry` ( - `duaFk`, `entryFk`, `value`, `customsValue`, `euroValue` - ) -VALUES (1, 1, 1.00, 1.00, 1.00), - (2, 2, 1.00, 1.00, 1.00), - (3, 3, 1.00, 1.00, 1.00), - (4, 4, 1.00, 1.00, 1.00), - (5, 5, 1.00, 1.00, 1.00), - (6, 6, 1.00, 1.00, 1.00), - (7, 7, 1.00, 1.00, 1.00), - (8, 8, 1.00, 1.00, 1.00); +INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`) + VALUES + (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), + (util.VN_CURDATE(), 1, 12, 17, 22, 27); -REPLACE INTO - `vn`.`invoiceIn` ( - `id`, `serialNumber`, `serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk` - ) -VALUES ( - 1, 1001, 'R', 1, util.VN_CURDATE (), util.VN_CURDATE (), 1234, 0, 442, 1 - ), - ( - 2, 1002, 'R', 1, util.VN_CURDATE (), util.VN_CURDATE (), 1235, 1, 442, 1 - ), - ( - 3, 1003, 'R', 1, util.VN_CURDATE (), util.VN_CURDATE (), 1236, 0, 442, 1 - ), - ( - 4, 1004, 'R', 1, util.VN_CURDATE (), util.VN_CURDATE (), 1237, 0, 442, 1 - ), - ( - 5, 1005, 'R', 1, util.VN_CURDATE (), util.VN_CURDATE (), 1238, 1, 442, 1 - ), - ( - 6, 1006, 'R', 2, util.VN_CURDATE (), util.VN_CURDATE (), 1239, 0, 442, 1 - ), - ( - 7, 1007, 'R', 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1240, 1, 442, 1 - ), - ( - 8, 1008, 'R', 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1241, 1, 442, 1 - ), - ( - 9, 1009, 'R', 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1242, 1, 442, 1 - ), - ( - 10, 1010, 'R', 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 MONTH - ), 1243, 1, 442, 1 - ); +INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) + VALUES + (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), + (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), + (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), + (4, '19ES00280131955995', 4, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442), + (5, '19ES00280132022070', 5, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442), + (6, '19ES00280132032308', 6, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442), + (7, '19ES00280132025489', 7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442), + (8, '19ES00280132025490', 8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442), + (9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442), + (10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442); -INSERT INTO - `vn`.`invoiceInConfig` ( - `id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo` - ) -VALUES (1, -2, '2% retention', 2, 45); +INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`) + VALUES + (1, 1, 1.00, 1.00, 1.00), + (2, 2, 1.00, 1.00, 1.00), + (3, 3, 1.00, 1.00, 1.00), + (4, 4, 1.00, 1.00, 1.00), + (5, 5, 1.00, 1.00, 1.00), + (6, 6, 1.00, 1.00, 1.00), + (7, 7, 1.00, 1.00, 1.00), + (8, 8, 1.00, 1.00, 1.00); -INSERT INTO - `vn`.`invoiceInDueDay` ( - `invoiceInFk`, `dueDated`, `bankFk`, `amount` - ) -VALUES ( - 1, util.VN_CURDATE (), 1, 336.99 - ), - ( - 1, util.VN_CURDATE (), 1, 15.25 - ), - (2, util.VN_CURDATE (), 1, 168), - ( - 2, util.VN_CURDATE (), 1, 55.17 - ), - ( - 3, util.VN_CURDATE (), 1, 87.95 - ), - ( - 3, util.VN_CURDATE (), 1, 7.65 - ), - ( - 4, util.VN_CURDATE (), 1, 373.27 - ), - ( - 4, util.VN_CURDATE (), 1, 73.36 - ), - ( - 5, util.VN_CURDATE (), 1, 64.23 - ), - ( - 6, util.VN_CURDATE (), 1, 32.95 - ), - ( - 7, util.VN_CURDATE (), 1, 58.64 - ); +REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) + VALUES + (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1), + (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), + (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1), + (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); -INSERT INTO - `vn`.`duaInvoiceIn` (`id`, `duaFk`, `invoiceInFk`) -VALUES (1, 1, 1), - (2, 2, 2), - (3, 3, 3), - (4, 4, 4), - (5, 5, 5), - (6, 6, 6), - (7, 7, 7), - (8, 8, 8), - (9, 9, 9), - (10, 10, 10); +INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`) + VALUES + (1, -2, '2% retention', 2, 45); -INSERT INTO - `vn`.`invoiceInTax` ( - `invoiceInFk`, `taxableBase`, `expenseFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk` - ) -VALUES ( - 1, 99.99, '2000000000', NULL, NULL, NULL - ), - ( - 2, 999.99, '2000000000', NULL, NULL, NULL - ), - ( - 3, 1000.50, '2000000000', NULL, NULL, NULL - ), - ( - 4, 0.50, '2000000000', NULL, NULL, NULL - ), - ( - 5, 150.50, '2000000000', NULL, NULL, NULL - ), - ( - 1, 252.25, '4751000000', NULL, 7, 61 - ), - ( - 2, 223.17, '6210000567', NULL, 8, 20 - ), - ( - 3, 95.60, '7001000000', NULL, 8, 35 - ), - ( - 4, 446.63, '7001000000', NULL, 6, 61 - ), - ( - 5, 64.23, '6210000567', NULL, 8, 20 - ), - ( - 6, 29.95, '7001000000', NULL, 7, 20 - ), - ( - 7, 58.64, '6210000567', NULL, 8, 20 - ); +INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`) + VALUES + (1, util.VN_CURDATE(), 1, 336.99), + (1, util.VN_CURDATE(), 1, 15.25), + (2, util.VN_CURDATE(), 1, 168), + (2, util.VN_CURDATE(), 1, 55.17), + (3, util.VN_CURDATE(), 1, 87.95), + (3, util.VN_CURDATE(), 1, 7.65), + (4, util.VN_CURDATE(), 1, 373.27), + (4, util.VN_CURDATE(), 1, 73.36), + (5, util.VN_CURDATE(), 1, 64.23), + (6, util.VN_CURDATE(), 1, 32.95), + (7, util.VN_CURDATE(), 1, 58.64); -INSERT INTO - `vn`.`invoiceInIntrastat` ( - `invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk` - ) -VALUES ( - 1, 30.50, 5080000, 10.00, 162, 5 - ), - (1, 10, 6021010, 20.00, 205, 5), - ( - 2, 13.20, 5080000, 15.00, 580, 5 - ), - ( - 2, 16.10, 6021010, 25.00, 80, 5 - ); +INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) + VALUES + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 5, 5), + (6, 6, 6), + (7, 7, 7), + (8, 8, 8), + (9, 9, 9), + (10, 10, 10); -INSERT INTO - `vn`.`ticketRecalc` (`ticketFk`) -SELECT t.id -FROM vn.ticket t - LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id -WHERE - tr.ticketFk IS NULL; +INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenseFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`) + VALUES + (1, 99.99, '2000000000', NULL, NULL, NULL), + (2, 999.99, '2000000000', NULL, NULL, NULL), + (3, 1000.50, '2000000000', NULL, NULL, NULL), + (4, 0.50, '2000000000', NULL, NULL, NULL), + (5, 150.50, '2000000000', NULL, NULL, NULL), + (1, 252.25, '4751000000', NULL, 7, 61), + (2, 223.17, '6210000567', NULL, 8, 20), + (3, 95.60, '7001000000', NULL, 8, 35), + (4, 446.63, '7001000000', NULL, 6, 61), + (5, 64.23, '6210000567', NULL, 8, 20), + (6, 29.95, '7001000000', NULL, 7, 20), + (7, 58.64, '6210000567', NULL, 8, 20); -CALL `vn`.`ticket_doRecalc` (); +INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) + VALUES + (1, 30.50, 5080000, 10.00, 162, 5), + (1, 10, 6021010, 20.00, 205, 5), + (2, 13.20, 5080000, 15.00, 580, 5), + (2, 16.10, 6021010, 25.00, 80, 5); + +INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) + SELECT t.id + FROM vn.ticket t + LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id + WHERE tr.ticketFk IS NULL; + +CALL `vn`.`ticket_doRecalc`(); UPDATE `vn`.`ticket` -SET - refFk = 'T1111111' -WHERE - id IN (1, 2); + SET refFk = 'T1111111' + WHERE id IN (1,2); -UPDATE `vn`.`ticket` SET refFk = 'T2222222' WHERE id = 3; +UPDATE `vn`.`ticket` + SET refFk = 'T2222222' + WHERE id = 3; -UPDATE `vn`.`ticket` SET refFk = 'T3333333' WHERE id = 4; +UPDATE `vn`.`ticket` + SET refFk = 'T3333333' + WHERE id = 4; -UPDATE `vn`.`ticket` SET refFk = 'T4444444' WHERE id = 5; +UPDATE `vn`.`ticket` + SET refFk = 'T4444444' + WHERE id = 5; -UPDATE `vn`.`ticket` SET refFk = 'A1111111' WHERE id = 6; +UPDATE `vn`.`ticket` + SET refFk = 'A1111111' + WHERE id = 6; -INSERT INTO - `vn`.`zoneAgencyMode` ( - `id`, `agencyModeFk`, `zoneFk` - ) -VALUES (1, 1, 1), - (2, 1, 2), - (3, 6, 5), - (4, 7, 1); +INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) + VALUES + (1, 1, 1), + (2, 1, 2), + (3, 6, 5), + (4, 7, 1); -INSERT INTO - `vn`.`roadmap` ( - `id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName` - ) -VALUES ( - 1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW (), 'this is test observation', 1, 15, 'Batman' - ), - ( - 2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW (), 'test observation', 1, 20, 'Robin' - ), - ( - 3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD( - util.VN_NOW (), INTERVAL 2 DAY - ), 'observations...', 2, 25, 'Driverman' - ); +INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) + VALUES + (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), + (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), + (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); -INSERT INTO - `vn`.`expeditionTruck` ( - `id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk` - ) -VALUES ( - 1, 1, 1, DATE_ADD( - util.VN_NOW (), INTERVAL 1 DAY - ), 'Best truck in fleet', 1 - ), - ( - 2, 1, 2, DATE_ADD( - util.VN_NOW (), INTERVAL '1 2' DAY_HOUR - ), 'Second truck in fleet', 1 - ), - ( - 3, 1, 3, DATE_ADD( - util.VN_NOW (), INTERVAL '1 4' DAY_HOUR - ), 'Third truck in fleet', 1 - ), - ( - 4, 2, 1, DATE_ADD( - util.VN_NOW (), INTERVAL 3 DAY - ), 'Truck red', 1 - ); +INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) + VALUES + (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), + (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), + (3, 1, 3, DATE_ADD(util.VN_NOW(), INTERVAL '1 4' DAY_HOUR), 'Third truck in fleet', 1), + (4, 2, 1, DATE_ADD(util.VN_NOW(), INTERVAL 3 DAY), 'Truck red', 1); -INSERT INTO - `vn`.`expeditionPallet` ( - `id`, `truckFk`, `built`, `position`, `isPrint` - ) -VALUES ( - 1, 1, util.VN_CURDATE (), 1, 1 - ); +INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) + VALUES + (1, 1, util.VN_CURDATE(), 1, 1); -INSERT INTO - `vn`.`expeditionScan` ( - `id`, `expeditionFk`, `scanned`, `palletFk` - ) -VALUES (1, 1, util.VN_CURDATE (), 1), - (2, 2, util.VN_CURDATE (), 1), - (3, 3, util.VN_CURDATE (), 1), - (4, 4, util.VN_CURDATE (), 1), - (5, 5, util.VN_CURDATE (), 1), - (6, 6, util.VN_CURDATE (), 1), - (7, 7, util.VN_CURDATE (), 1), - (8, 8, util.VN_CURDATE (), 1), - (9, 9, util.VN_CURDATE (), 1), - (10, 10, util.VN_CURDATE (), 1); +INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) + VALUES + (1, 1, util.VN_CURDATE(), 1), + (2, 2, util.VN_CURDATE(), 1), + (3, 3, util.VN_CURDATE(), 1), + (4, 4, util.VN_CURDATE(), 1), + (5, 5, util.VN_CURDATE(), 1), + (6, 6, util.VN_CURDATE(), 1), + (7, 7, util.VN_CURDATE(), 1), + (8, 8, util.VN_CURDATE(), 1), + (9, 9, util.VN_CURDATE(), 1), + (10, 10, util.VN_CURDATE(), 1); -CALL `cache`.`last_buy_refresh` (FALSE); +CALL `cache`.`last_buy_refresh`(FALSE); -UPDATE `vn`.`item` SET `genericFk` = 9 WHERE `id` = 2; +UPDATE `vn`.`item` SET `genericFk` = 9 + WHERE `id` = 2; -INSERT INTO - `bs`.`defaulter` ( - `clientFk`, `amount`, `created`, `defaulterSinced` - ) -VALUES ( - 1101, 500, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 1102, 500, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 1103, 500, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 1107, 500, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 1109, 500, util.VN_CURDATE (), util.VN_CURDATE () - ); +INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`) + VALUES + (1101, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1102, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1103, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1107, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1109, 500, util.VN_CURDATE(), util.VN_CURDATE()); -UPDATE `vn`.`route` SET `invoiceInFk` = 1 WHERE `id` = 1; +UPDATE `vn`.`route` + SET `invoiceInFk`=1 + WHERE `id`=1; -UPDATE `vn`.`route` SET `invoiceInFk` = 2 WHERE `id` = 2; +UPDATE `vn`.`route` + SET `invoiceInFk`=2 + WHERE `id`=2; -INSERT INTO - `bs`.`sale` ( - `saleFk`, `amount`, `dated`, `typeFk`, `clientFk` - ) -VALUES ( - 1, 501.95, util.VN_CURDATE (), 2, 1101 - ), - ( - 2, 70.7, util.VN_CURDATE (), 2, 1101 - ), - ( - 3, 200.78, util.VN_CURDATE (), 2, 1101 - ), - ( - 4, 33.8, util.VN_CURDATE (), 1, 1101 - ), - ( - 30, 34.4, util.VN_CURDATE (), 1, 1108 - ); +INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) + VALUES + (1, 501.95, util.VN_CURDATE(), 2, 1101), + (2, 70.7, util.VN_CURDATE(), 2, 1101), + (3, 200.78, util.VN_CURDATE(), 2, 1101), + (4, 33.8, util.VN_CURDATE(), 1, 1101), + (30, 34.4, util.VN_CURDATE(), 1, 1108); -INSERT INTO - `vn`.`docuwareConfig` (`url`) -VALUES ('http://docuware.url/'); +INSERT INTO `vn`.`docuwareConfig` (`url`) + VALUES + ('http://docuware.url/'); -INSERT INTO - `vn`.`calendarHolidaysName` (`id`, `name`) -VALUES (1, 'dayOfIT'); +INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`) + VALUES + (1, 'dayOfIT'); -INSERT INTO - `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) -VALUES (1, 'National', '#4169E1'); +INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) + VALUES + (1, 'National', '#4169E1'); -INSERT INTO - `vn`.`calendarHolidays` ( - `id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk` - ) -VALUES ( - 1, 1, CONCAT( - YEAR(util.VN_CURDATE ()), '-12-09' - ), 1, 1 - ); +INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) + VALUES + (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); -INSERT INTO - `vn`.`supplierAgencyTerm` ( - `agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price` - ) -VALUES ( - 1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23 - ), - ( - 2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33 - ), - ( - 3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0 - ), - ( - 4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0 - ), - ( - 5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0 - ); +INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) + VALUES + (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23), + (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33), + (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), + (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), + (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); -INSERT INTO - `vn`.`chat` ( - `senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts` - ) -VALUES ( - 1101, '@PetterParker', util.VN_CURDATE (), 1, 'First test message', 0, 'sent' - ), - ( - 1101, '@PetterParker', util.VN_CURDATE (), 0, 'Second test message', 0, 'pending' - ); +INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) + VALUES + (1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 'sent'), + (1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending'); -INSERT INTO - `vn`.`mobileAppVersionControl` ( - `appName`, `version`, `isVersionCritical` - ) -VALUES ('delivery', '9.2', 0), - ('warehouse', '8.1', 0); -INSERT INTO - `vn`.`machine` ( - `plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk` - ) -VALUES ( - 'RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442 - ), - ( - 'RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442 - ); +INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`) + VALUES + ('delivery', '9.2', 0), + ('warehouse', '8.1', 0); -INSERT INTO - `vn`.`machineWorker` ( - `workerFk`, `machineFk`, `inTimed`, `outTimed` - ) -VALUES ( - 1106, 1, util.VN_CURDATE (), util.VN_CURDATE () - ), - ( - 1106, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ), - ( - 1106, 2, util.VN_CURDATE (), NULL - ), - ( - 1106, 2, DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ), DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 DAY - ) - ); +INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`) + VALUES + ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442), + ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); -INSERT INTO - `vn`.`zoneExclusion` ( - `id`, `zoneFk`, `dated`, `created`, `userFk` - ) -VALUES ( - 1, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 7, 7, 14 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ), util.VN_CURDATE (), 100 - ), - ( - 2, 1, DATE_ADD( - util.VN_CURDATE (), INTERVAL( - IF( - DAYOFWEEK(util.VN_CURDATE ()) <= 8, 8, 15 - ) - DAYOFWEEK(util.VN_CURDATE ()) - ) DAY - ), util.VN_CURDATE (), 100 - ); +INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) + VALUES + (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()), + (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (1106, 2, util.VN_CURDATE(), NULL), + (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)); -INSERT INTO - `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`) -VALUES (2, 1); +INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) +VALUES + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100), + (2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100); -INSERT INTO - `vn`.`mdbBranch` (`name`) -VALUES ('test'), - ('master'); +INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`) + VALUES + (2, 1); -INSERT INTO - `vn`.`mdbVersion` (`app`, `branchFk`, `version`) -VALUES ('tpv', 'test', '1'), - ('lab', 'master', '1'); +INSERT INTO `vn`.`mdbBranch` (`name`) + VALUES + ('test'), + ('master'); -INSERT INTO - `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`) -VALUES ( - 1, CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL -1 YEAR - ) - ), '-01-01' - ), CONCAT( - YEAR( - DATE_ADD( - util.VN_CURDATE (), INTERVAL + 1 YEAR - ) - ), '-01-01' - ) - ); +INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`) + VALUES + ('tpv', 'test', '1'), + ('lab', 'master', '1'); -INSERT INTO - `vn`.`saleGroup` ( - `userFk`, `parkingFk`, `sectorFk` - ) -VALUES (1, 1, 1); +INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`) + VALUES + (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-01-01'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-01')); -INSERT INTO - `vn`.`saleGroupDetail` (`saleFk`, `saleGroupFk`) -VALUES (31, 1); -INSERT INTO - `vn`.`sectorCollection` (`userFk`, `sectorFk`) -VALUES (1, 1); +INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`) + VALUES + (1, 1, 1); -INSERT INTO - `vn`.`sectorCollectionSaleGroup` ( - `sectorCollectionFk`, `saleGroupFk` - ) -VALUES (1, 1); +INSERT INTO `vn`.`saleGroupDetail` (`saleFk`, `saleGroupFk`) + VALUES + (31, 1); -INSERT INTO - `vn`.`workerTimeControlConfig` ( - `id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`, `maxTimeToBreak`, `maxWorkShortCycle`, `maxWorkLongCycle` - ) -VALUES ( - 1, 43200, 32400, 129600, 259200, 1080000, '', 'imap.verdnatura.es', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.00, 0.33, 40, '22:00:00', '06:00:00', 72000, 1200, 18000, 72000, 6, 13, 28800, 32400, 3600, 561600, 950400 - ); +INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) + VALUES + (1, 1); -INSERT INTO - `vn`.`host` ( - `id`, `code`, `description`, `warehouseFk`, `bankFk` - ) -VALUES (1, 'pc1', 'pc host', 1, 1); +INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) + VALUES + (1, 1); -INSERT INTO - `vn`.`packingSite` ( - `id`, `code`, `hostFk`, `monitorId` - ) -VALUES (1, 'h1', 1, ''); +INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`, `maxTimeToBreak`, `maxWorkShortCycle`, `maxWorkLongCycle`) + VALUES + (1, 43200, 32400, 129600, 259200, 1080000, '', 'imap.verdnatura.es', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.00, 0.33, 40, '22:00:00', '06:00:00', 72000, 1200, 18000, 72000, 6, 13, 28800, 32400, 3600, 561600, 950400); -INSERT INTO - `vn`.`packingSiteConfig` ( - `shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime` - ) -VALUES ( - '', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000 - ); +INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`) + VALUES + (1, 'pc1', 'pc host', 1, 1); -INSERT INTO `util`.`notificationConfig` SET `cleanDays` = 90; +INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) + VALUES + (1, 'h1', 1, ''); -INSERT INTO - `util`.`notification` (`id`, `name`, `description`) -VALUES ( - 1, 'print-email', 'notification fixture one' - ), - ( - 2, 'invoice-electronic', 'A electronic invoice has been generated' - ), - ( - 3, 'not-main-printer-configured', 'A printer distinct than main has been configured' - ), - ( - 4, 'supplier-pay-method-update', 'A supplier pay method has been updated' - ), - ( - 5, 'modified-entry', 'An entry has been modified' - ), - ( - 6, 'book-entry-deleted', 'accounting entries deleted' - ); +INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) + VALUES + ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); +INSERT INTO `util`.`notificationConfig` + SET `cleanDays` = 90; -INSERT INTO - `util`.`notificationAcl` (`notificationFk`, `roleFk`) -VALUES (1, 9), - (1, 1), - (2, 1), - (3, 9), - (4, 1), - (5, 9), - (6, 9); +INSERT INTO `util`.`notification` (`id`, `name`, `description`) + VALUES + (1, 'print-email', 'notification fixture one'), + (2, 'invoice-electronic', 'A electronic invoice has been generated'), + (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), + (5, 'modified-entry', 'An entry has been modified'), + (6, 'book-entry-deleted', 'accounting entries deleted'), + (7, 'zone-included','An email to notify zoneCollisions'); +INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) + VALUES + (1, 9), + (1, 1), + (2, 1), + (3, 9), + (4, 1), + (5, 9), + (6, 9), + (7, 1); -INSERT INTO - `util`.`notificationQueue` ( - `id`, `notificationFk`, `params`, `authorFk`, `status`, `created` - ) -VALUES ( - 1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE () - ), - ( - 2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE () - ), - ( - 3, 'print-email', null, null, 'pending', util.VN_CURDATE () - ); +INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) + VALUES + (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), + (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), + (3, 'print-email', null, null, 'pending', util.VN_CURDATE()); -INSERT INTO - `util`.`notificationSubscription` (`notificationFk`, `userFk`) -VALUES (1, 1109), - (1, 1110), - (2, 1110), - (4, 1110), - (2, 1109), - (1, 9), - (1, 3), - (6, 9); +INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) + VALUES + (1, 1109), + (1, 1110), + (2, 1110), + (4, 1110), + (2, 1109), + (1, 9), + (1, 3), + (6, 9), + (7, 9); -INSERT INTO - `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) -VALUES (1, 9); -INSERT INTO - `vn`.`productionConfig` ( - `isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge` - ) -VALUES ( - 0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6 - ); +INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) + VALUES + (1, 9); -INSERT INTO - `vn`.`collection` ( - `id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons` - ) -VALUES ( - 3, util.VN_NOW (), 1107, 5, NULL, 0, 0, 1, NULL, NULL - ); +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`) + VALUES + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6); -INSERT INTO - `vn`.`itemConfig` ( - `id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk` - ) -VALUES ( - 0, 0, 24, '', '[1,2,3]', 2, 56, 60 - ); +INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) + VALUES + (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); -INSERT INTO - `vn`.`ticketCollection` ( - `ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters` - ) -VALUES ( - 9, 3, util.VN_NOW (), NULL, 0, NULL, NULL, NULL, NULL - ); +INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`) + VALUES + (0, 0, 24, '', '[1,2,3]', 2, 56, 60); -INSERT INTO - `vn`.`saleCloned` ( - `saleClonedFk`, `saleOriginalFk` - ) -VALUES (29, 25); +INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) + VALUES + (9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL); + +INSERT INTO `vn`.`saleCloned` (`saleClonedFk`, `saleOriginalFk`) + VALUES + (29, 25); UPDATE `account`.`user` -SET - `hasGrant` = 1 -WHERE - `id` = 66; + SET `hasGrant` = 1 + WHERE `id` = 66; -INSERT INTO - `vn`.`ticketLog` ( - `originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description` - ) -VALUES ( - 7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 22, NULL - ), - ( - 7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 22, NULL - ), - ( - 7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 22, NULL - ), - ( - 7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 100cm de '5' a '10'" - ), - ( - 16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}', 12, 'Shield' - ); +INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`) + VALUES + (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 22, NULL), + (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 22, NULL), + (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 22, NULL), + (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 100cm de '5' a '10'"), + (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 12, 'Shield'); -INSERT INTO - `vn`.`ticketLog` ( - originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description - ) -VALUES ( - 1, NULL, 'delete', '2001-06-09 11:00:04', 'Ticket', 45, 'Spider Man', NULL, NULL, NULL - ), - ( - 1, 18, 'select', '2001-06-09 11:00:03', 'Ticket', 45, 'Spider Man', NULL, NULL, NULL - ), - ( - 1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 5, 'Armor', '{"isPicked": false}', '{"isPicked": true}', NULL - ), - ( - 1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 5, 'Armor', NULL, NULL, 'Armor quantity changed from ''15'' to ''10''' - ), - ( - 1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 4, 'Shield', '{"quantity":10,"concept":"Shield"}', NULL, NULL - ), - ( - 1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 1, 'Armor', NULL, '{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL - ), - ( - 1, 18, 'update', '2000-12-28 08:40:45', 'Ticket', 45, 'Spider Man', '{"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"isBlocked":false,"hasPriority":false,"companyFk":442,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', '{"warehouseFk":61,"shipped":"2023-05-17T22:00:00.000Z","nickname":"Spider Man","isSigned":false,"isLabeled":false,"isPrinted":false,"packages":1,"hour":0,"isBlocked":true,"hasPriority":true,"companyFk":443,"landed":"2023-05-18T22:00:00.000Z","isBoxed":false,"isDeleted":false,"zoneFk":713,"zonePrice":13,"zoneBonus":1}', NULL - ), - ( - 1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL, NULL, NULL, NULL - ), - ( - 1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 4, 'Shield', NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL - ), - ( - 1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man', NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL - ); -INSERT INTO - `vn`.`osTicketConfig` ( - `id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo` - ) -VALUES ( - 0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all' - ); +INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description) + VALUES + (1, NULL, 'delete', '2001-06-09 11:00:04', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL), + (1, 18, 'select', '2001-06-09 11:00:03', 'Ticket', 45, 'Spider Man' , NULL, NULL, NULL), + (1, NULL, 'update', '2001-05-09 10:00:02', 'Sale', 5, 'Armor' , '{"isPicked": false}','{"isPicked": true}', NULL), + (1, 18, 'update', '2001-01-01 10:05:01', 'Sale', 5, 'Armor' , NULL, NULL, 'Armor quantity changed from ''15'' to ''10'''), + (1, NULL, 'delete', '2001-01-01 10:00:10', 'Sale', 4, 'Shield' , '{"quantity":10,"concept":"Shield"}', NULL, NULL), + (1, 18, 'insert', '2000-12-31 15:00:05', 'Sale', 1, 'Armor' , NULL,'{"quantity":15,"concept":"Armor", "price": 345.99, "itemFk": 2}', NULL), + (1, 18, 'update', '2000-12-28 08:40:45', 'Ticket', 45, 'Spider Man' , '{"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"isBlocked":false,"hasPriority":false,"companyFk":442,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}','{"warehouseFk":61,"shipped":"2023-05-17T22:00:00.000Z","nickname":"Spider Man","isSigned":false,"isLabeled":false,"isPrinted":false,"packages":1,"hour":0,"isBlocked":true,"hasPriority":true,"companyFk":443,"landed":"2023-05-18T22:00:00.000Z","isBoxed":false,"isDeleted":false,"zoneFk":713,"zonePrice":13,"zoneBonus":1}', NULL), + (1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL), + (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 4, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL), + (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); +INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) + VALUES + (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); -INSERT INTO - `vn`.`mdbApp` ( - `app`, `baselineBranchFk`, `userFk`, `locked` - ) -VALUES ('foo', 'master', NULL, NULL), - ( - 'bar', 'test', 9, util.VN_NOW () - ); +INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) + VALUES + ('foo', 'master', NULL, NULL), + ('bar', 'test', 9, util.VN_NOW()); -INSERT INTO - `vn`.`profileType` (`id`, `name`) -VALUES (1, 'working'); +INSERT INTO `vn`.`profileType` (`id`, `name`) + VALUES + (1, 'working'); -INSERT INTO - `salix`.`url` ( - `appName`, `environment`, `url` - ) -VALUES ( - 'lilium', 'development', 'http://localhost:9000/#/' - ), - ( - 'hedera', 'development', 'http://localhost:9090/' - ), - ( - 'salix', 'development', 'http://localhost:5000/#!/' - ); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('lilium', 'development', 'http://localhost:9000/#/'), + ('hedera', 'development', 'http://localhost:9090/'), + ('salix', 'development', 'http://localhost:5000/#!/'); -INSERT INTO - `vn`.`report` ( - `id`, `name`, `paperSizeFk`, `method` - ) -VALUES ( - 3, 'invoice', NULL, 'InvoiceOuts/{refFk}/invoice-out-pdf' - ); +INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`) + VALUES + (3, 'invoice', NULL, 'InvoiceOuts/{refFk}/invoice-out-pdf'); -INSERT INTO - `vn`.`payDemDetail` (`id`, `detail`) -VALUES (1, 1), - (2, 20), - (7, 1); +INSERT INTO `vn`.`payDemDetail` (`id`, `detail`) + VALUES + (1, 1), + (2, 20), + (7, 1); -INSERT INTO - `vn`.`workerConfig` ( - `id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk` - ) -VALUES (1, NULL, 1, 4, 'worker'); +INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`) + VALUES + (1, NULL, 1, 4, 'worker'); -INSERT INTO - `vn`.`ticketRefund` ( - `refundTicketFk`, `originalTicketFk` - ) -VALUES (24, 8); +INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`) + VALUES + (24, 8); -INSERT INTO - `vn`.`deviceProductionModels` (`code`) -VALUES ('BLACKVIEW'), - ('DODGEE'), - ('ZEBRA'); +INSERT INTO `vn`.`deviceProductionModels` (`code`) + VALUES + ('BLACKVIEW'), + ('DODGEE'), + ('ZEBRA'); -INSERT INTO - `vn`.`deviceProductionState` (`code`, `description`) -VALUES ('active', 'activo'), - ('idle', 'inactivo'), - ('lost', 'perdida'), - ('repair', 'reparación'), - ('retired', 'retirada'); +INSERT INTO `vn`.`deviceProductionState` (`code`, `description`) + VALUES + ('active', 'activo'), + ('idle', 'inactivo'), + ('lost', 'perdida'), + ('repair', 'reparación'), + ('retired', 'retirada'); -INSERT INTO - `vn`.`deviceProduction` ( - `imei`, `modelFk`, `macWifi`, `serialNumber`, `android_id`, `purchased`, `stateFk`, `isInScalefusion`, `description` - ) -VALUES ( - 'ime1', 'BLACKVIEW', 'macWifi1', 'serialNumber1', 'androidid11234567890', util.VN_NOW (), 'active', 0, NULL - ), - ( - 'ime2', 'DODGEE', 'macWifi2', 'serialNumber2', 'androidid21234567890', util.VN_NOW (), 'idle', 0, NULL - ), - ( - 'ime3', 'ZEBRA', 'macWifi3', 'serialNumber3', 'androidid31234567890', util.VN_NOW (), 'active', 0, NULL - ), - ( - 'ime4', 'BLACKVIEW', 'macWifi4', 'serialNumber4', 'androidid41234567890', util.VN_NOW (), 'idle', 0, NULL - ); +INSERT INTO `vn`.`deviceProduction` (`imei`, `modelFk`, `macWifi`, `serialNumber`, `android_id`, `purchased`, `stateFk`, `isInScalefusion`, `description`) +VALUES + ('ime1', 'BLACKVIEW', 'macWifi1', 'serialNumber1', 'androidid11234567890', util.VN_NOW(), 'active', 0, NULL), + ('ime2', 'DODGEE', 'macWifi2', 'serialNumber2', 'androidid21234567890', util.VN_NOW(), 'idle', 0, NULL), + ('ime3', 'ZEBRA', 'macWifi3', 'serialNumber3', 'androidid31234567890', util.VN_NOW(), 'active', 0, NULL), + ('ime4', 'BLACKVIEW', 'macWifi4', 'serialNumber4', 'androidid41234567890', util.VN_NOW(), 'idle', 0, NULL); -INSERT INTO - `vn`.`deviceProductionUser` ( - `deviceProductionFk`, `userFk`, `created` - ) -VALUES (1, 1, util.VN_NOW ()), - (3, 3, util.VN_NOW ()); +INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `created`) + VALUES + (1, 1, util.VN_NOW()), + (3, 3, util.VN_NOW()); -INSERT INTO - `vn`.`workerTimeControlMail` ( - `id`, `workerFk`, `year`, `week`, `state`, `updated`, `sendedCounter`, `reason` - ) -VALUES ( - 1, 9, 2000, 49, 'REVISE', util.VN_NOW (), 1, 'test2' - ), - ( - 2, 9, 2000, 50, 'SENDED', util.VN_NOW (), 1, NULL - ), - ( - 3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW (), 1, NULL - ), - ( - 4, 9, 2001, 1, 'SENDED', util.VN_NOW (), 1, NULL - ); +INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `state`, `updated`, `sendedCounter`, `reason`) + VALUES + (1, 9, 2000, 49, 'REVISE', util.VN_NOW(), 1, 'test2'), + (2, 9, 2000, 50, 'SENDED', util.VN_NOW(), 1, NULL), + (3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL), + (4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL); -INSERT INTO - `vn`.`wagonConfig` ( - `id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays` - ) -VALUES (1, 1350, 1900, 200, 50, 6); +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`) + VALUES + (1, 1350, 1900, 200, 50, 6); -INSERT INTO - `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) -VALUES (1, 'white', '#ffffff'), - (2, 'red', '#ff0000'), - (3, 'green', '#00ff00'), - (4, 'blue', '#0000ff'); +INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) + VALUES + (1, 'white', '#ffffff'), + (2, 'red', '#ff0000'), + (3, 'green', '#00ff00'), + (4, 'blue', '#0000ff'); -INSERT INTO - `vn`.`wagonType` (`id`, `name`, `divisible`) -VALUES (1, 'Wagon Type #1', 1); +INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`) + VALUES + (1, 'Wagon Type #1', 1); -INSERT INTO - `vn`.`wagonTypeTray` ( - `id`, `typeFk`, `height`, `colorFk` - ) -VALUES (1, 1, 100, 1), - (2, 1, 50, 2), - (3, 1, 0, 3); +INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`) + VALUES + (1, 1, 100, 1), + (2, 1, 50, 2), + (3, 1, 0, 3); -INSERT INTO - `salix`.`accessTokenConfig` ( - `id`, `renewPeriod`, `courtesyTime`, `renewInterval` - ) -VALUES (1, 21600, 60, 300); +INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`) + VALUES + (1, 21600, 60, 300); -INSERT INTO - `vn`.`travelConfig` ( - `id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk` - ) -VALUES (1, 1, 1, 1, 442); +INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`) + VALUES + (1, 1, 1, 1, 442); -INSERT INTO - `vn`.`buyConfig` (`id`, `monthsAgo`) -VALUES (1, 6); +INSERT INTO `vn`.`buyConfig` (`id`, `monthsAgo`) + VALUES + (1, 6); -INSERT INTO - `vn`.`invoiceInSerial` ( - `code`, `description`, `cplusTerIdNifFk`, `taxAreaFk` - ) -VALUES ('C', 'Asgard', 1, 'WORLD'), - ('E', 'Midgard', 1, 'CEE'), - ( - 'R', 'Jotunheim', 1, 'NATIONAL' - ), - ('W', 'Vanaheim', 1, 'WORLD'); +INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `taxAreaFk`) + VALUES + ('C', 'Asgard', 1, 'WORLD'), + ('E', 'Midgard', 1, 'CEE'), + ('R', 'Jotunheim', 1, 'NATIONAL'), + ('W', 'Vanaheim', 1, 'WORLD'); -INSERT INTO - `hedera`.`imageConfig` ( - `id`, `maxSize`, `useXsendfile`, `url` - ) -VALUES (1, 0, 0, 'marvel.com'); -INSERT INTO - vn.XDiario ( - id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, BASEEURO, SERIE, FACTURA, IVA, RECEQUIV, CLAVE, CAMBIO, DEBEME, HABERME, AUXILIAR, MONEDAUSO, TIPOOPE, NFACTICK, TERIDNIF, TERNIF, TERNOM, OPBIENES, L340, enlazado, FECHA_EX, LRECT349, empresa_id, LDIFADUAN, METAL, METALIMP, CLIENTE, METALEJE, FECHA_OP, FACTURAEX, TIPOCLAVE, TIPOEXENCI, TIPONOSUJE, TIPOFACT, TIPORECTIF, SERIE_RT, FACTU_RT, BASEIMP_RT, BASEIMP_RF, RECTIFICA, FECHA_RT, FECREGCON, enlazadoSage - ) -VALUES ( - 1, 1.0, util.VN_CURDATE (), '4300001104', NULL, 'n/fra T3333333', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1 - ), - ( - 2, 1.0, util.VN_CURDATE (), '2000000000', '4300001104', 'n/fra T3333333 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1 - ), - ( - 3, 1.0, util.VN_CURDATE (), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T3333333 Tony Stark', NULL, 0.81, 8.07, 'T', '3333333', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1 - ), - ( - 4, 2.0, util.VN_CURDATE (), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 - ), - ( - 5, 2.0, util.VN_CURDATE (), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 - ), - ( - 6, 2.0, util.VN_CURDATE (), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE (), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE (), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 - ); +INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`) + VALUES + (1, 0, 0, 'marvel.com'); -INSERT INTO - `vn`.`mistakeType` (`id`, `description`) -VALUES (1, 'Incorrect quantity'); +INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, BASEEURO, SERIE, FACTURA, IVA, RECEQUIV, CLAVE, CAMBIO, DEBEME, HABERME, AUXILIAR, MONEDAUSO, TIPOOPE, NFACTICK, TERIDNIF, TERNIF, TERNOM, OPBIENES, L340, enlazado, FECHA_EX, LRECT349, empresa_id, LDIFADUAN, METAL, METALIMP, CLIENTE, METALEJE, FECHA_OP, FACTURAEX, TIPOCLAVE, TIPOEXENCI, TIPONOSUJE, TIPOFACT, TIPORECTIF, SERIE_RT, FACTU_RT, BASEIMP_RT, BASEIMP_RF, RECTIFICA, FECHA_RT, FECREGCON, enlazadoSage) + VALUES + (1, 1.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T3333333', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1), + (2, 1.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T3333333 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1), + (3, 1.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T3333333 Tony Stark', NULL, 0.81, 8.07, 'T', '3333333', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 1), + (4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0), + (5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0), + (6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0); -INSERT INTO - `vn`.`invoiceCorrectionType` (`id`, `description`) -VALUES (1, 'Error in VAT calculation'), - (2, 'Error in sales details'), - (3, 'Error in customer data'); +INSERT INTO `vn`.`mistakeType` (`id`, `description`) + VALUES + (1, 'Incorrect quantity'); -UPDATE `vn`.`client` SET fi = '65004204V' WHERE id = 1; +INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`) + VALUES + (1, 'Error in VAT calculation'), + (2, 'Error in sales details'), + (3, 'Error in customer data'); -UPDATE `vn`.`worker` SET fi = '59328808D' WHERE id = 1106; +UPDATE `vn`.`client` + SET fi='65004204V' + WHERE id=1; -INSERT INTO - `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`) -VALUES (1, 1), - (2, 9), - (3, 15); +UPDATE `vn`.`worker` + SET fi='59328808D' + WHERE id=1106; -INSERT INTO - `vn`.`docuwareTablet` (`tablet`, `description`) -VALUES ('Tablet1', 'Jarvis tablet'), - ('Tablet2', 'Avengers tablet'); -INSERT INTO - `vn`.`sms` ( - `id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created` - ) -VALUES ( - 1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE () - ), - ( - 2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE () - ), - ( - 3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE () - ), - ( - 4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE () - ); +INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`) + VALUES + (1, 1), + (2, 9), + (3, 15); -INSERT INTO - `vn`.`clientSms` ( - `id`, `clientFk`, `smsFk`, `ticketFk` - ) -VALUES (1, 1103, 1, NULL), - (2, 1103, 2, NULL), - (3, 1103, 3, 32), - (4, 1103, 4, 32), - (13, 1101, 1, NULL), - (14, 1101, 4, 27); +INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`) + VALUES + ('Tablet1','Jarvis tablet'), + ('Tablet2','Avengers tablet'); + +INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`) + VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()), + (2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()), + (3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()), + (4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()); + +INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) + VALUES(1, 1103, 1, NULL), + (2, 1103, 2, NULL), + (3, 1103, 3, 32), + (4, 1103, 4, 32), + (13, 1101, 1, NULL), + (14, 1101, 4, 27); + +UPDATE salix.ACL + SET principalId='employee' WHERE model ="Notification"; From 7abf81f815584e0e899213dcbba66c9f3810c597 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:12:58 +0100 Subject: [PATCH 024/136] refs #5858 fix: restore test to default --- modules/zone/back/methods/zone/specs/deleteZone.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index e105bb296..bb8416b16 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -30,7 +30,7 @@ describe('zone deletezone()', () => { } }); - it('should NOT delete a zone if is included', async() => { + xit('should NOT delete a zone if is included', async() => { const tx = await models.Zone.beginTransaction({}); let isIncluded = false; try { @@ -45,7 +45,7 @@ describe('zone deletezone()', () => { } }); - it('should NOT delete a zone if is included check', async() => { + xit('should NOT delete a zone if is included check', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; @@ -61,12 +61,12 @@ describe('zone deletezone()', () => { try { const options = {transaction: tx}; - const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); + /* const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); await models.ZoneIncluded.destroyById(zoneIncluded[0].id, options); const zoneIncludedDeleted = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); - expect(zoneIncludedDeleted.length).toEqual(0); + expect(zoneIncludedDeleted.length).toEqual(0);*/ await models.Zone.deleteZone(ctx, zoneId, options); From 3cb494c7357a016765d89b75e39050d758329220 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:14:23 +0100 Subject: [PATCH 025/136] refs #5858 fix: restore test to default --- .../methods/zone/specs/deleteZone.spec.js | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index e105bb296..a9e0a768f 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -30,43 +30,11 @@ describe('zone deletezone()', () => { } }); - it('should NOT delete a zone if is included', async() => { - const tx = await models.Zone.beginTransaction({}); - let isIncluded = false; - try { - const options = {transaction: tx}; - const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}); - isIncluded = zoneIncluded.length > 0; - await models.Zone.deleteZone(ctx, zoneId, options); - } catch (e) { - expect(isIncluded).toBeTrue(); - expect(e).not.toBeNull(); - await tx.rollback(); - } - }); - - it('should NOT delete a zone if is included check', async() => { - const tx = await models.Zone.beginTransaction({}); - try { - const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId, options); - } catch (e) { - expect(e).not.toBeNull(); - await tx.rollback(); - } - }); - it('should delete a zone and update their tickets', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - const zoneIncluded = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); - await models.ZoneIncluded.destroyById(zoneIncluded[0].id, options); - - const zoneIncludedDeleted = await models.ZoneIncluded.find({where: {zoneFk: zoneId}}, options); - - expect(zoneIncludedDeleted.length).toEqual(0); await models.Zone.deleteZone(ctx, zoneId, options); From e5b7395e5ceebbe58c84050fc58ab4ba6fce654e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:27:28 +0100 Subject: [PATCH 026/136] refs #5858 fix: test Notification getList --- back/methods/notification/specs/getList.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index 52ac497a5..6c60d3505 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -7,7 +7,7 @@ describe('NotificationSubscription getList()', () => { const notifications = await models.Notification.find({}); const totalAvailable = notifications.length - active.length; - expect(active.length).toEqual(2); + expect(active.length).toEqual(3); expect(available.length).toEqual(totalAvailable); }); }); From 337190ef6de03056b476e9b342816bbde301fbb0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:27:46 +0100 Subject: [PATCH 027/136] refs #5858 feat: use notification system --- .../vn/procedures/zone_getCollisions.sql | 98 ++++++++----------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/db/routines/vn/procedures/zone_getCollisions.sql b/db/routines/vn/procedures/zone_getCollisions.sql index f6779e1b7..a3a637e84 100644 --- a/db/routines/vn/procedures/zone_getCollisions.sql +++ b/db/routines/vn/procedures/zone_getCollisions.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() BEGIN /** - * Calcula si para un mismo codigo postal y dia + * Calcula si para un mismo codigo postal y dia * hay mas de una zona configurada y manda correo * */ @@ -10,17 +10,18 @@ BEGIN DECLARE vZoneFk INT; DECLARE vIsDone INT DEFAULT FALSE; DECLARE vTableCollisions TEXT; + DECLARE json_data JSON; DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; DROP TEMPORARY TABLE IF EXISTS tmp.zone; CREATE TEMPORARY TABLE tmp.zone - SELECT z.id + SELECT z.id FROM zone z JOIN agencyMode am ON am.id = z.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY'); + WHERE dm.code IN ('AGENCY','DELIVERY'); CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE); @@ -35,7 +36,7 @@ BEGIN PRIMARY KEY zoneFkk (zoneFk, geoFk), INDEX(geoFk)) ENGINE = MyISAM; - + OPEN cur1; cur1Loop: LOOP SET vIsDone = FALSE; @@ -43,83 +44,62 @@ BEGIN IF vIsDone THEN LEAVE cur1Loop; END IF; - + CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE); - myLoop: LOOP + myLoop: LOOP SET vGeoFk = NULL; - SELECT geoFk INTO vGeoFk + SELECT geoFk INTO vGeoFk FROM tmp.zoneNodes zn WHERE NOT isChecked LIMIT 1; - + IF vGeoFk IS NULL THEN LEAVE myLoop; END IF; - + CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE); UPDATE tmp.zoneNodes - SET isChecked = TRUE + SET isChecked = TRUE WHERE geoFk = vGeoFk; END LOOP; END LOOP; CLOSE cur1; - DELETE FROM tmp.zoneNodes + DELETE FROM tmp.zoneNodes WHERE sons > 0; - + DROP TEMPORARY TABLE IF EXISTS geoCollision; CREATE TEMPORARY TABLE geoCollision SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk FROM tmp.zoneNodes zn JOIN zone z ON z.id = zn.zoneFk - JOIN zoneWarehouse zw ON z.id = zw.zoneFk + JOIN zoneWarehouse zw ON z.id = zw.zoneFk GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk HAVING count(*) > 1; - - SELECT ' - - - - - - - - ' INTO vTableCollisions; - - INSERT INTO mail (receiver,replyTo,subject,body) - SELECT 'pepe@verdnatura.es' receiver, - 'noreply@verdnatura.es' replyTo, - CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject, - CONCAT(vTableCollisions, - GROUP_CONCAT(sub.td SEPARATOR ''), - '
C.PostalNúmero de zonaPrecioZonaAlmacénSalix
') body - FROM(SELECT - CONCAT(' - ', zn.name, ' - ', zoneFk,' - ', z.price,' - ', z.name,' - ', w.name, ' - ', CONCAT('' - 'https://salix.verdnatura.es/#!/zone/', - zoneFk, - '/location?q=%7B%22search%22:%22', - zn.name, - '%22%7D'),' - ') td - FROM tmp.zoneNodes zn - JOIN zone z ON z.id = zn.zoneFk - JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk - JOIN warehouse w ON w.id = gc.warehouseFk) sub; - - DROP TEMPORARY TABLE - geoCollision, + + SELECT JSON_ARRAYAGG( + JSON_OBJECT( + 'zoneFk', zoneFk, + 'zn', JSON_OBJECT('name', zn.name), + 'z', JSON_OBJECT('name', z.name,'price', z.price), + 'w', JSON_OBJECT('name', w.name) + ) + ) FROM tmp.zoneNodes zn + JOIN zone z ON z.id = zn.zoneFk + JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk + JOIN warehouse w ON w.id = gc.warehouseFk + INTO json_data; + + SELECT util.notification_send( + 'zone-included', + JSON_OBJECT('zoneCollisions',json_data), + account.myUser_getId() + ); + + DROP TEMPORARY TABLE + geoCollision, tmp.zone, tmp.zoneNodes; -END$$ +END ;; DELIMITER ; From cff59d197d0bb2b6b4a5dbc550050ca598ef356f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:28:07 +0100 Subject: [PATCH 028/136] refs #5858 feat: use active event when trigger --- db/routines/vn/triggers/zoneIncluded_afterDelete.sql | 1 + db/routines/vn/triggers/zoneIncluded_beforeInsert.sql | 1 + db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql | 1 + 3 files changed, 3 insertions(+) diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 6d184bb12..501e16c32 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -8,5 +8,6 @@ BEGIN `changedModel` = 'zoneIncluded', `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); + UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 5eff33efa..a1cf232b3 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index 445f37699..e83058782 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; From 7f1e3c66e2a83261d77fd474c905babf4da91e70 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 10:35:12 +0100 Subject: [PATCH 029/136] refs #5858 feat: define event --- db/routines/vn/events/zone_getCollisions.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/routines/vn/events/zone_getCollisions.sql diff --git a/db/routines/vn/events/zone_getCollisions.sql b/db/routines/vn/events/zone_getCollisions.sql new file mode 100644 index 000000000..680b264f0 --- /dev/null +++ b/db/routines/vn/events/zone_getCollisions.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE EVENT IF NOT EXISTS `zone_getCollisions` + ON SCHEDULE EVERY 1 DAY + STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY + ENABLE + DO BEGIN + CALL `zone_getCollisions`(); + -- Desactivar el evento después de ejecutarse + ALTER EVENT `zone_getCollisions` DISABLE; +END$$ +DELIMITER; From 0a398fdd6cc119aceb0c21328479099893e76530 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 11:37:08 +0100 Subject: [PATCH 030/136] refs #5858 feat: comments --- db/routines/vn/events/zone_getCollisions.sql | 12 ++++++------ db/routines/vn/procedures/zone_getCollisions.sql | 7 +++++-- db/routines/vn/triggers/zoneIncluded_afterDelete.sql | 2 ++ .../vn/triggers/zoneIncluded_beforeInsert.sql | 2 ++ .../vn/triggers/zoneIncluded_beforeUpdate.sql | 2 ++ .../10881-greenHydrangea/01-notification.vn.sql | 10 ++++++++++ .../zone/back/methods/zone/specs/deleteZone.spec.js | 1 - 7 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 db/versions/10881-greenHydrangea/01-notification.vn.sql diff --git a/db/routines/vn/events/zone_getCollisions.sql b/db/routines/vn/events/zone_getCollisions.sql index 680b264f0..5df262e63 100644 --- a/db/routines/vn/events/zone_getCollisions.sql +++ b/db/routines/vn/events/zone_getCollisions.sql @@ -1,11 +1,11 @@ DELIMITER $$ + CREATE EVENT IF NOT EXISTS `zone_getCollisions` ON SCHEDULE EVERY 1 DAY STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY - ENABLE - DO BEGIN + DO BEGIN CALL `zone_getCollisions`(); - -- Desactivar el evento después de ejecutarse - ALTER EVENT `zone_getCollisions` DISABLE; -END$$ -DELIMITER; + ALTER EVENT `zone_getCollisions` DISABLE; + END$$ + +DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getCollisions.sql b/db/routines/vn/procedures/zone_getCollisions.sql index a3a637e84..023b9aac2 100644 --- a/db/routines/vn/procedures/zone_getCollisions.sql +++ b/db/routines/vn/procedures/zone_getCollisions.sql @@ -1,5 +1,6 @@ DELIMITER $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() + +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`() BEGIN /** * Calcula si para un mismo codigo postal y dia @@ -78,6 +79,7 @@ BEGIN GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk HAVING count(*) > 1; + -- Recojo los datos de la zona que ha dado conflicto SELECT JSON_ARRAYAGG( JSON_OBJECT( 'zoneFk', zoneFk, @@ -91,6 +93,7 @@ BEGIN JOIN warehouse w ON w.id = gc.warehouseFk INTO json_data; + -- Creo un registro de la notificacion 'zone-included' para reportar via email SELECT util.notification_send( 'zone-included', JSON_OBJECT('zoneCollisions',json_data), @@ -101,5 +104,5 @@ BEGIN geoCollision, tmp.zone, tmp.zoneNodes; -END ;; +END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 501e16c32..005709506 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -8,6 +8,8 @@ BEGIN `changedModel` = 'zoneIncluded', `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); + + -- Activo el evento 'zone_getCollisions' UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index a1cf232b3..4ea26e154 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + -- Activo el evento 'zone_getCollisions' UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index e83058782..1bc12d891 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + -- Activo el evento 'zone_getCollisions' UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; END$$ DELIMITER ; diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql new file mode 100644 index 000000000..d05902461 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -0,0 +1,10 @@ +INSERT INTO util.notification (id, name,description) + VALUES ( +(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); + +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index a9e0a768f..968685fec 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -35,7 +35,6 @@ describe('zone deletezone()', () => { try { const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId, options); const updatedZone = await models.Zone.findById(zoneId, null, options); From e8c783ca680a629e07836ec191205e59e43a55ae Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 13:14:41 +0100 Subject: [PATCH 031/136] refs #5858 feat: comments --- .../10881-greenHydrangea/00-firstScript.sql | 18 ++++++++++++++++++ .../01-notification.vnx.sql | 10 ++++++++++ 2 files changed, 28 insertions(+) create mode 100644 db/versions/10881-greenHydrangea/00-firstScript.sql create mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/versions/10881-greenHydrangea/00-firstScript.sql b/db/versions/10881-greenHydrangea/00-firstScript.sql new file mode 100644 index 000000000..1ca77c1a0 --- /dev/null +++ b/db/versions/10881-greenHydrangea/00-firstScript.sql @@ -0,0 +1,18 @@ + +-- UPDATE salix.ACL +-- SET principalId='employee' WHERE model ="Notification"; + +-- INSERT INTO util.notification (name,description) +-- VALUES ('zone-included','An email to notify zoneCollisions'); + +-- INSERT INTO util.notificationSubscription (notificationFk,userFk) +-- SELECT +-- (SELECT id FROM util.notification WHERE name= "zone-included") AS notificationFk, +-- (SELECT account.myUser_getId() ) AS userFk; + + +-- INSERT INTO util.notificationAcl (notificationFk, roleFk) +-- SELECT +-- (SELECT id FROM util.notification WHERE name = 'zone-included') AS notificationFk, +-- (SELECT id FROM account.role WHERE name = 'system') AS roleFk; + diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql new file mode 100644 index 000000000..83e2be1d0 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vnx.sql @@ -0,0 +1,10 @@ +-- INSERT INTO util.notification (id, name,description) +-- VALUES ( +-- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); + +-- INSERT INTO util.notificationSubscription (notificationFk,userFk) +-- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; + + +-- INSERT INTO util.notificationAcl (notificationFk,roleFk) +-- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 05d685c86bef4aba674d1e1f8eb5fc333d96bf4e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 13:17:47 +0100 Subject: [PATCH 032/136] refs #5858 feat: comments --- db/dump/fixtures.before.sql | 13 ++++--------- .../10881-greenHydrangea/00-firstScript.sql | 18 ------------------ .../01-notification.vn.sql | 10 ---------- .../01-notification.vnx.sql | 10 ---------- 4 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 db/versions/10881-greenHydrangea/00-firstScript.sql delete mode 100644 db/versions/10881-greenHydrangea/01-notification.vn.sql delete mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8a6bd85fd..be9fe05ff 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2816,8 +2816,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), - (6, 'book-entry-deleted', 'accounting entries deleted'), - (7, 'zone-included','An email to notify zoneCollisions'); + (6, 'book-entry-deleted', 'accounting entries deleted'); + INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), @@ -2826,8 +2826,7 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (3, 9), (4, 1), (5, 9), - (6, 9), - (7, 1); + (6, 9); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2844,8 +2843,7 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (2, 1109), (1, 9), (1, 3), - (6, 9), - (7, 9); + (6, 9); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) @@ -3064,6 +3062,3 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); - -UPDATE salix.ACL - SET principalId='employee' WHERE model ="Notification"; diff --git a/db/versions/10881-greenHydrangea/00-firstScript.sql b/db/versions/10881-greenHydrangea/00-firstScript.sql deleted file mode 100644 index 1ca77c1a0..000000000 --- a/db/versions/10881-greenHydrangea/00-firstScript.sql +++ /dev/null @@ -1,18 +0,0 @@ - --- UPDATE salix.ACL --- SET principalId='employee' WHERE model ="Notification"; - --- INSERT INTO util.notification (name,description) --- VALUES ('zone-included','An email to notify zoneCollisions'); - --- INSERT INTO util.notificationSubscription (notificationFk,userFk) --- SELECT --- (SELECT id FROM util.notification WHERE name= "zone-included") AS notificationFk, --- (SELECT account.myUser_getId() ) AS userFk; - - --- INSERT INTO util.notificationAcl (notificationFk, roleFk) --- SELECT --- (SELECT id FROM util.notification WHERE name = 'zone-included') AS notificationFk, --- (SELECT id FROM account.role WHERE name = 'system') AS roleFk; - diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql deleted file mode 100644 index d05902461..000000000 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ /dev/null @@ -1,10 +0,0 @@ -INSERT INTO util.notification (id, name,description) - VALUES ( -(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); - -INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; - - -INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql deleted file mode 100644 index 83e2be1d0..000000000 --- a/db/versions/10881-greenHydrangea/01-notification.vnx.sql +++ /dev/null @@ -1,10 +0,0 @@ --- INSERT INTO util.notification (id, name,description) --- VALUES ( --- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); - --- INSERT INTO util.notificationSubscription (notificationFk,userFk) --- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; - - --- INSERT INTO util.notificationAcl (notificationFk,roleFk) --- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 955828c63ed62480685e1a73ff55ab421e995e5f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 Feb 2024 15:13:18 +0100 Subject: [PATCH 033/136] refs #5858 feat: comments --- db/dump/fixtures.before.sql | 13 ++++--------- db/routines/util/events/vn_scheduler.sql | 9 +++++++++ db/routines/util/procedures/vn_scheduler.sql | 8 ++++++++ db/routines/vn/events/zone_getCollisions.sql | 11 ----------- .../vn/triggers/zoneIncluded_afterDelete.sql | 4 +++- .../vn/triggers/zoneIncluded_beforeInsert.sql | 4 ++-- .../vn/triggers/zoneIncluded_beforeUpdate.sql | 4 ++-- 7 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 db/routines/util/events/vn_scheduler.sql create mode 100644 db/routines/util/procedures/vn_scheduler.sql delete mode 100644 db/routines/vn/events/zone_getCollisions.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8a6bd85fd..be9fe05ff 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2816,8 +2816,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), - (6, 'book-entry-deleted', 'accounting entries deleted'), - (7, 'zone-included','An email to notify zoneCollisions'); + (6, 'book-entry-deleted', 'accounting entries deleted'); + INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), @@ -2826,8 +2826,7 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (3, 9), (4, 1), (5, 9), - (6, 9), - (7, 1); + (6, 9); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2844,8 +2843,7 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (2, 1109), (1, 9), (1, 3), - (6, 9), - (7, 9); + (6, 9); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) @@ -3064,6 +3062,3 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); - -UPDATE salix.ACL - SET principalId='employee' WHERE model ="Notification"; diff --git a/db/routines/util/events/vn_scheduler.sql b/db/routines/util/events/vn_scheduler.sql new file mode 100644 index 000000000..4c5c99b6a --- /dev/null +++ b/db/routines/util/events/vn_scheduler.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER` + ON SCHEDULE EVERY 1 DAY + STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY + DO BEGIN + CALL `VN_SCHEDULER`(); + END$$ + +DELIMITER ; diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql new file mode 100644 index 000000000..d34fe9092 --- /dev/null +++ b/db/routines/util/procedures/vn_scheduler.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`() +BEGIN + -- Obtener datos de la tabla vn_schedules + +END$$ + +DELIMITER ; diff --git a/db/routines/vn/events/zone_getCollisions.sql b/db/routines/vn/events/zone_getCollisions.sql deleted file mode 100644 index 5df262e63..000000000 --- a/db/routines/vn/events/zone_getCollisions.sql +++ /dev/null @@ -1,11 +0,0 @@ -DELIMITER $$ - -CREATE EVENT IF NOT EXISTS `zone_getCollisions` - ON SCHEDULE EVERY 1 DAY - STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY - DO BEGIN - CALL `zone_getCollisions`(); - ALTER EVENT `zone_getCollisions` DISABLE; - END$$ - -DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 005709506..248717f51 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -10,6 +10,8 @@ BEGIN `userFk` = account.myUser_getId(); -- Activo el evento 'zone_getCollisions' - UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; + -- UPDATE `mysql`.`event` SET status = 1 WHERE name = 'zone_getCollisions'; + + -- Insert en vn_schedules 'zone_getCollisions' END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 4ea26e154..2e1f70407 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -1,11 +1,11 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert` BEFORE INSERT ON `zoneIncluded` - FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); -- Activo el evento 'zone_getCollisions' - UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; + -- Insert en vn_schedulesla key 'zone_getCollisions' + END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index 1bc12d891..05c3acd41 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp BEGIN SET NEW.editorFk = account.myUser_getId(); - -- Activo el evento 'zone_getCollisions' - UPDATE mysql.event SET status = 1 WHERE name = 'zone_getCollisions'; + -- Activo el evento 'zone_getCollisions' -- Insert en vn_schedules 'zone_getCollisions' + END$$ DELIMITER ; From 7b862c5c30c659addf7b7136db49ddcf97ab60ba Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Feb 2024 16:10:58 +0100 Subject: [PATCH 034/136] fix: refs #6744 fix setPassword --- .../worker/back/methods/worker/setPassword.js | 47 +++++++++++-------- modules/worker/front/descriptor/index.html | 4 +- modules/worker/front/descriptor/index.js | 5 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/modules/worker/back/methods/worker/setPassword.js b/modules/worker/back/methods/worker/setPassword.js index 43d3d946f..0f6905e80 100644 --- a/modules/worker/back/methods/worker/setPassword.js +++ b/modules/worker/back/methods/worker/setPassword.js @@ -2,42 +2,49 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('setPassword', { description: 'Set a new password', - accepts: [ - { - arg: 'workerFk', - type: 'number', - required: true, - description: 'The worker id', - }, - { - arg: 'newPass', - type: 'String', - required: true, - description: 'The new worker password' - } + accepts: [{ + arg: 'workerFk', + type: 'number', + required: true, + description: 'The worker id', + }, { + arg: 'newPass', + type: 'String', + required: true, + description: 'The new worker password' + }, { + arg: 'emailVerified', + type: 'Boolean', + required: true, + }, ], http: { path: `/:id/setPassword`, verb: 'PATCH' } }); - Self.setPassword = async(ctx, options) => { + Self.setPassword = async(ctx, workerFk, newPass, emailVerified, options) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {}; - const {args} = ctx; let tx; + if (typeof options == 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - try { - const isSubordinate = await models.Worker.isSubordinate(ctx, args.workerFk, myOptions); - if (!isSubordinate) throw new UserError('You don\'t have enough privileges.'); - await models.VnUser.setPassword(args.workerFk, args.newPass, myOptions); - await models.VnUser.updateAll({id: args.workerFk}, {emailVerified: true}, myOptions); + try { + const ishimself = userId === workerFk; + const isSubordinate = await models.Worker.isSubordinate(ctx, workerFk, myOptions); + + if (ishimself || (isSubordinate && !emailVerified)) { + await models.VnUser.setPassword(workerFk, newPass, myOptions); + await models.VnUser.updateAll({id: workerFk}, {emailVerified: true}, myOptions); + } else + throw new UserError('You don\'t have enough privileges.'); if (tx) await tx.commit(); } catch (e) { diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 8290e2a15..67776ce47 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -11,8 +11,8 @@ ? 'Click to allow the user to be disabled' : 'Click to exclude the user from getting disabled'}} - - Change password + + Change password diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 13ffa6f2f..4ef98fe3b 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -15,6 +15,8 @@ class Controller extends Descriptor { this.entity = value; if (value) this.getIsExcluded(); + this.$http.get(`UserConfigs/getUserConfig`) + .then(res => this.userFk = res.data.userFk); if (this.entity && !this.entity.user.emailVerified) this.getPassRequirements(); @@ -69,6 +71,7 @@ class Controller extends Descriptor { } ] }; + return this.getData(`Workers/${this.id}`, {filter}) .then(res => this.entity = res.data); } @@ -87,7 +90,7 @@ class Controller extends Descriptor { throw new UserError(`Passwords don't match`); this.$http.patch( `Workers/${this.entity.id}/setPassword`, - {workerFk: this.entity.id, newPass: this.newPassword} + {workerFk: this.entity.id, newPass: this.newPassword, emailVerified: !!this.entity.user.emailVerified} ) .then(() => { this.vnApp.showSuccess(this.$translate.instant('Password changed!')); }); From 24984e8acacfa15661d4b47dfa9184ee21f53713 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 13 Feb 2024 08:32:04 +0100 Subject: [PATCH 035/136] Revert "refs #5858 feat: comments" This reverts commit 05d685c86bef4aba674d1e1f8eb5fc333d96bf4e. --- db/dump/fixtures.before.sql | 13 +++++++++---- .../10881-greenHydrangea/00-firstScript.sql | 18 ++++++++++++++++++ .../01-notification.vn.sql | 10 ++++++++++ .../01-notification.vnx.sql | 10 ++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 db/versions/10881-greenHydrangea/00-firstScript.sql create mode 100644 db/versions/10881-greenHydrangea/01-notification.vn.sql create mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index be9fe05ff..8a6bd85fd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2816,8 +2816,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), - (6, 'book-entry-deleted', 'accounting entries deleted'); - + (6, 'book-entry-deleted', 'accounting entries deleted'), + (7, 'zone-included','An email to notify zoneCollisions'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), @@ -2826,7 +2826,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (3, 9), (4, 1), (5, 9), - (6, 9); + (6, 9), + (7, 1); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2843,7 +2844,8 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (2, 1109), (1, 9), (1, 3), - (6, 9); + (6, 9), + (7, 9); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) @@ -3062,3 +3064,6 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); + +UPDATE salix.ACL + SET principalId='employee' WHERE model ="Notification"; diff --git a/db/versions/10881-greenHydrangea/00-firstScript.sql b/db/versions/10881-greenHydrangea/00-firstScript.sql new file mode 100644 index 000000000..1ca77c1a0 --- /dev/null +++ b/db/versions/10881-greenHydrangea/00-firstScript.sql @@ -0,0 +1,18 @@ + +-- UPDATE salix.ACL +-- SET principalId='employee' WHERE model ="Notification"; + +-- INSERT INTO util.notification (name,description) +-- VALUES ('zone-included','An email to notify zoneCollisions'); + +-- INSERT INTO util.notificationSubscription (notificationFk,userFk) +-- SELECT +-- (SELECT id FROM util.notification WHERE name= "zone-included") AS notificationFk, +-- (SELECT account.myUser_getId() ) AS userFk; + + +-- INSERT INTO util.notificationAcl (notificationFk, roleFk) +-- SELECT +-- (SELECT id FROM util.notification WHERE name = 'zone-included') AS notificationFk, +-- (SELECT id FROM account.role WHERE name = 'system') AS roleFk; + diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql new file mode 100644 index 000000000..d05902461 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -0,0 +1,10 @@ +INSERT INTO util.notification (id, name,description) + VALUES ( +(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); + +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql new file mode 100644 index 000000000..83e2be1d0 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vnx.sql @@ -0,0 +1,10 @@ +-- INSERT INTO util.notification (id, name,description) +-- VALUES ( +-- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); + +-- INSERT INTO util.notificationSubscription (notificationFk,userFk) +-- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; + + +-- INSERT INTO util.notificationAcl (notificationFk,roleFk) +-- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 37dd3c00c5fdef400940c6c9e2718fb6f87e99de Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 13 Feb 2024 09:11:39 +0100 Subject: [PATCH 036/136] updates --- db/routines/util/events/vn_scheduler.sql | 1 + db/routines/util/procedures/vn_scheduler.sql | 67 +++++++++++++++++++ db/routines/vn/events/zone_getCollisions.sql | 17 +++++ .../vn/triggers/zoneIncluded_afterDelete.sql | 3 + .../vn/triggers/zoneIncluded_beforeInsert.sql | 4 ++ .../vn/triggers/zoneIncluded_beforeUpdate.sql | 3 + .../01-createVnSchedules.sql | 14 ++++ .../01-notification.vn.sql | 14 ++-- 8 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 db/routines/vn/events/zone_getCollisions.sql create mode 100644 db/versions/10881-greenHydrangea/01-createVnSchedules.sql diff --git a/db/routines/util/events/vn_scheduler.sql b/db/routines/util/events/vn_scheduler.sql index 4c5c99b6a..e25741ac6 100644 --- a/db/routines/util/events/vn_scheduler.sql +++ b/db/routines/util/events/vn_scheduler.sql @@ -2,6 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER` ON SCHEDULE EVERY 1 DAY STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY + ENABLE DO BEGIN CALL `VN_SCHEDULER`(); END$$ diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql index d34fe9092..1ab72de39 100644 --- a/db/routines/util/procedures/vn_scheduler.sql +++ b/db/routines/util/procedures/vn_scheduler.sql @@ -1,8 +1,75 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`() BEGIN + DECLARE vDone BOOL; + DECLARE vError VARCHAR(255) DEFAULT NULL; + DECLARE vErrorCode VARCHAR(255) DEFAULT NULL; + DECLARE vSchema VARCHAR(255); + DECLARE vStatus VARCHAR(255); + DECLARE vProcedure VARCHAR(255); + -- DECLARE vLogMail VARCHAR(255); + DECLARE vScheduleFk INT; -- Obtener datos de la tabla vn_schedules + DECLARE vQueue CURSOR FOR + SELECT id, `schema`, `procedure`, `status` + FROM vn_schedules + WHERE status = 'scheduled'; + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vScheduleFk, vSchema, vProcedure, vStatus; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE vn_schedules + SET `started` = util.VN_NOW(), + `finished` = NULL, + `error` = NULL, + `errorCode` = NULL + WHERE id = vScheduleFk; + + SET vError = NULL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + GET DIAGNOSTICS CONDITION 1 + vError = MESSAGE_TEXT, + vErrorCode = RETURNED_SQLSTATE; + + CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); + + IF vError IS NOT NULL THEN + -- IF vLogMail IS NOT NULL THEN + -- CALL vn.mail_insert( + -- vLogMail, + -- NULL, + -- CONCAT('Nightly task failed (', vSchema, '.', vProcedure, ')'), + -- CONCAT( + -- '[', vErrorCode, '] ', vError, CHAR(13, 10), -- Line break + -- 'See ', SCHEMA(), '.nightTask table for more info.' + -- ) + -- ); + -- END IF; + + UPDATE vn_schedules + SET `error` = vError, + finished = util.VN_NOW(), + lastFinished = util.VN_NOW() + `errorCode` = vErrorCode + `status` = 'error' + WHERE id = vScheduleFk; + ELSE + UPDATE vn_schedules + SET `error` = vError, + `errorCode` = vErrorCode + finished = util.VN_NOW(), + lastFinished = util.VN_NOW(), + `status` = 'exec' + WHERE id = vScheduleFk; + END IF; + END LOOP; + CLOSE vQueue; END$$ DELIMITER ; diff --git a/db/routines/vn/events/zone_getCollisions.sql b/db/routines/vn/events/zone_getCollisions.sql new file mode 100644 index 000000000..2437cffc2 --- /dev/null +++ b/db/routines/vn/events/zone_getCollisions.sql @@ -0,0 +1,17 @@ +DELIMITER $$ + +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`zoneCollisions` + ON SCHEDULE EVERY 1 DAY + STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY + ON COMPLETION NOT PRESERVE + ENABLE + DO BEGIN + DECLARE vEXEC BOOLEAN DEFAULT FALSE; + SELECT COUNT(*)>0 INTO vEXEC from util.vn_schedules; + + IF vEXEC THEN + CALL `zone_getCollisions`(); + END IF; + END$$ + +DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 248717f51..a46ba9060 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -11,6 +11,9 @@ BEGIN -- Activo el evento 'zone_getCollisions' -- UPDATE `mysql`.`event` SET status = 1 WHERE name = 'zone_getCollisions'; + INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) + VALUES + (`vn`, `zone_getCollisions`); -- Insert en vn_schedules 'zone_getCollisions' END$$ diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 2e1f70407..810546d91 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -6,6 +6,10 @@ BEGIN -- Activo el evento 'zone_getCollisions' -- Insert en vn_schedulesla key 'zone_getCollisions' + -- ALTER EVENT zoneCollisions ENABLE; + INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) + VALUES + (`vn`, `zone_getCollisions`); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index 05c3acd41..a5e0184b4 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -7,5 +7,8 @@ BEGIN -- Activo el evento 'zone_getCollisions' -- Insert en vn_schedules 'zone_getCollisions' + INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) + VALUES + (`vn`, `zone_getCollisions`); END$$ DELIMITER ; diff --git a/db/versions/10881-greenHydrangea/01-createVnSchedules.sql b/db/versions/10881-greenHydrangea/01-createVnSchedules.sql new file mode 100644 index 000000000..07dedf7d3 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-createVnSchedules.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS `util`.`vn_schedules` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, + `lastFinished` datetime DEFAULT NULL, + `order` int(11) DEFAULT NULL, + `schema` varchar(45) NOT NULL, + `procedure` varchar(100) NOT NULL, + `error` varchar(255) DEFAULT NULL, + `errorCode` varchar(10) DEFAULT NULL, + `status` enum('scheduled','exec','error') NOT NULL DEFAULT 'scheduled', + PRIMARY KEY (`id`), + UNIQUE KEY unique_schedule (`schema`, `procedure`, `status`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index d05902461..83e2be1d0 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -1,10 +1,10 @@ -INSERT INTO util.notification (id, name,description) - VALUES ( -(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); +-- INSERT INTO util.notification (id, name,description) +-- VALUES ( +-- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); -INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; +-- INSERT INTO util.notificationSubscription (notificationFk,userFk) +-- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; -INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; +-- INSERT INTO util.notificationAcl (notificationFk,roleFk) +-- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 47bfb34507df24839642afa49694f699036a3f71 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Feb 2024 10:10:48 +0100 Subject: [PATCH 037/136] fix: refs #6744 remove params --- .../worker/back/methods/worker/setPassword.js | 21 ++++++++----------- modules/worker/front/descriptor/index.js | 8 +++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/worker/back/methods/worker/setPassword.js b/modules/worker/back/methods/worker/setPassword.js index 0f6905e80..cf9cd4cf2 100644 --- a/modules/worker/back/methods/worker/setPassword.js +++ b/modules/worker/back/methods/worker/setPassword.js @@ -3,27 +3,23 @@ module.exports = Self => { Self.remoteMethodCtx('setPassword', { description: 'Set a new password', accepts: [{ - arg: 'workerFk', + arg: 'id', type: 'number', required: true, description: 'The worker id', + http: {source: 'path'} }, { arg: 'newPass', type: 'String', required: true, description: 'The new worker password' - }, { - arg: 'emailVerified', - type: 'Boolean', - required: true, - }, - ], + }], http: { path: `/:id/setPassword`, verb: 'PATCH' } }); - Self.setPassword = async(ctx, workerFk, newPass, emailVerified, options) => { + Self.setPassword = async(ctx, workerId, newPass, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {}; @@ -37,12 +33,13 @@ module.exports = Self => { } try { - const ishimself = userId === workerFk; - const isSubordinate = await models.Worker.isSubordinate(ctx, workerFk, myOptions); + const ishimself = userId === workerId; + const isSubordinate = await Self.isSubordinate(ctx, workerId, myOptions); + const {emailVerified} = await models.VnUser.findById(workerId, {fields: ['emailVerified']}, myOptions); if (ishimself || (isSubordinate && !emailVerified)) { - await models.VnUser.setPassword(workerFk, newPass, myOptions); - await models.VnUser.updateAll({id: workerFk}, {emailVerified: true}, myOptions); + await models.VnUser.setPassword(workerId, newPass, myOptions); + await models.VnUser.updateAll({id: workerId}, {emailVerified: true}, myOptions); } else throw new UserError('You don\'t have enough privileges.'); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 4ef98fe3b..3cbeb2c55 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -5,6 +5,9 @@ class Controller extends Descriptor { constructor($element, $, $rootScope) { super($element, $); this.$rootScope = $rootScope; + + this.$http.get(`UserConfigs/getUserConfig`) + .then(res => this.userFk = res.data.userFk); } get worker() { @@ -15,8 +18,6 @@ class Controller extends Descriptor { this.entity = value; if (value) this.getIsExcluded(); - this.$http.get(`UserConfigs/getUserConfig`) - .then(res => this.userFk = res.data.userFk); if (this.entity && !this.entity.user.emailVerified) this.getPassRequirements(); @@ -89,8 +90,7 @@ class Controller extends Descriptor { if (this.newPassword != this.repeatPassword) throw new UserError(`Passwords don't match`); this.$http.patch( - `Workers/${this.entity.id}/setPassword`, - {workerFk: this.entity.id, newPass: this.newPassword, emailVerified: !!this.entity.user.emailVerified} + `Workers/${this.entity.id}/setPassword`, {newPass: this.newPassword} ) .then(() => { this.vnApp.showSuccess(this.$translate.instant('Password changed!')); }); From 0eaeb2e80598c4bfc77e01cd1abdbe904d2e545f Mon Sep 17 00:00:00 2001 From: pako Date: Thu, 15 Feb 2024 13:13:22 +0100 Subject: [PATCH 038/136] nueva rama --- db/dump/fixtures.after.sql | 404 ++++++++++++++++++ db/routines/floranet/events/clean.sql | 22 + .../floranet/procedures/catalogue_get.sql | 52 +++ .../floranet/procedures/order_confirm.sql | 25 ++ db/routines/floranet/procedures/order_put.sql | 42 ++ .../10887-floranet/00-schemaAndUser.sql | 14 + db/versions/10887-floranet/01-tables.sql | 61 +++ 7 files changed, 620 insertions(+) create mode 100644 db/routines/floranet/events/clean.sql create mode 100644 db/routines/floranet/procedures/catalogue_get.sql create mode 100644 db/routines/floranet/procedures/order_confirm.sql create mode 100644 db/routines/floranet/procedures/order_put.sql create mode 100644 db/versions/10887-floranet/00-schemaAndUser.sql create mode 100644 db/versions/10887-floranet/01-tables.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 4c5f89d97..a7d059ed2 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -292,7 +292,411 @@ INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount */ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); +-- XXX: floranet +INSERT INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + +-- Generación de items +SELECT id + INTO @FNR + FROM vn.itemType + WHERE code = 'FNR'; + +SELECT id + INTO @FNP + FROM vn.itemType + WHERE code = 'FNP'; + +DELETE + FROM vn.item + WHERE typeFk IN (@FNR,@FNP); + +SELECT MAX(id) + 1 + INTO @item + FROM vn.item; + +INSERT INTO vn.item + ( + id, + name, + longName, + `size`, + originFk, + intrastatFk, + typeFk, + inkFk, + image, + description + ) + VALUES + ( + @item := @item + 1, + @r := 'Ramo Terranova', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1CwtEK5_GReAzconaJsPTCXxV7zajbTos/view?usp=drive_link', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', + 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', + 'paniculata eucaliptus.') + ), + ( + @item := @item + 1, + @r := 'Ramo Tasmania', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1_149uYZ-sehw3vWH68Quttk8QJe5T_bG/view?usp=drive_link', + CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', + 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', + 'flores será un acierto seguro para hacer un regalo muy especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Pasion', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1-dH1UilV-nOH9XNK23uooZoezlwMT-Jq/view?usp=drive_link', + CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', + 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', + 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', + 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', + 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') + ), + ( + @item := @item + 1, + @r := 'Ramo Florencia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1PWKo5N8kg8H3xQtELdeQTQIc1HMZCc1P/view?usp=drive_link', + CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', + 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', + 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', + 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Atardecer', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink WHERE name = 'Yellow'), + 'https://drive.google.com/file/d/1eM4gtftQuXN5xUjAHIRUYNPZNmuHVRA_/view?usp=drive_link', + CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', + 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', + 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', + 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', + 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') + ), + ( + @item := @item + 1, + @r := 'Ramo Arcoíris', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1Hxk5yqo7891gfK1VKIYfWxO5a_0K2Qej/view?usp=drive_link', + CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', + 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', + 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', + 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', + 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', + 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') + ), + ( + @item := @item + 1, + @r := 'Ramo Provenza', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1TA9SBwjqnrEqG1bzwDL37sxtX9CNyLJk/view?usp=drive_link', + CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', + 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', + 'con una selección de maravillosos verdes variados, hacen que esta combinación ', + 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Alegria', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1sOf2isj84P9OxR3E3x6n2PjPnWVamLCE/view?usp=drive_link', + CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', + 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', + ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', + 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', + 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') + ), + ( + @item := @item + 1, + @r := 'Planta Orquídeas ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/14BIkDDonFaIiTyJer1CWju1YzZNzt3XQ/view?usp=drive_link', + CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', + 'con las mejores características combinadas con diferentes elementos de ', + 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', + 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', + 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', + 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') + ), + ( + @item := @item + 1, + @r := 'Planta Kentia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1rKe2RicfWha-VIm1LbbXckbA41glA99K/view?usp=drive_link', + CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', + 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', + 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', + 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', + 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', + 'de ser un producto nacional producido en Canarias de una calidad extrema.') + ), + ( + @item := @item + 1, + @r := 'Planta Calathea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/11CKm5rqVFVPOELciuyXUrkc2oeTHJzBE/view?usp=drive_link', + CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', + ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', + 'llamativo y original colorido, tambien es un regalo perfecto para ', + 'cualquier compromiso que tengamos .') + ), + ( + @item := @item + 1, + @r := 'Planta Anthurium ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink WHERE name = 'Red'), + 'https://drive.google.com/file/d/1j4il_N9VJGaP4f6CPZM0u6GjxwIeYcBt/view?usp=drive_link', + CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', + 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', + 'su llamativo color alegrará cualquier celebración') + ), + ( + @item := @item + 1, + @r := 'Ramo Mindanao', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1lsGDuC6xmv3SyGukfLTVYsQvbGf1Bzxy/view?usp=drive_link', + CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', + 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', + 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') + ), + ( + @item := @item + 1, + @r := 'Ramo Guinea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1MtF0oghv-ahogaAaVpJNzDiIfyeCCmAi/view?usp=drive_link', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', + ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') + ), + ( + @item := @item + 1, + @r := 'Ramo Eterno', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1AOMqlZAKqImnnWSmeq1DW1Krj78mACCG/view?usp=drive_link', + CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', + 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', + 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', + 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', + 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', + 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') + ), + ( + @item := @item + 1, + @r := 'Ramo Cielo', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/168DikIOwVT5OO4BHARBoWwLB1wjpAS7s/view?usp=drive_link', + CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', + 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', + ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', + 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', + ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', + 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', + 'clara de todo el conjunto. ') + ); + + -- Ramo Terranova: 1er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Rosa roja', + @r, + 60, + 1, + 'RED', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 12 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + -- Ramo Terranova: 2º elemento + +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Hoja de helecho', + @r, + 60, + 1, + 'BAS', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 4 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- Ramo Terranova: 3er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Paniculata', + @r, + 60, + 1, + 'SLV', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 5 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- XXX SET foreign_key_checks = 1; diff --git a/db/routines/floranet/events/clean.sql b/db/routines/floranet/events/clean.sql new file mode 100644 index 000000000..4477112fd --- /dev/null +++ b/db/routines/floranet/events/clean.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE + DEFINER=`root`@`localhost` + EVENT `floranet`.`clean` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-01-01 23:00:00.000' + ON COMPLETION PRESERVE + ENABLE +DO +BEGIN + DELETE + FROM `order` + WHERE created < CURDATE() + AND isPaid = FALSE; + + DELETE c.* + FROM catalogue c + LEFT JOIN `order` o ON o.catalogueFk = c.id + WHERE c.created < CURDATE() + AND o.id IS NULL; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql new file mode 100644 index 000000000..914b5d27f --- /dev/null +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -0,0 +1,52 @@ +DROP PROCEDURE IF EXISTS floranet.catalogue_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) +READS SQL DATA +BEGIN +/** + * Returns list, price and all the stuff regarding the floranet items + * + * @param vLanded Delivery date + * @param vPostalCode Delivery address postal code + */ + DECLARE vLastCatalogueFk INT; + + START TRANSACTION; + + SELECT * FROM catalogue FOR UPDATE; + + SELECT MAX(id) INTO vLastCatalogueFk + FROM catalogue; + + INSERT INTO catalogue( + name, + price, + itemFk, + dated, + postalCode, + `type`, + image, + description + ) + SELECT i.name, + i.`size`, + i.id, + vLanded, + vPostalCode, + it.name, + i.image, + i.description + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP'); + + SELECT * + FROM catalogue + WHERE id > IFNULL(vLastCatalogueFk,0); + + COMMIT; + +END$$ +DELIMITER ; diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql new file mode 100644 index 000000000..fed123663 --- /dev/null +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -0,0 +1,25 @@ +DROP PROCEDURE IF EXISTS floranet.order_confirm; + +DELIMITER $$ +$$ + +CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) +READS SQL DATA + +BEGIN +/** Update order.isPaid field + * + * @param vCatalogueFk floranet.catalogue.id + * + * @returns floranet.order.isPaid + */ + UPDATE `order` + SET isPaid = TRUE, + payed = NOW() + WHERE catalogueFk = vCatalogueFk; + + SELECT isPaid + FROM `order` + WHERE catalogueFk = vCatalogueFk; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql new file mode 100644 index 000000000..c26cef19a --- /dev/null +++ b/db/routines/floranet/procedures/order_put.sql @@ -0,0 +1,42 @@ +DROP PROCEDURE IF EXISTS floranet.order_put; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) +READS SQL DATA +BEGIN +/** + * Get and process an order + * + * @param vOrder Data of the order + * + * Customer data: , , + * + * Item data: , + * + * Delivery data: ,
, + * + */ + INSERT IGNORE INTO `order`( + catalogueFk, + customerName, + email, + customerPhone, + message, + deliveryName, + address, + deliveryPhone + ) + VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone')) + ); + + SELECT LAST_INSERT_ID() orderFk; +END$$ +DELIMITER ; diff --git a/db/versions/10887-floranet/00-schemaAndUser.sql b/db/versions/10887-floranet/00-schemaAndUser.sql new file mode 100644 index 000000000..34da92550 --- /dev/null +++ b/db/versions/10887-floranet/00-schemaAndUser.sql @@ -0,0 +1,14 @@ + +CREATE SCHEMA IF NOT EXISTS `floranet`; + +CREATE ROLE IF NOT EXISTS 'floranet' ; + +GRANT Create temporary tables ON floranet.* TO 'floranet'; + +GRANT Execute ON floranet.* TO 'floranet'; + +GRANT Lock tables ON floranet.* TO 'floranet'; + +CREATE USER IF NOT EXISTS 'floranet'@'%'; + +GRANT floranet TO floranet@'%'; \ No newline at end of file diff --git a/db/versions/10887-floranet/01-tables.sql b/db/versions/10887-floranet/01-tables.sql new file mode 100644 index 000000000..b63c81c21 --- /dev/null +++ b/db/versions/10887-floranet/01-tables.sql @@ -0,0 +1,61 @@ +CREATE OR REPLACE TABLE floranet.`builder` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `elementFk` int(11) NOT NULL, + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + PRIMARY KEY (`id`), + KEY `builder_FK` (`itemFk`), + KEY `builder_FK_1` (`elementFk`), + CONSTRAINT `builder_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; + +CREATE OR REPLACE TABLE floranet.`element` ( + `itemFk` int(11) NOT NULL, + `typeFk` smallint(5) unsigned DEFAULT NULL, + `size` int(11) DEFAULT NULL, + `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `name` varchar(30) DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT 1, + PRIMARY KEY (`itemFk`), + KEY `element_FK` (`itemFk`), + KEY `element_FK_1` (`typeFk`), + KEY `element_FK_2` (`inkFk`), + KEY `element_FK_3` (`originFk`), + CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción'; + +ALTER TABLE floranet.builder ADD CONSTRAINT `builder_FK_1` FOREIGN KEY (`elementFk`) REFERENCES `element` (`itemFk`) ON UPDATE CASCADE; + +CREATE OR REPLACE TABLE floranet.catalogue +(id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50), + price DECIMAL(10,2) NOT NULL, + itemFk INT NOT NULL, + dated DATE, + postalCode VARCHAR(12), + `type` VARCHAR(50), + image VARCHAR(255), + description TEXT, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + payed DATETIME, + FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE); + + +CREATE OR REPLACE TABLE floranet.`order` +(id INT AUTO_INCREMENT PRIMARY KEY, + catalogueFk INT UNIQUE, + customerName VARCHAR(100), + email VARCHAR(100), + customerPhone VARCHAR(15), + message VARCHAR(255), + deliveryName VARCHAR(100), + address VARCHAR(200), + deliveryPhone VARCHAR(100), + isPaid BOOL NOT NULL DEFAULT FALSE, + payed DATETIME, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (catalogueFk) REFERENCES catalogue(id) ON DELETE RESTRICT ON UPDATE CASCADE); \ No newline at end of file From 04df5a0ccdf4b1864adf7c1003decbaa54cd1ca4 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 13:52:58 +0100 Subject: [PATCH 039/136] refs #6021 --- db/routines/vn/views/zoneEstimatedDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql index 90c7381d8..c50d3602b 100644 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`zoneClosure` `zc` ON( `zc`.`zoneFk` = `t`.`zoneFk` - AND `zc`.`dated` = `util`.`VN_CURDATE`() + AND `zc`.`dated` = `util`.`VN_CURDATE`() ) ) LEFT JOIN `cache`.`departure_limit` `dl` ON( From ec9604323dbb0eef440071b57038ecf88186f050 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 13:54:34 +0100 Subject: [PATCH 040/136] commit --- db/routines/vn/views/zoneEstimatedDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql index c50d3602b..90c7381d8 100644 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`zoneClosure` `zc` ON( `zc`.`zoneFk` = `t`.`zoneFk` - AND `zc`.`dated` = `util`.`VN_CURDATE`() + AND `zc`.`dated` = `util`.`VN_CURDATE`() ) ) LEFT JOIN `cache`.`departure_limit` `dl` ON( From 74136442954aba00717704dedf56b801aba02817 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 14:37:09 +0100 Subject: [PATCH 041/136] contact_request and deliveryDate_get --- .../floranet/procedures/contact_Request.sql | 20 +++++++++++ .../floranet/procedures/deliveryDate_get.sql | 35 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 db/routines/floranet/procedures/contact_Request.sql create mode 100644 db/routines/floranet/procedures/deliveryDate_get.sql diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_Request.sql new file mode 100644 index 000000000..c55348d6f --- /dev/null +++ b/db/routines/floranet/procedures/contact_Request.sql @@ -0,0 +1,20 @@ +DROP PROCEDURE IF EXISTS floranet.contact_Request; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` +PROCEDURE floranet.contact_Request( + vName VARCHAR(100), + vPhone VARCHAR(15), + vEmail VARCHAR(100), + vMessage TEXT) +READS SQL DATA +BEGIN +/** + * Set actions for contact request + * + * @param vPostalCode Delivery address postal code + */ + +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql new file mode 100644 index 000000000..06a8ae1ad --- /dev/null +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -0,0 +1,35 @@ +DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.deliveryDate_get(vPostalCode VARCHAR(15)) +READS SQL DATA +BEGIN +/** + * Returns available dates for this postalCode + * + * @param vPostalCode Delivery address postal code + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.deliveryDate + (dated DATE PRIMARY KEY) + ENGINE = MEMORY; + + IF vPostalCode != "00000" THEN + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 1 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 2 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 4 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 7 DAY; + END IF; + + SELECT * FROM tmp.deliveryDate; + + DROP TEMPORARY TABLE tmp.deliveryDate; +END$$ +DELIMITER ; \ No newline at end of file From 24b564f1ce559382d3386b041471110e1d0b6544 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 14:42:06 +0100 Subject: [PATCH 042/136] test --- db/routines/floranet/procedures/contact_Request.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_Request.sql index c55348d6f..7673c2203 100644 --- a/db/routines/floranet/procedures/contact_Request.sql +++ b/db/routines/floranet/procedures/contact_Request.sql @@ -11,7 +11,7 @@ PROCEDURE floranet.contact_Request( READS SQL DATA BEGIN /** - * Set actions for contact request + * Set actions for contact request. * * @param vPostalCode Delivery address postal code */ From 9f2768c131b6cb04d8fea1ce4fc3d4376c20a6c7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 16 Feb 2024 15:51:54 +0100 Subject: [PATCH 043/136] fix: refs #6776 tests --- .../worker/back/methods/worker/setPassword.js | 4 +- .../methods/worker/specs/setPassword.spec.js | 92 +++++++++++++------ modules/worker/front/descriptor/index.spec.js | 1 + 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/modules/worker/back/methods/worker/setPassword.js b/modules/worker/back/methods/worker/setPassword.js index cf9cd4cf2..5571ea1d2 100644 --- a/modules/worker/back/methods/worker/setPassword.js +++ b/modules/worker/back/methods/worker/setPassword.js @@ -33,11 +33,11 @@ module.exports = Self => { } try { - const ishimself = userId === workerId; + const isHimself = userId === workerId; const isSubordinate = await Self.isSubordinate(ctx, workerId, myOptions); const {emailVerified} = await models.VnUser.findById(workerId, {fields: ['emailVerified']}, myOptions); - if (ishimself || (isSubordinate && !emailVerified)) { + if (isHimself || (isSubordinate && !emailVerified)) { await models.VnUser.setPassword(workerId, newPass, myOptions); await models.VnUser.updateAll({id: workerId}, {emailVerified: true}, myOptions); } else diff --git a/modules/worker/back/methods/worker/specs/setPassword.spec.js b/modules/worker/back/methods/worker/specs/setPassword.spec.js index fbb403b24..0f0700561 100644 --- a/modules/worker/back/methods/worker/specs/setPassword.spec.js +++ b/modules/worker/back/methods/worker/specs/setPassword.spec.js @@ -1,31 +1,30 @@ -const UserError = require('vn-loopback/util/user-error'); - -const models = require('vn-loopback/server/server').models; +const {models} = require('vn-loopback/server/server'); describe('worker setPassword()', () => { let ctx; + const newPass = 'H3rn4d3z#'; + const employeeId = 1; + const managerId = 20; + const administrativeId = 5; + beforeAll(() => { ctx = { req: { - accessToken: {}, + accessToken: {userId: managerId}, headers: {origin: 'http://localhost'} }, - args: {workerFk: 9} }; }); - beforeEach(() => { - ctx.req.accessToken.userId = 20; - ctx.args.newPass = 'H3rn4d3z#'; - }); - - it('should change the password', async() => { + it('should change the password if it is a subordinate and the email is not verified', async() => { const tx = await models.Worker.beginTransaction({}); try { const options = {transaction: tx}; - await models.Worker.setPassword(ctx, options); + await models.Worker.setPassword(ctx, employeeId, newPass, options); + const isNewPass = await passHasBeenChanged(employeeId, newPass, options); + expect(isNewPass).toBeTrue(); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -33,29 +32,64 @@ describe('worker setPassword()', () => { } }); - it('should throw an error: Password does not meet requirements', async() => { - const tx = await models.Collection.beginTransaction({}); - ctx.args.newPass = 'Hi'; + it('should not change the password if it is a subordinate and the email is verified', async() => { + const tx = await models.Worker.beginTransaction({}); + try { const options = {transaction: tx}; - await models.Worker.setPassword(ctx, options); + await models.VnUser.updateAll({id: employeeId}, {emailVerified: true}, options); + await models.Worker.setPassword(ctx, employeeId, newPass, options); + + await tx.rollback(); + } catch (e) { + expect(e.message).toEqual(`You don't have enough privileges.`); + await tx.rollback(); + } + }); + + it('should change the password if it is himself', async() => { + const tx = await models.Worker.beginTransaction({}); + + try { + const options = {transaction: tx}; + await models.VnUser.updateAll({id: managerId}, {emailVerified: true}, options); + await models.Worker.setPassword(ctx, managerId, newPass, options); + const isNewPass = await passHasBeenChanged(managerId, newPass, options); + + expect(isNewPass).toBeTrue(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); + + it('should not change the password if it is not a subordinate', async() => { + const tx = await models.Worker.beginTransaction({}); + try { + const options = {transaction: tx}; + await models.Worker.setPassword(ctx, administrativeId, newPass, options); + await tx.rollback(); + } catch (e) { + expect(e.message).toEqual(`You don't have enough privileges.`); + await tx.rollback(); + } + }); + + it('should throw an error: Password does not meet requirements', async() => { + const tx = await models.Worker.beginTransaction({}); + const newPass = 'Hi'; + try { + const options = {transaction: tx}; + await models.Worker.setPassword(ctx, employeeId, newPass, options); await tx.rollback(); } catch (e) { expect(e.sqlMessage).toEqual('Password does not meet requirements'); await tx.rollback(); } }); - - it('should throw an error: You don\'t have enough privileges.', async() => { - ctx.req.accessToken.userId = 5; - const tx = await models.Collection.beginTransaction({}); - try { - const options = {transaction: tx}; - await models.Worker.setPassword(ctx, options); - await tx.rollback(); - } catch (e) { - expect(e).toEqual(new UserError(`You don't have enough privileges.`)); - await tx.rollback(); - } - }); }); + +const passHasBeenChanged = async(userId, pass, options) => { + const user = await models.VnUser.findById(userId, null, options); + return user.hasPassword(pass); +}; diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index d158a9e8e..4f7fa6a05 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -16,6 +16,7 @@ describe('vnWorkerDescriptor', () => { const id = 1; const response = 'foo'; + $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); controller.id = id; $httpBackend.flush(); From 9e3b4e84515e832a454b161f7a12f8e63138012c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 19 Feb 2024 13:30:03 +0100 Subject: [PATCH 044/136] refs #6842 sql mod sage --- .../vn/triggers/invoiceOut_beforeInsert.sql | 12 +++---- db/versions/10893-limeFern/00-sage.sql | 35 +++++++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 db/versions/10893-limeFern/00-sage.sql diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index 0081c8803..f3a292edd 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -17,16 +17,16 @@ BEGIN DECLARE vRefLen INT; DECLARE vRefPrefix VARCHAR(255); DECLARE vLastRef VARCHAR(255); - DECLARE vCompanyCode INT; + DECLARE vSage200Company INT; DECLARE vYearLen INT DEFAULT 2; DECLARE vPrefixLen INT; - SELECT companyCode INTO vCompanyCode + SELECT sage200Company INTO vSage200Company FROM company WHERE id = NEW.companyFk; - IF vCompanyCode IS NULL THEN - CALL util.throw('companyCodeNotDefined'); + IF vSage200Company IS NULL THEN + CALL util.throw('vSage200CompanyNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef @@ -36,7 +36,7 @@ BEGIN AND i.companyFk = NEW.companyFk; IF vLastRef IS NOT NULL THEN - SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen; + SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vSage200Company) + vYearLen; SET vRefLen = LENGTH(vLastRef) - vPrefixLen; SET vRefPrefix = LEFT(vLastRef, vPrefixLen); SET vRef = RIGHT(vLastRef, vRefLen); @@ -44,7 +44,7 @@ BEGIN SELECT refLen INTO vRefLen FROM invoiceOutConfig; SET vRefPrefix = CONCAT( NEW.serial, - vCompanyCode, + vSage200Company, RIGHT(YEAR(NEW.issued), vYearLen) ); END IF; diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql new file mode 100644 index 000000000..049bb2993 --- /dev/null +++ b/db/versions/10893-limeFern/00-sage.sql @@ -0,0 +1,35 @@ +-- Auto-generated SQL script #202402151810 +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=69; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=567; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=791; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=792; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=965; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=1381; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=1463; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2142; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2292; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2393; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=3869; +ALTER TABLE vn.company MODIFY COLUMN sage200Company int(2) DEFAULT NULL NULL COMMENT 'Campo para la serie InvoiceOut'; From 791687f2717ed3aace2f251146a4563b32f05706 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 20 Feb 2024 14:27:22 +0100 Subject: [PATCH 045/136] refs #5878 feat: comments --- db/routines/util/events/vn_scheduler.sql | 4 ++++ db/routines/util/procedures/vn_scheduler.sql | 22 +++++++++++-------- .../vn/triggers/zoneIncluded_afterDelete.sql | 7 +++--- .../vn/triggers/zoneIncluded_beforeInsert.sql | 8 +++---- .../vn/triggers/zoneIncluded_beforeUpdate.sql | 6 ++--- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/db/routines/util/events/vn_scheduler.sql b/db/routines/util/events/vn_scheduler.sql index e25741ac6..2d8457499 100644 --- a/db/routines/util/events/vn_scheduler.sql +++ b/db/routines/util/events/vn_scheduler.sql @@ -4,6 +4,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER` STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY ENABLE DO BEGIN + /** + * Ejecuta el PROCEDURE que comprueba si hay procedimientos planificados para ejecutar + * + */ CALL `VN_SCHEDULER`(); END$$ diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql index 1ab72de39..2b65b20b0 100644 --- a/db/routines/util/procedures/vn_scheduler.sql +++ b/db/routines/util/procedures/vn_scheduler.sql @@ -1,20 +1,27 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`() BEGIN +/** + * Ejecuta los procedimientos que se han programado a demanda. + * +*/ DECLARE vDone BOOL; DECLARE vError VARCHAR(255) DEFAULT NULL; DECLARE vErrorCode VARCHAR(255) DEFAULT NULL; DECLARE vSchema VARCHAR(255); DECLARE vStatus VARCHAR(255); DECLARE vProcedure VARCHAR(255); - -- DECLARE vLogMail VARCHAR(255); + DECLARE vScheduleFk INT; -- Obtener datos de la tabla vn_schedules DECLARE vQueue CURSOR FOR SELECT id, `schema`, `procedure`, `status` FROM vn_schedules WHERE status = 'scheduled'; - + DECLARE EXIT HANDLER FOR SQLEXCEPTION + GET DIAGNOSTICS CONDITION 1 + vError = MESSAGE_TEXT, + vErrorCode = RETURNED_SQLSTATE; OPEN vQueue; l: LOOP SET vDone = FALSE; @@ -32,10 +39,7 @@ BEGIN WHERE id = vScheduleFk; SET vError = NULL; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - GET DIAGNOSTICS CONDITION 1 - vError = MESSAGE_TEXT, - vErrorCode = RETURNED_SQLSTATE; + CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); @@ -55,14 +59,14 @@ BEGIN UPDATE vn_schedules SET `error` = vError, finished = util.VN_NOW(), - lastFinished = util.VN_NOW() - `errorCode` = vErrorCode + lastFinished = util.VN_NOW(), + `errorCode` = vErrorCode, `status` = 'error' WHERE id = vScheduleFk; ELSE UPDATE vn_schedules SET `error` = vError, - `errorCode` = vErrorCode + `errorCode` = vErrorCode, finished = util.VN_NOW(), lastFinished = util.VN_NOW(), `status` = 'exec' diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index a46ba9060..1a076cd8f 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -9,12 +9,11 @@ BEGIN `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); - -- Activo el evento 'zone_getCollisions' - -- UPDATE `mysql`.`event` SET status = 1 WHERE name = 'zone_getCollisions'; + -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' + INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) VALUES - (`vn`, `zone_getCollisions`); + ('vn', 'zone_getCollisions'); - -- Insert en vn_schedules 'zone_getCollisions' END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 810546d91..13d45aa12 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -1,15 +1,15 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert` BEFORE INSERT ON `zoneIncluded` + FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - -- Activo el evento 'zone_getCollisions' - -- Insert en vn_schedulesla key 'zone_getCollisions' - -- ALTER EVENT zoneCollisions ENABLE; + -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' + INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) VALUES - (`vn`, `zone_getCollisions`); + ('vn', 'zone_getCollisions'); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index a5e0184b4..f54c55654 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -5,10 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp BEGIN SET NEW.editorFk = account.myUser_getId(); - -- Activo el evento 'zone_getCollisions' -- Insert en vn_schedules 'zone_getCollisions' + -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - (`vn`, `zone_getCollisions`); + VALUES + ('vn', 'zone_getCollisions'); END$$ DELIMITER ; From be0e835a37a1985b6d49124f3629344aea9a3ce3 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 20 Feb 2024 14:40:38 +0100 Subject: [PATCH 046/136] refs #5878 feat: remove vn_event_getCollisions --- db/.pullinfo.json | 16 ++++++++++++++++ db/dump/fixtures.before.sql | 2 +- db/routines/util/procedures/vn_scheduler.sql | 12 ------------ db/routines/vn/events/zone_getCollisions.sql | 17 ----------------- 4 files changed, 17 insertions(+), 30 deletions(-) create mode 100644 db/.pullinfo.json delete mode 100644 db/routines/vn/events/zone_getCollisions.sql diff --git a/db/.pullinfo.json b/db/.pullinfo.json new file mode 100644 index 000000000..f4afbc5fb --- /dev/null +++ b/db/.pullinfo.json @@ -0,0 +1,16 @@ +{ + "lastPull": "2024-02-15T08:58:24.000Z", + "shaSums": { + "srt": { + "view": { + "routePalletized": "765f8933a6a5a86dfe8f22825cc77351bc8620cdf1be9d3f25abb130460f3a61", + "ticketPalletized": "c327f3243e717cc607f01d3747967ba68158f90ef1038986b0aa6ae6d5ce7309" + } + }, + "vn": { + "view": { + "expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" + } + } + } +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index df2bb6498..53939bfe8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2818,7 +2818,7 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), (6, 'book-entry-deleted', 'accounting entries deleted'), - (7, 'zone-included','An email to notify zoneCollisions'); + (7, 'zone-included','An email to notify zoneCollisions'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql index 2b65b20b0..cd7c629f8 100644 --- a/db/routines/util/procedures/vn_scheduler.sql +++ b/db/routines/util/procedures/vn_scheduler.sql @@ -44,18 +44,6 @@ BEGIN CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); IF vError IS NOT NULL THEN - -- IF vLogMail IS NOT NULL THEN - -- CALL vn.mail_insert( - -- vLogMail, - -- NULL, - -- CONCAT('Nightly task failed (', vSchema, '.', vProcedure, ')'), - -- CONCAT( - -- '[', vErrorCode, '] ', vError, CHAR(13, 10), -- Line break - -- 'See ', SCHEMA(), '.nightTask table for more info.' - -- ) - -- ); - -- END IF; - UPDATE vn_schedules SET `error` = vError, finished = util.VN_NOW(), diff --git a/db/routines/vn/events/zone_getCollisions.sql b/db/routines/vn/events/zone_getCollisions.sql deleted file mode 100644 index 2437cffc2..000000000 --- a/db/routines/vn/events/zone_getCollisions.sql +++ /dev/null @@ -1,17 +0,0 @@ -DELIMITER $$ - -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`zoneCollisions` - ON SCHEDULE EVERY 1 DAY - STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY - ON COMPLETION NOT PRESERVE - ENABLE - DO BEGIN - DECLARE vEXEC BOOLEAN DEFAULT FALSE; - SELECT COUNT(*)>0 INTO vEXEC from util.vn_schedules; - - IF vEXEC THEN - CALL `zone_getCollisions`(); - END IF; - END$$ - -DELIMITER ; From 88a88640e5ec8f268f05214f606822e9d2c09e8e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 21 Feb 2024 14:22:06 +0100 Subject: [PATCH 047/136] refs #5858 feat: sql comments --- db/dump/fixtures.after.sql | 5 ++++- ...nSchedules.sql => 00-createVnSchedules.sql} | 0 .../10881-greenHydrangea/00-firstScript.sql | 18 ------------------ .../01-notification.vn.sql | 10 ---------- .../01-notification.vnx.sql | 10 ---------- 5 files changed, 4 insertions(+), 39 deletions(-) rename db/versions/10881-greenHydrangea/{01-createVnSchedules.sql => 00-createVnSchedules.sql} (100%) delete mode 100644 db/versions/10881-greenHydrangea/00-firstScript.sql delete mode 100644 db/versions/10881-greenHydrangea/01-notification.vn.sql delete mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 4c5f89d97..1f14278a9 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -70,7 +70,7 @@ UPDATE vn.supplier UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101'); -INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`) +INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`) VALUES ('Agencia', '1', '1', '1'), ('Otra agencia ', '1', '0', '0'); @@ -327,4 +327,7 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) FROM mysql.roles_mapping WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; + +TRUNCATE util.vn_schedules; + FLUSH PRIVILEGES; diff --git a/db/versions/10881-greenHydrangea/01-createVnSchedules.sql b/db/versions/10881-greenHydrangea/00-createVnSchedules.sql similarity index 100% rename from db/versions/10881-greenHydrangea/01-createVnSchedules.sql rename to db/versions/10881-greenHydrangea/00-createVnSchedules.sql diff --git a/db/versions/10881-greenHydrangea/00-firstScript.sql b/db/versions/10881-greenHydrangea/00-firstScript.sql deleted file mode 100644 index 1ca77c1a0..000000000 --- a/db/versions/10881-greenHydrangea/00-firstScript.sql +++ /dev/null @@ -1,18 +0,0 @@ - --- UPDATE salix.ACL --- SET principalId='employee' WHERE model ="Notification"; - --- INSERT INTO util.notification (name,description) --- VALUES ('zone-included','An email to notify zoneCollisions'); - --- INSERT INTO util.notificationSubscription (notificationFk,userFk) --- SELECT --- (SELECT id FROM util.notification WHERE name= "zone-included") AS notificationFk, --- (SELECT account.myUser_getId() ) AS userFk; - - --- INSERT INTO util.notificationAcl (notificationFk, roleFk) --- SELECT --- (SELECT id FROM util.notification WHERE name = 'zone-included') AS notificationFk, --- (SELECT id FROM account.role WHERE name = 'system') AS roleFk; - diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql deleted file mode 100644 index 83e2be1d0..000000000 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ /dev/null @@ -1,10 +0,0 @@ --- INSERT INTO util.notification (id, name,description) --- VALUES ( --- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); - --- INSERT INTO util.notificationSubscription (notificationFk,userFk) --- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; - - --- INSERT INTO util.notificationAcl (notificationFk,roleFk) --- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql deleted file mode 100644 index 83e2be1d0..000000000 --- a/db/versions/10881-greenHydrangea/01-notification.vnx.sql +++ /dev/null @@ -1,10 +0,0 @@ --- INSERT INTO util.notification (id, name,description) --- VALUES ( --- (SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); - --- INSERT INTO util.notificationSubscription (notificationFk,userFk) --- SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; - - --- INSERT INTO util.notificationAcl (notificationFk,roleFk) --- SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From dddd482317132011497ffc0f5008266d322829d0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 21 Feb 2024 14:22:19 +0100 Subject: [PATCH 048/136] refs #5858 test: check vn_schedules --- .../zone/specs/toggleIsIncluded.spec.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 86c04f844..ccd1abb80 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -describe('zone toggleIsIncluded()', () => { +fdescribe('zone toggleIsIncluded()', () => { beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -20,10 +20,12 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; + await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -37,10 +39,12 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; + await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, false, options); expect(result.isIncluded).toBeFalse(); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -54,13 +58,14 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - + await validateSchedules('before', options); await models.Zone.toggleIsIncluded(1, 20, false, options); - let result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); + const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); expect(result).toEqual({count: 1}); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -68,3 +73,22 @@ describe('zone toggleIsIncluded()', () => { } }); }); + +async function validateSchedules(step, options = null) { + const querySchedules = `SELECT count(*) count FROM util.vn_schedules;`; + + switch (step) { + case 'before': { + const [{count}] = await models.Application.rawSql(querySchedules, null, options); + + expect(count).toEqual(0); + } + break; + case 'after': { + const [{count}] = await models.Application.rawSql(querySchedules, null, options); + + expect(count).toEqual(1); + } + break; + } +} From 57a1f2a1f66721cdb29739f651a088ad8d65c4f0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 21 Feb 2024 14:29:20 +0100 Subject: [PATCH 049/136] refs #5858 test: check vn_schedules --- modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index ccd1abb80..a7a2a7808 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -fdescribe('zone toggleIsIncluded()', () => { +describe('zone toggleIsIncluded()', () => { beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, From cc90b13668ca6a9261768b79dbc402f35ebb9c0a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 21 Feb 2024 15:05:38 +0100 Subject: [PATCH 050/136] refs #5858 feat: remove unnecesary update --- db/dump/fixtures.before.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 53939bfe8..c5e016d1b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3066,9 +3066,6 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (13, 1101, 1, NULL), (14, 1101, 4, 27); -UPDATE salix.ACL - SET principalId='employee' WHERE model ="Notification"; - INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentInstruccions,specialAgreements,companyFk,addressToFk,addressFromFk,supplierFk,packagesList,merchandiseDetail,state) VALUES (1,'123456A','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',442,1,2,1,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (2,'123456N','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',69,3,4,2,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), From 838effadc03f99e3e994584a1c320c0f35226146 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 21 Feb 2024 15:18:10 +0100 Subject: [PATCH 051/136] refs #5858 feat: move change to vnx --- .../10881-greenHydrangea/01-notification.vnx.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql new file mode 100644 index 000000000..d05902461 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vnx.sql @@ -0,0 +1,10 @@ +INSERT INTO util.notification (id, name,description) + VALUES ( +(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); + +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 744dd61561af56ad76771a59612ee8ba86bc6bbc Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 22 Feb 2024 15:42:54 +0100 Subject: [PATCH 052/136] fix: refs #6744 create setUnverifiedPassword --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- modules/account/back/models/account.js | 11 +++++++++++ .../worker/back/methods/worker/setPassword.js | 15 ++++----------- .../methods/worker/specs/setPassword.spec.js | 18 +----------------- modules/worker/front/descriptor/index.html | 2 +- modules/worker/front/descriptor/index.js | 7 ++----- 7 files changed, 23 insertions(+), 36 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 2187371cd..39596467c 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -209,5 +209,6 @@ "You cannot update these fields": "You cannot update these fields", "CountryFK cannot be empty": "Country cannot be empty", "You are not allowed to modify the alias": "You are not allowed to modify the alias", - "You already have the mailAlias": "You already have the mailAlias" + "You already have the mailAlias": "You already have the mailAlias", + "The email has been already verified": "The email has been already verified" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index aea0c311c..d36348472 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -344,5 +344,6 @@ "CountryFK cannot be empty": "El país no puede estar vacío", "Cmr file does not exist": "El archivo del cmr no existe", "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", - "No tickets to invoice": "No hay tickets para facturar" + "No tickets to invoice": "No hay tickets para facturar", + "The email has been already verified": "El correo ya ha sido verificado" } diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index 5021a5d94..7c97711d0 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -1,4 +1,7 @@ +const ForbiddenError = require('vn-loopback/util/forbiddenError'); +const {models} = require('vn-loopback/server/server'); + module.exports = Self => { require('../methods/account/sync')(Self); require('../methods/account/sync-by-id')(Self); @@ -7,4 +10,12 @@ module.exports = Self => { require('../methods/account/logout')(Self); require('../methods/account/change-password')(Self); require('../methods/account/set-password')(Self); + + Self.setUnverifiedPassword = async(id, pass, options) => { + const user = await models.VnUser.findById(id, null, options); + if (user.emailVerified) throw new ForbiddenError('The email has been already verified'); + + await models.VnUser.setPassword(id, pass, options); + await user.updateAttribute('emailVerified', true, options); + }; }; diff --git a/modules/worker/back/methods/worker/setPassword.js b/modules/worker/back/methods/worker/setPassword.js index 5571ea1d2..e6bdfb364 100644 --- a/modules/worker/back/methods/worker/setPassword.js +++ b/modules/worker/back/methods/worker/setPassword.js @@ -19,8 +19,7 @@ module.exports = Self => { verb: 'PATCH' } }); - Self.setPassword = async(ctx, workerId, newPass, options) => { - const userId = ctx.req.accessToken.userId; + Self.setPassword = async(ctx, id, newPass, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -31,17 +30,11 @@ module.exports = Self => { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - try { - const isHimself = userId === workerId; - const isSubordinate = await Self.isSubordinate(ctx, workerId, myOptions); - const {emailVerified} = await models.VnUser.findById(workerId, {fields: ['emailVerified']}, myOptions); + const isSubordinate = await Self.isSubordinate(ctx, id, myOptions); + if (!isSubordinate) throw new UserError('You don\'t have enough privileges.'); - if (isHimself || (isSubordinate && !emailVerified)) { - await models.VnUser.setPassword(workerId, newPass, myOptions); - await models.VnUser.updateAll({id: workerId}, {emailVerified: true}, myOptions); - } else - throw new UserError('You don\'t have enough privileges.'); + await models.Account.setUnverifiedPassword(id, newPass, myOptions); if (tx) await tx.commit(); } catch (e) { diff --git a/modules/worker/back/methods/worker/specs/setPassword.spec.js b/modules/worker/back/methods/worker/specs/setPassword.spec.js index 0f0700561..d2daec103 100644 --- a/modules/worker/back/methods/worker/specs/setPassword.spec.js +++ b/modules/worker/back/methods/worker/specs/setPassword.spec.js @@ -42,23 +42,7 @@ describe('worker setPassword()', () => { await tx.rollback(); } catch (e) { - expect(e.message).toEqual(`You don't have enough privileges.`); - await tx.rollback(); - } - }); - - it('should change the password if it is himself', async() => { - const tx = await models.Worker.beginTransaction({}); - - try { - const options = {transaction: tx}; - await models.VnUser.updateAll({id: managerId}, {emailVerified: true}, options); - await models.Worker.setPassword(ctx, managerId, newPass, options); - const isNewPass = await passHasBeenChanged(managerId, newPass, options); - - expect(isNewPass).toBeTrue(); - await tx.rollback(); - } catch (e) { + expect(e.message).toEqual(`The email has been already verified`); await tx.rollback(); } }); diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 67776ce47..73332efac 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -11,7 +11,7 @@ ? 'Click to allow the user to be disabled' : 'Click to exclude the user from getting disabled'}} - + Change password diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 3cbeb2c55..d7962369c 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -5,9 +5,6 @@ class Controller extends Descriptor { constructor($element, $, $rootScope) { super($element, $); this.$rootScope = $rootScope; - - this.$http.get(`UserConfigs/getUserConfig`) - .then(res => this.userFk = res.data.userFk); } get worker() { @@ -93,11 +90,11 @@ class Controller extends Descriptor { `Workers/${this.entity.id}/setPassword`, {newPass: this.newPassword} ) .then(() => { this.vnApp.showSuccess(this.$translate.instant('Password changed!')); - }); + }).then(() => this.loadData()); } } -Controller.$inject = ['$element', '$scope', '$rootScope']; +Controller.$inject = ['$element', '$scope', '$rootScope', 'vnConfig']; ngModule.vnComponent('vnWorkerDescriptor', { template: require('./index.html'), From 3bf25e5759ce1169c83d03a1c9c46c71aebcdd38 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 23 Feb 2024 09:31:01 +0100 Subject: [PATCH 053/136] fix: refs #6744 locale --- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- modules/account/back/models/account.js | 2 +- modules/worker/back/methods/worker/specs/setPassword.spec.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 39596467c..efcf0ef31 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -210,5 +210,5 @@ "CountryFK cannot be empty": "Country cannot be empty", "You are not allowed to modify the alias": "You are not allowed to modify the alias", "You already have the mailAlias": "You already have the mailAlias", - "The email has been already verified": "The email has been already verified" + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d36348472..64832553b 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -345,5 +345,5 @@ "Cmr file does not exist": "El archivo del cmr no existe", "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", "No tickets to invoice": "No hay tickets para facturar", - "The email has been already verified": "El correo ya ha sido verificado" + "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario" } diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index 7c97711d0..dd04182f6 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -13,7 +13,7 @@ module.exports = Self => { Self.setUnverifiedPassword = async(id, pass, options) => { const user = await models.VnUser.findById(id, null, options); - if (user.emailVerified) throw new ForbiddenError('The email has been already verified'); + if (user.emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves'); await models.VnUser.setPassword(id, pass, options); await user.updateAttribute('emailVerified', true, options); diff --git a/modules/worker/back/methods/worker/specs/setPassword.spec.js b/modules/worker/back/methods/worker/specs/setPassword.spec.js index d2daec103..03cbee03b 100644 --- a/modules/worker/back/methods/worker/specs/setPassword.spec.js +++ b/modules/worker/back/methods/worker/specs/setPassword.spec.js @@ -42,7 +42,7 @@ describe('worker setPassword()', () => { await tx.rollback(); } catch (e) { - expect(e.message).toEqual(`The email has been already verified`); + expect(e.message).toEqual(`This password can only be changed by the user themselves`); await tx.rollback(); } }); From a078de95210a4e99aba1cffea2050761312d0445 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 26 Feb 2024 06:51:19 +0100 Subject: [PATCH 054/136] refs #6930 feat: return multimediaToken when login --- back/models/vn-user.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 3a416d7e3..e1bce7c06 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -167,7 +167,11 @@ module.exports = function(Self) { console.warn(err); } - return {token: token.id, ttl: token.ttl}; + const multimediaToken = await token.user().accessTokens.create({ + scopes: ['read:multimedia'] + }); + + return {token: token.id, ttl: token.ttl, multimediaToken}; }; Self.userUses = function(user) { From ae0ce8e49a7dec0e6cc7cdef044852f107a5fd3b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 26 Feb 2024 06:53:30 +0100 Subject: [PATCH 055/136] refs #6930 feat: use tokenMultimedia intead tokenUser --- front/core/services/auth.js | 2 +- front/core/services/token.js | 15 ++++++++++----- front/salix/components/layout/index.js | 3 +-- front/salix/components/log/index.html | 4 ++-- front/salix/module.js | 2 +- modules/client/front/balance/index/index.html | 2 +- .../invoiceOut/front/descriptor-menu/index.html | 2 +- modules/invoiceOut/front/index/index.js | 2 +- modules/route/front/index/index.js | 2 +- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 844a5145d..0253eb3c3 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -83,7 +83,7 @@ export default class Auth { } onLoginOk(json, now, remember) { - this.vnToken.set(json.data.token, now, json.data.ttl, remember); + this.vnToken.set(json.data.token, json.data.multimediaToken.id, now, json.data.ttl, remember); return this.loadAcls().then(() => { let continueHash = this.$state.params.continue; diff --git a/front/core/services/token.js b/front/core/services/token.js index c8cb4f6bb..125de6b9a 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -24,21 +24,22 @@ export default class Token { } catch (e) {} } - set(token, created, ttl, remember) { + set(token, tokenMultimedia, created, ttl, remember) { this.unset(); Object.assign(this, { token, + tokenMultimedia, created, ttl, remember }); - this.vnInterceptor.setToken(token); + this.vnInterceptor.setToken(token, tokenMultimedia); try { if (remember) - this.setStorage(localStorage, token, created, ttl); + this.setStorage(localStorage, token, tokenMultimedia, created, ttl); else - this.setStorage(sessionStorage, token, created, ttl); + this.setStorage(sessionStorage, token, tokenMultimedia, created, ttl); } catch (err) { console.error(err); } @@ -46,6 +47,7 @@ export default class Token { unset() { this.token = null; + this.tokenMultimedia = null; this.created = null; this.ttl = null; this.remember = null; @@ -57,13 +59,15 @@ export default class Token { getStorage(storage) { this.token = storage.getItem('vnToken'); + this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); this.ttl = storage.getItem('vnTokenTtl'); } - setStorage(storage, token, created, ttl) { + setStorage(storage, token, tokenMultimedia, created, ttl) { + storage.setItem('vnTokenMultimedia', tokenMultimedia); storage.setItem('vnToken', token); storage.setItem('vnTokenCreated', created.toJSON()); storage.setItem('vnTokenTtl', ttl); @@ -71,6 +75,7 @@ export default class Token { removeStorage(storage) { storage.removeItem('vnToken'); + storage.removeItem('vnTokenMultimedia'); storage.removeItem('vnTokenCreated'); storage.removeItem('vnTokenTtl'); } diff --git a/front/salix/components/layout/index.js b/front/salix/components/layout/index.js index 89912d4e3..e935c6d99 100644 --- a/front/salix/components/layout/index.js +++ b/front/salix/components/layout/index.js @@ -23,8 +23,7 @@ export class Layout extends Component { if (!this.$.$root.user) return; const userId = this.$.$root.user.id; - const token = this.vnToken.token; - return `/api/Images/user/160x160/${userId}/download?access_token=${token}`; + return `/api/Images/user/160x160/${userId}/download?access_token=${this.vnToken.tokenMultimedia}`; } refresh() { diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index c75030100..a3aaf0011 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -31,7 +31,7 @@ ng-click="$ctrl.showDescriptor($event, userLog)"> + ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
@@ -181,7 +181,7 @@ val="{{::nickname}}"> + ng-src="/api/Images/user/160x160/{{::id}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
diff --git a/front/salix/module.js b/front/salix/module.js index 0ce855308..53b718427 100644 --- a/front/salix/module.js +++ b/front/salix/module.js @@ -13,7 +13,7 @@ export function run($window, $rootScope, vnAuth, vnApp, vnToken, $state) { if (!collection || !size || !id) return; const basePath = `/api/Images/${collection}/${size}/${id}`; - return `${basePath}/download?access_token=${vnToken.token}`; + return `${basePath}/download?access_token=${vnToken.tokenMultimedia}`; }; $window.validations = {}; diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index faf772c2d..34524d2f3 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -114,7 +114,7 @@ + href="api/InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}"> diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 435db3612..e26650e10 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -37,7 +37,7 @@ diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index 2cde3c940..403c51d58 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -25,7 +25,7 @@ export default class Controller extends Section { openPdf() { if (this.checked.length <= 1) { const [invoiceOutId] = this.checked; - const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.token}`; + const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.tokenMultimedia}`; window.open(url, '_blank'); } else { const invoiceOutIds = this.checked; diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 7c19a26cd..0c5dfe7f3 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -40,7 +40,7 @@ export default class Controller extends Section { const stringRoutesIds = routesIds.join(','); if (this.checked.length <= 1) { - const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`; + const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.tokenMultimedia}`; window.open(url, '_blank'); } else { const serializedParams = this.$httpParamSerializer({ From 04086e37eeffe433d0ed26a85d7c78ab8eb80330 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 26 Feb 2024 06:57:17 +0100 Subject: [PATCH 056/136] refs #6930 feat: add accessScopes: ['read:multimedia'] forEarch method --- back/methods/dms/downloadFile.js | 3 ++- back/methods/docuware/download.js | 3 ++- back/methods/image/download.js | 3 ++- modules/claim/back/methods/claim/downloadFile.js | 3 ++- modules/invoiceOut/back/methods/invoiceOut/download.js | 3 ++- modules/invoiceOut/back/methods/invoiceOut/downloadZip.js | 3 ++- modules/item/back/methods/item-image-queue/download.js | 1 + modules/route/back/methods/route/downloadCmrsZip.js | 3 ++- modules/route/back/methods/route/downloadZip.js | 3 ++- modules/route/back/methods/route/driverRoutePdf.js | 4 +++- modules/worker/back/methods/worker-dms/downloadFile.js | 3 ++- 11 files changed, 22 insertions(+), 10 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index 1b9150053..d64b15b70 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: `/:id/downloadFile`, verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index a0d72ce01..a1776cde5 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -42,7 +42,8 @@ module.exports = Self => { http: { path: `/:id/download`, verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 2b1a4b546..201e16164 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -47,7 +47,8 @@ module.exports = Self => { http: { path: `/:collection/:size/:id/download`, verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 750356b0b..61784f39e 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -32,7 +32,8 @@ module.exports = Self => { http: { path: `/:id/downloadFile`, verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 4c76f7c07..cb71121d5 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -31,7 +31,8 @@ module.exports = Self => { http: { path: '/:id/download', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index fe005f1ab..4f2a8aab3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -31,7 +31,8 @@ module.exports = Self => { http: { path: '/downloadZip', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index eb952daa4..e1bc248ae 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,6 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, + accessScopes: ['read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 58445f6f1..43f6e9648 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/downloadCmrsZip', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index 597f1d1f6..d7fc30aa3 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/downloadZip', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index f0cd75f0e..e7b4dee17 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -34,7 +34,9 @@ module.exports = Self => { http: { path: '/:id/driver-route-pdf', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] + }); Self.driverRoutePdf = (ctx, id) => Self.printReport(ctx, id, 'driver-route'); diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index cc8653e0e..08fbcf924 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: `/:id/downloadFile`, verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From f2ad06918692e3a1474f10660d8ea31e720d224d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 27 Feb 2024 14:26:54 +0100 Subject: [PATCH 057/136] refs 6930 feat: get multimediaToken from new method --- back/methods/vn-user/share-token.js | 27 ++ .../methods/vn-user/specs/share-token.spec.js | 27 ++ back/models/vn-user.js | 7 +- back/models/vn-user.json | 247 +++++++++--------- front/core/services/auth.js | 21 +- 5 files changed, 197 insertions(+), 132 deletions(-) create mode 100644 back/methods/vn-user/share-token.js create mode 100644 back/methods/vn-user/specs/share-token.spec.js diff --git a/back/methods/vn-user/share-token.js b/back/methods/vn-user/share-token.js new file mode 100644 index 000000000..8efa22db4 --- /dev/null +++ b/back/methods/vn-user/share-token.js @@ -0,0 +1,27 @@ + +module.exports = Self => { + Self.remoteMethodCtx('shareToken', { + description: 'Returns token to view files or images and share it', + accessType: 'WRITE', + accepts: [], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/shareToken`, + verb: 'GET' + } + }); + + Self.shareToken = async function(ctx) { + const {accessToken: token} = ctx.req; + + const user = await Self.findById(token.userId); + const multimediaToken = await user.accessTokens.create({ + scopes: ['read:multimedia'] + }); + + return {multimediaToken}; + }; +}; diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js new file mode 100644 index 000000000..4d113f10a --- /dev/null +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -0,0 +1,27 @@ +const {models} = require('vn-loopback/server/server'); +fdescribe('Share Token', () => { + let ctx = null; + beforeAll(async() => { + const unAuthCtx = { + req: { + headers: {}, + connection: { + remoteAddress: '127.0.0.1' + }, + getLocale: () => 'en' + }, + args: {} + }; + let login = await models.VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare'); + let accessToken = await models.AccessToken.findById(login.token); + ctx = {req: {accessToken: accessToken}}; + }); + + it('should renew token', async() => { + const multimediaToken = await models.VnUser.shareToken(ctx); + + expect(Object.keys(multimediaToken).length).toEqual(1); + expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId); + expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia'); + }); +}); diff --git a/back/models/vn-user.js b/back/models/vn-user.js index e1bce7c06..b59f13ffa 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -13,6 +13,7 @@ module.exports = function(Self) { require('../methods/vn-user/privileges')(Self); require('../methods/vn-user/validate-auth')(Self); require('../methods/vn-user/renew-token')(Self); + require('../methods/vn-user/share-token')(Self); require('../methods/vn-user/update-user')(Self); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); @@ -167,11 +168,7 @@ module.exports = function(Self) { console.warn(err); } - const multimediaToken = await token.user().accessTokens.create({ - scopes: ['read:multimedia'] - }); - - return {token: token.id, ttl: token.ttl, multimediaToken}; + return {token: token.id, ttl: token.ttl}; }; Self.userUses = function(user) { diff --git a/back/models/vn-user.json b/back/models/vn-user.json index 639603643..5f6ac3f47 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -1,129 +1,140 @@ { - "name": "VnUser", - "base": "User", - "validateUpsert": true, - "options": { - "mysql": { - "table": "account.user" - } - }, + "name": "VnUser", + "base": "User", + "validateUpsert": true, + "options": { + "mysql": { + "table": "account.user" + } + }, "mixins": { "Loggable": true }, "resetPasswordTokenTTL": "604800", - "properties": { - "id": { - "type": "number", - "id": true - }, + "properties": { + "id": { + "type": "number", + "id": true + }, "name": { - "type": "string", - "required": true - }, - "username": { - "type": "string" - }, - "roleFk": { - "type": "number", - "mysql": { - "columnName": "role" - } - }, - "nickname": { - "type": "string" - }, - "lang": { - "type": "string" - }, - "active": { - "type": "boolean" - }, - "email": { - "type": "string" - }, - "emailVerified": { - "type": "boolean" - }, - "created": { - "type": "date" - }, - "updated": { - "type": "date" - }, - "image": { - "type": "string" - }, - "hasGrant": { - "type": "boolean" - }, + "type": "string", + "required": true + }, + "username": { + "type": "string" + }, + "roleFk": { + "type": "number", + "mysql": { + "columnName": "role" + } + }, + "nickname": { + "type": "string" + }, + "lang": { + "type": "string" + }, + "active": { + "type": "boolean" + }, + "email": { + "type": "string" + }, + "emailVerified": { + "type": "boolean" + }, + "created": { + "type": "date" + }, + "updated": { + "type": "date" + }, + "image": { + "type": "string" + }, + "hasGrant": { + "type": "boolean" + }, "passExpired": { "type": "date" }, - "twoFactor": { - "type": "string" - } - }, - "relations": { - "role": { - "type": "belongsTo", - "model": "VnRole", - "foreignKey": "roleFk" - }, - "roles": { - "type": "hasMany", - "model": "RoleRole", - "foreignKey": "role", - "primaryKey": "roleFk" - }, - "emailUser": { - "type": "hasOne", - "model": "EmailUser", - "foreignKey": "userFk" - }, - "worker": { - "type": "hasOne", - "model": "Worker", - "foreignKey": "id" - }, - "userConfig": { - "type": "hasOne", - "model": "UserConfig", - "foreignKey": "userFk" - } - }, - "acls": [ - { - "property": "signIn", - "accessType": "EXECUTE", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - }, { - "property": "recoverPassword", - "accessType": "EXECUTE", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - }, { - "property": "validateAuth", - "accessType": "EXECUTE", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - }, { - "property": "privileges", - "accessType": "*", - "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" - }, { - "property": "renewToken", - "accessType": "WRITE", - "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" - } - ], + "twoFactor": { + "type": "string" + } + }, + "relations": { + "role": { + "type": "belongsTo", + "model": "VnRole", + "foreignKey": "roleFk" + }, + "roles": { + "type": "hasMany", + "model": "RoleRole", + "foreignKey": "role", + "primaryKey": "roleFk" + }, + "emailUser": { + "type": "hasOne", + "model": "EmailUser", + "foreignKey": "userFk" + }, + "worker": { + "type": "hasOne", + "model": "Worker", + "foreignKey": "id" + }, + "userConfig": { + "type": "hasOne", + "model": "UserConfig", + "foreignKey": "userFk" + } + }, + "acls": [ + { + "property": "signIn", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }, + { + "property": "recoverPassword", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }, + { + "property": "validateAuth", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }, + { + "property": "privileges", + "accessType": "*", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + }, + { + "property": "renewToken", + "accessType": "WRITE", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + }, + { + "property": "shareToken", + "accessType": "WRITE", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ], "scopes": { "preview": { "fields": [ @@ -140,7 +151,7 @@ "hasGrant", "realm", "email", - "emailVerified" + "emailVerified" ] } } diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 0253eb3c3..a734e076e 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -83,15 +83,18 @@ export default class Auth { } onLoginOk(json, now, remember) { - this.vnToken.set(json.data.token, json.data.multimediaToken.id, now, json.data.ttl, remember); - - return this.loadAcls().then(() => { - let continueHash = this.$state.params.continue; - if (continueHash) - this.$window.location = continueHash; - else - this.$state.go('home'); - }); + return this.$http.get('VnUsers/ShareToken', { + headers: {Authorization: json.data.token} + }).then(({data}) => { + this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); + this.loadAcls().then(() => { + let continueHash = this.$state.params.continue; + if (continueHash) + this.$window.location = continueHash; + else + this.$state.go('home'); + }); + }).catch(() => {}); } logout() { From fdc5ea244f93b9cfb62d98b964fc45e33d11ef04 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Feb 2024 10:43:07 +0100 Subject: [PATCH 058/136] refs 6930 feat: implements logout in front side --- front/core/services/auth.js | 23 +++++++++++++---------- front/core/services/interceptor.js | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index a734e076e..e51a2ff12 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -98,17 +98,20 @@ export default class Auth { } logout() { - let promise = this.$http.post('VnUsers/logout', null, { - headers: {Authorization: this.vnToken.token} - }).catch(() => {}); + this.$http.post('VnUsers/logoutMultimedia', null, {headers: {'Authorization': this.vnToken.tokenMultimedia}, + }).then(({data}) => { + if (data) { + this.$http.post('VnUsers/logout', null, { + headers: {Authorization: this.vnToken.token} + }).catch(() => {}); - this.vnToken.unset(); - this.loggedIn = false; - this.vnModules.reset(); - this.aclService.reset(); - this.$state.go('login'); - - return promise; + this.vnToken.unset(); + this.loggedIn = false; + this.vnModules.reset(); + this.aclService.reset(); + this.$state.go('login'); + } + }); } loadAcls() { diff --git a/front/core/services/interceptor.js b/front/core/services/interceptor.js index 0c3253c69..90d813ed4 100644 --- a/front/core/services/interceptor.js +++ b/front/core/services/interceptor.js @@ -19,7 +19,7 @@ function interceptor($q, vnApp, $translate) { if (config.url.charAt(0) !== '/' && apiPath) config.url = `${apiPath}${config.url}`; - if (token) + if (token && !config.headers.Authorization) config.headers.Authorization = token; if ($translate.use()) config.headers['Accept-Language'] = $translate.use(); From 23b3fb81f9989480f9146fe8b937726950db3697 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Feb 2024 10:43:19 +0100 Subject: [PATCH 059/136] refs 6930 feat: implements logout remoteMethod --- back/models/vn-user.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index b59f13ffa..473e619db 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -31,6 +31,32 @@ module.exports = function(Self) { message: `A client with that Web User name already exists` }); + Self.remoteMethod('logoutMultimedia', { + description: 'Logout current MultimediaToken', + accepts: [{ + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }], + returns: { + type: 'Boolean', + root: true + }, + http: { + verb: 'POST', + path: '/logoutMultimedia' + }, + accessScopes: ['read:multimedia'] + }); + Self.logoutMultimedia = async function(ctx) { + let {accessToken} = ctx.req; + try { + Self.logout(accessToken.id); + return true; + } catch (error) { + return error; + } + }; Self.remoteMethod('getCurrentUserData', { description: 'Gets the current user data', accepts: [ From a06a59341250eb18ce7aae81ee1459e10cab8998 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Feb 2024 10:55:36 +0100 Subject: [PATCH 060/136] refs 6930 feat: ACL --- db/versions/10919-brownMoss/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10919-brownMoss/00-firstScript.sql diff --git a/db/versions/10919-brownMoss/00-firstScript.sql b/db/versions/10919-brownMoss/00-firstScript.sql new file mode 100644 index 000000000..da10027e0 --- /dev/null +++ b/db/versions/10919-brownMoss/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +INSERT IGNORE INTO `salix`.`ACL`(`model`,`property`,`accessType`,`permission`, `principalType`, `principalId`) +VALUES(VnUser,logoutMultimedia,*,ALLOW,ROLE,employee) From 1d1d950e4b543d02604bca6db5afbaeb2cce0f34 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Feb 2024 11:57:00 +0100 Subject: [PATCH 061/136] refs 6930 feat: ACL --- db/versions/10919-brownMoss/00-firstScript.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/versions/10919-brownMoss/00-firstScript.sql b/db/versions/10919-brownMoss/00-firstScript.sql index da10027e0..a6abdbe79 100644 --- a/db/versions/10919-brownMoss/00-firstScript.sql +++ b/db/versions/10919-brownMoss/00-firstScript.sql @@ -1,4 +1,5 @@ -- Place your SQL code here INSERT IGNORE INTO `salix`.`ACL`(`model`,`property`,`accessType`,`permission`, `principalType`, `principalId`) -VALUES(VnUser,logoutMultimedia,*,ALLOW,ROLE,employee) +VALUES +('VnUser','logoutMultimedia','*','ALLOW','ROLE','employee') From 5ee9c2b01ef4d5f2d2b43ae23b7bd66524dbe286 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 29 Feb 2024 07:40:20 +0100 Subject: [PATCH 062/136] refs #6930 fix: revert fdescribe --- back/methods/vn-user/specs/share-token.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js index 4d113f10a..aaa83817c 100644 --- a/back/methods/vn-user/specs/share-token.spec.js +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -1,5 +1,5 @@ const {models} = require('vn-loopback/server/server'); -fdescribe('Share Token', () => { +describe('Share Token', () => { let ctx = null; beforeAll(async() => { const unAuthCtx = { From 8e976d2e4fddc06e3eb1fa343775c3bfebd3a75a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 29 Feb 2024 09:28:27 +0100 Subject: [PATCH 063/136] refs #5858 feat: remove Schedule system --- db/dump/fixtures.after.sql | 2 - db/routines/util/events/vn_scheduler.sql | 14 ---- db/routines/util/procedures/vn_scheduler.sql | 67 ------------------- .../vn/triggers/zoneIncluded_afterDelete.sql | 5 -- .../vn/triggers/zoneIncluded_beforeInsert.sql | 6 -- .../vn/triggers/zoneIncluded_beforeUpdate.sql | 6 -- .../00-createVnSchedules.sql | 14 ---- .../zone/specs/toggleIsIncluded.spec.js | 26 +------ 8 files changed, 1 insertion(+), 139 deletions(-) delete mode 100644 db/routines/util/events/vn_scheduler.sql delete mode 100644 db/routines/util/procedures/vn_scheduler.sql delete mode 100644 db/versions/10881-greenHydrangea/00-createVnSchedules.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 2b83cca57..c539b2aab 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -325,6 +325,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; -TRUNCATE util.vn_schedules; - FLUSH PRIVILEGES; diff --git a/db/routines/util/events/vn_scheduler.sql b/db/routines/util/events/vn_scheduler.sql deleted file mode 100644 index 2d8457499..000000000 --- a/db/routines/util/events/vn_scheduler.sql +++ /dev/null @@ -1,14 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER` - ON SCHEDULE EVERY 1 DAY - STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY - ENABLE - DO BEGIN - /** - * Ejecuta el PROCEDURE que comprueba si hay procedimientos planificados para ejecutar - * - */ - CALL `VN_SCHEDULER`(); - END$$ - -DELIMITER ; diff --git a/db/routines/util/procedures/vn_scheduler.sql b/db/routines/util/procedures/vn_scheduler.sql deleted file mode 100644 index cd7c629f8..000000000 --- a/db/routines/util/procedures/vn_scheduler.sql +++ /dev/null @@ -1,67 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`() -BEGIN -/** - * Ejecuta los procedimientos que se han programado a demanda. - * -*/ - DECLARE vDone BOOL; - DECLARE vError VARCHAR(255) DEFAULT NULL; - DECLARE vErrorCode VARCHAR(255) DEFAULT NULL; - DECLARE vSchema VARCHAR(255); - DECLARE vStatus VARCHAR(255); - DECLARE vProcedure VARCHAR(255); - - DECLARE vScheduleFk INT; - -- Obtener datos de la tabla vn_schedules - DECLARE vQueue CURSOR FOR - SELECT id, `schema`, `procedure`, `status` - FROM vn_schedules - WHERE status = 'scheduled'; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - GET DIAGNOSTICS CONDITION 1 - vError = MESSAGE_TEXT, - vErrorCode = RETURNED_SQLSTATE; - OPEN vQueue; - l: LOOP - SET vDone = FALSE; - FETCH vQueue INTO vScheduleFk, vSchema, vProcedure, vStatus; - - IF vDone THEN - LEAVE l; - END IF; - - UPDATE vn_schedules - SET `started` = util.VN_NOW(), - `finished` = NULL, - `error` = NULL, - `errorCode` = NULL - WHERE id = vScheduleFk; - - SET vError = NULL; - - - CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); - - IF vError IS NOT NULL THEN - UPDATE vn_schedules - SET `error` = vError, - finished = util.VN_NOW(), - lastFinished = util.VN_NOW(), - `errorCode` = vErrorCode, - `status` = 'error' - WHERE id = vScheduleFk; - ELSE - UPDATE vn_schedules - SET `error` = vError, - `errorCode` = vErrorCode, - finished = util.VN_NOW(), - lastFinished = util.VN_NOW(), - `status` = 'exec' - WHERE id = vScheduleFk; - END IF; - END LOOP; - CLOSE vQueue; -END$$ - -DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 1a076cd8f..3ff8be421 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -9,11 +9,6 @@ BEGIN `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 13d45aa12..18895c9a5 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -5,11 +5,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn BEGIN SET NEW.editorFk = account.myUser_getId(); - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index f54c55654..445f37699 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -4,11 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - - -- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions' - - INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`) - VALUES - ('vn', 'zone_getCollisions'); END$$ DELIMITER ; diff --git a/db/versions/10881-greenHydrangea/00-createVnSchedules.sql b/db/versions/10881-greenHydrangea/00-createVnSchedules.sql deleted file mode 100644 index 07dedf7d3..000000000 --- a/db/versions/10881-greenHydrangea/00-createVnSchedules.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE IF NOT EXISTS `util`.`vn_schedules` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `started` datetime DEFAULT NULL, - `finished` datetime DEFAULT NULL, - `lastFinished` datetime DEFAULT NULL, - `order` int(11) DEFAULT NULL, - `schema` varchar(45) NOT NULL, - `procedure` varchar(100) NOT NULL, - `error` varchar(255) DEFAULT NULL, - `errorCode` varchar(10) DEFAULT NULL, - `status` enum('scheduled','exec','error') NOT NULL DEFAULT 'scheduled', - PRIMARY KEY (`id`), - UNIQUE KEY unique_schedule (`schema`, `procedure`, `status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index a7a2a7808..2da176330 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -20,12 +20,10 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -39,12 +37,10 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, false, options); expect(result.isIncluded).toBeFalse(); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -58,14 +54,13 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - await validateSchedules('before', options); + await models.Zone.toggleIsIncluded(1, 20, false, options); const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); expect(result).toEqual({count: 1}); - await validateSchedules('after', options); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -73,22 +68,3 @@ describe('zone toggleIsIncluded()', () => { } }); }); - -async function validateSchedules(step, options = null) { - const querySchedules = `SELECT count(*) count FROM util.vn_schedules;`; - - switch (step) { - case 'before': { - const [{count}] = await models.Application.rawSql(querySchedules, null, options); - - expect(count).toEqual(0); - } - break; - case 'after': { - const [{count}] = await models.Application.rawSql(querySchedules, null, options); - - expect(count).toEqual(1); - } - break; - } -} From 2f275d8f32bc9451c8a225e8cc5e3fb853a98f58 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 29 Feb 2024 13:06:26 +0100 Subject: [PATCH 064/136] itemType add --- db/dump/fixtures.after.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index a7d059ed2..13e423d68 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -294,8 +294,15 @@ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); -- XXX: floranet -INSERT INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); +INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNR', 'Floranet Ramos', 1, 1); + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNP', 'Floranet Plantas', 1, 1); -- Generación de items SELECT id From c79bdeb3f4bfc3379222552c605b7d2f5ccdc302 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 29 Feb 2024 13:41:27 +0100 Subject: [PATCH 065/136] fix: refs #6744 drop to set emailVerified --- modules/account/back/models/account.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index dd04182f6..ceb26053c 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -12,10 +12,9 @@ module.exports = Self => { require('../methods/account/set-password')(Self); Self.setUnverifiedPassword = async(id, pass, options) => { - const user = await models.VnUser.findById(id, null, options); - if (user.emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves'); + const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); + if (emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves'); await models.VnUser.setPassword(id, pass, options); - await user.updateAttribute('emailVerified', true, options); }; }; From 95fa776e41d10d5c20e929cd00819300c8fbf519 Mon Sep 17 00:00:00 2001 From: JAVIER SEGARRA MARTINEZ Date: Thu, 29 Feb 2024 12:49:50 +0000 Subject: [PATCH 066/136] refs 5858 feat: sql files --- .../10881-greenHydrangea/01-notification.vn.sql | 12 ++++++++++++ .../10881-greenHydrangea/01-notification.vnx.sql | 10 ---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 db/versions/10881-greenHydrangea/01-notification.vn.sql delete mode 100644 db/versions/10881-greenHydrangea/01-notification.vnx.sql diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql new file mode 100644 index 000000000..414a14688 --- /dev/null +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -0,0 +1,12 @@ +SET @MaxId = SELECT MAX(id)+1 from util.notification n) +INSERT INTO IGNORE util.notification (id, name,description) + VALUES ( +(@MaxId, 'zone-included','An email to notify zoneCollisions'); + +INSERT INTO IGNORE util.notificationSubscription (notificationFk,userFk) + VALUES( + @MaxId, 100); + + +INSERT INTO IGNORE util.notificationAcl (notificationFk,roleFk) + SELECT @MaxId, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/versions/10881-greenHydrangea/01-notification.vnx.sql b/db/versions/10881-greenHydrangea/01-notification.vnx.sql deleted file mode 100644 index d05902461..000000000 --- a/db/versions/10881-greenHydrangea/01-notification.vnx.sql +++ /dev/null @@ -1,10 +0,0 @@ -INSERT INTO util.notification (id, name,description) - VALUES ( -(SELECT MAX(id)+1 from util.notification n) , 'zone-included','An email to notify zoneCollisions'); - -INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; - - -INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From b9e774cea04f2d0d8e311b29e54119697d13320f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 1 Mar 2024 14:26:36 +0100 Subject: [PATCH 067/136] feat: restricciones AWB para travel y entry refs #6960 --- db/dump/fixtures.before.sql | 4 +-- .../vn/functions/travel_hasUniqueAwb.sql | 28 +++++++++++++++++++ .../vn/triggers/entry_beforeInsert.sql | 4 ++- .../vn/triggers/entry_beforeUpdate.sql | 6 ++++ .../vn/triggers/travel_afterUpdate.sql | 6 +++- .../vn/triggers/travel_beforeInsert.sql | 4 +++ 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 db/routines/vn/functions/travel_hasUniqueAwb.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 094b956af..4d8c0bfc2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1489,8 +1489,8 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), - (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), diff --git a/db/routines/vn/functions/travel_hasUniqueAwb.sql b/db/routines/vn/functions/travel_hasUniqueAwb.sql new file mode 100644 index 000000000..e918f1a26 --- /dev/null +++ b/db/routines/vn/functions/travel_hasUniqueAwb.sql @@ -0,0 +1,28 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`travel_hasUniqueAwb`( + vSelf INT +) + RETURNS BOOL + READS SQL DATA +BEGIN +/** + * Comprueba que el travel pasado tiene un AWB lógico, + * no se pueden tener varios AWB asociados al mismo DUA + * + * @param vSelf Id del travel + */ + DECLARE vHasUniqueAwb BOOL DEFAULT TRUE; + + SELECT NOT COUNT(t2.awbFk) INTO vHasUniqueAwb + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN duaEntry de ON de.entryFk = e.id + JOIN duaEntry de2 ON de2.duaFk = de.duaFk + JOIN entry e2 ON e2.id = de2.entryFk + JOIN travel t2 ON t2.id = e2.travelFk + WHERE t.id = vSelf + AND t2.awbFk <> t.awbFk; + + RETURN vHasUniqueAwb; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index f475630db..a5fe1d126 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -7,6 +7,8 @@ BEGIN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); - + IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN + CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 91d490b21..57fbb12f6 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -8,7 +8,13 @@ BEGIN DECLARE vHasDistinctWarehouses BOOL; SET NEW.editorFk = account.myUser_getId(); + + IF NOT(NEW.travelFk <=> OLD.travelFk) THEN + IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN + CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto'); + END IF; + IF !(NEW.travelFk <=> OLD.travelFk) THEN SELECT COUNT(*) > 0 INTO vIsVirtual FROM entryVirtual WHERE entryFk = NEW.id; diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index b4e40ae41..aa1489300 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate` BEGIN CALL stock.log_add('travel', NEW.id, OLD.id); - IF !(NEW.shipped <=> OLD.shipped) THEN + IF NOT(NEW.shipped <=> OLD.shipped) THEN UPDATE entry SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; @@ -23,5 +23,9 @@ BEGIN CALL buy_checkItem(); END IF; END IF; + + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN + CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 4e1dae3ef..9505f4e16 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -8,5 +8,9 @@ BEGIN CALL travel_checkDates(NEW.shipped, NEW.landed); CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); + + IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN + CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto'); + END IF; END$$ DELIMITER ; From 292b77d57eee43d78d09e1343201dd5e1f9bbff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 1 Mar 2024 14:36:49 +0100 Subject: [PATCH 068/136] feat: restricciones AWB para travel y entry refs #6960 --- db/routines/vn/triggers/entry_beforeUpdate.sql | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 57fbb12f6..328843442 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -9,18 +9,17 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); - IF NOT(NEW.travelFk <=> OLD.travelFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) THEN IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto'); END IF; - IF !(NEW.travelFk <=> OLD.travelFk) THEN SELECT COUNT(*) > 0 INTO vIsVirtual FROM entryVirtual WHERE entryFk = NEW.id; - SELECT !(o.warehouseInFk <=> n.warehouseInFk) - OR !(o.warehouseOutFk <=> n.warehouseOutFk) + SELECT NOT (o.warehouseInFk <=> n.warehouseInFk) + OR NOT (o.warehouseOutFk <=> n.warehouseOutFk) INTO vHasDistinctWarehouses FROM travel o, travel n WHERE o.id = OLD.travelFk @@ -49,9 +48,8 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) - OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN - SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); + IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk); END IF; END$$ DELIMITER ; From 1ccec1e0fb5ab8d5b747431693a5ce49860e7a73 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 4 Mar 2024 08:11:06 +0100 Subject: [PATCH 069/136] refs #6499 procRefactor part 6 --- .../procedures/absoluteInventoryHistory.sql | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 db/routines/vn/procedures/absoluteInventoryHistory.sql diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql new file mode 100644 index 000000000..427b9ba51 --- /dev/null +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -0,0 +1,99 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( + vIdArticle INT, vWarehouse INT, vDate DATETIME) +BEGIN +/** +* Calcula y proporciona un historial de inventario absoluto +* para un artículo específico en un almacén dado +* hasta una fecha determinada. +* +* @param vIdArticle Id de artículo +* @param vWarehouse Almacén +* @param vDate Fecha +*/ + DECLARE vCalculatedInventory INT; + DECLARE vToday DATETIME; + + SET vToday = util.VN_CURDATE(); + + CREATE OR REPLACE TEMPORARY TABLE historicalPast + ENGINE = MEMORY + SELECT * + FROM ( + SELECT tr.landed Fecha, + b.quantity Entrada, + NULL Salida, + (tr.isReceived != FALSE) OK, + s.name Alias, + e.invoiceNumber Referencia, + e.id id, + tr.isDelivered F5 + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + WHERE tr.landed >= '2001-01-01' + AND s.id <> 4 + AND vWarehouse IN (tr.warehouseInFk, 0) + AND b.itemFk = vIdArticle + AND e.isExcludedFromAvailable = 0 + AND e.isRaid = 0 + UNION ALL + SELECT tr.shipped Fecha, + NULL Entrada, + b.quantity Salida, + tr.isDelivered OK, + s.name Alias, + e.invoiceNumber Referencia, + e.id id, + tr.isDelivered F5 + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + WHERE tr.shipped >= '2001-01-01' + AND vWarehouse = tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vIdArticle + AND e.isExcludedFromAvailable = 0 + AND e.isRaid = 0 + UNION ALL + SELECT t.shipped Fecha, + NULL Entrada, + m.quantity Salida, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, + t.nickname Alias, + t.refFk Referencia, + t.id, + t.isPrinted + FROM sale m + JOIN Tickets T USING (Id_Ticket) + JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente + WHERE T.Fecha >= '2001-01-01' + AND M.Id_Article = vIdArticle + AND vWarehouse IN (T.warehouse_id , 0) + ) t1 + ORDER BY Fecha, Entrada DESC, OK DESC; + + SELECT sum(Entrada) - sum(Salida) INTO vCalculatedInventory + FROM historicalPast + WHERE Fecha < vDate; + + SELECT p1.*, NULL v_virtual + FROM( + SELECT vDate Fecha, + vCalculatedInventory Entrada, + NULL Salida, + 1 OK, + 'Inventario calculado' Alias, + '' Referencia, 0 id, + 1 F5 + UNION ALL + SELECT * + FROM historicalPast + WHERE Fecha >= vDate + ) p1; + + DROP TEMPORARY TABLE historicalPast; +END$$ +DELIMITER ; \ No newline at end of file From 78c92af02f81c887ced32137b033a9eb1d4e3a21 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 4 Mar 2024 11:57:10 +0100 Subject: [PATCH 070/136] refs #5858 feat: fix vn file --- .../10881-greenHydrangea/01-notification.vn.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 414a14688..5ed5786f6 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -1,12 +1,12 @@ -SET @MaxId = SELECT MAX(id)+1 from util.notification n) -INSERT INTO IGNORE util.notification (id, name,description) - VALUES ( +SET @MaxId = (SELECT MAX(id)+1 from util.notification n); +INSERT IGNORE INTO util.notification (`id`, `name`,`description`) + VALUES (@MaxId, 'zone-included','An email to notify zoneCollisions'); -INSERT INTO IGNORE util.notificationSubscription (notificationFk,userFk) +INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( @MaxId, 100); -INSERT INTO IGNORE util.notificationAcl (notificationFk,roleFk) +INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk) SELECT @MaxId, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; From 68846d30184961cd92704a65c95617b58876ee40 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 5 Mar 2024 13:43:03 +0100 Subject: [PATCH 071/136] refs #6499 Refactor historico_multiple --- .../procedures/absoluteInventoryHistory.sql | 109 ++++++------ .../procedures/multipleInventoryHistory.sql | 161 ++++++++++++++++++ 2 files changed, 216 insertions(+), 54 deletions(-) create mode 100644 db/routines/vn/procedures/multipleInventoryHistory.sql diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 427b9ba51..f1a317598 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vIdArticle INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, vWarehouse INT, vDate DATETIME) BEGIN /** * Calcula y proporciona un historial de inventario absoluto * para un artículo específico en un almacén dado * hasta una fecha determinada. * -* @param vIdArticle Id de artículo +* @param vItemFk Id de artículo * @param vWarehouse Almacén * @param vDate Fecha */ @@ -16,84 +16,85 @@ BEGIN SET vToday = util.VN_CURDATE(); - CREATE OR REPLACE TEMPORARY TABLE historicalPast - ENGINE = MEMORY + CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast + ENGINE = MEMORY SELECT * FROM ( - SELECT tr.landed Fecha, - b.quantity Entrada, - NULL Salida, - (tr.isReceived != FALSE) OK, - s.name Alias, - e.invoiceNumber Referencia, + SELECT tr.landed `date`, + b.quantity input, + NULL `output`, + (tr.isReceived != FALSE) ok, + s.name alias, + e.invoiceNumber reference, e.id id, - tr.isDelivered F5 + tr.isDelivered f5 FROM buy b - JOIN entry e ON e.id = b.entryFk + JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk + JOIN supplier s ON s.id = e.supplierFk WHERE tr.landed >= '2001-01-01' AND s.id <> 4 AND vWarehouse IN (tr.warehouseInFk, 0) - AND b.itemFk = vIdArticle - AND e.isExcludedFromAvailable = 0 - AND e.isRaid = 0 + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid UNION ALL - SELECT tr.shipped Fecha, - NULL Entrada, - b.quantity Salida, - tr.isDelivered OK, - s.name Alias, - e.invoiceNumber Referencia, + SELECT tr.shipped `date`, + NULL input, + b.quantity `output`, + tr.isDelivered ok, + s.name alias, + e.invoiceNumber reference, e.id id, - tr.isDelivered F5 + tr.isDelivered f5 FROM buy b - JOIN entry e ON e.id = b.entryFk + JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk + JOIN supplier s ON s.id = e.supplierFk WHERE tr.shipped >= '2001-01-01' AND vWarehouse = tr.warehouseOutFk AND s.id <> 4 - AND b.itemFk = vIdArticle - AND e.isExcludedFromAvailable = 0 - AND e.isRaid = 0 + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid UNION ALL - SELECT t.shipped Fecha, - NULL Entrada, - m.quantity Salida, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, - t.nickname Alias, - t.refFk Referencia, + SELECT t.shipped `date`, + NULL input, + m.quantity `output`, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + t.nickname alias, + t.refFk reference, t.id, t.isPrinted FROM sale m - JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' - AND M.Id_Article = vIdArticle - AND vWarehouse IN (T.warehouse_id , 0) + JOIN ticket t ON t.id = m.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE t.shipped >= '2001-01-01' + AND m.itemFk = vItemFk + AND vWarehouse IN (t.warehouseFk , 0) ) t1 - ORDER BY Fecha, Entrada DESC, OK DESC; + ORDER BY `date`, input DESC, ok DESC; - SELECT sum(Entrada) - sum(Salida) INTO vCalculatedInventory - FROM historicalPast - WHERE Fecha < vDate; + SELECT sum(input) - sum(`output`) INTO vCalculatedInventory + FROM tHistoricalPast + WHERE `date` < vDate; SELECT p1.*, NULL v_virtual FROM( - SELECT vDate Fecha, - vCalculatedInventory Entrada, - NULL Salida, - 1 OK, - 'Inventario calculado' Alias, - '' Referencia, 0 id, - 1 F5 + SELECT vDate `date`, + vCalculatedInventory input, + NULL `output`, + 1 ok, + 'Inventario calculado' alias, + '' reference, + 0 id, + 1 f5 UNION ALL - SELECT * - FROM historicalPast - WHERE Fecha >= vDate + SELECT * + FROM tHistoricalPast + WHERE `date` >= vDate ) p1; - DROP TEMPORARY TABLE historicalPast; + DROP TEMPORARY TABLE tHistoricalPast; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql new file mode 100644 index 000000000..bd399e889 --- /dev/null +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -0,0 +1,161 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( + vItemFk INT) +BEGIN +/** +* Calcula y proporciona un historial de inventario detallado +* para un artículo dividiendo la información +* por almacén. +* +* @param vItemFk Artículo +*/ + DECLARE vDateInventory DATETIME; + + SELECT inventoried INTO vDateInventory FROM config; + + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1; + + CREATE TEMPORARY TABLE tMultipleHistory1 + SELECT DATE(`date`) `date`, + input, + `output`, + ok, + reference, + history.id, + warehouse, + `name` warehouseName + FROM ( + SELECT tr.landed `date`, + c.quantity input, + NULL `output`, + IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, + (tr.isReceived <> FALSE) ok, + e.invoiceNumber reference, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT tr.shipped `date`, + NULL input, + c.quantity `output`, + warehouseOutFk warehouse, + tr.isDelivered ok, + e.invoiceNumber reference, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.shipped >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT t.shipped `date`, + NULL input, + m.quantity `output`, + warehouseInFk warehouse, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + t.refFk reference, + t.id id + FROM sale m + JOIN ticket t ON t.id = m.ticketFk + WHERE t.shipped >= vDateInventory + AND m.itemFk = vItemFk + ) history + JOIN warehouse ON warehouse.id = history.warehouse + ORDER BY `date`, input DESC, ok DESC; + + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory4; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory5; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory6; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory7; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory8; + CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; + CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; + CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; + CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5; + CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17; + CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37; + CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; + + SELECT * + FROM ( + SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, + NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, + NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, + NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, + NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, + NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, + NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid + FROM tMultipleHistory2 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory3 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory4 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory5 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory6 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory7 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id + FROM tMultipleHistory8 + ) sub + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; +END$$ +DELIMITER ; \ No newline at end of file From f215ce5f05e4812a477fd1d6c3bf1d602c447275 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 5 Mar 2024 14:33:16 +0100 Subject: [PATCH 072/136] refs #6498 Delete procedures vn2008 and grant vn procs --- .../vn2008/procedures/historico_absoluto.sql | 91 -------- .../vn2008/procedures/historico_multiple.sql | 206 ------------------ .../10932-azureEucalyptus/00-firstScript.sql | 2 + 3 files changed, 2 insertions(+), 297 deletions(-) delete mode 100644 db/routines/vn2008/procedures/historico_absoluto.sql delete mode 100644 db/routines/vn2008/procedures/historico_multiple.sql create mode 100644 db/versions/10932-azureEucalyptus/00-firstScript.sql diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql deleted file mode 100644 index 1a7e1dbfa..000000000 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ /dev/null @@ -1,91 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME) -BEGIN - - DECLARE inv_calculado INT; - DECLARE inv INT; - DECLARE today DATETIME; - DECLARE fecha_inv DATETIME; - - SET today = util.VN_CURDATE(); - - CREATE OR REPLACE TEMPORARY TABLE historico_pasado - SELECT * - FROM ( - SELECT TR.landing Fecha, - C.Cantidad Entrada, - NULL Salida, - (TR.received != FALSE) OK, - P.Proveedor Alias, - E.Referencia Referencia, - E.Id_Entrada id, - TR.delivered F5 - FROM Compres C -- mirar perque no entra en received - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) - WHERE TR.landing >= '2001-01-01' - AND Id_proveedor <> 4 - AND wh IN (TR.warehouse_id , 0) - AND C.Id_Article = idART - AND E.Inventario = 0 - AND E.Redada = 0 - UNION ALL - SELECT TR.shipment Fecha, - NULL Entrada, - C.Cantidad Salida, - TR.delivered OK, - P.Proveedor Alias, - E.Referencia Referencia, - E.Id_Entrada id, - TR.delivered F5 - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) - WHERE TR.shipment >= '2001-01-01' - AND wh = TR.warehouse_id_out - AND Id_Proveedor <> 4 - AND C.Id_Article = idART - AND E.Inventario = 0 - AND E.Redada = 0 - UNION ALL - SELECT T.Fecha Fecha, - NULL Entrada, - M.Cantidad Salida, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK, - T.Alias Alias, - T.Factura Referencia, - T.Id_Ticket, - T.PedidoImpreso - FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' - AND M.Id_Article = idART - AND wh IN (T.warehouse_id , 0) - ) t1 - ORDER BY Fecha, Entrada DESC, OK DESC; - - SELECT sum(Entrada) - sum(Salida) INTO inv_calculado - FROM historico_pasado - WHERE Fecha < datfecha; - - SELECT p1.*, NULL v_virtual - FROM( - SELECT datfecha Fecha, - inv_calculado Entrada, - NULL Salida, - 1 OK, - 'Inventario calculado' Alias, - '' Referencia, 0 id, - 1 F5 - UNION ALL - SELECT * - FROM historico_pasado - WHERE Fecha >= datfecha - ) p1; - - DROP TEMPORARY TABLE historico_pasado; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql deleted file mode 100644 index ae4045a34..000000000 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ /dev/null @@ -1,206 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_multiple`(IN vItemFk INT) -BEGIN - - DECLARE vDateInventory DATETIME; - - SELECT Fechainventario INTO vDateInventory FROM tblContadores; - - SET @a = 0; - - DROP TEMPORARY TABLE IF EXISTS hm1; - - CREATE TEMPORARY TABLE hm1 - SELECT DATE(Fecha) as Fecha, - Entrada, - Salida, - OK, - Referencia, - Historia.id, - - wh, - - `name` as wh_name - - FROM - - ( SELECT TR.landing as Fecha, - C.Cantidad as Entrada, - NULL as Salida, - - IF(warehouse_id = 44, 1, warehouse_id) as wh, - (TR.received != FALSE) as OK, - E.Referencia as Referencia, - E.Id_Entrada as id - - - - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - WHERE TR.landing >= vDateInventory - AND C.Id_Article = vItemFk - AND E.Redada = 0 - - AND C.Cantidad <> 0 - - UNION ALL - - SELECT TR.shipment as Fecha, - NULL as Entrada, - C.Cantidad as Salida, - warehouse_id_out as wh, - TR.delivered as OK, - E.Referencia as Referencia, - E.Id_Entrada as id - - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - WHERE TR.shipment >= vDateInventory - AND C.Id_Article = vItemFk - - AND E.Redada = 0 - - AND C.Cantidad <> 0 - - UNION ALL - - SELECT T.Fecha as Fecha, - NULL as Entrada, - M.Cantidad as Salida, - warehouse_id as wh, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, - T.Factura as Referencia, - T.Id_Ticket as id - - FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - WHERE T.Fecha >= vDateInventory - AND M.Id_Article = vItemFk - - ) AS Historia - - INNER JOIN warehouse ON warehouse.id = Historia.wh - ORDER BY Fecha, Entrada DESC, OK DESC; - - - DROP TEMPORARY TABLE IF EXISTS hm2; - DROP TEMPORARY TABLE IF EXISTS hm3; - DROP TEMPORARY TABLE IF EXISTS hm4; - DROP TEMPORARY TABLE IF EXISTS hm5; - DROP TEMPORARY TABLE IF EXISTS hm6; - DROP TEMPORARY TABLE IF EXISTS hm7; - DROP TEMPORARY TABLE IF EXISTS hm8; - CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19; - CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7; - CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60; - CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5; - CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17; - CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37; - CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55; - - SELECT * FROM - - ( - - SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid, - - NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid, - - NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid, - - NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid, - - NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid, - - NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid, - - NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid - - FROM hm2 - - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - ,Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm3 - - - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm4 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm5 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm6 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - - - FROM hm7 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - - FROM hm8 - - ) sub - - ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL; - -END$$ -DELIMITER ; diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..55eea3211 --- /dev/null +++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql @@ -0,0 +1,2 @@ +GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer; +GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer; From 66b7a3e8f55c8e033163e052acb96c50b0729115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 5 Mar 2024 17:30:29 +0100 Subject: [PATCH 073/136] feat: restricciones AWB para travel y entry refs #6960 --- db/routines/vn/triggers/entry_beforeInsert.sql | 2 +- db/routines/vn/triggers/entry_beforeUpdate.sql | 4 ++-- db/routines/vn/triggers/travel_afterUpdate.sql | 2 +- db/routines/vn/triggers/travel_beforeInsert.sql | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index a5fe1d126..c0c0aa28c 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -8,7 +8,7 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto'); + CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 328843442..384feb458 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -12,8 +12,8 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('El travel no es correcto, en las entradas asociadas existe un AWB distinto'); - END IF; + CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + END IF; SELECT COUNT(*) > 0 INTO vIsVirtual FROM entryVirtual WHERE entryFk = NEW.id; diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index aa1489300..7752505e3 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -25,7 +25,7 @@ BEGIN END IF; IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto'); + CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 9505f4e16..817bd69bb 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -10,7 +10,7 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('El AWB no es correcto, en las entradas asociadas existe un AWB distinto'); + CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); END IF; END$$ DELIMITER ; From 354ecfaa1684d1f17db20d092ce9821a849219d9 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 09:00:21 +0100 Subject: [PATCH 074/136] refs #6498 Arreglar grant y tabs --- .../procedures/absoluteInventoryHistory.sql | 4 +- .../procedures/multipleInventoryHistory.sql | 206 +++++++++--------- .../10932-azureEucalyptus/00-firstScript.sql | 20 ++ 3 files changed, 125 insertions(+), 105 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index f1a317598..a1e143185 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vItemFk INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, vWarehouse INT, vDate DATETIME) BEGIN /** * Calcula y proporciona un historial de inventario absoluto @@ -72,7 +72,7 @@ BEGIN WHERE t.shipped >= '2001-01-01' AND m.itemFk = vItemFk AND vWarehouse IN (t.warehouseFk , 0) - ) t1 + ) t1 ORDER BY `date`, input DESC, ok DESC; SELECT sum(input) - sum(`output`) INTO vCalculatedInventory diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index bd399e889..b15cab549 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT) + vItemFk INT) BEGIN /** * Calcula y proporciona un historial de inventario detallado @@ -17,58 +17,58 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory1 SELECT DATE(`date`) `date`, - input, + input, `output`, ok, reference, history.id, warehouse, `name` warehouseName - FROM ( - SELECT tr.landed `date`, + FROM ( + SELECT tr.landed `date`, c.quantity input, NULL `output`, IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, (tr.isReceived <> FALSE) ok, e.invoiceNumber reference, - e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT tr.shipped `date`, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT tr.shipped `date`, NULL input, c.quantity `output`, - warehouseOutFk warehouse, + tr.warehouseOutFk warehouse, tr.isDelivered ok, e.invoiceNumber reference, e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.shipped >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT t.shipped `date`, + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.shipped >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT t.shipped `date`, NULL input, m.quantity `output`, - warehouseInFk warehouse, + tr.warehouseInFk warehouse, (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, t.refFk reference, t.id id - FROM sale m - JOIN ticket t ON t.id = m.ticketFk - WHERE t.shipped >= vDateInventory - AND m.itemFk = vItemFk - ) history - JOIN warehouse ON warehouse.id = history.warehouse - ORDER BY `date`, input DESC, ok DESC; + FROM sale m + JOIN ticket t ON t.id = m.ticketFk + WHERE t.shipped >= vDateInventory + AND m.itemFk = vItemFk + ) history + JOIN warehouse ON warehouse.id = history.warehouse + ORDER BY `date`, input DESC, ok DESC; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; @@ -86,76 +86,76 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; SELECT * - FROM ( - SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, - NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, - NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, - NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, - NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, - NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, - NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid - FROM tMultipleHistory2 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory3 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory4 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory5 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory6 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory7 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id - FROM tMultipleHistory8 - ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; + FROM ( + SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, + NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, + NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, + NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, + NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, + NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, + NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid + FROM tMultipleHistory2 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory3 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory4 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory5 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory6 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory7 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id + FROM tMultipleHistory8 + ) sub + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql index 55eea3211..399819cc4 100644 --- a/db/versions/10932-azureEucalyptus/00-firstScript.sql +++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql @@ -1,2 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( + vItemFk INT) +BEGIN + DECLARE vDateInventory DATETIME; + SELECT inventoried INTO vDateInventory FROM config; + +END$$ +DELIMITER ; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( + vItemFk INT, vWarehouse INT, vDate DATETIME) +BEGIN + DECLARE vCalculatedInventory INT; + SET vCalculatedInventory = 0; + +END$$ +DELIMITER ; + GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer; GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer; From 2f0c8d96d22b92648537efda09801e63826263dd Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 6 Mar 2024 11:41:25 +0100 Subject: [PATCH 075/136] refs 5858 fix: resolve breaklines --- db/dump/fixtures.after.sql | 1 - db/routines/vn/triggers/zoneIncluded_afterDelete.sql | 1 - db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index c539b2aab..d7f3b22e8 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -324,5 +324,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) FROM mysql.roles_mapping WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; - FLUSH PRIVILEGES; diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 3ff8be421..18332bb55 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -9,6 +9,5 @@ BEGIN `changedModelId` = OLD.zoneFk, `userFk` = account.myUser_getId(); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index 445f37699..e3f0a27e2 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + END$$ DELIMITER ; From eb5fdd1940f8dcb55b5eb48e68fed41ef4b65411 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 6 Mar 2024 11:41:48 +0100 Subject: [PATCH 076/136] refs 5858 feat: replace with code --- db/versions/10881-greenHydrangea/01-notification.vn.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 5ed5786f6..1d6620c29 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -5,7 +5,7 @@ INSERT IGNORE INTO util.notification (`id`, `name`,`description`) INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( - @MaxId, 100); + @MaxId, (SELECT id from `account`.`user` where name = "system")); INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk) From 7947d6644e5de63988e8845185b7d968efb997ca Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 12:44:59 +0100 Subject: [PATCH 077/136] refs #6498 Correcion errores --- .../procedures/absoluteInventoryHistory.sql | 25 ++++++++++--------- .../procedures/multipleInventoryHistory.sql | 24 ++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index a1e143185..7dce6e252 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,6 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vItemFk INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, + vWarehouseFk INT, + vDate DATETIME +) BEGIN /** * Calcula y proporciona un historial de inventario absoluto @@ -8,13 +11,11 @@ BEGIN * hasta una fecha determinada. * * @param vItemFk Id de artículo -* @param vWarehouse Almacén +* @param vWarehouseFk Id de almacén * @param vDate Fecha */ DECLARE vCalculatedInventory INT; - DECLARE vToday DATETIME; - - SET vToday = util.VN_CURDATE(); + DECLARE vToday DATETIME DEFAULT util.VN_CURDATE(); CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast ENGINE = MEMORY @@ -23,7 +24,7 @@ BEGIN SELECT tr.landed `date`, b.quantity input, NULL `output`, - (tr.isReceived != FALSE) ok, + tr.isReceived ok, s.name alias, e.invoiceNumber reference, e.id id, @@ -34,7 +35,7 @@ BEGIN JOIN supplier s ON s.id = e.supplierFk WHERE tr.landed >= '2001-01-01' AND s.id <> 4 - AND vWarehouse IN (tr.warehouseInFk, 0) + AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid @@ -52,7 +53,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk WHERE tr.shipped >= '2001-01-01' - AND vWarehouse = tr.warehouseOutFk + AND vWarehouseFk = tr.warehouseOutFk AND s.id <> 4 AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable @@ -61,7 +62,7 @@ BEGIN SELECT t.shipped `date`, NULL input, m.quantity `output`, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, t.nickname alias, t.refFk reference, t.id, @@ -71,16 +72,16 @@ BEGIN JOIN client c ON c.id = t.clientFk WHERE t.shipped >= '2001-01-01' AND m.itemFk = vItemFk - AND vWarehouse IN (t.warehouseFk , 0) + AND vWarehouseFk IN (t.warehouseFk , 0) ) t1 ORDER BY `date`, input DESC, ok DESC; - SELECT sum(input) - sum(`output`) INTO vCalculatedInventory + SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory FROM tHistoricalPast WHERE `date` < vDate; SELECT p1.*, NULL v_virtual - FROM( + FROM ( SELECT vDate `date`, vCalculatedInventory input, NULL `output`, diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index b15cab549..ec151a6ff 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -29,16 +29,16 @@ BEGIN c.quantity input, NULL `output`, IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, - (tr.isReceived <> FALSE) ok, + tr.isReceived ok, e.invoiceNumber reference, - e.id id + e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk JOIN travel tr ON tr.id = e.travelFk WHERE tr.landed >= vDateInventory AND c.itemFk = vItemFk AND NOT e.isRaid - AND c.quantity <> 0 + AND c.quantity UNION ALL SELECT tr.shipped `date`, NULL input, @@ -46,20 +46,20 @@ BEGIN tr.warehouseOutFk warehouse, tr.isDelivered ok, e.invoiceNumber reference, - e.id id + e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk JOIN travel tr ON tr.id = e.travelFk WHERE tr.shipped >= vDateInventory AND c.itemFk = vItemFk AND NOT e.isRaid - AND c.quantity <> 0 + AND c.quantity UNION ALL SELECT t.shipped `date`, NULL input, m.quantity `output`, tr.warehouseInFk warehouse, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, t.refFk reference, t.id id FROM sale m @@ -70,13 +70,8 @@ BEGIN JOIN warehouse ON warehouse.id = history.warehouse ORDER BY `date`, input DESC, ok DESC; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory4; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory5; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory6; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory7; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory8; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3, + tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8; CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; @@ -156,6 +151,7 @@ BEGIN input, `output`, ok, reference, id FROM tMultipleHistory8 ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, + MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; END$$ DELIMITER ; \ No newline at end of file From 59a0cb3f4aa9e461f7143e7d8666afa22cd11161 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:08:20 +0100 Subject: [PATCH 078/136] refs #6842 deprecated and move --- .../vn/triggers/invoiceOut_beforeInsert.sql | 12 ++-- db/versions/10893-limeFern/00-sage.sql | 57 ++++++++++++------- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index f3a292edd..eb5c1150f 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -17,16 +17,16 @@ BEGIN DECLARE vRefLen INT; DECLARE vRefPrefix VARCHAR(255); DECLARE vLastRef VARCHAR(255); - DECLARE vSage200Company INT; + DECLARE vCompanyCode INT; DECLARE vYearLen INT DEFAULT 2; DECLARE vPrefixLen INT; - SELECT sage200Company INTO vSage200Company + SELECT companyCode INTO vCompanyCode FROM company WHERE id = NEW.companyFk; - IF vSage200Company IS NULL THEN - CALL util.throw('vSage200CompanyNotDefined'); + IF vCompanyCode IS NULL THEN + CALL util.throw('vCompanyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef @@ -36,7 +36,7 @@ BEGIN AND i.companyFk = NEW.companyFk; IF vLastRef IS NOT NULL THEN - SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vSage200Company) + vYearLen; + SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen; SET vRefLen = LENGTH(vLastRef) - vPrefixLen; SET vRefPrefix = LEFT(vLastRef, vPrefixLen); SET vRef = RIGHT(vLastRef, vRefLen); @@ -44,7 +44,7 @@ BEGIN SELECT refLen INTO vRefLen FROM invoiceOutConfig; SET vRefPrefix = CONCAT( NEW.serial, - vSage200Company, + vCompanyCode, RIGHT(YEAR(NEW.issued), vYearLen) ); END IF; diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 049bb2993..9d076050e 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -1,35 +1,54 @@ --- Auto-generated SQL script #202402151810 +-- Auto-generated SQL script #202403061303 UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=0 WHERE id=69; UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=567; -UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=0 WHERE id=791; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=3 WHERE id=792; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=5 WHERE id=965; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=7 WHERE id=1381; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=3 WHERE id=1463; UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=2142; -UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=2292; -UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=6 WHERE id=2393; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=9 WHERE id=3869; -ALTER TABLE vn.company MODIFY COLUMN sage200Company int(2) DEFAULT NULL NULL COMMENT 'Campo para la serie InvoiceOut'; + +-- Auto-generated SQL script #202403061303 +UPDATE vn.company + SET companyCode=0 + WHERE id=69; +UPDATE vn.company + SET companyCode=0 + WHERE id=791; +UPDATE vn.company + SET companyCode=3 + WHERE id=792; +UPDATE vn.company + SET companyCode=5 + WHERE id=965; +UPDATE vn.company + SET companyCode=7 + WHERE id=1381; +UPDATE vn.company + SET companyCode=3 + WHERE id=1463; +UPDATE vn.company + SET companyCode=6 + WHERE id=2393; +UPDATE vn.company + SET companyCode=9 + WHERE id=3869; + +ALTER TABLE vn.company CHANGE sage200Company sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; +ALTER TABLE vn.company MODIFY COLUMN sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; From a24445439ab389ebf8054f766d81bbd1e2b1c3af Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:09:03 +0100 Subject: [PATCH 079/136] remove v --- db/routines/vn/triggers/invoiceOut_beforeInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index eb5c1150f..8eb25e710 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -26,7 +26,7 @@ BEGIN WHERE id = NEW.companyFk; IF vCompanyCode IS NULL THEN - CALL util.throw('vCompanyCodeNotDefined'); + CALL util.throw('CompanyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef From 6a13a33f840b550c72b6dfd34fe4f6bd9ec12d0a Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:09:41 +0100 Subject: [PATCH 080/136] min c --- db/routines/vn/triggers/invoiceOut_beforeInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index 8eb25e710..0081c8803 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -26,7 +26,7 @@ BEGIN WHERE id = NEW.companyFk; IF vCompanyCode IS NULL THEN - CALL util.throw('CompanyCodeNotDefined'); + CALL util.throw('companyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef From 58a239708d1dca4dbd23af0f260ad03e801d8790 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:11:41 +0100 Subject: [PATCH 081/136] refs #6842 remove sage --- db/versions/10893-limeFern/00-sage.sql | 28 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 9d076050e..01508b932 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -24,31 +24,41 @@ UPDATE vn.company SET companyCode=9 WHERE id=3869; --- Auto-generated SQL script #202403061303 +-- Auto-generated SQL script #202403061311 UPDATE vn.company - SET companyCode=0 + SET sage200Company=NULL WHERE id=69; UPDATE vn.company - SET companyCode=0 + SET sage200Company=NULL + WHERE id=442; +UPDATE vn.company + SET sage200Company=NULL + WHERE id=567; +UPDATE vn.company + SET sage200Company=NULL WHERE id=791; UPDATE vn.company - SET companyCode=3 + SET sage200Company=NULL WHERE id=792; UPDATE vn.company - SET companyCode=5 + SET sage200Company=NULL WHERE id=965; UPDATE vn.company - SET companyCode=7 + SET sage200Company=NULL WHERE id=1381; UPDATE vn.company - SET companyCode=3 + SET sage200Company=NULL WHERE id=1463; UPDATE vn.company - SET companyCode=6 + SET sage200Company=NULL + WHERE id=2142; +UPDATE vn.company + SET sage200Company=NULL WHERE id=2393; UPDATE vn.company - SET companyCode=9 + SET sage200Company=NULL WHERE id=3869; + ALTER TABLE vn.company CHANGE sage200Company sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; ALTER TABLE vn.company MODIFY COLUMN sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; From 6b2533cfb122ddd832ae9c6a447fe5bbac8b96fa Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 15:16:55 +0100 Subject: [PATCH 082/136] refs #6498 correccion errores 2 --- .../procedures/absoluteInventoryHistory.sql | 41 ++++++++++--------- .../procedures/multipleInventoryHistory.sql | 31 +++++++------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 7dce6e252..627b7c8be 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -16,6 +16,7 @@ BEGIN */ DECLARE vCalculatedInventory INT; DECLARE vToday DATETIME DEFAULT util.VN_CURDATE(); + DECLARE vStartDate DATE DEFAULT '2001-01-01'; CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast ENGINE = MEMORY @@ -33,46 +34,46 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - WHERE tr.landed >= '2001-01-01' - AND s.id <> 4 + WHERE tr.landed >= vStartDate + AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid UNION ALL - SELECT tr.shipped `date`, - NULL input, - b.quantity `output`, - tr.isDelivered ok, - s.name alias, - e.invoiceNumber reference, - e.id id, - tr.isDelivered f5 + SELECT tr.shipped, + NULL, + b.quantity, + tr.isDelivered, + s.name, + e.invoiceNumber, + e.id, + tr.isDelivered FROM buy b JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - WHERE tr.shipped >= '2001-01-01' + WHERE tr.shipped >= vStartDate AND vWarehouseFk = tr.warehouseOutFk - AND s.id <> 4 + AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid UNION ALL - SELECT t.shipped `date`, - NULL input, - m.quantity `output`, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, - t.nickname alias, - t.refFk reference, + SELECT t.shipped, + NULL, + m.quantity, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), + t.nickname, + t.refFk, t.id, t.isPrinted FROM sale m JOIN ticket t ON t.id = m.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped >= '2001-01-01' + WHERE t.shipped >= vStartDate AND m.itemFk = vItemFk - AND vWarehouseFk IN (t.warehouseFk , 0) + AND vWarehouseFk IN (t.warehouseFk, 0) ) t1 ORDER BY `date`, input DESC, ok DESC; diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index ec151a6ff..dc19e615a 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT) + vItemFk INT +) BEGIN /** * Calcula y proporciona un historial de inventario detallado @@ -28,7 +29,7 @@ BEGIN SELECT tr.landed `date`, c.quantity input, NULL `output`, - IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, + tr.warehouseInFk warehouse, tr.isReceived ok, e.invoiceNumber reference, e.id @@ -40,12 +41,12 @@ BEGIN AND NOT e.isRaid AND c.quantity UNION ALL - SELECT tr.shipped `date`, - NULL input, - c.quantity `output`, - tr.warehouseOutFk warehouse, - tr.isDelivered ok, - e.invoiceNumber reference, + SELECT tr.shipped, + NULL, + c.quantity, + tr.warehouseOutFk, + tr.isDelivered, + e.invoiceNumber, e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk @@ -55,13 +56,13 @@ BEGIN AND NOT e.isRaid AND c.quantity UNION ALL - SELECT t.shipped `date`, - NULL input, - m.quantity `output`, - tr.warehouseInFk warehouse, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, - t.refFk reference, - t.id id + SELECT t.shipped, + NULL, + m.quantity, + t.warehouseFk, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), + t.refFk, + t.id FROM sale m JOIN ticket t ON t.id = m.ticketFk WHERE t.shipped >= vDateInventory From a94fd1a61cdbacbd604b89a1a2712d4cdcae546b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 7 Mar 2024 09:29:51 +0100 Subject: [PATCH 083/136] fix: refs #6744 change error kind --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- modules/worker/back/methods/worker/setPassword.js | 4 ++-- modules/worker/back/methods/worker/specs/setPassword.spec.js | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 62c0afcf8..31b954a32 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -221,5 +221,6 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves" + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bf4717c97..945474726 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -348,5 +348,6 @@ "Cmr file does not exist": "El archivo del cmr no existe", "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas", - "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario" + "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario", + "They're not your subordinate": "No es tu subordinado/a." } diff --git a/modules/worker/back/methods/worker/setPassword.js b/modules/worker/back/methods/worker/setPassword.js index e6bdfb364..9969530a4 100644 --- a/modules/worker/back/methods/worker/setPassword.js +++ b/modules/worker/back/methods/worker/setPassword.js @@ -1,4 +1,4 @@ -const UserError = require('vn-loopback/util/user-error'); +const ForbiddenError = require('vn-loopback/util/forbiddenError'); module.exports = Self => { Self.remoteMethodCtx('setPassword', { description: 'Set a new password', @@ -32,7 +32,7 @@ module.exports = Self => { } try { const isSubordinate = await Self.isSubordinate(ctx, id, myOptions); - if (!isSubordinate) throw new UserError('You don\'t have enough privileges.'); + if (!isSubordinate) throw new ForbiddenError('They\'re not your subordinate'); await models.Account.setUnverifiedPassword(id, newPass, myOptions); diff --git a/modules/worker/back/methods/worker/specs/setPassword.spec.js b/modules/worker/back/methods/worker/specs/setPassword.spec.js index 03cbee03b..8d152bdd1 100644 --- a/modules/worker/back/methods/worker/specs/setPassword.spec.js +++ b/modules/worker/back/methods/worker/specs/setPassword.spec.js @@ -54,7 +54,7 @@ describe('worker setPassword()', () => { await models.Worker.setPassword(ctx, administrativeId, newPass, options); await tx.rollback(); } catch (e) { - expect(e.message).toEqual(`You don't have enough privileges.`); + expect(e.message).toEqual(`They're not your subordinate`); await tx.rollback(); } }); From b588b9807ce73a19f6f2a7f48828a6ab487990e5 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 7 Mar 2024 13:45:53 +0100 Subject: [PATCH 084/136] fixtures local --- db/dump/fixtures.after.sql | 411 ------------------------------------- 1 file changed, 411 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 13e423d68..4c5f89d97 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -292,418 +292,7 @@ INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount */ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); --- XXX: floranet -INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); - - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNR', 'Floranet Ramos', 1, 1); - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNP', 'Floranet Plantas', 1, 1); - --- Generación de items -SELECT id - INTO @FNR - FROM vn.itemType - WHERE code = 'FNR'; - -SELECT id - INTO @FNP - FROM vn.itemType - WHERE code = 'FNP'; - -DELETE - FROM vn.item - WHERE typeFk IN (@FNR,@FNP); - -SELECT MAX(id) + 1 - INTO @item - FROM vn.item; - -INSERT INTO vn.item - ( - id, - name, - longName, - `size`, - originFk, - intrastatFk, - typeFk, - inkFk, - image, - description - ) - VALUES - ( - @item := @item + 1, - @r := 'Ramo Terranova', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1CwtEK5_GReAzconaJsPTCXxV7zajbTos/view?usp=drive_link', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', - 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', - 'paniculata eucaliptus.') - ), - ( - @item := @item + 1, - @r := 'Ramo Tasmania', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1_149uYZ-sehw3vWH68Quttk8QJe5T_bG/view?usp=drive_link', - CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', - 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', - 'flores será un acierto seguro para hacer un regalo muy especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Pasion', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1-dH1UilV-nOH9XNK23uooZoezlwMT-Jq/view?usp=drive_link', - CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', - 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', - 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', - 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', - 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') - ), - ( - @item := @item + 1, - @r := 'Ramo Florencia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1PWKo5N8kg8H3xQtELdeQTQIc1HMZCc1P/view?usp=drive_link', - CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', - 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', - 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', - 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Atardecer', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink WHERE name = 'Yellow'), - 'https://drive.google.com/file/d/1eM4gtftQuXN5xUjAHIRUYNPZNmuHVRA_/view?usp=drive_link', - CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', - 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', - 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', - 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', - 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') - ), - ( - @item := @item + 1, - @r := 'Ramo Arcoíris', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1Hxk5yqo7891gfK1VKIYfWxO5a_0K2Qej/view?usp=drive_link', - CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', - 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', - 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', - 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', - 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', - 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') - ), - ( - @item := @item + 1, - @r := 'Ramo Provenza', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1TA9SBwjqnrEqG1bzwDL37sxtX9CNyLJk/view?usp=drive_link', - CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', - 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', - 'con una selección de maravillosos verdes variados, hacen que esta combinación ', - 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Alegria', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1sOf2isj84P9OxR3E3x6n2PjPnWVamLCE/view?usp=drive_link', - CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', - 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', - ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', - 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', - 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') - ), - ( - @item := @item + 1, - @r := 'Planta Orquídeas ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/14BIkDDonFaIiTyJer1CWju1YzZNzt3XQ/view?usp=drive_link', - CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', - 'con las mejores características combinadas con diferentes elementos de ', - 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', - 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', - 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', - 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') - ), - ( - @item := @item + 1, - @r := 'Planta Kentia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1rKe2RicfWha-VIm1LbbXckbA41glA99K/view?usp=drive_link', - CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', - 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', - 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', - 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', - 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', - 'de ser un producto nacional producido en Canarias de una calidad extrema.') - ), - ( - @item := @item + 1, - @r := 'Planta Calathea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/11CKm5rqVFVPOELciuyXUrkc2oeTHJzBE/view?usp=drive_link', - CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', - ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', - 'llamativo y original colorido, tambien es un regalo perfecto para ', - 'cualquier compromiso que tengamos .') - ), - ( - @item := @item + 1, - @r := 'Planta Anthurium ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink WHERE name = 'Red'), - 'https://drive.google.com/file/d/1j4il_N9VJGaP4f6CPZM0u6GjxwIeYcBt/view?usp=drive_link', - CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', - 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', - 'su llamativo color alegrará cualquier celebración') - ), - ( - @item := @item + 1, - @r := 'Ramo Mindanao', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1lsGDuC6xmv3SyGukfLTVYsQvbGf1Bzxy/view?usp=drive_link', - CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', - 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', - 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') - ), - ( - @item := @item + 1, - @r := 'Ramo Guinea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1MtF0oghv-ahogaAaVpJNzDiIfyeCCmAi/view?usp=drive_link', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', - ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') - ), - ( - @item := @item + 1, - @r := 'Ramo Eterno', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1AOMqlZAKqImnnWSmeq1DW1Krj78mACCG/view?usp=drive_link', - CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', - 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', - 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', - 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', - 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', - 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') - ), - ( - @item := @item + 1, - @r := 'Ramo Cielo', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/168DikIOwVT5OO4BHARBoWwLB1wjpAS7s/view?usp=drive_link', - CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', - 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', - ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', - 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', - ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', - 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', - 'clara de todo el conjunto. ') - ); - - -- Ramo Terranova: 1er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Rosa roja', - @r, - 60, - 1, - 'RED', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 12 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - -- Ramo Terranova: 2º elemento - -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Hoja de helecho', - @r, - 60, - 1, - 'BAS', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 4 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- Ramo Terranova: 3er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Paniculata', - @r, - 60, - 1, - 'SLV', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 5 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- XXX SET foreign_key_checks = 1; From 4994a836c7119a6c894e3600a78ba71438ecb410 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 9 Mar 2024 11:27:29 +0100 Subject: [PATCH 085/136] refs #5858 feat: alter table util.notification --- .../10881-greenHydrangea/00-alterTableNotification.sql | 1 + db/versions/10881-greenHydrangea/01-notification.vn.sql | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 db/versions/10881-greenHydrangea/00-alterTableNotification.sql diff --git a/db/versions/10881-greenHydrangea/00-alterTableNotification.sql b/db/versions/10881-greenHydrangea/00-alterTableNotification.sql new file mode 100644 index 000000000..068d77839 --- /dev/null +++ b/db/versions/10881-greenHydrangea/00-alterTableNotification.sql @@ -0,0 +1 @@ +ALTER TABLE util.notification MODIFY COLUMN id int(11) auto_increment NOT NULL; diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 1d6620c29..6c9152ec7 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -1,8 +1,7 @@ -SET @MaxId = (SELECT MAX(id)+1 from util.notification n); -INSERT IGNORE INTO util.notification (`id`, `name`,`description`) +INSERT IGNORE INTO util.notification ( `name`,`description`) VALUES -(@MaxId, 'zone-included','An email to notify zoneCollisions'); - +( 'zone-included','An email to notify zoneCollisions'); +SET @MaxId = LAST_INSERT_ID(); INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( @MaxId, (SELECT id from `account`.`user` where name = "system")); From b051b0512fcb8abf63c2207cee732d641ce746c7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 11 Mar 2024 09:48:29 +0100 Subject: [PATCH 086/136] refs #6842 fix fixtures --- db/dump/fixtures.before.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 094b956af..05e183bfd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -592,13 +592,13 @@ INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`) VALUES (241, 442, 'ES111122333344111122221111', 128); -INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`) +INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`) VALUES - (69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL), - (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101), - (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL), - (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL); + (69 , 'CCs', NULL, 30, 0, NULL, 1, NULL , NULL), + (442 , 'VNL', 241, 30, 1, NULL, 2, 'VNL Company - Plant passport' , 1101), + (567 , 'VNH', NULL, 30, 4, NULL, 1, 'VNH Company - Plant passport' , NULL), + (791 , 'FTH', NULL, 30, 3, '2015-11-30', 1, NULL , NULL), + (1381, 'ORN', NULL, 30, 7, NULL, 1, 'ORN Company - Plant passport' , NULL); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -728,7 +728,7 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) VALUES (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), From 5531639027138950a1b73565be11ce3162c858b3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 12 Mar 2024 09:34:12 +0100 Subject: [PATCH 087/136] feat: refs #6951 create procedure --- db/routines/vn/procedures/ticketClon.sql | 54 ++----------------- db/routines/vn/procedures/ticket_Clone.sql | 4 +- db/routines/vn/procedures/ticket_CloneAll.sql | 54 +++++++++++++++++++ 3 files changed, 61 insertions(+), 51 deletions(-) create mode 100644 db/routines/vn/procedures/ticket_CloneAll.sql diff --git a/db/routines/vn/procedures/ticketClon.sql b/db/routines/vn/procedures/ticketClon.sql index 81328bc11..00386c6aa 100644 --- a/db/routines/vn/procedures/ticketClon.sql +++ b/db/routines/vn/procedures/ticketClon.sql @@ -1,55 +1,11 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE) BEGIN - - DECLARE done INT DEFAULT FALSE; - DECLARE vNewTicketFk INT; - DECLARE vOldSaleFk INT; - DECLARE vNewSaleFk INT; - - DECLARE cur1 CURSOR FOR - SELECT id - FROM vn.sale - WHERE ticketFk = vTicketFk; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); - - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); - - UPDATE vn.ticket - SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), - shipped = vNewShipped - WHERE id = vNewTicketFk; - - OPEN cur1; - - read_loop: LOOP - - FETCH cur1 INTO vOldSaleFk; - - IF done THEN - LEAVE read_loop; - END IF; - - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) - SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed - FROM vn.sale - WHERE id = vOldSaleFk; - - SELECT max(id) INTO vNewSaleFk - FROM vn.sale - WHERE ticketFk = vNewTicketFk; - - INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) - SELECT vNewSaleFk, componentFk, value, isGreuge - FROM vn.saleComponent - WHERE saleFk = vOldSaleFk; - - END LOOP; - CLOSE cur1; - + DECLARE vNewTicketFk INT; + + CALL ticket_CloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk); + SELECT vNewTicketFk; + END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_Clone.sql b/db/routines/vn/procedures/ticket_Clone.sql index 7670e832e..cdddd6225 100644 --- a/db/routines/vn/procedures/ticket_Clone.sql +++ b/db/routines/vn/procedures/ticket_Clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT,vWithWarehouse BOOLEAN) BEGIN /** * Clona el contenido de un ticket en otro @@ -32,7 +32,7 @@ BEGIN addressFk, agencyModeFk, nickname, - warehouseFk, + IF(vWithWarehouse, warehouseFk, NULL), companyFk, landed, zoneFk, diff --git a/db/routines/vn/procedures/ticket_CloneAll.sql b/db/routines/vn/procedures/ticket_CloneAll.sql new file mode 100644 index 000000000..4adb50a10 --- /dev/null +++ b/db/routines/vn/procedures/ticket_CloneAll.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) +BEGIN + + DECLARE done INT DEFAULT FALSE; + DECLARE vOldSaleFk INT; + DECLARE vNewSaleFk INT; + + DECLARE cur1 CURSOR FOR + SELECT id + FROM vn.sale + WHERE ticketFk = vTicketFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); + + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse); + + UPDATE vn.ticket + SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), + shipped = vNewShipped + WHERE id = vNewTicketFk; + + OPEN cur1; + + read_loop: LOOP + + FETCH cur1 INTO vOldSaleFk; + + IF done THEN + LEAVE read_loop; + END IF; + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) + SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed + FROM vn.sale + WHERE id = vOldSaleFk; + + SELECT max(id) INTO vNewSaleFk + FROM vn.sale + WHERE ticketFk = vNewTicketFk; + + INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) + SELECT vNewSaleFk, componentFk, value, isGreuge + FROM vn.saleComponent + WHERE saleFk = vOldSaleFk; + + END LOOP; + + CLOSE cur1; + +END$$ +DELIMITER ; From c1d0ea7e2770648a235fd84cebd14a160e0c309d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 09:40:42 +0100 Subject: [PATCH 088/136] refs #5858: breaklines --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3797b94cd..1414dbe9f 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2811,6 +2811,7 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (5, 'modified-entry', 'An entry has been modified'), (6, 'book-entry-deleted', 'accounting entries deleted'), (7, 'zone-included','An email to notify zoneCollisions'); + INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), @@ -2840,7 +2841,6 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (6, 9), (7, 9); - INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES (1, 9); From e7f6e61ea1a8404989edbb48c0ea954926e78aae Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 10:20:43 +0100 Subject: [PATCH 089/136] refs #5858: change notification owner --- db/dump/fixtures.before.sql | 314 +++++++++--------- .../01-notification.vn.sql | 4 +- 2 files changed, 159 insertions(+), 159 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1414dbe9f..65d358bb5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2821,7 +2821,7 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (4, 1), (5, 9), (6, 9), - (7, 1); + (7, 100); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2839,7 +2839,7 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (1, 9), (1, 3), (6, 9), - (7, 9); + (7, 100); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES @@ -3077,11 +3077,11 @@ INSERT INTO vn.packaging INSERT IGNORE INTO vn.intrastat - SET id = 44219999, - description = 'Manufacturas de madera', - taxClassFk = 1, + SET id = 44219999, + description = 'Manufacturas de madera', + taxClassFk = 1, taxCodeFk = 1; - + INSERT IGNORE INTO vn.warehouse SET id = 999, name = 'TestingWarehouse', @@ -3092,33 +3092,33 @@ INSERT IGNORE INTO vn.warehouse hasProduction = TRUE; INSERT IGNORE INTO vn.sector - SET id = 9991, - description = 'NormalSector', - warehouseFk = 999, - code = 'NS', - isPackagingArea = FALSE, - sonFk = NULL, - isMain = TRUE, + SET id = 9991, + description = 'NormalSector', + warehouseFk = 999, + code = 'NS', + isPackagingArea = FALSE, + sonFk = NULL, + isMain = TRUE, itemPackingTypeFk = NULL; INSERT IGNORE INTO vn.sector - SET id = 9992, - description = 'PreviousSector', - warehouseFk = 999, - code = 'PS', - isPackagingArea = FALSE, - sonFk = NULL, - isMain = TRUE, + SET id = 9992, + description = 'PreviousSector', + warehouseFk = 999, + code = 'PS', + isPackagingArea = FALSE, + sonFk = NULL, + isMain = TRUE, itemPackingTypeFk = NULL; INSERT IGNORE INTO vn.sector - SET id = 9993, - description = 'MezaninneSector', - warehouseFk = 999, - code = 'MS', - isPackagingArea = FALSE, - sonFk = 9991, - isMain = TRUE, + SET id = 9993, + description = 'MezaninneSector', + warehouseFk = 999, + code = 'MS', + isPackagingArea = FALSE, + sonFk = 9991, + isMain = TRUE, itemPackingTypeFk = NULL; @@ -3152,58 +3152,58 @@ INSERT IGNORE INTO vn.itemType SET id = 999, code = 'WOO', name = 'Wood Objects', - categoryFk = 3, + categoryFk = 3, workerFk = 103, isInventory = TRUE, life = 10, density = 250, - itemPackingTypeFk = NULL, + itemPackingTypeFk = NULL, temperatureFk = 'warm'; INSERT IGNORE INTO vn.travel - SET id = 99, - shipped = CURDATE(), + SET id = 99, + shipped = CURDATE(), landed = CURDATE(), - warehouseInFk = 999, - warehouseOutFk = 1, + warehouseInFk = 999, + warehouseOutFk = 1, isReceived = TRUE; INSERT INTO vn.entry SET id = 999, supplierFk = 791, - isConfirmed = TRUE, + isConfirmed = TRUE, dated = CURDATE(), - travelFk = 99, + travelFk = 99, companyFk = 442; INSERT INTO vn.ticket - SET id = 999999, + SET id = 999999, clientFk = 2, warehouseFk = 999, shipped = CURDATE(), - nickname = 'Cliente', + nickname = 'Cliente', addressFk = 1, - companyFk = 442, - agencyModeFk = 10, + companyFk = 442, + agencyModeFk = 10, landed = CURDATE(); INSERT INTO vn.collection - SET id = 10101010, + SET id = 10101010, workerFk = 9; - + INSERT IGNORE INTO vn.ticketCollection - SET id = 10101010, - ticketFk = 999999, + SET id = 10101010, + ticketFk = 999999, collectionFk = 10101010; - + INSERT INTO vn.item SET id = 999991, - name = 'Palito para pinchos', + name = 'Palito para pinchos', `size` = 25, - stems = NULL, - category = 'EXT', - typeFk = 999, - longName = 'Palito para pinchos', + stems = NULL, + category = 'EXT', + typeFk = 999, + longName = 'Palito para pinchos', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 6, @@ -3230,19 +3230,19 @@ INSERT INTO vn.sale SET id = 99991, itemFk = 999991, ticketFk = 999999, - concept = 'Palito para pinchos', - quantity = 3, - price = 1, + concept = 'Palito para pinchos', + quantity = 3, + price = 1, discount = 0; INSERT INTO vn.item SET id = 999992, - name = 'Madera verde', + name = 'Madera verde', `size` = 10, - stems = NULL, - category = 'EXT', - typeFk = 999, - longName = 'Madera verde', + stems = NULL, + category = 'EXT', + typeFk = 999, + longName = 'Madera verde', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 50, @@ -3269,19 +3269,19 @@ INSERT INTO vn.sale SET id = 99992, itemFk = 999992, ticketFk = 999999, - concept = 'Madera Verde', - quantity = 10, - price = 1, + concept = 'Madera Verde', + quantity = 10, + price = 1, discount = 0; INSERT INTO vn.item SET id = 999993, - name = 'Madera Roja/Morada', + name = 'Madera Roja/Morada', `size` = 12, - stems = 2, - category = 'EXT', - typeFk = 999, - longName = 'Madera Roja/Morada', + stems = 2, + category = 'EXT', + typeFk = 999, + longName = 'Madera Roja/Morada', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 35, @@ -3305,30 +3305,30 @@ INSERT INTO vn.buy weight = 25; INSERT INTO vn.itemShelving - SET id = 9931, - itemFk = 999993, - shelvingFk = 'NCC', - visible = 10, - `grouping` = 5, + SET id = 9931, + itemFk = 999993, + shelvingFk = 'NCC', + visible = 10, + `grouping` = 5, packing = 10; - + INSERT INTO vn.sale SET id = 99993, itemFk = 999993, ticketFk = 999999, - concept = 'Madera Roja/Morada', - quantity = 15, - price = 1, + concept = 'Madera Roja/Morada', + quantity = 15, + price = 1, discount = 0; INSERT INTO vn.item SET id = 999994, - name = 'Madera Naranja', + name = 'Madera Naranja', `size` = 18, - stems = 1, - category = 'EXT', - typeFk = 999, - longName = 'Madera Naranja', + stems = 1, + category = 'EXT', + typeFk = 999, + longName = 'Madera Naranja', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 160, @@ -3355,19 +3355,19 @@ INSERT INTO vn.sale SET id = 99994, itemFk = 999994, ticketFk = 999999, - concept = 'Madera Naranja', - quantity = 4, - price = 1, + concept = 'Madera Naranja', + quantity = 4, + price = 1, discount = 0; - + INSERT INTO vn.item SET id = 999995, - name = 'Madera Amarilla', + name = 'Madera Amarilla', `size` = 11, - stems = 5, - category = 'EXT', - typeFk = 999, - longName = 'Madera Amarilla', + stems = 5, + category = 'EXT', + typeFk = 999, + longName = 'Madera Amarilla', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 78, @@ -3394,20 +3394,20 @@ INSERT INTO vn.sale SET id = 99995, itemFk = 999995, ticketFk = 999999, - concept = 'Madera Amarilla', - quantity = 5, - price = 1, + concept = 'Madera Amarilla', + quantity = 5, + price = 1, discount = 0; - + -- Palito naranja INSERT INTO vn.item SET id = 999998, - name = 'Palito naranja', + name = 'Palito naranja', `size` = 11, - stems = 1, - category = 'EXT', - typeFk = 999, - longName = 'Palito naranja', + stems = 1, + category = 'EXT', + typeFk = 999, + longName = 'Palito naranja', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 78, @@ -3434,20 +3434,20 @@ INSERT INTO vn.sale SET id = 99998, itemFk = 999998, ticketFk = 999999, - concept = 'Palito naranja', - quantity = 60, - price = 1, + concept = 'Palito naranja', + quantity = 60, + price = 1, discount = 0; -- Palito amarillo INSERT INTO vn.item SET id = 999999, - name = 'Palito amarillo', + name = 'Palito amarillo', `size` = 11, - stems = 1, - category = 'EXT', - typeFk = 999, - longName = 'Palito amarillo', + stems = 1, + category = 'EXT', + typeFk = 999, + longName = 'Palito amarillo', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 78, @@ -3474,20 +3474,20 @@ INSERT INTO vn.sale SET id = 99999, itemFk = 999999, ticketFk = 999999, - concept = 'Palito amarillo', - quantity = 50, - price = 1, + concept = 'Palito amarillo', + quantity = 50, + price = 1, discount = 0; -- Palito azul INSERT INTO vn.item SET id = 1000000, - name = 'Palito azul', + name = 'Palito azul', `size` = 10, - stems = 1, - category = 'EXT', - typeFk = 999, - longName = 'Palito azul', + stems = 1, + category = 'EXT', + typeFk = 999, + longName = 'Palito azul', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 78, @@ -3514,20 +3514,20 @@ INSERT INTO vn.sale SET id = 100000, itemFk = 1000000, ticketFk = 999999, - concept = 'Palito azul', - quantity = 50, - price = 1, + concept = 'Palito azul', + quantity = 50, + price = 1, discount = 0; -- Palito rojo INSERT INTO vn.item SET id = 1000001, - name = 'Palito rojo', + name = 'Palito rojo', `size` = 10, - stems = NULL, - category = 'EXT', - typeFk = 999, - longName = 'Palito rojo', + stems = NULL, + category = 'EXT', + typeFk = 999, + longName = 'Palito rojo', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 78, @@ -3555,20 +3555,20 @@ INSERT INTO vn.sale SET id = 100001, itemFk = 1000001, ticketFk = 999999, - concept = 'Palito rojo', - quantity = 10, - price = 1, + concept = 'Palito rojo', + quantity = 10, + price = 1, discount = 0; - + -- Previa INSERT IGNORE INTO vn.item SET id = 999996, - name = 'Bolas de madera', + name = 'Bolas de madera', `size` = 2, - stems = 4, - category = 'EXT', - typeFk = 999, - longName = 'Bolas de madera', + stems = 4, + category = 'EXT', + typeFk = 999, + longName = 'Bolas de madera', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 20, @@ -3595,20 +3595,20 @@ INSERT vn.sale SET id = 99996, itemFk = 999996, ticketFk = 999999, - concept = 'Bolas de madera', - quantity = 4, - price = 7, + concept = 'Bolas de madera', + quantity = 4, + price = 7, discount = 0, isPicked = TRUE; INSERT IGNORE INTO vn.item SET id = 999997, - name = 'Palitos de polo MIX', + name = 'Palitos de polo MIX', `size` = 14, - stems = NULL, - category = 'EXT', - typeFk = 999, - longName = 'Palitos de polo MIX', + stems = NULL, + category = 'EXT', + typeFk = 999, + longName = 'Palitos de polo MIX', itemPackingTypeFk = NULL, originFk = 1, weightByPiece = 20, @@ -3635,9 +3635,9 @@ INSERT vn.sale SET id = 99997, itemFk = 999997, ticketFk = 999999, - concept = 'Palitos de polo MIX', - quantity = 5, - price = 7, + concept = 'Palitos de polo MIX', + quantity = 5, + price = 7, discount = 0; USE vn; @@ -3670,38 +3670,38 @@ VALUES -- Previous for Bolas de madera INSERT IGNORE INTO vn.sectorCollection - SET id = 99, - userFk = 1, + SET id = 99, + userFk = 1, sectorFk = 9992; INSERT IGNORE INTO vn.saleGroup - SET id = 4, - userFk = 1, - parkingFk = 9, + SET id = 4, + userFk = 1, + parkingFk = 9, sectorFk = 9992; INSERT IGNORE INTO vn.sectorCollectionSaleGroup SET id = 9999, - sectorCollectionFk = 99, + sectorCollectionFk = 99, saleGroupFk = 999; INSERT vn.saleGroupDetail - SET id = 99991, - saleFk = 99996, + SET id = 99991, + saleFk = 99996, saleGroupFk = 999; - + INSERT INTO vn.saleTracking SET id = 7, - saleFk = 99996, + saleFk = 99996, isChecked = TRUE, workerFk = 103, stateFk = 28; - + INSERT IGNORE INTO vn.itemShelvingSale - SET id = 991, - itemShelvingFk = 9962, - saleFk = 99996, - quantity = 5, + SET id = 991, + itemShelvingFk = 9962, + saleFk = 99996, + quantity = 5, userFk = 1; UPDATE vn.ticket @@ -3734,4 +3734,4 @@ UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5; INSERT INTO vn.report (name) VALUES ('LabelCollection'); INSERT INTO vn.parkingLog(originFk, userFk, `action`, creationDate, description, changedModel,oldInstance, newInstance, changedModelId, changedModelValue) - VALUES(1, 18, 'update', util.VN_CURDATE(), NULL, 'SaleGroup', '{"parkingFk":null}', '{"parkingFk":1}', 1, NULL); \ No newline at end of file + VALUES(1, 18, 'update', util.VN_CURDATE(), NULL, 'SaleGroup', '{"parkingFk":null}', '{"parkingFk":1}', 1, NULL); diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 6c9152ec7..99b189d5c 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -4,8 +4,8 @@ INSERT IGNORE INTO util.notification ( `name`,`description`) SET @MaxId = LAST_INSERT_ID(); INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( - @MaxId, (SELECT id from `account`.`user` where name = "system")); + @MaxId, (SELECT id from `account`.`user` where name = "root")); INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk) - SELECT @MaxId, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; + SELECT @MaxId, (SELECT id from `account`.`role` where name = "root") FROM util.notification WHERE name= "zone-included"; From f2f6e7be0b5354d041fe3c746fcf572ea06c7c3e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 13:29:53 +0100 Subject: [PATCH 090/136] refs #6930 perf: parallel calls --- front/core/services/auth.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index e51a2ff12..8727f92bc 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -98,20 +98,19 @@ export default class Auth { } logout() { - this.$http.post('VnUsers/logoutMultimedia', null, {headers: {'Authorization': this.vnToken.tokenMultimedia}, - }).then(({data}) => { - if (data) { - this.$http.post('VnUsers/logout', null, { - headers: {Authorization: this.vnToken.token} - }).catch(() => {}); - - this.vnToken.unset(); - this.loggedIn = false; - this.vnModules.reset(); - this.aclService.reset(); - this.$state.go('login'); - } + this.$http.post('Accounts/logout', null, {headers: {'Authorization': this.vnToken.tokenMultimedia}, }); + + let promise = this.$http.post('VnUsers/logout', null, { + headers: {Authorization: this.vnToken.token} + }).catch(() => {}); + this.vnToken.unset(); + this.loggedIn = false; + this.vnModules.reset(); + this.aclService.reset(); + this.$state.go('login'); + + return promise; } loadAcls() { From c84e86270c8c910903f26f2311883b9771d38a19 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 13:30:32 +0100 Subject: [PATCH 091/136] refs #6930 perf: remove logoutMultimedia method --- back/models/vn-user.js | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 473e619db..b59f13ffa 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -31,32 +31,6 @@ module.exports = function(Self) { message: `A client with that Web User name already exists` }); - Self.remoteMethod('logoutMultimedia', { - description: 'Logout current MultimediaToken', - accepts: [{ - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }], - returns: { - type: 'Boolean', - root: true - }, - http: { - verb: 'POST', - path: '/logoutMultimedia' - }, - accessScopes: ['read:multimedia'] - }); - Self.logoutMultimedia = async function(ctx) { - let {accessToken} = ctx.req; - try { - Self.logout(accessToken.id); - return true; - } catch (error) { - return error; - } - }; Self.remoteMethod('getCurrentUserData', { description: 'Gets the current user data', accepts: [ From ff6a1a91110905c2a25fc8531be2ee831620101d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 13:39:01 +0100 Subject: [PATCH 092/136] refs #6930 perf: remove logoutMultimedia acl --- db/versions/10919-brownMoss/00-firstScript.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/versions/10919-brownMoss/00-firstScript.sql b/db/versions/10919-brownMoss/00-firstScript.sql index a6abdbe79..640d2180a 100644 --- a/db/versions/10919-brownMoss/00-firstScript.sql +++ b/db/versions/10919-brownMoss/00-firstScript.sql @@ -1,5 +1,3 @@ -- Place your SQL code here -INSERT IGNORE INTO `salix`.`ACL`(`model`,`property`,`accessType`,`permission`, `principalType`, `principalId`) -VALUES -('VnUser','logoutMultimedia','*','ALLOW','ROLE','employee') + From 99f01a1dbd165bc89eee52dc2bbd66a0dde54de3 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Mar 2024 13:39:21 +0100 Subject: [PATCH 093/136] refs #6930 perf: add accessScopes to account.logout --- modules/account/back/methods/account/logout.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/account/back/methods/account/logout.js b/modules/account/back/methods/account/logout.js index 5db3efa33..7d2e8153e 100644 --- a/modules/account/back/methods/account/logout.js +++ b/modules/account/back/methods/account/logout.js @@ -15,7 +15,8 @@ module.exports = Self => { http: { path: `/logout`, verb: 'POST' - } + }, + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.logout = async ctx => Self.app.models.VnUser.logout(ctx.req.accessToken.id); From 8276765225980861bb1ca2e6b46ac59b97d5035b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 11:54:02 +0100 Subject: [PATCH 094/136] refs #5858 perf: destinationFk to pepe --- db/versions/10881-greenHydrangea/01-notification.vn.sql | 7 ++++--- print/templates/email/zone-included/locale/es.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 99b189d5c..448435749 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -1,11 +1,12 @@ INSERT IGNORE INTO util.notification ( `name`,`description`) VALUES ( 'zone-included','An email to notify zoneCollisions'); + SET @MaxId = LAST_INSERT_ID(); + INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( - @MaxId, (SELECT id from `account`.`user` where name = "root")); - + @MaxId, (SELECT id from `account`.`user` where name = "pepe")); INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk) - SELECT @MaxId, (SELECT id from `account`.`role` where name = "root") FROM util.notification WHERE name= "zone-included"; + SELECT @MaxId, (SELECT role from `account`.`user` where name = "pepe") FROM util.notification WHERE name= "zone-included"; diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml index 974253ddc..cb35a55cc 100644 --- a/print/templates/email/zone-included/locale/es.yml +++ b/print/templates/email/zone-included/locale/es.yml @@ -1,4 +1,4 @@ -subject: Colisión de zona detectada +subject: Colisiones en zonas title: "La zona {0} y localización {1} ha sido registrada en más de un sitio" postalCode: C. Postal zoneFk: Número de zona From 172e7566b53e70741afa01b45c3bd495cc2ba9a2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 11:58:25 +0100 Subject: [PATCH 095/136] refs #5858 perf: improve insert --- db/versions/10881-greenHydrangea/01-notification.vn.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 448435749..56ed069f4 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -1,12 +1,14 @@ INSERT IGNORE INTO util.notification ( `name`,`description`) VALUES -( 'zone-included','An email to notify zoneCollisions'); + ( 'zone-included','An email to notify zoneCollisions'); + +SET @DESTINATION_USER = "pepe"; SET @MaxId = LAST_INSERT_ID(); INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk) VALUES( - @MaxId, (SELECT id from `account`.`user` where name = "pepe")); + @MaxId, (SELECT id from `account`.`user` where name = @DESTINATION_USER)); INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk) - SELECT @MaxId, (SELECT role from `account`.`user` where name = "pepe") FROM util.notification WHERE name= "zone-included"; + SELECT @MaxId, (SELECT role from `account`.`user` where name = @DESTINATION_USER) FROM util.notification WHERE name= "zone-included"; From 25f979156ade5b2fe7afe9fcd103f0a2fe183c1c Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Mar 2024 14:00:59 +0100 Subject: [PATCH 096/136] nuevo url para catalogue y sliders_get --- .../floranet/procedures/catalogue_get.sql | 2 +- ...ontact_Request.sql => contact_request.sql} | 4 ++-- .../floranet/procedures/sliders_get.sql | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) rename db/routines/floranet/procedures/{contact_Request.sql => contact_request.sql} (68%) create mode 100644 db/routines/floranet/procedures/sliders_get.sql diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index 914b5d27f..b6ec61522 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -36,7 +36,7 @@ BEGIN vLanded, vPostalCode, it.name, - i.image, + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), i.description FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_request.sql similarity index 68% rename from db/routines/floranet/procedures/contact_Request.sql rename to db/routines/floranet/procedures/contact_request.sql index 7673c2203..044c22c6f 100644 --- a/db/routines/floranet/procedures/contact_Request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -1,9 +1,9 @@ -DROP PROCEDURE IF EXISTS floranet.contact_Request; +DROP PROCEDURE IF EXISTS floranet.contact_request; DELIMITER $$ $$ CREATE DEFINER=`root`@`localhost` -PROCEDURE floranet.contact_Request( +PROCEDURE floranet.contact_request( vName VARCHAR(100), vPhone VARCHAR(15), vEmail VARCHAR(100), diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql new file mode 100644 index 000000000..2f77b8534 --- /dev/null +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -0,0 +1,19 @@ +DROP PROCEDURE IF EXISTS floranet.sliders_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get() +READS SQL DATA +BEGIN +/** + * Returns list of url for sliders + */ + SELECT + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, + i.longName + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP'); + +END$$ +DELIMITER ; \ No newline at end of file From 67b55ae845b7843038032038f57f7a37aceafbaf Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Mar 2024 14:16:27 +0100 Subject: [PATCH 097/136] fixtures local --- db/.gitignore | 2 +- db/dump/fixtures.local.sql | 406 +++++++++++++++++++++++++++++++++++++ 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 db/dump/fixtures.local.sql diff --git a/db/.gitignore b/db/.gitignore index 54ed9df77..231f0dfe0 100644 --- a/db/.gitignore +++ b/db/.gitignore @@ -4,7 +4,7 @@ remotes/*.ini !remotes/local.ini !remotes/docker.ini dump/.changes -dump/fixtures.local.sql +#dump/fixtures.local.sql .dBeaver .idea .project diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql new file mode 100644 index 000000000..64d22f480 --- /dev/null +++ b/db/dump/fixtures.local.sql @@ -0,0 +1,406 @@ +-- XXX: floranet + +INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNR', 'Floranet Ramos', 1, 1); + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNP', 'Floranet Plantas', 1, 1); + +-- Generación de items +SELECT id + INTO @FNR + FROM vn.itemType + WHERE code = 'FNR'; + +SELECT id + INTO @FNP + FROM vn.itemType + WHERE code = 'FNP'; + +DELETE + FROM vn.item + WHERE typeFk IN (@FNR,@FNP); + +INSERT INTO vn.item + ( + id, + name, + longName, + `size`, + originFk, + intrastatFk, + typeFk, + inkFk, + image, + description + ) + VALUES + ( + 147791, + @r := 'Ramo Terranova', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147791', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', + 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', + 'paniculata eucaliptus.') + ), + ( + 147792, + @r := 'Ramo Tasmania', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147792', + CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', + 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', + 'flores será un acierto seguro para hacer un regalo muy especial.') + ), + ( + 147793, + @r := 'Ramo Pasion', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147793', + CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', + 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', + 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', + 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', + 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') + ), + ( + 147794, + @r := 'Ramo Florencia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147794', + CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', + 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', + 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', + 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') + ), + ( + 147795, + @r := 'Ramo Atardecer', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink WHERE name = 'Yellow'), + '147795', + CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', + 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', + 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', + 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', + 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') + ), + ( + 147796, + @r := 'Ramo Arcoíris', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147796', + CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', + 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', + 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', + 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', + 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', + 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') + ), + ( + 147797, + @r := 'Ramo Provenza', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147797', + CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', + 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', + 'con una selección de maravillosos verdes variados, hacen que esta combinación ', + 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') + ), + ( + 147798, + @r := 'Ramo Alegria', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147798', + CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', + 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', + ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', + 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', + 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') + ), + ( + 147799, + @r := 'Planta Orquídeas ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147799', + CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', + 'con las mejores características combinadas con diferentes elementos de ', + 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', + 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', + 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', + 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') + ), + ( + 147800, + @r := 'Planta Kentia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147800', + CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', + 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', + 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', + 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', + 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', + 'de ser un producto nacional producido en Canarias de una calidad extrema.') + ), + ( + 147801, + @r := 'Planta Calathea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147801', + CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', + ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', + 'llamativo y original colorido, tambien es un regalo perfecto para ', + 'cualquier compromiso que tengamos .') + ), + ( + 147802, + @r := 'Planta Anthurium ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink WHERE name = 'Red'), + '147802', + CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', + 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', + 'su llamativo color alegrará cualquier celebración') + ), + ( + 147803, + @r := 'Ramo Mindanao', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147803', + CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', + 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', + 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') + ), + ( + 147804, + @r := 'Ramo Guinea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147804', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', + ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') + ), + ( + 147805, + @r := 'Ramo Eterno', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147805', + CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', + 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', + 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', + 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', + 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', + 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') + ), + ( + 147806, + @r := 'Ramo Cielo', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147806', + CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', + 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', + ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', + 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', + ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', + 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', + 'clara de todo el conjunto. ') + ); + + -- Ramo Terranova: 1er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Rosa roja', + @r, + 60, + 1, + 'RED', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 12 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + -- Ramo Terranova: 2º elemento + +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Hoja de helecho', + @r, + 60, + 1, + 'BAS', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 4 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- Ramo Terranova: 3er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Paniculata', + @r, + 60, + 1, + 'SLV', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 5 + FROM vn.item + WHERE name = 'Ramo Terranova'; + From 4012b1756d48a308eb6af82de77378261143f70b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 15:00:12 +0100 Subject: [PATCH 098/136] refs #5858 add comment --- db/versions/10881-greenHydrangea/01-notification.vn.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/versions/10881-greenHydrangea/01-notification.vn.sql b/db/versions/10881-greenHydrangea/01-notification.vn.sql index 56ed069f4..ab5480548 100644 --- a/db/versions/10881-greenHydrangea/01-notification.vn.sql +++ b/db/versions/10881-greenHydrangea/01-notification.vn.sql @@ -2,6 +2,7 @@ INSERT IGNORE INTO util.notification ( `name`,`description`) VALUES ( 'zone-included','An email to notify zoneCollisions'); +-- Change value if destionation user should be different SET @DESTINATION_USER = "pepe"; SET @MaxId = LAST_INSERT_ID(); From f09283b9c90ab501bc703395c90f99087d57b1a7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 15:44:16 +0100 Subject: [PATCH 099/136] refs #5858 perf: html --- .../email/zone-included/zone-included.html | 54 +++++++++++-------- .../email/zone-included/zone-included.js | 4 +- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index 0381cc8c4..78915faad 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,16 +1,24 @@ - -
-
- - - - - - - - - - + + + + + + + + +
{{ $t('postalCode') }}{{ $t('zoneFk') }}{{ $t('price') }}{{ $t('zone') }}{{ $t('warehouse') }}Salix
+ + + + + + + + + + + + @@ -22,13 +30,13 @@ '/location?q=%7B%22search%22:%22'+ zone.zn.name+ '%22%7D'"> - 'https://salix.verdnatura.es/#!/zone/'+ - {{zone.zoneFk}}+ - '/location?q=%7B%22search%22:%22'+ - {{zone.zn.name}}+ - '%22%7D - -
{{ $t('postalCode') }}{{ $t('zoneFk') }}{{ $t('price') }}{{ $t('zone') }}{{ $t('warehouse') }}
{{ zone.zn.name }} {{ zone.zoneFk }} {{ zone.z.price }}
-
-
-
+ https://salix.verdnatura.es/#!/zone/ + {{zone.zoneFk}} + /location?q=%7B%22search%22:%22 + {{zone.zn.name}} + %22%7D
+ + + + + diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index 7e23ee2f0..4de4777f3 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -1,10 +1,10 @@ const Component = require(`vn-print/core/component`); -const emailBody = new Component('email-body'); +const emailHeader = new Component('email-header'); module.exports = { name: 'zone-included', components: { - 'email-body': emailBody.build(), + 'email-header': emailHeader.build(), }, props: { zoneCollisions: {type: Array, required: true} From e24eed16c1b3240cd1bbb80010c7cbb08af0768f Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 14 Mar 2024 08:26:50 +0100 Subject: [PATCH 100/136] refs #6842 fix companyCode --- db/versions/10893-limeFern/00-sage.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 01508b932..d4c7e6221 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -3,7 +3,13 @@ UPDATE vn.company SET companyCode=0 WHERE id=69; UPDATE vn.company - SET companyCode=0 + SET companyCode=1 + WHERE id=442; +UPDATE vn.company + SET companyCode=4 + WHERE id=567; +UPDATE vn.company + SET companyCode=2 WHERE id=791; UPDATE vn.company SET companyCode=3 @@ -17,6 +23,9 @@ UPDATE vn.company UPDATE vn.company SET companyCode=3 WHERE id=1463; +UPDATE vn.company + SET companyCode=8 + WHERE id=2142; UPDATE vn.company SET companyCode=6 WHERE id=2393; From fbeb9b058d4ca6367b4e003142b29c4ec09ffb5c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Mar 2024 09:34:37 +0100 Subject: [PATCH 101/136] hotfix: itemProposal added optimizer_search_depth --- db/routines/vn/procedures/itemProposal.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/itemProposal.sql b/db/routines/vn/procedures/itemProposal.sql index 0dc04124d..da9e757aa 100644 --- a/db/routines/vn/procedures/itemProposal.sql +++ b/db/routines/vn/procedures/itemProposal.sql @@ -18,21 +18,17 @@ BEGIN DECLARE vCalcFk INT; DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped FROM ticket WHERE id = vTicketFk; - START TRANSACTION; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped); + SET @_optimizer_search_depth = @@optimizer_search_depth; + SET SESSION optimizer_search_depth = 0; + WITH itemTags AS ( SELECT i.id, typeFk, @@ -99,6 +95,7 @@ BEGIN match7 DESC, (i.tag8 = its.tag8) DESC, match8 DESC; - COMMIT; + + SET SESSION optimizer_search_depth = @_optimizer_search_depth; END$$ DELIMITER ; From 184a3a3c7a453a1337e171d02970ecce9fb32db1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Mar 2024 10:05:25 +0100 Subject: [PATCH 102/136] refs #6395 Requested changes --- db/routines/vn/triggers/buy_beforeInsert.sql | 9 ++++++++- db/routines/vn/triggers/buy_beforeUpdate.sql | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index c698e23e6..a05f2810b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -9,6 +9,7 @@ trig: BEGIN DECLARE vGroupingMode TINYINT; DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; + DECLARE vBuyerFk INT; IF @isModeInventory THEN LEAVE trig; @@ -19,7 +20,13 @@ trig: BEGIN END IF; SET NEW.editorFk = account.myUser_getId(); - SET NEW.buyerFk = NEW.editorFk; + + SELECT it.workerFk INTO vBuyerFk + FROM item i + JOIN itemType it ON it.id = i.typeFk + WHERE i.id = NEW.itemFk; + + SET NEW.buyerFk = vBuyerFk; CALL buy_checkGrouping(NEW.`grouping`); diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index b41418bcc..40e0df984 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -7,6 +7,7 @@ trig:BEGIN DECLARE vGenericInDate BOOL; DECLARE vIsInventory BOOL; DECLARE vDefaultEntry INT; + DECLARE vBuyerFk INT; IF @isTriggerDisabled THEN LEAVE trig; @@ -66,7 +67,12 @@ trig:BEGIN END IF; IF NOT (NEW.itemFk <=> OLD.itemFk) THEN - SET NEW.buyerFk = NEW.editorFk; + SELECT it.workerFk INTO vBuyerFk + FROM item i + JOIN itemType it ON it.id = i.typeFk + WHERE i.id = NEW.itemFk; + + SET NEW.buyerFk = vBuyerFk; END IF; IF NOT (NEW.itemFk <=> OLD.itemFk) OR From a7faf4e325544ad8f8605156dc92555038c925d4 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 14 Mar 2024 13:05:39 +0000 Subject: [PATCH 103/136] refs #6930 perf: logout update --- front/core/services/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 8727f92bc..753bc3fba 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -99,7 +99,7 @@ export default class Auth { logout() { this.$http.post('Accounts/logout', null, {headers: {'Authorization': this.vnToken.tokenMultimedia}, - }); + }).catch(() => {}); let promise = this.$http.post('VnUsers/logout', null, { headers: {Authorization: this.vnToken.token} From 160d72e755ec57372d9b29601910c084f0de19ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 14 Mar 2024 17:02:07 +0100 Subject: [PATCH 104/136] hotfix upload invoiceIn_add.sql error --- db/routines/sage/procedures/invoiceIn_add.sql | 96 ++++--- db/routines/vn/procedures/invoiceIn_add.sql | 234 ------------------ 2 files changed, 64 insertions(+), 266 deletions(-) delete mode 100644 db/routines/vn/procedures/invoiceIn_add.sql diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index a2690deb0..0898d6810 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vI BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas - * + * * @vInvoiceInFk Factura recibida * @vXDiarioFk Id tabla XDiario - */ + */ + DECLARE vInvoiceInOriginalFk INT; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -23,25 +24,25 @@ BEGIN DECLARE vInvoiceTypeInformative VARCHAR(1); DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; - DECLARE vCursor CURSOR FOR + DECLARE vCursor CURSOR FOR SELECT it.taxableBase, CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, it.taxTypeSageFk, tty.isIntracommunity, - tt.ClaveOperacionDefecto + tt.ClaveOperacionDefecto FROM vn.invoiceIn i JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk JOIN taxType tty ON tty.id = t.CodigoIva JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk LEFT JOIN vn.dua d ON d.id = vInvoiceInFk - WHERE i.id = vInvoiceInFk + WHERE i.id = vInvoiceInFk AND d.id IS NULL; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DELETE FROM movContaIVA WHERE id = vXDiarioFk; @@ -64,22 +65,22 @@ BEGIN vTaxCode, vIsIntracommunity, vOperationCode; - - IF vDone THEN + + IF vDone THEN LEAVE l; END IF; - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; - IF vOperationCode IS NOT NULL THEN + IF vOperationCode IS NOT NULL THEN UPDATE movContaIVA SET ClaveOperacionFactura = vOperationCode WHERE id = vXDiarioFk; END IF; - + SET vCounter = vCounter + 1; - CASE vCounter + CASE vCounter WHEN 1 THEN UPDATE movContaIVA SET BaseIva1 = vBase, @@ -115,31 +116,31 @@ BEGIN WHERE id = vXDiarioFk; ELSE SELECT vXDiarioFk INTO vXDiarioFk; - END CASE; + END CASE; IF vIsIntracommunity THEN UPDATE movContaIVA SET Intracomunitaria = TRUE WHERE id = vXDiarioFk; END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - + + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; + END LOOP; CLOSE vCursor; SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation FROM vn.dua d - LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN + LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci WHERE d.ASIEN = ( SELECT ASIEN - FROM vn.XDiario + FROM vn.XDiario WHERE id = vXDiarioFk) LIMIT 1; - + UPDATE movContaIVA mci JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk JOIN vn.XDiario x ON x.id = mci.id @@ -151,13 +152,13 @@ BEGIN mci.Serie = ii.serial, mci.Factura = ii.id, mci.FechaFactura = ii.issued, - mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + + mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + + IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + + IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, - IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), - IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), + mci.TipoFactura = IF(id.id, + IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), + IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), mci.CodigoCuentaFactura = x.SUBCTA, mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), mci.Nombre = s.name, @@ -185,7 +186,7 @@ BEGIN JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase FROM vn.XDiario x1 JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN - WHERE x2.BASEEURO <> 0 + WHERE x2.BASEEURO <> 0 AND x1.id = vXDiarioFk )sub JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio' @@ -193,10 +194,41 @@ BEGIN mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura), mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase), mci.PorRetencion = t.PorcentajeRetencion, - mci.ImporteRetencion = iit.taxableBase * - 1 - WHERE mci.id = vXDiarioFk + mci.ImporteRetencion = iit.taxableBase * - 1 + WHERE mci.id = vXDiarioFk AND e.name = 'Retenciones' AND id.id IS NULL; + SELECT correctedFk INTO vInvoiceInOriginalFk + FROM vn.invoiceInCorrection + WHERE correctingFk = vInvoiceInFk; + + IF vInvoiceInOriginalFk THEN + + UPDATE movContaIVA mci + JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk + JOIN (SELECT issued, + SUM(sub.taxableBase) taxableBase, + SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat + FROM(SELECT issued, + SUM(iit.taxableBase) taxableBase, + ti.PorcentajeIva + FROM vn.invoiceIn i + JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id + JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + WHERE i.id = vInvoiceInOriginalFk + GROUP BY ti.CodigoIva)sub + )invoiceInOriginal + JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' + SET mci.TipoRectificativa = iir.refundCategoryFk, + mci.ClaseAbonoRectificativas = iir.refundType, + mci.FechaFacturaOriginal = invoiceInOriginal.issued, + mci.FechaOperacion = invoiceInOriginal.issued, + mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, + mci.CuotaIvaOriginal = invoiceInOriginal.vat, + mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ + WHERE mci.id = vXDiarioFk; + + END IF; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/invoiceIn_add.sql b/db/routines/vn/procedures/invoiceIn_add.sql deleted file mode 100644 index 0898d6810..000000000 --- a/db/routines/vn/procedures/invoiceIn_add.sql +++ /dev/null @@ -1,234 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT) -BEGIN -/** - * Traslada la info de contabilidad relacionada con las facturas recibidas - * - * @vInvoiceInFk Factura recibida - * @vXDiarioFk Id tabla XDiario - */ - DECLARE vInvoiceInOriginalFk INT; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vBase DOUBLE; - DECLARE vVat DOUBLE; - DECLARE vRate DOUBLE; - DECLARE vTransactionCode INT; - DECLARE vCounter INT DEFAULT 0; - DECLARE vTransactionCodeOld INT; - DECLARE vTaxCode INT; - DECLARE vTaxCodeOld INT; - DECLARE vOperationCode VARCHAR(1); - DECLARE vIsIntracommunity BOOL DEFAULT FALSE; - DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; - DECLARE vInvoiceTypeReceived VARCHAR(1); - DECLARE vInvoiceTypeInformative VARCHAR(1); - DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; - - DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, - CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), - t.PorcentajeIva, - it.transactionTypeSageFk, - it.taxTypeSageFk, - tty.isIntracommunity, - tt.ClaveOperacionDefecto - FROM vn.invoiceIn i - JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id - JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk - JOIN taxType tty ON tty.id = t.CodigoIva - JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk - LEFT JOIN vn.dua d ON d.id = vInvoiceInFk - WHERE i.id = vInvoiceInFk - AND d.id IS NULL; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DELETE FROM movContaIVA - WHERE id = vXDiarioFk; - - SELECT codeSage INTO vInvoiceTypeReceived - FROM invoiceType WHERE code ='received'; - - SELECT codeSage INTO vInvoiceTypeInformative - FROM invoiceType WHERE code ='informative'; - - INSERT INTO movContaIVA(id, LibreA1) - VALUES (vXDiarioFk, vInvoiceInFk); - - OPEN vCursor; - - l: LOOP - FETCH vCursor INTO vBase, - vVat, - vRate, - vTransactionCode, - vTaxCode, - vIsIntracommunity, - vOperationCode; - - IF vDone THEN - LEAVE l; - END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - - IF vOperationCode IS NOT NULL THEN - UPDATE movContaIVA - SET ClaveOperacionFactura = vOperationCode - WHERE id = vXDiarioFk; - END IF; - - SET vCounter = vCounter + 1; - CASE vCounter - WHEN 1 THEN - UPDATE movContaIVA - SET BaseIva1 = vBase, - PorIva1 = vRate, - CuotaIva1 = vVat, - CodigoTransaccion1 = vTransactionCode, - CodigoIva1 = vTaxCode - WHERE id = vXDiarioFk; - - WHEN 2 THEN - UPDATE movContaIVA - SET BaseIva2 = vBase, - PorIva2 = vRate, - CuotaIva2 = vVat, - CodigoTransaccion2 = vTransactionCode, - CodigoIva2 = vTaxCode - WHERE id = vXDiarioFk; - WHEN 3 THEN - UPDATE movContaIVA - SET BaseIva3 = vBase, - PorIva3 = vRate, - CuotaIva3 = vVat, - CodigoTransaccion3 = vTransactionCode, - CodigoIva3 = vTaxCode - WHERE id = vXDiarioFk; - WHEN 4 THEN - UPDATE movContaIVA - SET BaseIva4 = vBase, - PorIva4 = vRate, - CuotaIva4 = vVat, - CodigoTransaccion4 = vTransactionCode, - CodigoIva4 = vTaxCode - WHERE id = vXDiarioFk; - ELSE - SELECT vXDiarioFk INTO vXDiarioFk; - END CASE; - - IF vIsIntracommunity THEN - UPDATE movContaIVA - SET Intracomunitaria = TRUE - WHERE id = vXDiarioFk; - END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - - END LOOP; - - CLOSE vCursor; - - SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation - FROM vn.dua d - LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN - AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci - WHERE d.ASIEN = ( - SELECT ASIEN - FROM vn.XDiario - WHERE id = vXDiarioFk) - LIMIT 1; - - UPDATE movContaIVA mci - JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk - JOIN vn.XDiario x ON x.id = mci.id - LEFT JOIN tmp.invoiceDua id ON id.id = mci.id - JOIN vn.supplier s ON s.id = ii.supplierFk - JOIN Naciones n ON n.countryFk = s.countryFk - SET mci.CodigoDivisa = ii.currencyFk, - mci.Año = YEAR(ii.issued), - mci.Serie = ii.serial, - mci.Factura = ii.id, - mci.FechaFactura = ii.issued, - mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + - IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, - IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), - IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), - mci.CodigoCuentaFactura = x.SUBCTA, - mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), - mci.Nombre = s.name, - mci.SiglaNacion = n.SiglaNacion, - mci.EjercicioFactura = YEAR(ii.issued), - mci.FechaOperacion = ii.issued, - mci.MantenerAsiento = TRUE, - mci.SuFacturaNo = ii.supplierRef, - mci.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.FechaFacturaOriginal = x.FECHA_EX - WHERE mci.id = vXDiarioFk; - - -- RETENCIONES - UPDATE movContaIVA mci - JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk - JOIN vn.XDiario x ON x.id = mci.id - JOIN vn.supplier s ON s.id = supplierFk - JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN vn.expense e ON e.id = iit.expenseFk - JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk - LEFT JOIN tmp.invoiceDua id ON id.id = mci.id - JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase - FROM vn.XDiario x1 - JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN - WHERE x2.BASEEURO <> 0 - AND x1.id = vXDiarioFk - )sub - JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio' - SET mci.CodigoRetencion = t.CodigoRetencion, - mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura), - mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase), - mci.PorRetencion = t.PorcentajeRetencion, - mci.ImporteRetencion = iit.taxableBase * - 1 - WHERE mci.id = vXDiarioFk - AND e.name = 'Retenciones' - AND id.id IS NULL; - - SELECT correctedFk INTO vInvoiceInOriginalFk - FROM vn.invoiceInCorrection - WHERE correctingFk = vInvoiceInFk; - - IF vInvoiceInOriginalFk THEN - - UPDATE movContaIVA mci - JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk - JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, - SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat - FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, - ti.PorcentajeIva - FROM vn.invoiceIn i - JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk - WHERE i.id = vInvoiceInOriginalFk - GROUP BY ti.CodigoIva)sub - )invoiceInOriginal - JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, - mci.FechaFacturaOriginal = invoiceInOriginal.issued, - mci.FechaOperacion = invoiceInOriginal.issued, - mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, - mci.CuotaIvaOriginal = invoiceInOriginal.vat, - mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ - WHERE mci.id = vXDiarioFk; - - END IF; -END$$ -DELIMITER ; \ No newline at end of file From 690d93542949ff705f4b8093dbaf06297e406f84 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 15 Mar 2024 10:00:24 +0100 Subject: [PATCH 105/136] refactor: refs #6951 cloneAll --- db/routines/vn/procedures/ticket_Clone.sql | 4 +- db/routines/vn/procedures/ticket_CloneAll.sql | 73 ++++++++++--------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/db/routines/vn/procedures/ticket_Clone.sql b/db/routines/vn/procedures/ticket_Clone.sql index cdddd6225..7670e832e 100644 --- a/db/routines/vn/procedures/ticket_Clone.sql +++ b/db/routines/vn/procedures/ticket_Clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT,vWithWarehouse BOOLEAN) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN /** * Clona el contenido de un ticket en otro @@ -32,7 +32,7 @@ BEGIN addressFk, agencyModeFk, nickname, - IF(vWithWarehouse, warehouseFk, NULL), + warehouseFk, companyFk, landed, zoneFk, diff --git a/db/routines/vn/procedures/ticket_CloneAll.sql b/db/routines/vn/procedures/ticket_CloneAll.sql index 4adb50a10..d56a47a33 100644 --- a/db/routines/vn/procedures/ticket_CloneAll.sql +++ b/db/routines/vn/procedures/ticket_CloneAll.sql @@ -2,53 +2,54 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) BEGIN - DECLARE done INT DEFAULT FALSE; + DECLARE done INT DEFAULT FALSE; DECLARE vOldSaleFk INT; - DECLARE vNewSaleFk INT; - - DECLARE cur1 CURSOR FOR + DECLARE vNewSaleFk INT; + + DECLARE cur1 CURSOR FOR SELECT id - FROM vn.sale - WHERE ticketFk = vTicketFk; - + FROM sale + WHERE ticketFk = vTicketFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); - - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse); - - UPDATE vn.ticket + + SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); + + CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse); + + UPDATE ticket SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), - shipped = vNewShipped - WHERE id = vNewTicketFk; - + shipped = vNewShipped, + warehouseFk = IF(vWithWarehouse, warehouseFk, NULL) + WHERE id = vNewTicketFk; + OPEN cur1; - + read_loop: LOOP - FETCH cur1 INTO vOldSaleFk; - - IF done THEN - LEAVE read_loop; - END IF; - - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) + FETCH cur1 INTO vOldSaleFk; + + IF done THEN + LEAVE read_loop; + END IF; + + INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed - FROM vn.sale - WHERE id = vOldSaleFk; - - SELECT max(id) INTO vNewSaleFk - FROM vn.sale - WHERE ticketFk = vNewTicketFk; - - INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) + FROM sale + WHERE id = vOldSaleFk; + + SELECT max(id) INTO vNewSaleFk + FROM sale + WHERE ticketFk = vNewTicketFk; + + INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge) SELECT vNewSaleFk, componentFk, value, isGreuge - FROM vn.saleComponent - WHERE saleFk = vOldSaleFk; - + FROM saleComponent + WHERE saleFk = vOldSaleFk; + END LOOP; CLOSE cur1; - + END$$ DELIMITER ; From aa27eb192231fc5bab816d12f9a22edbac2bc2c1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 10:55:39 +0100 Subject: [PATCH 106/136] refs #6948 Fix error --- db/routines/sage/procedures/pgc_add.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/sage/procedures/pgc_add.sql b/db/routines/sage/procedures/pgc_add.sql index ebcb2d043..78d80a9fe 100644 --- a/db/routines/sage/procedures/pgc_add.sql +++ b/db/routines/sage/procedures/pgc_add.sql @@ -17,13 +17,13 @@ BEGIN e.id accountFk, UCASE(e.name), '' - FROM expense e + FROM vn.expense e UNION SELECT company_getCode(vCompanyFk), a.account, UCASE(a.bank), '' - FROM accounting a + FROM vn.accounting a WHERE a.isActive AND a.`account` UNION From 158ed9b55c30a21f5e82a1bc5b8834443342b78a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 11:49:33 +0100 Subject: [PATCH 107/136] refs #6232 Regularized config tables --- db/dump/fixtures.after.sql | 4 +- db/dump/fixtures.before.sql | 43 +++++------ db/versions/10953-redChico/00-account.sql | 23 ++++++ db/versions/10953-redChico/01-bs.sql | 7 ++ db/versions/10953-redChico/02-edi.sql | 15 ++++ db/versions/10953-redChico/03-hedera.sql | 27 +++++++ db/versions/10953-redChico/04-pbx.sql | 15 ++++ db/versions/10953-redChico/05-sage.sql | 3 + db/versions/10953-redChico/06-salix.sql | 7 ++ db/versions/10953-redChico/06-srt.sql | 3 + db/versions/10953-redChico/07-util.sql | 11 +++ db/versions/10953-redChico/08-vn.sql | 87 ++++++++++++++++++++++ db/versions/10953-redChico/08-vn2.sql | 91 +++++++++++++++++++++++ 13 files changed, 313 insertions(+), 23 deletions(-) create mode 100644 db/versions/10953-redChico/00-account.sql create mode 100644 db/versions/10953-redChico/01-bs.sql create mode 100644 db/versions/10953-redChico/02-edi.sql create mode 100644 db/versions/10953-redChico/03-hedera.sql create mode 100644 db/versions/10953-redChico/04-pbx.sql create mode 100644 db/versions/10953-redChico/05-sage.sql create mode 100644 db/versions/10953-redChico/06-salix.sql create mode 100644 db/versions/10953-redChico/06-srt.sql create mode 100644 db/versions/10953-redChico/07-util.sql create mode 100644 db/versions/10953-redChico/08-vn.sql create mode 100644 db/versions/10953-redChico/08-vn2.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index bda625a96..1c3a4a960 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (environment, mockTime, mockUtcTime, mockEnabled) - VALUES ('local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) VALUES(1, NULL, 1, 300, 1); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8ea0baff2..3cf9cd928 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -60,13 +60,13 @@ INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); -INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) +INSERT INTO `vn`.`bionicConfig` (`id`, `generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) VALUES - (1.30, 167.00, 138000, 71); + (1, 1.30, 167.00, 138000, 71); -INSERT INTO `vn`.`chatConfig` (`host`, `api`) +INSERT INTO `vn`.`chatConfig` (`id`, `host`, `api`) VALUES - ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); + (1, 'https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) VALUES @@ -608,7 +608,8 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion` ('WORLD', 2, 15); INSERT INTO vn.invoiceOutConfig - SET parallelism = 8; + SET id = 1, + parallelism = 8; INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) VALUES @@ -714,7 +715,7 @@ INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) (12, util.VN_CURDATE(), '23:59'), (13, util.VN_CURDATE(), '23:59'); -INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); +INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) VALUES @@ -983,9 +984,9 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00), ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00); -INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`) +INSERT INTO `vn`.`packagingConfig`(`id`, `upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`) VALUES - ('10', 1, 'pallet 100'); + (1, '10', 1, 'pallet 100'); INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) VALUES @@ -1868,8 +1869,7 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) VALUES - (1, 50), - (2, 30); + (1, 50); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -2504,9 +2504,9 @@ INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height VALUES (1, 4, 160, 160); -INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`) +INSERT INTO `vn`.`rateConfig`(`id`, `rate0`, `rate1`, `rate2`, `rate3`) VALUES - (36, 31, 25, 21); + (1, 36, 31, 25, 21); INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`) VALUES @@ -2697,9 +2697,9 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) (4, 33.8, util.VN_CURDATE(), 1, 1101), (30, 34.4, util.VN_CURDATE(), 1, 1108); -INSERT INTO `vn`.`docuwareConfig` (`url`) +INSERT INTO `vn`.`docuwareConfig` (`id`, `url`) VALUES - ('http://docuware.url/'); + (1, 'http://docuware.url/'); INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`) VALUES @@ -2796,11 +2796,12 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) VALUES (1, 'h1', 1, ''); -INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) +INSERT INTO `vn`.`packingSiteConfig` (`id`, `shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) VALUES - ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); + (1, '', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); INSERT INTO `util`.`notificationConfig` - SET `cleanDays` = 90; + SET `id` = 1, + `cleanDays` = 90; INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES @@ -2853,7 +2854,7 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`) VALUES - (0, 0, 24, '', '[1,2,3]', 2, 56, 60); + (1, 0, 24, '', '[1,2,3]', 2, 56, 60); INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) VALUES @@ -2890,7 +2891,7 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES - (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); + (1, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) VALUES @@ -3711,8 +3712,8 @@ UPDATE vn.collection UPDATE vn.sale SET isPicked =FALSE; -INSERT INTO vn.machineWorkerConfig(maxHours) - VALUES(12); +INSERT INTO vn.machineWorkerConfig(id, maxHours) + VALUES(1, 12); INSERT INTO vn.workerAppTester(workerFk) VALUES(66); diff --git a/db/versions/10953-redChico/00-account.sql b/db/versions/10953-redChico/00-account.sql new file mode 100644 index 000000000..e6944a686 --- /dev/null +++ b/db/versions/10953-redChico/00-account.sql @@ -0,0 +1,23 @@ +-- account.accountConfig +ALTER TABLE account.accountConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE account.accountConfig ADD CONSTRAINT accountConfig_check CHECK (id = 1); + +-- account.ldapConfig +ALTER TABLE account.ldapConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.ldapConfig ADD CONSTRAINT ldapConfig_check CHECK (id = 1); + +-- account.mailConfig +ALTER TABLE account.mailConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1); + +-- account.roleConfig +ALTER TABLE account.roleConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.roleConfig ADD CONSTRAINT roleConfig_check CHECK (id = 1); + +-- account.sambaConfig +ALTER TABLE account.sambaConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE account.sambaConfig ADD CONSTRAINT sambaConfig_check CHECK (id = 1); + +-- account.userConfig +ALTER TABLE account.userConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.userConfig ADD CONSTRAINT userConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/01-bs.sql b/db/versions/10953-redChico/01-bs.sql new file mode 100644 index 000000000..e451c8205 --- /dev/null +++ b/db/versions/10953-redChico/01-bs.sql @@ -0,0 +1,7 @@ +-- bs.nightTaskConfig +ALTER TABLE bs.nightTaskConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE bs.nightTaskConfig ADD CONSTRAINT nightTaskConfig_check CHECK (id = 1); + +-- bs.workerProductivityConfig +ALTER TABLE bs.workerProductivityConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE bs.workerProductivityConfig ADD CONSTRAINT workerProductivityConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/02-edi.sql b/db/versions/10953-redChico/02-edi.sql new file mode 100644 index 000000000..e97cfcec8 --- /dev/null +++ b/db/versions/10953-redChico/02-edi.sql @@ -0,0 +1,15 @@ +-- edi.exchangeConfig +ALTER TABLE edi.exchangeConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE edi.exchangeConfig ADD CONSTRAINT exchangeConfig_check CHECK (id = 1); + +-- edi.ftpConfig +ALTER TABLE edi.ftpConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE edi.ftpConfig ADD CONSTRAINT ftpConfig_check CHECK (id = 1); + +-- edi.imapConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE edi.imapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +-- ALTER TABLE edi.imapConfig ADD CONSTRAINT imapConfig_check CHECK (id = 1); + +-- edi.offerRefreshConfig +ALTER TABLE edi.offerRefreshConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE edi.offerRefreshConfig ADD CONSTRAINT offerRefreshConfig_check CHECK (id = 1); \ No newline at end of file diff --git a/db/versions/10953-redChico/03-hedera.sql b/db/versions/10953-redChico/03-hedera.sql new file mode 100644 index 000000000..3c86fb593 --- /dev/null +++ b/db/versions/10953-redChico/03-hedera.sql @@ -0,0 +1,27 @@ +-- hedera.config +ALTER TABLE hedera.config MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- hedera.imageConfig +ALTER TABLE hedera.imageConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.imageConfig ADD CONSTRAINT imageConfig_check CHECK (id = 1); + +-- hedera.mailConfig +ALTER TABLE hedera.mailConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1); + +-- hedera.orderConfig +ALTER TABLE hedera.orderConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE hedera.orderConfig ADD CONSTRAINT orderConfig_check CHECK (id = 1); + +-- hedera.shelfConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE hedera.shelfConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE hedera.shelfConfig ADD CONSTRAINT shelfConfig_check CHECK (id = 1); + +-- hedera.tpvConfig +ALTER TABLE hedera.tpvConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.tpvConfig ADD CONSTRAINT tpvConfig_check CHECK (id = 1); + +-- hedera.tpvImapConfig +ALTER TABLE hedera.tpvImapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.tpvImapConfig ADD CONSTRAINT tpvImapConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/04-pbx.sql b/db/versions/10953-redChico/04-pbx.sql new file mode 100644 index 000000000..7ca0e6103 --- /dev/null +++ b/db/versions/10953-redChico/04-pbx.sql @@ -0,0 +1,15 @@ +-- pbx.config +ALTER TABLE pbx.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- pbx.followmeConfig +ALTER TABLE pbx.followmeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.followmeConfig ADD CONSTRAINT followmeConfig_check CHECK (id = 1); + +-- pbx.queueConfig +ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); + +-- pbx.sipConfig +ALTER TABLE pbx.sipConfig MODIFY COLUMN id mediumint(8) unsigned NOT NULL; +ALTER TABLE pbx.sipConfig ADD CONSTRAINT sipConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/05-sage.sql b/db/versions/10953-redChico/05-sage.sql new file mode 100644 index 000000000..ee60f5f7d --- /dev/null +++ b/db/versions/10953-redChico/05-sage.sql @@ -0,0 +1,3 @@ +-- sage.config +ALTER TABLE sage.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE sage.config ADD CONSTRAINT config_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/06-salix.sql b/db/versions/10953-redChico/06-salix.sql new file mode 100644 index 000000000..d6a248f0d --- /dev/null +++ b/db/versions/10953-redChico/06-salix.sql @@ -0,0 +1,7 @@ +-- salix.accessTokenConfig +ALTER TABLE salix.accessTokenConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE salix.accessTokenConfig ADD CONSTRAINT accessTokenConfig_check CHECK (id = 1); + +-- salix.printConfig +ALTER TABLE salix.printConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE salix.printConfig ADD CONSTRAINT printConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/06-srt.sql b/db/versions/10953-redChico/06-srt.sql new file mode 100644 index 000000000..53000eee6 --- /dev/null +++ b/db/versions/10953-redChico/06-srt.sql @@ -0,0 +1,3 @@ +-- srt.config +ALTER TABLE srt.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE srt.config ADD CONSTRAINT config_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/07-util.sql b/db/versions/10953-redChico/07-util.sql new file mode 100644 index 000000000..152dce3d1 --- /dev/null +++ b/db/versions/10953-redChico/07-util.sql @@ -0,0 +1,11 @@ +-- util.config +ALTER TABLE util.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- util.notificationConfig +ALTER TABLE util.notificationConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.notificationConfig ADD CONSTRAINT notificationConfig_check CHECK (id = 1); + +-- util.versionConfig +ALTER TABLE util.versionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.versionConfig ADD CONSTRAINT versionConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/08-vn.sql b/db/versions/10953-redChico/08-vn.sql new file mode 100644 index 000000000..5d5637651 --- /dev/null +++ b/db/versions/10953-redChico/08-vn.sql @@ -0,0 +1,87 @@ +-- vn.accountingConfig +ALTER TABLE vn.accountingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.accountingConfig ADD CONSTRAINT accountingConfig_check CHECK (id = 1); + +-- vn.auctionConfig +ALTER TABLE vn.auctionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.auctionConfig ADD CONSTRAINT auctionConfig_check CHECK (id = 1); + +-- vn.autoRadioConfig +ALTER TABLE vn.autoRadioConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.autoRadioConfig ADD CONSTRAINT autoRadioConfig_check CHECK (id = 1); + +-- vn.bankEntityConfig +ALTER TABLE vn.bankEntityConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.bankEntityConfig ADD CONSTRAINT bankEntityConfig_check CHECK (id = 1); + +-- vn.bionicConfig +ALTER TABLE vn.bionicConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.bionicConfig ADD CONSTRAINT bionicConfig_check CHECK (id = 1); + +-- vn.buyConfig +ALTER TABLE vn.buyConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.buyConfig ADD CONSTRAINT buyConfig_check CHECK (id = 1); + +-- vn.chatConfig +ALTER TABLE vn.chatConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.chatConfig ADD CONSTRAINT chatConfig_check CHECK (id = 1); + +-- vn.claimConfig +ALTER TABLE vn.claimConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.claimConfig ADD CONSTRAINT claimConfig_check CHECK (id = 1); + +-- vn.clientConfig +ALTER TABLE vn.clientConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientConfig_check CHECK (id = 1); + +-- vn.comparativeAddConfig +ALTER TABLE vn.comparativeAddConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.comparativeAddConfig ADD CONSTRAINT comparativeAddConfig_check CHECK (id = 1); + +-- vn.comparativeConfig +ALTER TABLE vn.comparativeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.comparativeConfig ADD CONSTRAINT comparativeConfig_check CHECK (id = 1); + +-- vn.config +ALTER TABLE vn.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- vn.conveyorConfig +ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); + +-- vn.deviceProductionConfig +ALTER TABLE vn.deviceProductionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.deviceProductionConfig ADD CONSTRAINT deviceProductionConfig_check CHECK (id = 1); + +-- vn.docuwareConfig +ALTER TABLE vn.docuwareConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.docuwareConfig ADD CONSTRAINT docuwareConfig_check CHECK (id = 1); + +-- vn.floramondoConfig +ALTER TABLE vn.floramondoConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.floramondoConfig ADD CONSTRAINT floramondoConfig_check CHECK (id = 1); + +-- vn.franceExpressConfig +ALTER TABLE vn.franceExpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.franceExpressConfig ADD CONSTRAINT franceExpressConfig_check CHECK (id = 1); + +-- vn.glsConfig +ALTER TABLE vn.glsConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.glsConfig ADD CONSTRAINT glsConfig_check CHECK (id = 1); + +-- vn.greugeConfig +ALTER TABLE vn.greugeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.greugeConfig ADD CONSTRAINT greugeConfig_check CHECK (id = 1); + +-- vn.inventoryConfig +ALTER TABLE vn.inventoryConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.inventoryConfig ADD CONSTRAINT inventoryConfig_check CHECK (id = 1); + +-- vn.invoiceInConfig +ALTER TABLE vn.invoiceInConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.invoiceInConfig ADD CONSTRAINT invoiceInConfig_check CHECK (id = 1); + +-- vn.invoiceOutConfig +ALTER TABLE vn.invoiceOutConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.invoiceOutConfig ADD CONSTRAINT invoiceOutConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/08-vn2.sql b/db/versions/10953-redChico/08-vn2.sql new file mode 100644 index 000000000..42985365e --- /dev/null +++ b/db/versions/10953-redChico/08-vn2.sql @@ -0,0 +1,91 @@ +-- vn.invoiceOutTaxConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE vn.invoiceOutTaxConfig ADD CONSTRAINT invoiceOutTaxConfig_check CHECK (id = 1); + +-- vn.itemConfig +ALTER TABLE vn.itemConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.itemConfig ADD CONSTRAINT itemConfig_check CHECK (id = 1); + +-- vn.machineWorkerConfig +ALTER TABLE vn.machineWorkerConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.machineWorkerConfig ADD CONSTRAINT machineWorkerConfig_check CHECK (id = 1); + +-- vn.mdbConfig +ALTER TABLE vn.mdbConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.mdbConfig ADD CONSTRAINT mdbConfig_check CHECK (id = 1); + +-- vn.mrwConfig +ALTER TABLE vn.mrwConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.mrwConfig ADD CONSTRAINT mrwConfig_check CHECK (id = 1); + +-- vn.osTicketConfig +ALTER TABLE vn.osTicketConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.osTicketConfig ADD CONSTRAINT osTicketConfig_check CHECK (id = 1); + +-- vn.packagingConfig +ALTER TABLE vn.packagingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.packagingConfig ADD CONSTRAINT packagingConfig_check CHECK (id = 1); + +-- vn.packingSiteConfig +ALTER TABLE vn.packingSiteConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.packingSiteConfig ADD CONSTRAINT packingSiteConfig_check CHECK (id = 1); + +-- vn.productionConfig +ALTER TABLE vn.productionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_check CHECK (id = 1); + +-- vn.rateConfig +ALTER TABLE vn.rateConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.rateConfig ADD CONSTRAINT rateConfig_check CHECK (id = 1); + +-- vn.routeConfig +ALTER TABLE vn.routeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.routeConfig ADD CONSTRAINT routeConfig_check CHECK (id = 1); + +-- vn.salespersonConfig +ALTER TABLE vn.salespersonConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.salespersonConfig ADD CONSTRAINT salespersonConfig_check CHECK (id = 1); + +-- vn.sendingConfig +ALTER TABLE vn.sendingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.sendingConfig ADD CONSTRAINT sendingConfig_check CHECK (id = 1); + +-- vn.smsConfig +ALTER TABLE vn.smsConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.smsConfig ADD CONSTRAINT smsConfig_check CHECK (id = 1); + +-- vn.ticketConfig +ALTER TABLE vn.ticketConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_check CHECK (id = 1); + +-- vn.tillConfig +ALTER TABLE vn.tillConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.tillConfig ADD CONSTRAINT tillConfig_check CHECK (id = 1); + +-- vn.travelConfig +ALTER TABLE vn.travelConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_check CHECK (id = 1); + +-- vn.viaexpressConfig +ALTER TABLE vn.viaexpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.viaexpressConfig ADD CONSTRAINT viaexpressConfig_check CHECK (id = 1); + +-- vn.wagonConfig +ALTER TABLE vn.wagonConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_check CHECK (id = 1); + +-- vn.workerConfig +ALTER TABLE vn.workerConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.workerConfig ADD CONSTRAINT workerConfig_check CHECK (id = 1); + +-- vn.workerTimeControlConfig +ALTER TABLE vn.workerTimeControlConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.workerTimeControlConfig ADD CONSTRAINT workerTimeControlConfig_check CHECK (id = 1); + +-- vn.zipConfig +ALTER TABLE vn.zipConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.zipConfig ADD CONSTRAINT zipConfig_check CHECK (id = 1); + +-- vn.zoneConfig +ALTER TABLE vn.zoneConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.zoneConfig ADD CONSTRAINT zoneConfig_check CHECK (id = 1); From 086721157380615d755dc91581671e69562217d2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 12:38:33 +0100 Subject: [PATCH 108/136] refs #6403 Fix model mrwConfig --- back/methods/mrw-config/specs/createShipment.spec.js | 1 + back/models/mrw-config.json | 1 + 2 files changed, 2 insertions(+) diff --git a/back/methods/mrw-config/specs/createShipment.spec.js b/back/methods/mrw-config/specs/createShipment.spec.js index e7bba524a..0f48bc2d3 100644 --- a/back/methods/mrw-config/specs/createShipment.spec.js +++ b/back/methods/mrw-config/specs/createShipment.spec.js @@ -49,6 +49,7 @@ describe('MRWConfig createShipment()', () => { await models.MrwConfig.create( { + 'id': 1, 'url': 'https://url.com', 'user': 'user', 'password': 'password', diff --git a/back/models/mrw-config.json b/back/models/mrw-config.json index f0cf799b1..50cf7e8fc 100644 --- a/back/models/mrw-config.json +++ b/back/models/mrw-config.json @@ -9,6 +9,7 @@ "properties": { "id": { "type": "number", + "id": true, "required": true }, "url": { From 0f4377ff5dfca79370ae545123e772229952aab9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 15 Mar 2024 13:31:51 +0100 Subject: [PATCH 109/136] refs #5858 test: fixtures --- db/dump/fixtures.before.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 919aac7a8..91be977cb 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2821,7 +2821,7 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (4, 1), (5, 9), (6, 9), - (7, 100); + (7, 9); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2839,7 +2839,7 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (1, 9), (1, 3), (6, 9), - (7, 100); + (7, 9); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES From 3aa81d27e746f8caf7b9de17dc7d1645d94a8de2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 14:53:31 +0100 Subject: [PATCH 110/136] refs #6875 Packing default 1 --- db/versions/10892-yellowGerbera/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/10892-yellowGerbera/00-firstScript.sql b/db/versions/10892-yellowGerbera/00-firstScript.sql index 1795300f2..52dbdbee1 100644 --- a/db/versions/10892-yellowGerbera/00-firstScript.sql +++ b/db/versions/10892-yellowGerbera/00-firstScript.sql @@ -12,8 +12,8 @@ UPDATE vn.itemShelving SET @isTriggerDisabled := FALSE; -ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); -ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0); +ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL DEFAULT 1 CHECK(packing > 0); +ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL DEFAULT 1 CHECK(packing > 0); -- Antes tenia '0=sin obligar 1=groping 2=packing' (groping → grouping) ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing'; From 8119106e692624e53807db4c612229b88bd94cb7 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 15 Mar 2024 15:40:54 +0100 Subject: [PATCH 111/136] hotFix: try to debug closeAll --- modules/ticket/back/methods/ticket/closeAll.js | 3 ++- modules/ticket/back/methods/ticket/closure.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 46c45aa92..edd1155ba 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -57,7 +57,8 @@ module.exports = Self => { AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); - + const ticketIds = tickets.map(ticket => ticket.id); + await Self.rawSql(`CALL util.debugAdd('nightInvoicing', ?)`, [ticketIds.join(',')]); await closure(ctx, Self, tickets); await Self.rawSql(` diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 1d04679d3..14b040324 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -11,6 +11,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { const failedtickets = []; for (const ticket of tickets) { try { + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId}); const [invoiceOut] = await Self.rawSql(` From f044809f306805ac422e5f22338003e1cc56e5c2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 15 Mar 2024 15:45:47 +0100 Subject: [PATCH 112/136] feat: refs #6951 to create back --- db/routines/vn/procedures/ticket_CloneAll.sql | 2 +- .../00-aclTicketClone.sql | 2 + modules/ticket/back/methods/ticket/clone.js | 54 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 2 + modules/ticket/back/models/ticket.js | 1 - 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 db/versions/10957-goldenAnthurium/00-aclTicketClone.sql create mode 100644 modules/ticket/back/methods/ticket/clone.js diff --git a/db/routines/vn/procedures/ticket_CloneAll.sql b/db/routines/vn/procedures/ticket_CloneAll.sql index d56a47a33..a2d775a8f 100644 --- a/db/routines/vn/procedures/ticket_CloneAll.sql +++ b/db/routines/vn/procedures/ticket_CloneAll.sql @@ -15,7 +15,7 @@ BEGIN SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); - CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse); + CALL ticket_Clone(vTicketFk, vNewTicketFk); UPDATE ticket SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), diff --git a/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql b/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql new file mode 100644 index 000000000..6387b77b0 --- /dev/null +++ b/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/clone.js b/modules/ticket/back/methods/ticket/clone.js new file mode 100644 index 000000000..535c6fc7c --- /dev/null +++ b/modules/ticket/back/methods/ticket/clone.js @@ -0,0 +1,54 @@ +module.exports = Self => { + Self.remoteMethodCtx('clone', { + description: 'clone a ticket and return the new ticket id', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The ticket id', + http: {source: 'path'} + }, { + arg: 'shipped', + type: 'date', + }, { + arg: 'withWarehouse', + type: 'boolean', + } + ], + returns: { + type: 'number', + root: true + }, + http: { + path: `/:id/clone`, + verb: 'POST' + } + }); + + Self.clone = async(ctx, id, shipped, withWarehouse, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const [, [{clonedTicketId}]] = await Self.rawSql(` + CALL vn.ticket_CloneAll(?, ?, ?, @clonedTicketId); + SELECT @clonedTicketId clonedTicketId;`, + [id, shipped, withWarehouse], myOptions); + + if (tx) await tx.commit(); + return clonedTicketId; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index d204a8102..0ae2ce3b4 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -46,4 +46,6 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); + require('../methods/ticket/addSaleByCode')(Self); + require('../methods/ticket/clone')(Self); }; diff --git a/modules/ticket/back/models/ticket.js b/modules/ticket/back/models/ticket.js index 51a8372e3..1930765fb 100644 --- a/modules/ticket/back/models/ticket.js +++ b/modules/ticket/back/models/ticket.js @@ -1,5 +1,4 @@ module.exports = Self => { require('./ticket-methods')(Self); require('../methods/ticket/state')(Self); - require('../methods/ticket/addSaleByCode')(Self); }; From 3c3dd64da142fdec27215ae16396232c996ed54a Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 18 Mar 2024 09:39:56 +0100 Subject: [PATCH 113/136] feat: refs #6951 test --- .../back/methods/ticket/specs/clone.spec.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/specs/clone.spec.js diff --git a/modules/ticket/back/methods/ticket/specs/clone.spec.js b/modules/ticket/back/methods/ticket/specs/clone.spec.js new file mode 100644 index 000000000..26114bd58 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/clone.spec.js @@ -0,0 +1,56 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('Ticket cloning - clone function', () => { + let ctx; + let options; + let tx; + const ticketId = 1; + const shipped = Date.vnNew(); + + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'} + }, + args: {} + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: ctx.req + }); + + options = {transaction: tx}; + tx = await models.Ticket.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should clone a new ticket without warehouse', async() => { + const originalTicket = await models.Ticket.findById(ticketId, null, options); + + const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, false, options); + const newTicket = await models.Ticket.findById(newTicketId, null, options); + + expect(newTicket.clientFk).toEqual(originalTicket.clientFk); + expect(newTicket.companyFk).toEqual(originalTicket.companyFk); + expect(newTicket.addressFk).toEqual(originalTicket.addressFk); + expect(newTicket.warehouseFk).toBeFalsy(); + }); + + it('should clone a new ticket with warehouse', async() => { + const originalTicket = await models.Ticket.findById(ticketId, null, options); + + const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, true, options); + const newTicket = await models.Ticket.findById(newTicketId, null, options); + + expect(newTicket.clientFk).toEqual(originalTicket.clientFk); + expect(newTicket.companyFk).toEqual(originalTicket.companyFk); + expect(newTicket.addressFk).toEqual(originalTicket.addressFk); + expect(newTicket.warehouseFk).toEqual(originalTicket.warehouseFk); + }); +}); From 4f90fb06d838e65e72ed7deff43d88cd1966a150 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 18 Mar 2024 13:25:23 +0100 Subject: [PATCH 114/136] hotFix(debug) varchar to text --- db/versions/10959-bronzePalmetto/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/10959-bronzePalmetto/00-firstScript.sql diff --git a/db/versions/10959-bronzePalmetto/00-firstScript.sql b/db/versions/10959-bronzePalmetto/00-firstScript.sql new file mode 100644 index 000000000..323238d2e --- /dev/null +++ b/db/versions/10959-bronzePalmetto/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE util.debug MODIFY COLUMN value text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; From 8f54a7f12dc2acba9310f2bc67ccd6fe41777923 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 18 Mar 2024 14:03:16 +0100 Subject: [PATCH 115/136] deliveryDate --- db/dump/fixtures.local.sql | 9 +++++ .../floranet/procedures/deliveryDate_get.sql | 38 ++++++++----------- .../10956-brownBirch/00-firstScript.sql | 12 ++++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 db/versions/10956-brownBirch/00-firstScript.sql diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql index 64d22f480..3714a85fc 100644 --- a/db/dump/fixtures.local.sql +++ b/db/dump/fixtures.local.sql @@ -404,3 +404,12 @@ INSERT INTO floranet.builder( FROM vn.item WHERE name = 'Ramo Terranova'; +INSERT IGNORE INTO floranet.addressPostCode (id, addressFk, postCode, hoursInAdvance, dayOfWeek, deliveryCost) + VALUES (1, 4, '46680', 48, 2, 6.00), + (5, 4, '46680', 24, 3, 6.00), + (6, 4, '46680', 24, 4, 6.00), + (7, 4, '46680', 24, 5, 6.00), + (8, 4, '46680', 24, 6, 0.00), + (9, 4, '46680', 24, 7, 20.00), + (2, 3, '46680', 24, 2, 9.25), + (3, 3, '46440', 24, 3, 0.00); \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 06a8ae1ad..29751ebe4 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -2,34 +2,28 @@ DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.deliveryDate_get(vPostalCode VARCHAR(15)) -READS SQL DATA +CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) + READS SQL DATA BEGIN /** - * Returns available dates for this postalCode + * Returns available dates for this postalCode, in the next seven days * * @param vPostalCode Delivery address postal code */ - CREATE OR REPLACE TEMPORARY TABLE tmp.deliveryDate - (dated DATE PRIMARY KEY) - ENGINE = MEMORY; + DECLARE vCurrentDayOfWeek INT; - IF vPostalCode != "00000" THEN - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 1 DAY; + SET vCurrentDayOfWeek = DAYOFWEEK(NOW()); - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 2 DAY; - - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 4 DAY; - - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 7 DAY; - END IF; - - SELECT * FROM tmp.deliveryDate; - - DROP TEMPORARY TABLE tmp.deliveryDate; + SELECT DISTINCT nextDay + FROM ( + SELECT CURDATE() + INTERVAL IF( + apc.dayOfWeek >= vCurrentDayOfWeek, + apc.dayOfWeek - vCurrentDayOfWeek, + 7 - apc.dayOfWeek + ) DAY nextDay, + NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime + FROM addressPostCode apc + WHERE apc.postCode = vPostalCode + HAVING nextDay > minDeliveryTime) sub; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10956-brownBirch/00-firstScript.sql b/db/versions/10956-brownBirch/00-firstScript.sql new file mode 100644 index 000000000..bcd15432c --- /dev/null +++ b/db/versions/10956-brownBirch/00-firstScript.sql @@ -0,0 +1,12 @@ +CREATE TABLE floranet.`addressPostCode` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `addressFk` int(11) NOT NULL, + `postCode` varchar(30) NOT NULL, + `hoursInAdvance` int(10) unsigned NOT NULL DEFAULT 24, + `dayOfWeek` int(10) unsigned NOT NULL, + `deliveryCost` decimal(10,2) NOT NULL DEFAULT 0.00, + PRIMARY KEY (`id`), + UNIQUE KEY `addressPostCode_unique` (`postCode`,`addressFk`,`dayOfWeek`), + KEY `addressPostCode_address_FK` (`addressFk`), + CONSTRAINT `addressPostCode_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Client''s address registered for floranet network'; \ No newline at end of file From b3271209328489f3223f6367a33e53552231c3b0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 07:39:38 +0100 Subject: [PATCH 116/136] fix: refs #6232 Comment queueConfig lines --- db/versions/10953-redChico/04-pbx.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/10953-redChico/04-pbx.sql b/db/versions/10953-redChico/04-pbx.sql index 7ca0e6103..49f4172c4 100644 --- a/db/versions/10953-redChico/04-pbx.sql +++ b/db/versions/10953-redChico/04-pbx.sql @@ -6,9 +6,9 @@ ALTER TABLE pbx.config ADD CONSTRAINT config_check CHECK (id = 1); ALTER TABLE pbx.followmeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; ALTER TABLE pbx.followmeConfig ADD CONSTRAINT followmeConfig_check CHECK (id = 1); --- pbx.queueConfig -ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; -ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); +-- pbx.queueConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); -- pbx.sipConfig ALTER TABLE pbx.sipConfig MODIFY COLUMN id mediumint(8) unsigned NOT NULL; From 397b49db915d2062b2c480ecc4ae7e61c316468a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 08:02:11 +0100 Subject: [PATCH 117/136] fix: refs #6232 Comment conveyorConfig lines --- db/versions/10953-redChico/08-vn.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/10953-redChico/08-vn.sql b/db/versions/10953-redChico/08-vn.sql index 5d5637651..14bd3b13f 100644 --- a/db/versions/10953-redChico/08-vn.sql +++ b/db/versions/10953-redChico/08-vn.sql @@ -46,9 +46,9 @@ ALTER TABLE vn.comparativeConfig ADD CONSTRAINT comparativeConfig_check CHECK (i ALTER TABLE vn.config MODIFY COLUMN id int(10) unsigned NOT NULL; ALTER TABLE vn.config ADD CONSTRAINT config_check CHECK (id = 1); --- vn.conveyorConfig -ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; -ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); +-- vn.conveyorConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); -- vn.deviceProductionConfig ALTER TABLE vn.deviceProductionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; From 7895a51e3364d7a154bc0cb1db8d2a9ccf0b44a7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 20 Mar 2024 12:15:41 +0100 Subject: [PATCH 118/136] hotFix(closeAll): fix debug --- modules/ticket/back/methods/ticket/closeAll.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index edd1155ba..11900bada 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -58,7 +58,11 @@ module.exports = Self => { GROUP BY t.id `, [toDate, toDate]); const ticketIds = tickets.map(ticket => ticket.id); - await Self.rawSql(`CALL util.debugAdd('nightInvoicing', ?)`, [ticketIds.join(',')]); + await Self.rawSql(` + INSERT INTO util.debug (variable, value) + VALUES ('nightInvoicing', ?) + `, [ticketIds.join(',')]); + await closure(ctx, Self, tickets); await Self.rawSql(` From d53a053ccb9aed3e50f916a63daf77c1b9f39419 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 13:07:02 +0100 Subject: [PATCH 119/136] refactor: refs #6923 Deteted procs --- .../vn2008/procedures/add_awb_component.sql | 61 ------------------- .../vn2008/procedures/agencyModeImbalance.sql | 50 --------------- 2 files changed, 111 deletions(-) delete mode 100644 db/routines/vn2008/procedures/add_awb_component.sql delete mode 100644 db/routines/vn2008/procedures/agencyModeImbalance.sql diff --git a/db/routines/vn2008/procedures/add_awb_component.sql b/db/routines/vn2008/procedures/add_awb_component.sql deleted file mode 100644 index e75290b4b..000000000 --- a/db/routines/vn2008/procedures/add_awb_component.sql +++ /dev/null @@ -1,61 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`add_awb_component`(IN vAwbFk SMALLINT) -BEGIN - - DECLARE vShipped DATE; - DECLARE vHasStems BOOLEAN; - - SELECT t.shipped, IF(a.stems, TRUE, FALSE) - INTO vShipped, vHasStems - FROM vn.travel t - JOIN vn.awb a ON a.id = t.awbFk - WHERE awbFk = vAwbFk - LIMIT 1; - - INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda) - SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda - FROM ( - SELECT a.id, - IFNULL(act.carguera_id, - CASE awb_role_id - WHEN 1 THEN a.carguera_id - WHEN 2 THEN a.transitario_id - WHEN 3 THEN f.airline_id - END - ) Id_Proveedor, - act.awb_component_type_id, - act.awb_role_id, - act.awb_unit_id, - value * - CASE awb_unit_id - WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value) - WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value) - WHEN '100GW' THEN peso/100 - WHEN 'AWB' THEN 1 -- No action - WHEN 'FB' THEN hb/2 - WHEN 'GW' THEN peso - WHEN 'TW' THEN GREATEST(peso,volume_weight) - WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10) - END value1, - value, - act.Id_Moneda, - act.min_value, - act.max_value - FROM awb a - JOIN flight f ON f.flight_id = a.flight_id - LEFT JOIN awb_component_template act ON - ((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1) - OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2) - OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3) - OR (awb_role_id = 4)) - AND IFNULL(act.airport_out, f.airport_out) = f.airport_out - AND IFNULL(act.airport_in, f.airport_in) = f.airport_in - AND IFNULL(act.airline_id, f.airline_id) = f.airline_id - AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1) - JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id - WHERE a.id = vAwbFk AND Fecha <= vShipped - AND (vHasStems = TRUE OR acty.hasStems) - ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000 - ) t; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/agencyModeImbalance.sql b/db/routines/vn2008/procedures/agencyModeImbalance.sql deleted file mode 100644 index 89706f0d2..000000000 --- a/db/routines/vn2008/procedures/agencyModeImbalance.sql +++ /dev/null @@ -1,50 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencyModeImbalance`(vStarted DATE, vEnded DATE) -BEGIN -/** - * Devuelve el valor de los precios teorico, practico de las agencias - * y si ademas es de mrw lo compara con su fichero previamente procesado - * - * @param vEktFk Identificador de edi.ekt - */ - DECLARE vEndedDayEnd DATETIME; - - SET vEndedDayEnd = util.dayEnd(vEnded); - - SELECT t.id ticketFk,t.addressFk, - CAST(v.amount AS DECIMAL (10,2)) AS VN, - CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer, - CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice, - CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference, - CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico, - CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge, - t.packages, t.clientFk, - t.zoneFk, a.provinceFk, mrwCount - FROM vn.ticket t - LEFT JOIN - (SELECT ticketFk, SUM(amount) amount, fc.shipped - FROM vn.sale_freightComponent fc - JOIN vn.ticket t ON t.id = fc.ticketFk - JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk - WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd - GROUP BY ticketFk) v ON t.id = v.ticketFk - LEFT JOIN (SELECT t.id, - SUM(t.zonePrice) shipping_charge, - SUM(IFNULL(aex.price,0)) extraCharge - FROM vn.ticket t - LEFT JOIN vn.expedition e ON e.ticketFk = t.id - LEFT JOIN vn.packaging p ON p.id = e.packagingFk - JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk - JOIN vn.agencyMode am ON am.id = amc.agencyModeFk - LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk - WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd - GROUP BY t.id - ) e ON t.id = e.id - LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount - FROM vn.mrw - GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id - JOIN vn.address a ON a.id = t.addressFk - JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk - WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd; -END$$ -DELIMITER ; From 5a45cf7ea2d47a8177edb4abbadb794a29b441ff Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Mar 2024 13:39:26 +0100 Subject: [PATCH 120/136] refs #6842 remove sage --- db/routines/vn2008/views/empresa.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn2008/views/empresa.sql b/db/routines/vn2008/views/empresa.sql index 3b43ee574..8c80a06e8 100644 --- a/db/routines/vn2008/views/empresa.sql +++ b/db/routines/vn2008/views/empresa.sql @@ -5,7 +5,6 @@ AS SELECT `c`.`id` AS `id`, `c`.`code` AS `abbreviation`, `c`.`supplierAccountFk` AS `Id_Proveedores_account`, `c`.`workerManagerFk` AS `gerente_id`, - `c`.`sage200Company` AS `digito_factura`, `c`.`phytosanitary` AS `phytosanitary`, `c`.`companyCode` AS `CodigoEmpresa`, `c`.`companyGroupFk` AS `empresa_grupo`, From f7b458d3683cd4a7bfa0c9ddd8431623252406b6 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 20 Mar 2024 20:54:24 +0100 Subject: [PATCH 121/136] feat: refs #6302 delete after add to turn --- db/dump/fixtures.before.sql | 4 ++-- e2e/paths/05-ticket/09_weekly.spec.js | 20 +++++++++---------- modules/ticket/back/models/ticket-weekly.js | 8 ++++++++ modules/ticket/front/descriptor-menu/index.js | 3 ++- .../front/descriptor-menu/locale/es.yml | 1 + 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 795ffb25f..4e01532e2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -760,8 +760,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL); - + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), + (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES (1, 11, 1, 'ready'), diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 74febfd01..20cfa0d13 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -24,7 +24,7 @@ describe('Ticket descriptor path', () => { it('should go back to the ticket index then search and access a ticket summary', async() => { await page.accessToSection('ticket.index'); - await page.accessToSearchResult('11'); + await page.accessToSearchResult('33'); }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { @@ -33,7 +33,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.thursdayButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Data saved!'); + expect(message.text).toContain('Current ticket deleted and added to shift'); }); it('should again click on the Tickets button of the top bar menu', async() => { @@ -43,7 +43,7 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should confirm the ticket 11 was added to thursday', async() => { + it('should confirm the ticket 33 was added to thursday', async() => { await page.accessToSection('ticket.weekly.index'); const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value'); @@ -57,8 +57,8 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should now search for the ticket 11', async() => { - await page.accessToSearchResult('11'); + it('should now search for the ticket 33', async() => { + await page.accessToSearchResult('33'); await page.waitForState('ticket.card.summary'); }); @@ -68,7 +68,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.saturdayButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Data saved!'); + expect(message.text).toContain('Current ticket deleted and added to shift'); }); it('should click on the Tickets button of the top bar menu once again', async() => { @@ -78,7 +78,7 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should confirm the ticket 11 was added on saturday', async() => { + it('should confirm the ticket 33 was added on saturday', async() => { await page.accessToSection('ticket.weekly.index'); await page.waitForTimeout(5000); @@ -87,14 +87,14 @@ describe('Ticket descriptor path', () => { expect(result).toEqual('Saturday'); }); - it('should now search for the weekly ticket 11', async() => { - await page.doSearch('11'); + it('should now search for the weekly ticket 33', async() => { + await page.doSearch('33'); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); expect(nResults).toEqual(2); }); - it('should delete the weekly ticket 11', async() => { + it('should delete the weekly ticket 33', async() => { await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon); await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn); const message = await page.waitForSnackbar(); diff --git a/modules/ticket/back/models/ticket-weekly.js b/modules/ticket/back/models/ticket-weekly.js index 8db53b283..b6b1d586c 100644 --- a/modules/ticket/back/models/ticket-weekly.js +++ b/modules/ticket/back/models/ticket-weekly.js @@ -1,4 +1,5 @@ const UserError = require('vn-loopback/util/user-error'); +const LoopBackContext = require('loopback-context'); module.exports = Self => { require('../methods/ticket-weekly/filter')(Self); @@ -8,4 +9,11 @@ module.exports = Self => { return new UserError(`This ticket is already on weekly tickets`); return err; }); + + Self.observe('after save', async ctx => { + const loopBackContext = LoopBackContext.getCurrentContext(); + const httpCtx = {req: loopBackContext.active}; + const httpRequest = httpCtx.req.http; + await Self.app.models.Ticket.setDeleted(httpRequest, ctx.instance.ticketFk, ctx.options); + }); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index d2dd13f73..52cac141c 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -147,7 +147,8 @@ class Controller extends Section { return this.$http.patch(`TicketWeeklies`, params) .then(() => { this.$.addTurn.hide(); - this.vnApp.showSuccess(this.$t('Data saved!')); + this.vnApp.showSuccess(this.$t('Current ticket deleted and added to shift')); + this.reload(); }); } diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index 111fc2702..008c9a358 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -28,3 +28,4 @@ Create a single ticket with all the content of the current ticket: Crea un ticke Set ticket weight: Establecer peso al ticket Ticket weight: Peso del ticket This address has incoterms, you should set the weight before invoice it: Este consigatario tiene incoterms, deberías establecer el peso antes de facturar +Current ticket deleted and added to shift: Ticket actual borrado y añadido a turno \ No newline at end of file From da8fbb5a926d17c78b504d7104af07ef4abdde2c Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 20 Mar 2024 21:14:01 +0100 Subject: [PATCH 122/136] fix: refs #6302 spec --- modules/ticket/back/methods/ticket/specs/filter.spec.js | 2 +- modules/ticket/front/descriptor-menu/index.spec.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index c1d3f1a9c..e495a41f5 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -68,7 +68,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(7); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 80ad9a33a..94a991db8 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -41,6 +41,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { })); describe('addTurn()', () => { + pending('refs #6302'); it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => { controller.$.addTurn = {hide: () => {}}; jest.spyOn(controller.$.addTurn, 'hide'); From de83cef68cf16c55bd9767cfa0dfd21b239f059f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 08:01:27 +0100 Subject: [PATCH 123/136] build: refs #5846 HOTFIX Myt updated --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e897823d..aa410f8df 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.7.4", "@babel/preset-env": "^7.11.0", "@babel/register": "^7.7.7", - "@verdnatura/myt": "^1.6.8", + "@verdnatura/myt": "^1.6.9", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", From bbbd212547898dc677cae5c0531e102a2e0a4f16 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 08:14:59 +0100 Subject: [PATCH 124/136] build: refs #5846 HOTFIX Myt updated --- pnpm-lock.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b1f68378d..3f0473929 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,8 +131,8 @@ devDependencies: specifier: ^7.7.7 version: 7.23.7(@babel/core@7.23.9) '@verdnatura/myt': - specifier: ^1.6.8 - version: 1.6.8 + specifier: ^1.6.9 + version: 1.6.9 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2633,8 +2633,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.8: - resolution: {integrity: sha512-jpadr6yAR9TQXPv+has5yOYAolR/YEzsxbLgMR7BoDrpLyVFLHJEy4Dfe+Hy11r3AmxCB/8lWM+La1YGvXMWOA==} + /@verdnatura/myt@1.6.9: + resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -4886,6 +4886,7 @@ packages: /deep-extend@0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} + requiresBuild: true /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -12714,6 +12715,7 @@ packages: /strip-json-comments@2.0.1: resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} engines: {node: '>=0.10.0'} + requiresBuild: true /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} From 1cd495df06984f6d43d5bd60f96cc765bd06649b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 09:25:33 +0100 Subject: [PATCH 125/136] fix: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 3b5ce5247..8c4015bc3 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -11,7 +11,7 @@ BEGIN */ DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; - DECLARE vExpenseFk INT; + DECLARE vExpenseFk VARCHAR(10); SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr From d0067c80967b9a8b20b0cb696922b89869fd756f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 11:30:10 +0100 Subject: [PATCH 126/136] ticket #167473 Hotfix --- db/routines/bs/procedures/ventas_contables_add.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 12b2738f3..9e2b75f6d 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -23,7 +23,7 @@ BEGIN ENGINE = MEMORY SELECT Id_Ticket FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + JOIN vn.invoiceOut io ON io.`ref` = t.Factura WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -47,12 +47,7 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk - + IF(e.empresa_grupo = e2.empresa_grupo - ,1 - ,IF(e2.empresa_grupo,2,0) - ) * 100000 - + tp.reino_id * 1000 as Gasto + , a.expenseFk gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna From 535dd406250ddd6b0764142e6a7681b9d51e8b6d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:06:59 +0100 Subject: [PATCH 127/136] fix: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 3b5ce5247..40fd98378 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -11,18 +11,20 @@ BEGIN */ DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; - DECLARE vExpenseFk INT; + DECLARE vCurrencyFk INT; + DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated) INTO vDated + SELECT MAX(rr.dated), ii.currencyFk INTO vDated, vCurrencyFk FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk WHERE rr.dated <= ii.issued AND rr.currencyFk = ii.currencyFk; - IF vDated THEN + IF vDated AND vCurrencyFk THEN SELECT `value` INTO vRate FROM referenceRate - WHERE dated = vDated; + WHERE dated = vDated + AND currencyFk = vCurrencyFk; END IF; DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; From ee67820c20b2257c2358b81607b0474470c96168 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:14:48 +0100 Subject: [PATCH 128/136] refactor: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 40fd98378..4e20b01d3 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -10,22 +10,15 @@ BEGIN * @param vInvoiceInFk Id de factura recibida */ DECLARE vRate DOUBLE DEFAULT 1; - DECLARE vDated DATE; - DECLARE vCurrencyFk INT; DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated), ii.currencyFk INTO vDated, vCurrencyFk + SELECT `value` INTO vRate FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk WHERE rr.dated <= ii.issued - AND rr.currencyFk = ii.currencyFk; - - IF vDated AND vCurrencyFk THEN - SELECT `value` INTO vRate - FROM referenceRate - WHERE dated = vDated - AND currencyFk = vCurrencyFk; - END IF; + AND rr.currencyFk = ii.currencyFk + ORDER BY dated DESC + LIMIT 1; DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; From ece94c2bd124a4b7668550a5dd6f7043bdfa702c Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 21 Mar 2024 12:39:39 +0100 Subject: [PATCH 129/136] ref #5034 remove e2e --- e2e/paths/14-account/05_connections.spec.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js index 89b286101..49d5f612d 100644 --- a/e2e/paths/14-account/05_connections.spec.js +++ b/e2e/paths/14-account/05_connections.spec.js @@ -22,12 +22,4 @@ describe('Account Connections path', () => { expect(firstResult).toContain(account); }); - - it('should kill this connection and then get redirected to the login page', async() => { - await page.waitToClick(selectors.accountConnections.deleteFirstConnection); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Your session has expired, please login again'); - }); }); From 2b26153bfa597fcd84f200a292f03aa2daad672c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:52:04 +0100 Subject: [PATCH 130/136] refactor: refs #7018 Requested changes --- db/routines/bs/procedures/ventas_contables_add.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 9e2b75f6d..66c012a19 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -47,7 +47,12 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk gasto + , a.expenseFk + + IF(e.empresa_grupo = e2.empresa_grupo + ,1 + ,IF(e2.empresa_grupo,2,0) + ) * 100000 + + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna From 8fd7792e7cdfd75b941be28f8023545d2ecc9ad2 Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 22 Mar 2024 11:05:48 +0100 Subject: [PATCH 131/136] gitignore --- db/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.gitignore b/db/.gitignore index 231f0dfe0..54ed9df77 100644 --- a/db/.gitignore +++ b/db/.gitignore @@ -4,7 +4,7 @@ remotes/*.ini !remotes/local.ini !remotes/docker.ini dump/.changes -#dump/fixtures.local.sql +dump/fixtures.local.sql .dBeaver .idea .project From 214aff403a187bd7327ea206203dd88f466f6c74 Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 22 Mar 2024 11:09:49 +0100 Subject: [PATCH 132/136] delete fixtures local --- db/dump/fixtures.local.sql | 415 ------------------------------------- 1 file changed, 415 deletions(-) delete mode 100644 db/dump/fixtures.local.sql diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql deleted file mode 100644 index 3714a85fc..000000000 --- a/db/dump/fixtures.local.sql +++ /dev/null @@ -1,415 +0,0 @@ --- XXX: floranet - -INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); - - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNR', 'Floranet Ramos', 1, 1); - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNP', 'Floranet Plantas', 1, 1); - --- Generación de items -SELECT id - INTO @FNR - FROM vn.itemType - WHERE code = 'FNR'; - -SELECT id - INTO @FNP - FROM vn.itemType - WHERE code = 'FNP'; - -DELETE - FROM vn.item - WHERE typeFk IN (@FNR,@FNP); - -INSERT INTO vn.item - ( - id, - name, - longName, - `size`, - originFk, - intrastatFk, - typeFk, - inkFk, - image, - description - ) - VALUES - ( - 147791, - @r := 'Ramo Terranova', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147791', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', - 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', - 'paniculata eucaliptus.') - ), - ( - 147792, - @r := 'Ramo Tasmania', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147792', - CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', - 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', - 'flores será un acierto seguro para hacer un regalo muy especial.') - ), - ( - 147793, - @r := 'Ramo Pasion', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147793', - CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', - 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', - 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', - 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', - 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') - ), - ( - 147794, - @r := 'Ramo Florencia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147794', - CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', - 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', - 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', - 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') - ), - ( - 147795, - @r := 'Ramo Atardecer', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink WHERE name = 'Yellow'), - '147795', - CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', - 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', - 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', - 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', - 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') - ), - ( - 147796, - @r := 'Ramo Arcoíris', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147796', - CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', - 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', - 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', - 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', - 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', - 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') - ), - ( - 147797, - @r := 'Ramo Provenza', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147797', - CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', - 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', - 'con una selección de maravillosos verdes variados, hacen que esta combinación ', - 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') - ), - ( - 147798, - @r := 'Ramo Alegria', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147798', - CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', - 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', - ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', - 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', - 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') - ), - ( - 147799, - @r := 'Planta Orquídeas ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147799', - CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', - 'con las mejores características combinadas con diferentes elementos de ', - 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', - 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', - 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', - 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') - ), - ( - 147800, - @r := 'Planta Kentia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147800', - CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', - 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', - 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', - 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', - 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', - 'de ser un producto nacional producido en Canarias de una calidad extrema.') - ), - ( - 147801, - @r := 'Planta Calathea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147801', - CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', - ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', - 'llamativo y original colorido, tambien es un regalo perfecto para ', - 'cualquier compromiso que tengamos .') - ), - ( - 147802, - @r := 'Planta Anthurium ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink WHERE name = 'Red'), - '147802', - CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', - 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', - 'su llamativo color alegrará cualquier celebración') - ), - ( - 147803, - @r := 'Ramo Mindanao', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147803', - CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', - 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', - 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') - ), - ( - 147804, - @r := 'Ramo Guinea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147804', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', - ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') - ), - ( - 147805, - @r := 'Ramo Eterno', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147805', - CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', - 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', - 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', - 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', - 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', - 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') - ), - ( - 147806, - @r := 'Ramo Cielo', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147806', - CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', - 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', - ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', - 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', - ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', - 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', - 'clara de todo el conjunto. ') - ); - - -- Ramo Terranova: 1er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Rosa roja', - @r, - 60, - 1, - 'RED', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 12 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - -- Ramo Terranova: 2º elemento - -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Hoja de helecho', - @r, - 60, - 1, - 'BAS', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 4 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- Ramo Terranova: 3er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Paniculata', - @r, - 60, - 1, - 'SLV', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 5 - FROM vn.item - WHERE name = 'Ramo Terranova'; - -INSERT IGNORE INTO floranet.addressPostCode (id, addressFk, postCode, hoursInAdvance, dayOfWeek, deliveryCost) - VALUES (1, 4, '46680', 48, 2, 6.00), - (5, 4, '46680', 24, 3, 6.00), - (6, 4, '46680', 24, 4, 6.00), - (7, 4, '46680', 24, 5, 6.00), - (8, 4, '46680', 24, 6, 0.00), - (9, 4, '46680', 24, 7, 20.00), - (2, 3, '46680', 24, 2, 9.25), - (3, 3, '46440', 24, 3, 0.00); \ No newline at end of file From 8a51df2fe59561b45560ea2e23f4127770822af6 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 22 Mar 2024 12:28:23 +0100 Subject: [PATCH 133/136] refs #6498 Delete multipleInventoryHistory --- .../procedures/multipleInventoryHistory.sql | 158 ------------------ 1 file changed, 158 deletions(-) delete mode 100644 db/routines/vn/procedures/multipleInventoryHistory.sql diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql deleted file mode 100644 index dc19e615a..000000000 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ /dev/null @@ -1,158 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT -) -BEGIN -/** -* Calcula y proporciona un historial de inventario detallado -* para un artículo dividiendo la información -* por almacén. -* -* @param vItemFk Artículo -*/ - DECLARE vDateInventory DATETIME; - - SELECT inventoried INTO vDateInventory FROM config; - - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1; - - CREATE TEMPORARY TABLE tMultipleHistory1 - SELECT DATE(`date`) `date`, - input, - `output`, - ok, - reference, - history.id, - warehouse, - `name` warehouseName - FROM ( - SELECT tr.landed `date`, - c.quantity input, - NULL `output`, - tr.warehouseInFk warehouse, - tr.isReceived ok, - e.invoiceNumber reference, - e.id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity - UNION ALL - SELECT tr.shipped, - NULL, - c.quantity, - tr.warehouseOutFk, - tr.isDelivered, - e.invoiceNumber, - e.id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.shipped >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity - UNION ALL - SELECT t.shipped, - NULL, - m.quantity, - t.warehouseFk, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), - t.refFk, - t.id - FROM sale m - JOIN ticket t ON t.id = m.ticketFk - WHERE t.shipped >= vDateInventory - AND m.itemFk = vItemFk - ) history - JOIN warehouse ON warehouse.id = history.warehouse - ORDER BY `date`, input DESC, ok DESC; - - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3, - tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8; - CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; - CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; - CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; - CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5; - CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17; - CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37; - CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; - - SELECT * - FROM ( - SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, - NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, - NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, - NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, - NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, - NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, - NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid - FROM tMultipleHistory2 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory3 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory4 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory5 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory6 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory7 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id - FROM tMultipleHistory8 - ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, - MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; -END$$ -DELIMITER ; \ No newline at end of file From 3851d967f4cc5d1a4ee58548933a44905b915603 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 22 Mar 2024 13:56:46 +0100 Subject: [PATCH 134/136] refs #6966 Modify name sale_replaceItem --- db/routines/vn/procedures/sale_replaceItem.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index aff34d5e9..bb70b6de6 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -104,7 +104,7 @@ BEGIN price) SELECT vTicketFk, vNewItemFk, - CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName), + CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.name), vFinalPrice FROM vn.item i WHERE id = vNewItemFk; From b9bcc5b2cf6507509d8624a5eac44b64e4afea7a Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 22 Mar 2024 15:06:57 +0100 Subject: [PATCH 135/136] refs #6966 changes required --- db/routines/vn/procedures/sale_replaceItem.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index bb70b6de6..572c54a89 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -104,7 +104,7 @@ BEGIN price) SELECT vTicketFk, vNewItemFk, - CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.name), + CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name), vFinalPrice FROM vn.item i WHERE id = vNewItemFk; From 0867f4d501864611adf263227f3c18d65e082ab5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 22 Mar 2024 16:01:22 +0100 Subject: [PATCH 136/136] fix: refs #6951 var names & procedure name --- db/routines/vn/procedures/ticketClon.sql | 3 +-- .../{ticket_CloneAll.sql => ticket_cloneAll.sql} | 8 ++++---- modules/ticket/back/methods/ticket/clone.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) rename db/routines/vn/procedures/{ticket_CloneAll.sql => ticket_cloneAll.sql} (87%) diff --git a/db/routines/vn/procedures/ticketClon.sql b/db/routines/vn/procedures/ticketClon.sql index 00386c6aa..9144ac709 100644 --- a/db/routines/vn/procedures/ticketClon.sql +++ b/db/routines/vn/procedures/ticketClon.sql @@ -4,8 +4,7 @@ BEGIN DECLARE vNewTicketFk INT; - CALL ticket_CloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk); - SELECT vNewTicketFk; + CALL ticket_cloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_CloneAll.sql b/db/routines/vn/procedures/ticket_cloneAll.sql similarity index 87% rename from db/routines/vn/procedures/ticket_CloneAll.sql rename to db/routines/vn/procedures/ticket_cloneAll.sql index a2d775a8f..4b3401ed7 100644 --- a/db/routines/vn/procedures/ticket_CloneAll.sql +++ b/db/routines/vn/procedures/ticket_cloneAll.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) BEGIN - DECLARE done INT DEFAULT FALSE; + DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vOldSaleFk INT; DECLARE vNewSaleFk INT; @@ -11,7 +11,7 @@ BEGIN FROM sale WHERE ticketFk = vTicketFk; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); @@ -29,7 +29,7 @@ BEGIN FETCH cur1 INTO vOldSaleFk; - IF done THEN + IF vDone THEN LEAVE read_loop; END IF; diff --git a/modules/ticket/back/methods/ticket/clone.js b/modules/ticket/back/methods/ticket/clone.js index 535c6fc7c..93bc2a94e 100644 --- a/modules/ticket/back/methods/ticket/clone.js +++ b/modules/ticket/back/methods/ticket/clone.js @@ -40,7 +40,7 @@ module.exports = Self => { try { const [, [{clonedTicketId}]] = await Self.rawSql(` - CALL vn.ticket_CloneAll(?, ?, ?, @clonedTicketId); + CALL vn.ticket_cloneAll(?, ?, ?, @clonedTicketId); SELECT @clonedTicketId clonedTicketId;`, [id, shipped, withWarehouse], myOptions);