From 1a01b3e58795f1b17993d4d6b8a8a9e5ac82b33c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 10 Jun 2024 10:42:52 +0200 Subject: [PATCH 01/34] refs #7529 back models acls --- .../11094-maroonCyca/00-firstScript.sql | 8 +++ modules/worker/back/model-config.json | 9 +++ .../worker/back/models/disability-grade.json | 18 ++++++ modules/worker/back/models/worker-irpf.json | 60 +++++++++++++++++++ .../worker/back/models/worker-relatives.json | 53 ++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 db/versions/11094-maroonCyca/00-firstScript.sql create mode 100644 modules/worker/back/models/disability-grade.json create mode 100644 modules/worker/back/models/worker-irpf.json create mode 100644 modules/worker/back/models/worker-relatives.json diff --git a/db/versions/11094-maroonCyca/00-firstScript.sql b/db/versions/11094-maroonCyca/00-firstScript.sql new file mode 100644 index 000000000..dfaf5b79e --- /dev/null +++ b/db/versions/11094-maroonCyca/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here +-- Auto-generated SQL script #202406101036 +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','workerRelatives','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','workerIrpf','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','disabilityGrade','*','ALLOW','ROLE','hr'); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index b7c355511..e58685123 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -124,6 +124,15 @@ }, "Locker": { "dataSource": "vn" + }, + "WorkerIrpf": { + "dataSource": "vn" + }, + "DisabilityGrade": { + "dataSource": "vn" + }, + "WorkerRelatives": { + "dataSource": "vn" } } diff --git a/modules/worker/back/models/disability-grade.json b/modules/worker/back/models/disability-grade.json new file mode 100644 index 000000000..506138225 --- /dev/null +++ b/modules/worker/back/models/disability-grade.json @@ -0,0 +1,18 @@ +{ + "name": "DisabilityGrade", + "base": "VnModel", + "options": { + "mysql": { + "table": "disabilityGrade" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "description": { + "type": "string" + } + } +} diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json new file mode 100644 index 000000000..034bed368 --- /dev/null +++ b/modules/worker/back/models/worker-irpf.json @@ -0,0 +1,60 @@ +{ + "name": "WorkerIrpf", + "description": "Model 145 IRPF", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerIrpf" + } + }, + "properties": { + "workerFk": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "spouseNif": { + "type": "string" + }, + "geographicMobilityDate": { + "type": "date" + }, + "disabilityGradeFk": { + "type" : "number" + }, + "isDependent": { + "type" : "number" + }, + "familySituation": { + "type" : "number" + }, + "spousePension": { + "type" : "number" + }, + "childPension": { + "type" : "number" + }, + "hasHousingPaymentBefore": { + "type" : "number" + }, + "hasHousingPaymentAfter": { + "type" : "number" + }, + "updated": { + "type" : "date" + } + + }, + "relations": { + "disabilityGrade": { + "type": "belongsTo", + "model": "disabilityGrade", + "foreignKey": "disabilityGradeFk" + }, + "worker": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "workerFK" + } + } +} diff --git a/modules/worker/back/models/worker-relatives.json b/modules/worker/back/models/worker-relatives.json new file mode 100644 index 000000000..2429a2f1c --- /dev/null +++ b/modules/worker/back/models/worker-relatives.json @@ -0,0 +1,53 @@ +{ + "name": "WorkerRelatives", + "description": "Model 145 IRPF", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerRelatives" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "workerFk": { + "type": "number" + }, + "isDescendant": { + "type": "number" + }, + "disabilityGradeFk": { + "type" : "number" + }, + "birthed": { + "type" : "number" + }, + "adoptionYear": { + "type" : "number" + }, + "isDependend": { + "type" : "boolean" + }, + "islointCustody": { + "type" : "boolean" + }, + "updated": { + "type" : "date" + } + }, + "relations": { + "disabilityGrade": { + "type": "belongsTo", + "model": "disabilityGrade", + "foreignKey": "disabilityGradeFk" + }, + "worker": { + "type": "belongsTo", + "model": "WorkerIrpf", + "foreignKey": "workerFK" + } + } +} From 5da6c09f6808794778ad36629e6342c29e91da66 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 18 Sep 2024 12:08:49 +0200 Subject: [PATCH 02/34] fix: refs #7529 workerPit --- db/versions/11094-maroonCyca/00-firstScript.sql | 8 -------- .../11245-turquoiseAnthurium/00-firstScript.sql | 15 +++++++++++++++ modules/worker/back/model-config.json | 2 +- modules/worker/back/models/worker-irpf.json | 2 +- modules/worker/back/models/worker-relatives.json | 8 ++++---- modules/worker/back/models/worker.json | 12 +++++++++++- 6 files changed, 32 insertions(+), 15 deletions(-) delete mode 100644 db/versions/11094-maroonCyca/00-firstScript.sql create mode 100644 db/versions/11245-turquoiseAnthurium/00-firstScript.sql diff --git a/db/versions/11094-maroonCyca/00-firstScript.sql b/db/versions/11094-maroonCyca/00-firstScript.sql deleted file mode 100644 index dfaf5b79e..000000000 --- a/db/versions/11094-maroonCyca/00-firstScript.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Place your SQL code here --- Auto-generated SQL script #202406101036 -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','workerRelatives','*','ALLOW','ROLE','hr'); -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','workerIrpf','*','ALLOW','ROLE','hr'); -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','disabilityGrade','*','ALLOW','ROLE','hr'); diff --git a/db/versions/11245-turquoiseAnthurium/00-firstScript.sql b/db/versions/11245-turquoiseAnthurium/00-firstScript.sql new file mode 100644 index 000000000..6381f5db4 --- /dev/null +++ b/db/versions/11245-turquoiseAnthurium/00-firstScript.sql @@ -0,0 +1,15 @@ +ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; +ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; + +RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; + +ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; +ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; + + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES + ('Worker','workerRelative','*','ALLOW','ROLE','hr'), + ('Worker','workerIrpf','*','ALLOW','ROLE','hr'), + ('Worker','disabilityGrade','*','ALLOW','ROLE','hr'); + diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index eb3e573e1..dc078f4d0 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -131,7 +131,7 @@ "DisabilityGrade": { "dataSource": "vn" }, - "WorkerRelatives": { + "WorkerRelative": { "dataSource": "vn" }, "MedicalReview": { diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json index 034bed368..44bd9713c 100644 --- a/modules/worker/back/models/worker-irpf.json +++ b/modules/worker/back/models/worker-irpf.json @@ -22,7 +22,7 @@ "disabilityGradeFk": { "type" : "number" }, - "isDependent": { + "isDependend": { "type" : "number" }, "familySituation": { diff --git a/modules/worker/back/models/worker-relatives.json b/modules/worker/back/models/worker-relatives.json index 2429a2f1c..0815f7330 100644 --- a/modules/worker/back/models/worker-relatives.json +++ b/modules/worker/back/models/worker-relatives.json @@ -1,10 +1,10 @@ { - "name": "WorkerRelatives", + "name": "WorkerRelative", "description": "Model 145 IRPF", "base": "VnModel", "options": { "mysql": { - "table": "workerRelatives" + "table": "workerRelative" } }, "properties": { @@ -31,7 +31,7 @@ "isDependend": { "type" : "boolean" }, - "islointCustody": { + "isJointCustody": { "type" : "boolean" }, "updated": { @@ -46,7 +46,7 @@ }, "worker": { "type": "belongsTo", - "model": "WorkerIrpf", + "model": "VnUser", "foreignKey": "workerFK" } } diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 21c5bd10f..568d23b91 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -135,6 +135,16 @@ "type": "hasMany", "model": "WorkerTimeControlMail", "foreignKey": "workerFk" + }, + "irpf": { + "type": "hasMany", + "model": "WorkerIrpf", + "foreignKey": "workerFk" + }, + "workerRelative": { + "type": "hasMany", + "model": "WorkerRelative", + "foreignKey": "workerFK" } }, "acls": [ @@ -207,4 +217,4 @@ ] } } -} \ No newline at end of file +} From 903d85a2439d10eb2d6b1a51a16feb382770ed49 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 14:06:39 +0200 Subject: [PATCH 03/34] fix: refs #7529 fix back --- .../00-firstScript.sql | 20 +++++++++---------- .../11312-navyAralia/00-firstScript.sql | 15 ++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 db/versions/11312-navyAralia/00-firstScript.sql diff --git a/db/versions/11245-turquoiseAnthurium/00-firstScript.sql b/db/versions/11245-turquoiseAnthurium/00-firstScript.sql index 6381f5db4..f1c4d9471 100644 --- a/db/versions/11245-turquoiseAnthurium/00-firstScript.sql +++ b/db/versions/11245-turquoiseAnthurium/00-firstScript.sql @@ -1,15 +1,15 @@ -ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; -ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; +-- ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; +-- ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; -RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; +-- RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; -ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; -ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; +-- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; +-- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES - ('Worker','workerRelative','*','ALLOW','ROLE','hr'), - ('Worker','workerIrpf','*','ALLOW','ROLE','hr'), - ('Worker','disabilityGrade','*','ALLOW','ROLE','hr'); +-- INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) +-- VALUES +-- ('workerRelative','*','*','ALLOW','ROLE','hr'), +-- ('workerIrpf','*','*','ALLOW','ROLE','hr'), +-- ('disabilityGrade','*','*','ALLOW','ROLE','hr'); diff --git a/db/versions/11312-navyAralia/00-firstScript.sql b/db/versions/11312-navyAralia/00-firstScript.sql new file mode 100644 index 000000000..0d58503bb --- /dev/null +++ b/db/versions/11312-navyAralia/00-firstScript.sql @@ -0,0 +1,15 @@ +ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; +ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; + +-- RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; + +-- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; +-- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; + + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES + ('workerRelatives','*','*','ALLOW','ROLE','hr'), + ('workerIrpf','*','*','ALLOW','ROLE','hr'), + ('disabilityGrade','*','*','ALLOW','ROLE','hr'); + From 6b10f60933f4c9bda512053aa32d1c3ce9f4fb15 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 29 Oct 2024 08:03:18 +0100 Subject: [PATCH 04/34] fix: refs #7529 mod model --- modules/worker/back/models/worker-relatives.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker-relatives.json b/modules/worker/back/models/worker-relatives.json index 0815f7330..532a9446c 100644 --- a/modules/worker/back/models/worker-relatives.json +++ b/modules/worker/back/models/worker-relatives.json @@ -4,7 +4,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "workerRelative" + "table": "workerRelatives" } }, "properties": { From e0e487859fcbbe8adbc1f38f9d1bb39ed62cf6d3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 29 Oct 2024 13:59:47 +0100 Subject: [PATCH 05/34] fix: refs #7529 fix models --- db/dump/fixtures.before.sql | 6 ++++++ modules/worker/back/models/worker-irpf.json | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 595027b09..dd4bc7881 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4007,4 +4007,10 @@ INSERT IGNORE INTO pbx.queueMember UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO vn.workerRelatives (workerFk, isDescendant, disabilityGradeFk, birthed, adoptionYear, isDependend, isJointCustody, updated) + VALUES + (1106, 1, NULL, 0, NULL, 0, 0, '2024-10-29 08:42:44.000'); +INSERT INTO vn.workerIrpf (workerFk,spouseNif,geographicMobilityDate) + VALUES + (1106,'26493101E','2019-09-20'); diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json index 44bd9713c..65f72a1fd 100644 --- a/modules/worker/back/models/worker-irpf.json +++ b/modules/worker/back/models/worker-irpf.json @@ -10,7 +10,7 @@ "properties": { "workerFk": { "type": "number", - "id": true, + "id": 1, "description": "Identifier" }, "spouseNif": { @@ -50,11 +50,6 @@ "type": "belongsTo", "model": "disabilityGrade", "foreignKey": "disabilityGradeFk" - }, - "worker": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "workerFK" } } } From fa108e2af01637a7552d9364ca4838eac6302769 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 8 Nov 2024 11:56:17 +0100 Subject: [PATCH 06/34] fix: refs #7529 fix sql --- .../11245-turquoiseAnthurium/00-firstScript.sql | 15 --------------- db/versions/11312-navyAralia/00-firstScript.sql | 12 +++--------- 2 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 db/versions/11245-turquoiseAnthurium/00-firstScript.sql diff --git a/db/versions/11245-turquoiseAnthurium/00-firstScript.sql b/db/versions/11245-turquoiseAnthurium/00-firstScript.sql deleted file mode 100644 index f1c4d9471..000000000 --- a/db/versions/11245-turquoiseAnthurium/00-firstScript.sql +++ /dev/null @@ -1,15 +0,0 @@ --- ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; --- ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; - --- RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; - --- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; --- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; - - --- INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) --- VALUES --- ('workerRelative','*','*','ALLOW','ROLE','hr'), --- ('workerIrpf','*','*','ALLOW','ROLE','hr'), --- ('disabilityGrade','*','*','ALLOW','ROLE','hr'); - diff --git a/db/versions/11312-navyAralia/00-firstScript.sql b/db/versions/11312-navyAralia/00-firstScript.sql index 0d58503bb..446c7d4fe 100644 --- a/db/versions/11312-navyAralia/00-firstScript.sql +++ b/db/versions/11312-navyAralia/00-firstScript.sql @@ -1,15 +1,9 @@ ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_disabilityGradeFk; ALTER TABLE vn.workerRelatives DROP FOREIGN KEY workerRelatives_workerFk; --- RENAME TABLE `vn`.`workerRelatives` TO `vn`.`workerRelative`; - --- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE; --- ALTER TABLE vn.workerRelative ADD CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE; - - INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES - ('workerRelatives','*','*','ALLOW','ROLE','hr'), - ('workerIrpf','*','*','ALLOW','ROLE','hr'), - ('disabilityGrade','*','*','ALLOW','ROLE','hr'); + ('WorkerRelative','*','*','ALLOW','ROLE','hr'), + ('WorkerIrpf','*','*','ALLOW','ROLE','hr'), + ('DisabilityGrade','*','*','ALLOW','ROLE','hr'); From 25891e0bada36df43d809e00024504dc8808ca55 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 11 Nov 2024 10:42:06 +0100 Subject: [PATCH 07/34] feat: refs #6924 notify absences only to department boss --- modules/worker/back/methods/worker/createAbsence.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 0397886cf..c7f968edb 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -87,7 +87,8 @@ module.exports = Self => { `SELECT COUNT(*) halfHolidayCounter FROM vn.calendar c JOIN vn.business b ON b.id = c.businessFk - WHERE c.dayOffTypeFk = 6 + JOIN vn.absenceType at ON at.id = c.dayOffTypeFk + WHERE at.code = 'halfHoliday' AND b.workerFk = ? AND c.dated BETWEEN util.firstDayOfYear(?) AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]); @@ -120,10 +121,12 @@ module.exports = Self => { }, myOptions); const department = labour.department(); - if (department && department.notificationEmail) { + if (department) { const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions); const account = await models.VnUser.findById(userId, null, myOptions); const subordinated = await models.VnUser.findById(id, null, myOptions); + const worker = await models.Worker.findById(subordinated.id, null, myOptions); + const boss = await models.VnUser.findById(worker.bossFk, null, myOptions); const url = await Self.app.models.Url.getUrl(); const body = $t('Created absence', { author: account.nickname, @@ -135,7 +138,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Absence change notification on the labour calendar'), body: body, - receiver: department.notificationEmail + receiver: boss.email }, myOptions); } From cf102699d5b38ace3a1c212676369a57458c553e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 11 Nov 2024 14:19:11 +0100 Subject: [PATCH 08/34] feat: refs#8087 Redadas en travel --- db/dump/fixtures.before.sql | 24 +++++++++---------- .../procedures/availableNoRaids_refresh.sql | 2 +- .../triggers/supplyResponse_afterUpdate.sql | 2 +- .../hedera/procedures/item_getVisible.sql | 4 ++-- .../stock/procedures/log_refreshBuy.sql | 9 ++++--- .../procedures/absoluteInventoryHistory.sql | 4 ++-- .../vn/procedures/available_traslate.sql | 6 ++--- .../vn/procedures/entry_getTransfer.sql | 2 +- db/routines/vn/procedures/inventoryMake.sql | 4 ++-- db/routines/vn/procedures/item_getBalance.sql | 4 ++-- db/routines/vn/procedures/item_getMinacum.sql | 2 +- .../vn/procedures/item_multipleBuyByDate.sql | 2 +- .../vn/procedures/item_valuateInventory.sql | 6 ++--- .../vn/procedures/multipleInventory.sql | 8 +++---- .../vn/procedures/travelVolume_get.sql | 2 +- .../vn/procedures/travel_moveRaids.sql | 17 ++++++------- .../vn/triggers/entry_beforeUpdate.sql | 6 ++--- db/routines/vn/views/itemEntryIn.sql | 2 +- db/routines/vn/views/itemEntryOut.sql | 2 +- db/routines/vn/views/lastPurchases.sql | 2 +- db/routines/vn2008/views/entrySource.sql | 1 + db/routines/vn2008/views/travel.sql | 1 + db/routines/vn2008/views/v_compres.sql | 2 +- .../11332-tealErica/00-firstScript.sql | 4 ++++ modules/entry/back/locale/entry/en.yml | 1 + modules/entry/back/locale/entry/es.yml | 1 + modules/entry/back/methods/entry/filter.js | 2 +- modules/entry/back/methods/entry/getEntry.js | 4 ++-- modules/entry/back/models/entry.json | 3 +++ modules/entry/front/descriptor/index.html | 2 +- modules/entry/front/summary/index.html | 2 +- modules/travel/back/methods/travel/filter.js | 1 + modules/travel/back/models/travel.json | 3 +++ 33 files changed, 76 insertions(+), 61 deletions(-) create mode 100644 db/versions/11332-tealErica/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..54dd9ec14 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1505,18 +1505,18 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`) - 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, NULL), - (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL), - (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL), - (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, NULL), - (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, NULL), - (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, NULL), - (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, 2), - (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, NULL), - (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2), - (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL); +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `daysInForward`) + 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, FALSE, NULL), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, FALSE, NULL), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, NULL), + (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, FALSE, NULL), + (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, FALSE, NULL), + (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, FALSE,NULL), + (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, TRUE, 2), + (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, FALSE, NULL), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), + (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`) VALUES diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql index efbbf6a13..447300305 100644 --- a/db/routines/cache/procedures/availableNoRaids_refresh.sql +++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql @@ -53,7 +53,7 @@ proc: BEGIN WHERE t.landed BETWEEN vInventoryDate AND vStartDate AND t.warehouseInFk = vWarehouse AND s.name != 'INVENTARIO' - AND NOT t.daysInForward + AND NOT t.isRaid GROUP BY b.itemFk ) c JOIN vn.item i ON i.id = c.itemFk diff --git a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql index 28a8c9466..f3e5aaefd 100644 --- a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql +++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql @@ -14,7 +14,7 @@ BEGIN b.stickers = NEW.NumberOfUnits WHERE i.supplyResponseFk = NEW.ID AND am.name = 'LOGIFLORA' - AND tr.daysInForward + AND tr.isRaid AND tr.landed >= util.VN_CURDATE(); END$$ diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql index 365161bdf..d5bbe9d76 100644 --- a/db/routines/hedera/procedures/item_getVisible.sql +++ b/db/routines/hedera/procedures/item_getVisible.sql @@ -59,7 +59,7 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDateInv AND vDate AND t.warehouseInFk = vWarehouse - AND NOT t.daysInForward + AND NOT t.isRaid UNION ALL SELECT b.itemFk, -b.quantity FROM vn.buy b @@ -67,7 +67,7 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseOutFk = vWarehouse - AND NOT t.daysInForward + AND NOT t.isRaid AND t.isDelivered UNION ALL SELECT m.itemFk, -m.quantity diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql index d8e727f17..874e14072 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -6,12 +6,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues ENGINE = MEMORY - SELECT - b.id buyFk, + SELECT b.id buyFk, e.id entryFk, t.id travelFk, b.itemFk, - t.daysInForward, + t.isRaid, ADDTIME(t.shipped, IFNULL(t.shipmentHour, '00:00:00')) shipped, t.warehouseOutFk, @@ -50,7 +49,7 @@ BEGIN itemFk, TIMESTAMPADD(DAY, life, @dated), quantity, - IF(isIn, isReceived, isDelivered) AND NOT daysInForward + IF(isIn, isReceived, isDelivered) AND NOT isRaid FROM tValues WHERE isIn OR !lessThanInventory; @@ -65,7 +64,7 @@ BEGIN itemFk, created, quantity, - IF(isIn, isDelivered, isReceived) AND NOT daysInForward + IF(isIn, isDelivered, isReceived) AND NOT isRaid FROM tValues WHERE !isIn OR !lessThanInventory; diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 3ea8cf4de..d0d9ffac2 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -39,7 +39,7 @@ BEGIN AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT tr.daysInForward + AND NOT tr.isRaid UNION ALL SELECT tr.shipped, NULL, @@ -58,7 +58,7 @@ BEGIN AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT tr.daysInForward + AND NOT tr.isRaid UNION ALL SELECT t.shipped, NULL, diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 513f58e36..bfd5b34c8 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -42,7 +42,7 @@ proc: BEGIN WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom AND t.warehouseInFk = vWarehouseLanding AND NOT e.isExcludedFromAvailable - AND NOT t.daysInForward + AND NOT t.isRaid GROUP BY c.itemFk; -- Tabla con el ultimo dia de last_buy para cada producto @@ -57,7 +57,7 @@ proc: BEGIN JOIN travel tr ON tr.id = e.travelFk LEFT JOIN tItemRange i ON t.itemFk = i.itemFk WHERE t.warehouseFk = vWarehouseShipment - AND NOT tr.daysInForward + AND NOT tr.isRaid ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, tr.landed); @@ -94,7 +94,7 @@ proc: BEGIN JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk WHERE NOT e.isExcludedFromAvailable AND b.quantity <> 0 - AND NOT t.daysInForward + AND NOT t.isRaid AND t.warehouseInFk = vWarehouseLanding AND t.landed >= vDatedFrom AND (ir.dated IS NULL OR t.landed <= ir.dated) diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index 9527e0bf2..873827db2 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -166,7 +166,7 @@ BEGIN LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id LEFT JOIN buy b3 ON b3.id = bufi.buyFk WHERE ic.display - AND NOT tr.daysInForward + AND NOT tr.isRaid AND (ti.visible OR ti.available) ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name; diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index 65dceef3d..316083db0 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -137,7 +137,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk WHERE tr.warehouseInFk = vWarehouseFk AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday - AND NOT tr.daysInForward + AND NOT tr.isRaid GROUP BY b.itemFk; -- Transfers @@ -150,7 +150,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk WHERE tr.warehouseOutFk = vWarehouseFk AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday - AND NOT tr.daysInForward + AND NOT tr.isRaid GROUP BY b.itemFk ) sub ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut; diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 260f0a527..c4974491c 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -59,7 +59,7 @@ BEGIN AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT tr.daysInForward + AND NOT tr.isRaid ), entriesOut AS ( SELECT 'entry', @@ -95,7 +95,7 @@ BEGIN AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT w.isFeedStock - AND NOT tr.daysInForward + AND NOT tr.isRaid ), sales AS ( WITH itemSales AS ( diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 8a42bd737..e3c915820 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -63,7 +63,7 @@ BEGIN AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND NOT t.daysInForward + AND NOT t.isRaid UNION ALL SELECT r.itemFk, r.shipment, diff --git a/db/routines/vn/procedures/item_multipleBuyByDate.sql b/db/routines/vn/procedures/item_multipleBuyByDate.sql index 7bd809312..04d3f1855 100644 --- a/db/routines/vn/procedures/item_multipleBuyByDate.sql +++ b/db/routines/vn/procedures/item_multipleBuyByDate.sql @@ -30,7 +30,7 @@ BEGIN AND NOT s.name = 'INVENTARIO' AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND w.isComparative - AND NOT t.daysInForward + AND NOT t.isRaid GROUP BY i.id; UPDATE tmp.itemInventory y diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index b6d687960..7e420be27 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -109,7 +109,7 @@ BEGIN JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) - AND NOT tr.daysInForward + AND NOT tr.isRaid AND w.valuatedInventory AND t.isInventory AND e.supplierFk <> vInventorySupplierFk @@ -131,7 +131,7 @@ BEGIN JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd - AND NOT tr.daysInForward + AND NOT tr.isRaid AND w.valuatedInventory AND t.isInventory AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) @@ -196,7 +196,7 @@ BEGIN JOIN warehouse wIn ON wIn.id = tr.warehouseInFk JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk WHERE vDated >= tr.shipped AND vDated < tr.landed - AND NOT tr.daysInForward + AND NOT tr.isRaid AND wIn.valuatedInventory AND t.isInventory AND e.isConfirmed diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 6b26e456f..ee18bbe96 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -60,7 +60,7 @@ proc: BEGIN AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk AND w.isComparative AND NOT e.isExcludedFromAvailable - AND NOT t.daysInForward + AND NOT t.isRaid UNION ALL SELECT b.itemFk, - b.quantity FROM buy b @@ -71,7 +71,7 @@ proc: BEGIN AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk AND w.isComparative AND NOT e.isExcludedFromAvailable - AND NOT t.daysInForward + AND NOT t.isRaid ) sub GROUP BY itemFk; @@ -121,7 +121,7 @@ proc: BEGIN AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk AND w.isComparative AND NOT e.isExcludedFromAvailable - AND NOT t.daysInForward + AND NOT t.isRaid UNION ALL SELECT b.itemFk, t.shipped, - b.quantity FROM buy b @@ -132,7 +132,7 @@ proc: BEGIN AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk AND w.isComparative AND NOT e.isExcludedFromAvailable - AND NOT t.daysInForward + AND NOT t.isRaid ) sub GROUP BY sub.itemFk, sub.dated; diff --git a/db/routines/vn/procedures/travelVolume_get.sql b/db/routines/vn/procedures/travelVolume_get.sql index bb98cacdf..ab24a6395 100644 --- a/db/routines/vn/procedures/travelVolume_get.sql +++ b/db/routines/vn/procedures/travelVolume_get.sql @@ -10,7 +10,7 @@ BEGIN JOIN vn.entry e ON e.travelFk = tr.id JOIN vn.buy b ON b.entryFk = e.id WHERE tr.landed BETWEEN vFromDated AND vToDated - AND NOT tr.daysInForward + AND NOT tr.isRaid AND tr.warehouseInFk = vWarehouseFk GROUP BY tr.landed , a.name ; END$$ diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index aa554a1a0..cf0fce23c 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`() BEGIN /** * Desplaza los travels en el futuro y avisa a los compradores - * + * */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBuyerEmail VARCHAR(40); @@ -11,21 +11,21 @@ BEGIN DECLARE vMailBody TEXT DEFAULT ''; DECLARE vCur CURSOR FOR - SELECT GROUP_CONCAT(DISTINCT - CONCAT('https://salix.verdnatura.es/#!/travel/', - ttm.travelFk, + SELECT GROUP_CONCAT(DISTINCT + CONCAT('https://salix.verdnatura.es/#!/travel/', + ttm.travelFk, '/summary ') ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink, CONCAT(u.name, '@verdnatura.es') buyerEmail FROM tTravelToMove ttm - JOIN entry e ON e.travelFk = ttm.travelFk + JOIN entry e ON e.travelFk = ttm.travelFk JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk JOIN itemType it ON it.id = i.typeFk JOIN account.user u ON u.id = it.workerFk GROUP BY u.name; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -34,10 +34,11 @@ BEGIN END; CREATE OR REPLACE TEMPORARY TABLE tTravelToMove - SELECT id travelFk, + SELECT id travelFk, util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded FROM travel - WHERE daysInForward; + WHERE isRaid + AND daysInForward; START TRANSACTION; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 3b999012f..1d0c26fc1 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate` BEFORE UPDATE ON `entry` FOR EACH ROW BEGIN - DECLARE vDaysInForward INT; + DECLARE vIsRaid BOOL; DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; DECLARE vTotalBuy INT; @@ -38,7 +38,7 @@ BEGIN CALL travel_throwAwb(NEW.travelFk); END IF; - SELECT daysInForward INTO vDaysInForward + SELECT isRaid INTO vIsRaid FROM travel t JOIN entry e ON e.travelFk = t.id WHERE entryFk = NEW.id; @@ -50,7 +50,7 @@ BEGIN WHERE o.id = OLD.travelFk AND n.id = NEW.travelFk; - IF vDaysInForward AND vHasDistinctWarehouses THEN + IF vIsRaid AND vHasDistinctWarehouses THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses'; END IF; diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql index 6196e9396..60af585f2 100644 --- a/db/routines/vn/views/itemEntryIn.sql +++ b/db/routines/vn/views/itemEntryIn.sql @@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`, `b`.`itemFk` AS `itemFk`, `b`.`quantity` AS `quantity`, `t`.`isReceived` AS `isReceived`, - `t`.`daysInForward` AS `isVirtualStock`, + `t`.`isRaid` AS `isVirtualStock`, `e`.`id` AS `entryFk` FROM ( ( diff --git a/db/routines/vn/views/itemEntryOut.sql b/db/routines/vn/views/itemEntryOut.sql index f18116e61..4793ddbb8 100644 --- a/db/routines/vn/views/itemEntryOut.sql +++ b/db/routines/vn/views/itemEntryOut.sql @@ -15,5 +15,5 @@ FROM ( JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`) ) WHERE `e`.`isExcludedFromAvailable` = 0 - AND NOT `t`.`daysInForward` + AND NOT `t`.`isRaid` AND `b`.`quantity` <> 0 diff --git a/db/routines/vn/views/lastPurchases.sql b/db/routines/vn/views/lastPurchases.sql index 9dc5ec898..3dcaf8c1d 100644 --- a/db/routines/vn/views/lastPurchases.sql +++ b/db/routines/vn/views/lastPurchases.sql @@ -31,5 +31,5 @@ FROM ( LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`) ) WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`() - AND NOT `tr`.`daysInForward` + AND NOT `tr`.`isRaid` AND `b`.`stickers` > 0 diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql index 9c0c0f6ed..732603617 100644 --- a/db/routines/vn2008/views/entrySource.sql +++ b/db/routines/vn2008/views/entrySource.sql @@ -8,6 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`, `e`.`isExcludedFromAvailable` AS `Inventario`, `e`.`isConfirmed` AS `Confirmada`, `e`.`isOrdered` AS `Pedida`, + `tr`.`isRaid` AS `isRaid`, `tr`.`daysInForward` AS `daysInForward`, `e`.`evaNotes` AS `notas`, `e`.`supplierFk` AS `Id_Proveedor`, diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql index 0e1f5acb2..38dfd40ea 100644 --- a/db/routines/vn2008/views/travel.sql +++ b/db/routines/vn2008/views/travel.sql @@ -18,5 +18,6 @@ AS SELECT `t`.`id` AS `id`, `t`.`totalEntries` AS `totalEntries`, `t`.`appointment` AS `appointment`, `t`.`awbFk` AS `awbFk`, + `t`.`isRaid` AS `isRaid`, `t`.`daysInForward` AS `daysInForward` FROM `vn`.`travel` `t` diff --git a/db/routines/vn2008/views/v_compres.sql b/db/routines/vn2008/views/v_compres.sql index 324e459f6..633feb471 100644 --- a/db/routines/vn2008/views/v_compres.sql +++ b/db/routines/vn2008/views/v_compres.sql @@ -86,4 +86,4 @@ FROM ( ) WHERE NOT `W_IN`.`isFeedStock` AND NOT `E`.`Inventario` - AND NOT `TR`.`daysInForward` + AND NOT `TR`.`isRaid` diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql new file mode 100644 index 000000000..9d87f6dea --- /dev/null +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; + +ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL + COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed'; diff --git a/modules/entry/back/locale/entry/en.yml b/modules/entry/back/locale/entry/en.yml index ab8c0fd1c..6bc2333e6 100644 --- a/modules/entry/back/locale/entry/en.yml +++ b/modules/entry/back/locale/entry/en.yml @@ -9,6 +9,7 @@ columns: notes: notes isConfirmed: confirmed isVirtual: virtual + isRaid: raid commission: commission isOrdered: price3 created: created diff --git a/modules/entry/back/locale/entry/es.yml b/modules/entry/back/locale/entry/es.yml index 18bf1ca33..a892b05d2 100644 --- a/modules/entry/back/locale/entry/es.yml +++ b/modules/entry/back/locale/entry/es.yml @@ -9,6 +9,7 @@ columns: notes: notas isConfirmed: confirmado isVirtual: virtual + isRaid: redada commission: comisión isOrdered: pedida created: creado diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index a5c236fe4..b23e44212 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -194,7 +194,7 @@ module.exports = Self => { e.evaNotes observation, e.isConfirmed, e.isOrdered, - t.daysInForward, + t.isRaid, e.commission, e.created, e.travelFk, diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js index 4612de9a5..92be9a9dd 100644 --- a/modules/entry/back/methods/entry/getEntry.js +++ b/modules/entry/back/methods/entry/getEntry.js @@ -49,8 +49,8 @@ module.exports = Self => { 'isReceived', 'isDelivered', 'ref', - 'daysInForward', - ], + 'isRaid', + 'daysInForward'], include: [ { relation: 'agency', diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index 4a09c7d6a..e2da2c629 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -33,6 +33,9 @@ "isConfirmed": { "type": "boolean" }, + "isRaid": { + "type": "boolean" + }, "commission": { "type": "number" }, diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 40625a4d5..957bcafb5 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -30,7 +30,7 @@ + ng-if="$ctrl.entryData.travel.isRaid">