From 1f826e1214f23844ccb9607f02f84b1e26a648f9 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:16:55 +0200 Subject: [PATCH 1/7] sql code for production --- db/changes/10440-fallas/00-country.sql | 88 ++++++++++++++++++++++++++ db/changes/10440-fallas/00-worker.sql | 49 ++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 db/changes/10440-fallas/00-country.sql create mode 100644 db/changes/10440-fallas/00-worker.sql diff --git a/db/changes/10440-fallas/00-country.sql b/db/changes/10440-fallas/00-country.sql new file mode 100644 index 000000000..06b4f9b94 --- /dev/null +++ b/db/changes/10440-fallas/00-country.sql @@ -0,0 +1,88 @@ +ALTER TABLE `vn`.`country` ADD `a3Code` INT NULL COMMENT 'Código país para a3'; + +UPDATE `vn`.`country` c +JOIN `vn2008`.`payroll_pais` `p` ON `p`.`pais` = `c`.`country` +SET `c`.`a3Code` = `p`.`codpais`; + +UPDATE `vn`.`country` +SET `a3Code` = 710 +WHERE `country` = 'Sud-Africa'; -- ÁFRICA DEL SUR + +UPDATE `vn`.`country` +SET `a3Code` = 643 +WHERE `country` = 'Rusia'; -- FEDERACIÓN DE RUSIA + +UPDATE `vn`.`country` +SET `a3Code` = 28 +WHERE `country` = 'Antigua'; -- ANTIGUA Y BARBUDA + +UPDATE `vn`.`country` +SET `a3Code` = 840 +WHERE `country` = 'USA'; -- ESTADOS UNIDOS + +UPDATE `vn`.`country` +SET `a3Code` = 404 +WHERE `country` = 'Kenya'; -- KENIA + +UPDATE `vn`.`country` +SET `a3Code` = 498 +WHERE `country` = 'Moldavia'; -- REPÚBLICA DE MOLDAVIA + +UPDATE `vn`.`country` +SET `a3Code` = 826 +WHERE `country` = 'Gran Bretaña'; -- REINO UNIDO + +UPDATE `vn`.`country` +SET `a3Code` = 484 +WHERE `country` = 'Mexico'; -- MÉJICO + +UPDATE `vn`.`country` +SET `a3Code` = 716 +WHERE `country` = 'Zimbawe'; -- ZINBABWE + +UPDATE `vn`.`country` +SET `a3Code` = 203 +WHERE `country` = 'Chequia'; -- REPÚBLICA CHECA + +UPDATE `vn`.`country` +SET `a3Code` = 764 +WHERE `country` = 'Thailandia'; -- TAILANDIA + +UPDATE `vn`.`country` +SET `a3Code` = 276 +WHERE `country` = 'Alemania'; -- REPÚBLICA FEDERAL DE ALEMANIA + +UPDATE `vn`.`country` +SET `a3Code` = 112 +WHERE `country` = 'Bielorrusia'; -- BELARUS + +UPDATE `vn`.`country` +SET `a3Code` = 528 +WHERE `country` = 'Holanda'; -- PAÍSES BAJOS + +UPDATE `vn`.`country` +SET `a3Code` = 410 +WHERE `country` = 'Corea del Sur'; -- COREA (REPÚBLICA) + +UPDATE `vn`.`country` +SET `a3Code` = 724 +WHERE `country` = 'España exento'; -- ESPAÑA + +-- Borrar registro USA de country: +UPDATE `vn`.`supplier` `s` + SET `s`.`countryFk` = 62 + WHERE `s`.`countryFk` = 12; + +UPDATE `vn`.`bankEntity` + SET `countryFk` = 62 + WHERE `countryFk` = 12; + +DELETE FROM `vn`.`country` + WHERE `id`= 12; + +UPDATE `vn2008`.`payroll_pais` +SET `pais`='COREA NORTE (REPÚBLICA DEM. POPULAR)' +WHERE `codpais`=408; +UPDATE `vn2008`.`payroll_pais` +SET `pais`='COREA SUR (REPÚBLICA) ' +WHERE `codpais`=410; diff --git a/db/changes/10440-fallas/00-worker.sql b/db/changes/10440-fallas/00-worker.sql new file mode 100644 index 000000000..5688ebdf1 --- /dev/null +++ b/db/changes/10440-fallas/00-worker.sql @@ -0,0 +1,49 @@ + +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +UPDATE `vn`.`worker` `w` + SET `w`.`maritalStatus__` = NULL; + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id` + SET `w`.`maritalStatus__` = `pl`.`estadocivil`; + +ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen'; +ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL; +ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +INSERT INTO `vn`.`country` (`country`, `CEE`, `code`, `politicalCountryFk`, `isUeeMember`, `a3Code`) + VALUES + ('Argentina',2,'AR',80,0,32), + ('Cuba',2,'CU',81,0,192), + ('Guinea Ecuatorial',2,'GQ',82,0,226), + ('Guinea',2,'GN',83,0,324), + ('Honduras',2,'HN',84,0,340), + ('Mali',2,'ML',85,0,466), + ('Nicaragua',2,'NI',86,0,558), + ('Pakistán',2,'PK',87,0,586), + ('Paraguay',2,'PY',88,0,600), + ('Senegal',2,'SN',89,0,686), + ('Uruguay',2,'UY',90,0,858), + ('Venezuela',2,'VE',91,0,862), + ('Bulgaria',2,'BG',92,1,100), + ('Georgia',2,'GE',93,0,268); + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id` + JOIN `vn`.`country` `co` ON `co`.`a3Code` = `pl`.`codpais` + SET `w`.`originCountryFk` = `co`.`id`; + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id` + SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); \ No newline at end of file From bb267dad16426574f797bdc37577a1ecdb211541 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:17:27 +0200 Subject: [PATCH 2/7] feat: add fixtures --- db/changes/10440-fallas/00-aclEducationLevel.sql | 2 ++ db/dump/fixtures.sql | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 db/changes/10440-fallas/00-aclEducationLevel.sql diff --git a/db/changes/10440-fallas/00-aclEducationLevel.sql b/db/changes/10440-fallas/00-aclEducationLevel.sql new file mode 100644 index 000000000..26bf9d16f --- /dev/null +++ b/db/changes/10440-fallas/00-aclEducationLevel.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES('EducationLevel', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index aa03c39b5..63f206a7d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -47,6 +47,11 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active` INSERT INTO `account`.`account`(`id`) SELECT id FROM `account`.`user`; +INSERT INTO `vn`.`educationLevel` (`id`, `name`) + VALUES + (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), + (2, 'ENSEÑANZAS DE BACHILLERATO'); + INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 FROM `vn`.`user`; From 443db55f58e71e7a690ecfe9dd9be5d541154102 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:18:18 +0200 Subject: [PATCH 3/7] feat(worker_basic-data): add new fields --- modules/worker/back/model-config.json | 3 ++ .../worker/back/models/education-level.json | 18 ++++++++++ modules/worker/back/models/worker.json | 12 +++++++ modules/worker/front/basic-data/index.html | 36 +++++++++++++++++++ modules/worker/front/basic-data/index.js | 7 ++++ modules/worker/front/basic-data/locale/es.yml | 6 ++++ 6 files changed, 82 insertions(+) create mode 100644 modules/worker/back/models/education-level.json create mode 100644 modules/worker/front/basic-data/locale/es.yml diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index e35e39721..c155e331d 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -17,6 +17,9 @@ "Department": { "dataSource": "vn" }, + "EducationLevel": { + "dataSource": "vn" + }, "WorkCenter": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/education-level.json b/modules/worker/back/models/education-level.json new file mode 100644 index 000000000..641dfd6b4 --- /dev/null +++ b/modules/worker/back/models/education-level.json @@ -0,0 +1,18 @@ +{ + "name": "EducationLevel", + "base": "VnModel", + "options": { + "mysql": { + "table": "educationLevel" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number" + }, + "name": { + "type": "String" + } + } +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index cad38ac3b..209cc24f4 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -34,6 +34,18 @@ }, "bossFk": { "type" : "Number" + }, + "maritalStatus": { + "type" : "String" + }, + "originCountryFk": { + "type" : "Number" + }, + "educationLevelFk": { + "type" : "Number" + }, + "SSN": { + "type" : "String" } }, "relations": { diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index b61a4cf94..d49b7ab74 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -39,6 +39,42 @@ label="Boss"> + + + + + + + + + + + + diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index d2c7f5b70..ea75d7b97 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -2,6 +2,13 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $) { + super($element, $); + this.maritalStatus = [ + {code: 'M', name: this.$t('Married')}, + {code: 'S', name: this.$t('Single')} + ]; + } onSubmit() { return this.$.watcher.submit() .then(() => this.card.reload()); diff --git a/modules/worker/front/basic-data/locale/es.yml b/modules/worker/front/basic-data/locale/es.yml new file mode 100644 index 000000000..c4fcd5529 --- /dev/null +++ b/modules/worker/front/basic-data/locale/es.yml @@ -0,0 +1,6 @@ +Marital status: Estado civil +Origin country: País origen +Education level: Nivel educación +SSN: NSS +Married: Casado +Single: Soltero \ No newline at end of file From fe32b81d9e43a30ed8a403af34be94aeed3de76d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 10:50:05 +0200 Subject: [PATCH 4/7] sql update --- db/changes/10440-fallas/00-country.sql | 2 ++ db/changes/10440-fallas/00-worker.sql | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/changes/10440-fallas/00-country.sql b/db/changes/10440-fallas/00-country.sql index 06b4f9b94..6cc4ce1f9 100644 --- a/db/changes/10440-fallas/00-country.sql +++ b/db/changes/10440-fallas/00-country.sql @@ -86,3 +86,5 @@ WHERE `codpais`=408; UPDATE `vn2008`.`payroll_pais` SET `pais`='COREA SUR (REPÚBLICA) ' WHERE `codpais`=410; + +RENAME TABLE `vn2008`.`payroll_pais` TO `vn2008`.`payroll_pais__`; \ No newline at end of file diff --git a/db/changes/10440-fallas/00-worker.sql b/db/changes/10440-fallas/00-worker.sql index 5688ebdf1..0e0def841 100644 --- a/db/changes/10440-fallas/00-worker.sql +++ b/db/changes/10440-fallas/00-worker.sql @@ -46,4 +46,6 @@ UPDATE `vn`.`worker` `w` JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id` - SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); \ No newline at end of file + SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); + +RENAME TABLE `vn2008`.`profile_labour_payroll` TO `vn2008`.`profile_labour_payroll__`; From 2c54f31985b98cf8fd42e7cec79408ec29d04d69 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 10:54:30 +0200 Subject: [PATCH 5/7] refactor: uppercase --- modules/worker/back/models/education-level.json | 4 ++-- modules/worker/back/models/worker.json | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/worker/back/models/education-level.json b/modules/worker/back/models/education-level.json index 641dfd6b4..4ae2376c4 100644 --- a/modules/worker/back/models/education-level.json +++ b/modules/worker/back/models/education-level.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" } } } \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 209cc24f4..c8054caff 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -13,7 +13,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -26,26 +26,26 @@ "required": true }, "phone": { - "type" : "String" + "type" : "string" }, "userFk": { - "type" : "Number", + "type" : "number", "required": true }, "bossFk": { - "type" : "Number" + "type" : "number" }, "maritalStatus": { - "type" : "String" + "type" : "string" }, "originCountryFk": { - "type" : "Number" + "type" : "number" }, "educationLevelFk": { - "type" : "Number" + "type" : "number" }, "SSN": { - "type" : "String" + "type" : "string" } }, "relations": { From 5f29b272e1548a227f0603f09208f68f3121cf76 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 11:38:08 +0200 Subject: [PATCH 6/7] feat: add fixtures --- db/dump/fixtures.sql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 63f206a7d..bae229513 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -56,6 +56,27 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossF SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 FROM `vn`.`user`; +ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen'; +ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL; +ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +UPDATE `vn`.`worker` `w` + SET `maritalStatus` = 'S'; + +UPDATE `vn`.`worker` `w` + SET `originCountryFk` = '1'; + +UPDATE `vn`.`worker` `w` + SET `educationLevelFk` = '2'; + +UPDATE `vn`.`worker` `w` + SET `SSN` = '123456789123'; + 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; From a34876215345d88fdcce981302a1e20a3fffd35f Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 09:09:05 +0200 Subject: [PATCH 7/7] refactor: pull request changes --- modules/worker/front/basic-data/index.html | 4 ---- modules/worker/front/basic-data/locale/es.yml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index d49b7ab74..cbe683185 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -30,7 +30,6 @@ rule>