From fa9451ea38d72a2b2dc6d6386476e65761796d79 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 25 Oct 2024 16:15:13 +0200 Subject: [PATCH 01/24] feat: refs #7821 isBooked with grants --- db/dump/fixtures.before.sql | 27 +++++++------ .../vn/procedures/entry_isEditable.sql | 16 ++++---- .../11322-azureAspidistra/00-entryAcl.sql | 40 +++++++++++++++++++ loopback/locale/en.json | 10 +++-- loopback/locale/es.json | 8 +++- loopback/locale/fr.json | 3 +- loopback/locale/pt.json | 3 +- modules/entry/back/models/entry.js | 19 ++++++--- .../back/methods/supplier/getWithPackaging.js | 2 +- .../supplier/specs/getWithPackaging.spec.js | 16 +------- 10 files changed, 96 insertions(+), 48 deletions(-) create mode 100644 db/versions/11322-azureAspidistra/00-entryAcl.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4fbe16f33..40c8543fa 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1518,19 +1518,20 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4), (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); -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, ''), - (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''), - (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, ''); +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`, `typeFk`) + VALUES + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, '', 'packaging'), + (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two', 'product'), + (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three', 'product'), + (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four', 'product'), + (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five', 'product'), + (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six', 'product'), + (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven', 'product'), + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '', 'product'), + (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, '', 'product'), + (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '', 'product'); + INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) VALUES (2, 4, 1); diff --git a/db/routines/vn/procedures/entry_isEditable.sql b/db/routines/vn/procedures/entry_isEditable.sql index 12b6d0ef6..22cb25ba5 100644 --- a/db/routines/vn/procedures/entry_isEditable.sql +++ b/db/routines/vn/procedures/entry_isEditable.sql @@ -9,16 +9,16 @@ BEGIN * * @param vSelf Id de entrada */ - DECLARE vIsEditable BOOL; + DECLARE vIsNotEditable BOOL; - SELECT e.isBooked INTO vIsEditable + SELECT (e.typeFk IS NULL OR NOT et.isInformal) INTO vIsNotEditable FROM `entry` e - JOIN entryType et ON et.code = e.typeFk - WHERE NOT et.isInformal - AND e.id = vSelf; + LEFT JOIN entryType et ON et.code = e.typeFk + WHERE e.id = vSelf + AND e.isBooked; - IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); - END IF; + IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); + END IF; END$$ DELIMITER ; diff --git a/db/versions/11322-azureAspidistra/00-entryAcl.sql b/db/versions/11322-azureAspidistra/00-entryAcl.sql new file mode 100644 index 000000000..836737d4b --- /dev/null +++ b/db/versions/11322-azureAspidistra/00-entryAcl.sql @@ -0,0 +1,40 @@ +-- Eliminar registros existentes donde property = '*' +DELETE FROM `salix`.ACL WHERE model = 'entry' AND property = '*'; + +-- Insertar permisos para los métodos solicitados en el modelo Entry +INSERT INTO `salix`.ACL (model, property, accessType, permission, principalType, principalId) +VALUES + -- Permisos para administrative + ('Entry', 'upsert', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'isBooked', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'findById', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'filter', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'count', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'getEntry', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'getBuys', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'findOne', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'deleteBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'editLatestBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'importBuys', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'importBuysPreview', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'lastItemBuys', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('Entry', 'latestBuysFilter', 'READ', 'ALLOW', 'ROLE', 'administrative'), + + -- Permisos para buyer (excluyendo isBooked) + ('Entry', 'upsert', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'findById', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'find', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'filter', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'count', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'getEntry', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'getBuys', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'findOne', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'deleteBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'editLatestBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'importBuys', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'importBuysPreview', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'lastItemBuys', 'READ', 'ALLOW', 'ROLE', 'buyer'), + ('Entry', 'latestBuysFilter', 'READ', 'ALLOW', 'ROLE', 'buyer'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a7e21960b..c0b5c4386 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,10 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", - "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", + "Payment method is required": "Payment method is required", + "You do not have permission to modify the booked field": "You do not have permission to modify the booked field", + "null": "null", + "Invalid or expired verification code": "Invalid or expired verification code" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9f01bd290..ec7959450 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -385,5 +385,11 @@ "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", + "Entry 99 is not editable": "Entry 99 is not editable", + "Entry 9 is not editable": "Entry 9 is not editable", + "Entry must have lines to be marked booked": "Entry must have lines to be marked booked", + "Entry 10 is not editable": "Entry 10 is not editable", + "Entry 7 is not editable": "Entry 7 is not editable" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 23bd5cc04..1fc25a112 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -363,5 +363,6 @@ "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", + "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index f85afd607..d9f00095d 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -363,5 +363,6 @@ "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "You do not have permission to modify the booked field": "Você não tem permissão para modificar o campo contabilizado" } diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 8ca79f531..593f3fdcc 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); const LoopBackContext = require('loopback-context'); module.exports = Self => { require('../methods/entry/filter')(Self); @@ -18,11 +19,20 @@ module.exports = Self => { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; + const loopBackContext = LoopBackContext.getCurrentContext(); + const accessToken = {req: loopBackContext.active}; + const hasChanges = orgData && changes; + + const isBookedChanged = changes.isBooked !== undefined && orgData.isBooked !== changes.isBooked; + + if (isBookedChanged) { + const canEditIsBooked = await Self.app.models.ACL.checkAccessAcl(accessToken, 'Entry', 'isBooked', 'READ'); + if (!canEditIsBooked) + throw new UserError('You do not have permission to modify the booked field'); + } const observation = changes.observation || orgData.observation; - const hasChanges = orgData && changes; - const observationChanged = hasChanges - && orgData.observation != observation; + const observationChanged = hasChanges && orgData.observation != observation; if (observationChanged) { let tx; @@ -37,8 +47,7 @@ module.exports = Self => { } try { - const loopbackContext = LoopBackContext.getCurrentContext(); - const userId = loopbackContext.active.accessToken.userId; + const userId = loopBackContext.active.accessToken.userId; const id = changes.id || orgData.id; const entry = await Self.app.models.Entry.findById(id, null, myOptions); await entry.updateAttribute('observationEditorFk', userId, myOptions); diff --git a/modules/supplier/back/methods/supplier/getWithPackaging.js b/modules/supplier/back/methods/supplier/getWithPackaging.js index 07e563412..41b080964 100644 --- a/modules/supplier/back/methods/supplier/getWithPackaging.js +++ b/modules/supplier/back/methods/supplier/getWithPackaging.js @@ -15,7 +15,7 @@ module.exports = Self => { Self.getWithPackaging = async options => { const models = Self.app.models; const myOptions = {}; - const oneYearAgo = new Date(); + const oneYearAgo = Date.vnNew(); oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1); if (typeof options == 'object') diff --git a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js index bd30d7437..b6a780a10 100644 --- a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js @@ -1,26 +1,12 @@ const {models} = require('vn-loopback/server/server'); describe('Supplier getWithPackaging()', () => { + beforeAll.mockLoopBackContext(); it('should return a list of suppliers with an entry of type packaging', async() => { - const typeFk = 'packaging'; - const tx = await models.Supplier.beginTransaction({}); const myOptions = {transaction: tx}; try { - const entry = await models.Entry.findOne( - { - where: { - id: 1 - }, - myOptions - }); - - await entry.updateAttributes({ - typeFk: typeFk, - created: new Date() - }); - const result = await models.Supplier.getWithPackaging(myOptions); expect(result.length).toEqual(1); From cd3dd854ef33df2cac970e1e9beea2517402520c Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 29 Oct 2024 09:26:20 +0100 Subject: [PATCH 02/24] feat: refs #7821 eslint newDate --- .eslintrc.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.eslintrc.yml b/.eslintrc.yml index edbc47195..0d74348f2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -36,3 +36,7 @@ rules: jasmine/no-focused-tests: 0 jasmine/prefer-toHaveBeenCalledWith: 0 arrow-spacing: ["error", { "before": true, "after": true }] + no-restricted-syntax: + - "error" + - selector: "NewExpression[callee.name='Date']" + message: "Use Date.vnNew() instead of new Date()." From 25891e0bada36df43d809e00024504dc8808ca55 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 11 Nov 2024 10:42:06 +0100 Subject: [PATCH 03/24] 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 20bd426704efb8bf314f91a4100ffe5ed1ff9a9c Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 12 Nov 2024 17:25:05 +0100 Subject: [PATCH 04/24] refactor: refs #7690 unify workerTimeControlParams with workerTimeControlConfig --- back/methods/workerActivity/add.js | 4 +- db/dump/fixtures.before.sql | 4 - .../timeWorkerControl_getDirection.sql | 65 ------- .../vn/procedures/workerTimeControl_check.sql | 168 ------------------ .../worker-time-control-mail/checkInbox.js | 2 +- modules/worker/back/model-config.json | 3 - .../models/worker-time-control-config.json | 9 + myt.config.yml | 1 - 8 files changed, 12 insertions(+), 244 deletions(-) delete mode 100644 db/routines/vn/functions/timeWorkerControl_getDirection.sql delete mode 100644 db/routines/vn/procedures/workerTimeControl_check.sql diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index 4592a0797..89131491d 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -31,7 +31,7 @@ module.exports = Self => { return await Self.rawSql(` INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) SELECT ?, ?, ? - FROM workerTimeControlParams wtcp + FROM workerTimeControlConfig wtcc LEFT JOIN ( SELECT wa.workerFk, wa.created, @@ -44,7 +44,7 @@ module.exports = Self => { ) sub ON TRUE WHERE sub.workerFk IS NULL OR sub.code <> ? - OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` + OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;` , [userId, code, model, userId, code], myOptions); }; }; diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 595027b09..3e33ca246 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2520,10 +2520,6 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`) (2, 'Normal', 'normal'), (3, 'Baja', 'low'); -INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`) - VALUES - (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); - INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); INSERT INTO `vn`.`thermograph`(`id`, `model`) diff --git a/db/routines/vn/functions/timeWorkerControl_getDirection.sql b/db/routines/vn/functions/timeWorkerControl_getDirection.sql deleted file mode 100644 index c0f1e67ea..000000000 --- a/db/routines/vn/functions/timeWorkerControl_getDirection.sql +++ /dev/null @@ -1,65 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) - RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci - NOT DETERMINISTIC - READS SQL DATA -BEGIN -/** - * Verifica la dirección de la fichada - * @param vUserFk Identificador del trabajador - * @param vTimed Hora de la fichada - * @return Retorna sentido de la fichada 'in, out, middle' - */ - - DECLARE vPrevious DATETIME ; - DECLARE vNext DATETIME ; - DECLARE vPreviousDirection VARCHAR(3) ; - DECLARE vNextDirection VARCHAR(3) ; - DECLARE vDayStayMax INT; - DECLARE vTimedSeconds INT; - DECLARE vLastTimeIn INT; - - SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds; - - SELECT dayStayMax INTO vDayStayMax - FROM vn.workerTimeControlParams; - - SELECT timed, direction INTO vNext,vNextDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction IN ('in','out') - AND timed > vTimed - ORDER BY timed ASC - LIMIT 1; - - SELECT timed, direction INTO vPrevious, vPreviousDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction IN ('in','out') - AND timed < vTimed - ORDER BY timed DESC - LIMIT 1; - - IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN - RETURN 'middle'; - END IF; - - - IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN - IF vPreviousDirection = 'in' THEN - RETURN 'out'; - ELSE - SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction ='in' - AND timed < vPrevious; - IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN - RETURN 'out'; - END IF; - END IF; - END IF; - - RETURN 'in'; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/workerTimeControl_check.sql b/db/routines/vn/procedures/workerTimeControl_check.sql deleted file mode 100644 index 30cf5c639..000000000 --- a/db/routines/vn/procedures/workerTimeControl_check.sql +++ /dev/null @@ -1,168 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) -proc: BEGIN -/** - * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd - * - * @param vUserFk Identificador del trabajador - * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; - * En caso de tener algun problema retorna el primero que encuentra - */ - DECLARE vLastIn DATETIME ; - DECLARE vLastOut DATETIME ; - DECLARE vDayWorkMax INT; - DECLARE vDayBreak INT; - DECLARE vWeekBreak INT ; - DECLARE vWeekScope INT; - DECLARE vDayStayMax INT; - DECLARE vProblem VARCHAR(20) DEFAULT NULL; - DECLARE vTimedWorked INT; - DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; - DECLARE vDepartmentFk INT; - DECLARE vTo VARCHAR(50) DEFAULT NULL; - DECLARE vUserName VARCHAR(50) DEFAULT NULL; - DECLARE vBody VARCHAR(255) DEFAULT NULL; - - SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax - INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax - FROM workerTimeControlParams; - - SELECT MAX(timed) INTO vLastIn - FROM workerTimeControl - WHERE userFk = vUserFk - AND direction = 'in'; - - SELECT MAX(timed) INTO vLastOut - FROM workerTimeControl - WHERE userFk = vUserFk - AND direction = 'out'; - - SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo - FROM account.user u - WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk); - - SELECT CONCAT(firstName,' ',lastName) INTO vUserName - FROM worker w - WHERE w.id = vUserFk; - - - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA - - -- VERIFICAR DESCANSO DIARIO - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN - SELECT "Descansos 12 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ - IF (SELECT MOD(COUNT(*),2) -- <>0 - FROM workerTimeControl - WHERE userFk = vUserFk - AND timed >= vLastIn - ) THEN - SELECT "Dias con fichadas impares" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR VACACIONES - SELECT at2.name INTO vCalendarStateType - FROM calendar c - JOIN business b ON b.id = c.businessFk - JOIN absenceType at2 ON at2.id = c.dayOffTypeFk - WHERE c.dated = util.VN_CURDATE() - AND at2.isAllowedToWork = FALSE - AND b.workerFk = vUserFk - LIMIT 1; - - IF(LENGTH(vCalendarStateType)) THEN - SELECT vCalendarStateType AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - -- VERIFICAR CONTRATO EN VIGOR - IF (SELECT COUNT(*) - FROM business b - WHERE b.workerFk = vUserFk - AND b.started <= vDated - AND IFNULL(b.ended, vDated) >= vDated - ) = 0 THEN - SELECT "No hay un contrato en vigor" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - -- VERIFICAR DESCANSO SEMANAL - SET @vHasBreakWeek:= FALSE; - SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND)); - - DROP TEMPORARY TABLE IF EXISTS tmp.trash; - CREATE TEMPORARY TABLE tmp.trash - SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, - @vLastTimed:= UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND) - AND userFk= vUserFk - AND direction IN ('in','out') - ORDER BY timed ASC; - - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA - SELECT "Descansos 36 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE tmp.trash; - - ELSE -- DIA ACTUAL - - -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO - SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked - FROM workerTimeControl wtc - WHERE userFk = vUserFk - AND timed >= vLastIn - ORDER BY timed; - - IF vTimedWorked > vDayWorkMax THEN - SELECT "Jornadas" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - END IF; - - -- VERIFICAR DEPARTAMENTO - /* IF vTabletFk IS NOT NULL THEN - SELECT wtcu.departmentFk INTO vDepartmentFk - FROM workerTimeControlUserInfo wtcu - WHERE wtcu.userFk = vUserFk; - IF (SELECT COUNT(td.tabletFk) - FROM tabletDepartment td - WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk - ) = 0 THEN - SELECT "No perteneces a este departamento." AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - END IF;*/ - -END$$ -DELIMITER ; diff --git a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js index 4d9f98cc3..688cbb634 100644 --- a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js +++ b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js @@ -16,7 +16,7 @@ module.exports = Self => { }); Self.checkInbox = async() => { - let imapConfig = await Self.app.models.WorkerTimeControlParams.findOne(); + let imapConfig = await Self.app.models.WorkerTimeControlConfig.findOne(); let imap = new Imap({ user: imapConfig.mailUser, password: imapConfig.mailPass, diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 7bfc667ac..ab09ceacf 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -113,9 +113,6 @@ "WorkerTimeControlConfig": { "dataSource": "vn" }, - "WorkerTimeControlParams": { - "dataSource": "vn" - }, "WorkerTimeControlMail": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/worker-time-control-config.json b/modules/worker/back/models/worker-time-control-config.json index b96e2ae3b..1bd0d19f4 100644 --- a/modules/worker/back/models/worker-time-control-config.json +++ b/modules/worker/back/models/worker-time-control-config.json @@ -11,6 +11,15 @@ "id": true, "type": "number" }, + "mailPass": { + "type": "string" + }, + "mailHost": { + "type": "string" + }, + "mailUser": { + "type": "string" + }, "breakTime": { "type": "number" }, diff --git a/myt.config.yml b/myt.config.yml index 25f94f1bd..92936869e 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -385,7 +385,6 @@ localFixtures: - workerTimeControl - workerTimeControlConfig - workerTimeControlMail - - workerTimeControlParams - zone - zoneAgencyMode - zoneClosure From ea4adbea85fb21feea9745cc71234987dca85e15 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 13 Nov 2024 08:45:44 +0100 Subject: [PATCH 05/24] refactor: refs #6924 deleted department check --- .../back/methods/worker/createAbsence.js | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index c7f968edb..036e2bef7 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -120,27 +120,23 @@ module.exports = Self => { dated: args.dated }, myOptions); - const department = labour.department(); - 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, - employee: subordinated.nickname, - absenceType: absenceType.name, - dated: formatDate(args.dated), - workerUrl: `${url}worker/${id}/calendar` - }); - await models.Mail.create({ - subject: $t('Absence change notification on the labour calendar'), - body: body, - receiver: boss.email - }, 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 departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions); + const url = await Self.app.models.Url.getUrl(); + const body = $t('Created absence', { + author: account.nickname, + employee: subordinated.nickname, + absenceType: absenceType.name, + dated: formatDate(args.dated), + workerUrl: `${url}worker/${id}/calendar` + }); + await models.Mail.create({ + subject: $t('Absence change notification on the labour calendar'), + body: body, + receiver: departmentBoss.email + }, myOptions); if (tx) await tx.commit(); From 7be1bc385f90465b34edbc91763166642a0636b5 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 14 Nov 2024 08:35:28 +0100 Subject: [PATCH 06/24] perf: refs #6924 deleted useless relation --- modules/worker/back/methods/worker/createAbsence.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 036e2bef7..8e6380c3b 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -58,9 +58,7 @@ module.exports = Self => { if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - const labour = await models.WorkerLabour.findById(args.businessFk, { - include: {relation: 'department'} - }, myOptions); + const labour = await models.WorkerLabour.findById(args.businessFk, myOptions); if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended)) throw new UserError(`The contract was not active during the selected date`); From 6a11416838105e3ac00151937d4bfe0eb9e17f13 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 15 Nov 2024 14:30:32 +0100 Subject: [PATCH 07/24] refactor: refs #7690 copy acls and remove worker-time-control-params.json --- .../models/worker-time-control-config.json | 10 +++++- .../models/worker-time-control-params.json | 35 ------------------- 2 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 modules/worker/back/models/worker-time-control-params.json diff --git a/modules/worker/back/models/worker-time-control-config.json b/modules/worker/back/models/worker-time-control-config.json index 1bd0d19f4..53f1a14ea 100644 --- a/modules/worker/back/models/worker-time-control-config.json +++ b/modules/worker/back/models/worker-time-control-config.json @@ -32,5 +32,13 @@ "teleworkingStartBreakTime": { "type": "number" } - } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } diff --git a/modules/worker/back/models/worker-time-control-params.json b/modules/worker/back/models/worker-time-control-params.json deleted file mode 100644 index 14cabbfb0..000000000 --- a/modules/worker/back/models/worker-time-control-params.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "WorkerTimeControlParams", - "description": "imap config", - "base": "VnModel", - "options": { - "mysql": { - "table": "workerTimeControlParams" - } - }, - "properties": { - "mailHost": { - "type": "string" - }, - "mailUser": { - "type": "string" - }, - "mailPass": { - "type": "string" - }, - "mailSuccessFolder": { - "type": "string" - }, - "mailErrorFolder": { - "type": "string" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} From a40a5a22aba1f0ed857410248d1eb9bc4d98fe84 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 18 Nov 2024 14:27:38 +0100 Subject: [PATCH 08/24] fix: refs #7821 fixtures without raid --- db/dump/fixtures.before.sql | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 116a45598..32fd5ec58 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1505,20 +1505,19 @@ 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`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`, `typeFk`, `daysInForward`) - VALUES - (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, '', 'packaging', NULL), - (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two', 'product', NULL), - (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three', 'product', NULL), - (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four', 'product', NULL), - (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five', 'product', NULL), - (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six', 'product', NULL), - (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven', 'product', 2), - (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '', 'product', 2), - (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '', 'product', 2), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, '', 'product', 2), - (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '', 'product', NULL); - +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) +VALUES + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, '', 'packaging'), + (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two', 'product'), + (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three', 'product'), + (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four', 'product'), + (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five', 'product'), + (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six', 'product'), + (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'), + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'), + (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, '', 'product'), + (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99', 0, '', 'product'); 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), From 43e121a2f3da3a730389f6889db21ba9f0ba8eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 19 Nov 2024 11:04:16 +0100 Subject: [PATCH 09/24] refactor: refs #8210 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 166 ++++++++---------- .../11351-bronzeMedeola/00-firstScript.sql | 2 + 2 files changed, 71 insertions(+), 97 deletions(-) create mode 100644 db/versions/11351-bronzeMedeola/00-firstScript.sql diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 0ee865af5..594cd9836 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -5,122 +5,94 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki ) BEGIN /** - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id inicial para el tipo propuesto. + * Separa en diferentes tickets según el tipo de empaquetado + * El ticket original conserva las líneas del tipo de empaquetado especificado + * Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto. * - * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original - * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) + * @param vSelf ID del ticket original + * @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original + * @return Tabla temporal tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; + DECLARE vIsDone BOOLEAN DEFAULT FALSE; + DECLARE vCurrentPackingType VARCHAR(1); + DECLARE vDefaultPackingType VARCHAR(1); + DECLARE vHasOriginalPackingType BOOLEAN; DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vSaleGroup CURSOR FOR - SELECT itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + DECLARE vItemPackingTypes CURSOR FOR + SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - START TRANSACTION; + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( + ticketFk INT, + saleFk INT, + itemPackingTypeFk VARCHAR(1) + ) ENGINE=MEMORY; - SELECT id - FROM sale - WHERE ticketFk = vSelf - AND NOT quantity - FOR UPDATE; + SELECT vDefaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1; - DELETE FROM sale - WHERE NOT quantity - AND ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSale - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + SELECT EXISTS ( + SELECT TRUE FROM sale s JOIN item i ON i.id = s.itemFk - LEFT JOIN saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vSelf; + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk + ) INTO vHasOriginalPackingType; - CREATE OR REPLACE TEMPORARY TABLE tSaleGroup - ENGINE = MEMORY - SELECT itemPackingTypeFk, SUM(litros) totalLitros - FROM tSale - GROUP BY itemPackingTypeFk; + IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN + SET vOriginalItemPackingTypeFk = vDefaultPackingType; + END IF; - SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) + SELECT s.id, i.itemPackingTypeFk + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( - ticketFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE = MEMORY; + OPEN vItemPackingTypes; + l: LOOP + FETCH vItemPackingTypes INTO vCurrentPackingType; - CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vSelf, itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; - ELSE - OPEN vSaleGroup; - FETCH vSaleGroup INTO vItemPackingTypeFk; + IF vIsDone THEN + LEAVE l; + END IF; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); + CALL ticket_Clone(vSelf, vNewTicketFk); - l: LOOP - SET vDone = FALSE; - FETCH vSaleGroup INTO vItemPackingTypeFk; + UPDATE tSalesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vCurrentPackingType; - IF vDone THEN - LEAVE l; - END IF; + IF vCurrentPackingType = vDefaultPackingType THEN + INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk) + SELECT vNewTicketFk, s.id, i.itemPackingTypeFk + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk IS NULL; + END IF; + END LOOP; + CLOSE vItemPackingTypes; - CALL ticket_Clone(vSelf, vNewTicketFk); + UPDATE sale s + JOIN tSalesToMove t ON t.saleFk = s.id + SET s.ticketFk = t.ticketFk + WHERE t.ticketFk IS NOT NULL; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT + ENGINE=MEMORY + SELECT s.ticketFk, i.itemPackingTypeFk + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + GROUP BY s.ticketFk, i.itemPackingTypeFk + UNION + SELECT ticketFk, itemPackingTypeFk + FROM tSalesToMove + GROUP BY ticketFk, itemPackingTypeFk; - CLOSE vSaleGroup; - - SELECT s.id - FROM sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - FOR UPDATE; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; - - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tSaleGroup sg - WHERE sg.itemPackingTypeFk IS NOT NULL - ORDER BY sg.itemPackingTypeFk - LIMIT 1; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ts.itemPackingTypeFk IS NULL; - END CASE; - - COMMIT; - - DROP TEMPORARY TABLE - tSale, - tSaleGroup; + DROP TEMPORARY TABLE tSalesToMove; END$$ DELIMITER ; diff --git a/db/versions/11351-bronzeMedeola/00-firstScript.sql b/db/versions/11351-bronzeMedeola/00-firstScript.sql new file mode 100644 index 000000000..c94447a89 --- /dev/null +++ b/db/versions/11351-bronzeMedeola/00-firstScript.sql @@ -0,0 +1,2 @@ + +ALTER TABLE vn.itemConfig ADD defaultPackingTypeFk VARCHAR(1) DEFAULT 'H' NULL; From a7ab8696ac915a99aa6896b1e1aa8e02263f9d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 19 Nov 2024 11:07:19 +0100 Subject: [PATCH 10/24] refactor: refs #8210 ticket_splitItemPackingType --- db/routines/vn/procedures/ticket_splitItemPackingType.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 594cd9836..95b734b44 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -9,9 +9,9 @@ BEGIN * El ticket original conserva las líneas del tipo de empaquetado especificado * Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto. * - * @param vSelf ID del ticket original + * @param vSelf Id del ticket original * @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original - * @return Tabla temporal tmp.ticketIPT(ticketFk, itemPackingTypeFk) + * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ DECLARE vIsDone BOOLEAN DEFAULT FALSE; DECLARE vCurrentPackingType VARCHAR(1); From f145649fc73d979b2429cbd638e6b2c79aafe1c3 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 19 Nov 2024 13:40:31 +0100 Subject: [PATCH 11/24] fix: refs #6924 requested change --- modules/worker/back/methods/worker/createAbsence.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 8e6380c3b..419659083 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -58,7 +58,8 @@ module.exports = Self => { if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - const labour = await models.WorkerLabour.findById(args.businessFk, myOptions); + const labour = await models.WorkerLabour.findById(args.businessFk, + {fields: ['started', 'ended', 'businessFk']}, myOptions); if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended)) throw new UserError(`The contract was not active during the selected date`); From a9d45bde4cf0794c5e3b7c472401d40105f293c2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 19 Nov 2024 16:03:23 +0100 Subject: [PATCH 12/24] refactor: refs #7690 modify printQueue_check and rename tables --- db/routines/vn/events/printQueue_check.sql | 14 +++++++------- db/versions/11354-aquaMastic/00-firstScript.sql | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 db/versions/11354-aquaMastic/00-firstScript.sql diff --git a/db/routines/vn/events/printQueue_check.sql b/db/routines/vn/events/printQueue_check.sql index cddba8cf8..8a2552423 100644 --- a/db/routines/vn/events/printQueue_check.sql +++ b/db/routines/vn/events/printQueue_check.sql @@ -33,10 +33,10 @@ DO BEGIN FROM printQueue WHERE statusCode = 'queued'; SELECT isAlreadyNotified INTO vIsAlreadyNotified - FROM printingQueueCheck; + FROM printingQueueConfig; - IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND - (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND + IF (SELECT lastCount FROM printingQueueConfig) = vCurrentCount AND + (SELECT lastCheckSum FROM printingQueueConfig) = vCheckSum AND vIsAlreadyNotified = FALSE AND vCurrentCount > 0 THEN @@ -67,16 +67,16 @@ DO BEGIN CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '') ); - UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; + UPDATE printingQueueConfig SET isAlreadyNotified = TRUE; END IF; - IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND + IF (SELECT lastCount FROM printingQueueConfig) > vCurrentCount AND vIsAlreadyNotified = TRUE THEN - UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; + UPDATE printingQueueConfig SET isAlreadyNotified = FALSE; END IF; - UPDATE printingQueueCheck + UPDATE printingQueueConfig SET lastCount = vCurrentCount, lastCheckSum = vCheckSum; diff --git a/db/versions/11354-aquaMastic/00-firstScript.sql b/db/versions/11354-aquaMastic/00-firstScript.sql new file mode 100644 index 000000000..98fe9d956 --- /dev/null +++ b/db/versions/11354-aquaMastic/00-firstScript.sql @@ -0,0 +1,4 @@ +RENAME TABLE vn.workerTimeControlParams TO vn.workerTimeControlParams__; +ALTER TABLE vn.workerTimeControlParams__ COMMENT='@deprecated 2024-11-19'; + +RENAME TABLE vn.printingQueueCheck TO vn.printingQueueConfig; \ No newline at end of file From 43abb52efc250a81ebd652c222dc4206dfba67de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 19 Nov 2024 16:58:15 +0100 Subject: [PATCH 13/24] refactor: refs #8210 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 95b734b44..1a1e1ff07 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -18,19 +18,34 @@ BEGIN DECLARE vDefaultPackingType VARCHAR(1); DECLARE vHasOriginalPackingType BOOLEAN; DECLARE vNewTicketFk INT; + DECLARE vThrowAway INT; DECLARE vItemPackingTypes CURSOR FOR SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( ticketFk INT, saleFk INT, itemPackingTypeFk VARCHAR(1) ) ENGINE=MEMORY; - SELECT vDefaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1; + SELECT defaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1; + + START TRANSACTION; + + SELECT t.id INTO vThrowAway + FROM ticket t + JOIN sale s ON s.id = t.id + WHERE t.id = vSelf + FOR UPDATE; SELECT EXISTS ( SELECT TRUE @@ -48,11 +63,12 @@ BEGIN SELECT s.id, i.itemPackingTypeFk FROM sale s JOIN item i ON i.id = s.itemFk - WHERE s.ticketFk = vSelf - AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; OPEN vItemPackingTypes; l: LOOP + SET vIsDone = FALSE; FETCH vItemPackingTypes INTO vCurrentPackingType; IF vIsDone THEN @@ -61,6 +77,11 @@ BEGIN CALL ticket_Clone(vSelf, vNewTicketFk); + SELECT id INTO vThrowAway + FROM ticket t + WHERE t.id = vNewTicketFk + FOR UPDATE; + UPDATE tSalesToMove SET ticketFk = vNewTicketFk WHERE itemPackingTypeFk = vCurrentPackingType; @@ -73,25 +94,27 @@ BEGIN WHERE s.ticketFk = vSelf AND i.itemPackingTypeFk IS NULL; END IF; + END LOOP; CLOSE vItemPackingTypes; UPDATE sale s JOIN tSalesToMove t ON t.saleFk = s.id - SET s.ticketFk = t.ticketFk - WHERE t.ticketFk IS NOT NULL; + SET s.ticketFk = t.ticketFk; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT ENGINE=MEMORY - SELECT s.ticketFk, i.itemPackingTypeFk + SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk FROM sale s JOIN item i ON i.id = s.itemFk WHERE s.ticketFk = vSelf - GROUP BY s.ticketFk, i.itemPackingTypeFk + GROUP BY s.ticketFk UNION - SELECT ticketFk, itemPackingTypeFk + SELECT ticketFk, MAX(itemPackingTypeFk) FROM tSalesToMove - GROUP BY ticketFk, itemPackingTypeFk; + GROUP BY ticketFk; + + COMMIT; DROP TEMPORARY TABLE tSalesToMove; END$$ From 82f4815282ce7ed1199d455e2786c0a79514e2ac Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Nov 2024 14:16:26 +0100 Subject: [PATCH 14/24] fix: refs #7529 fix acls --- db/versions/11312-navyAralia/00-firstScript.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/db/versions/11312-navyAralia/00-firstScript.sql b/db/versions/11312-navyAralia/00-firstScript.sql index 466b18f6b..452b1feed 100644 --- a/db/versions/11312-navyAralia/00-firstScript.sql +++ b/db/versions/11312-navyAralia/00-firstScript.sql @@ -6,10 +6,18 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,princi ('WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr'), ('WorkerRelative','crud','WRITE','ALLOW','ROLE','hr'), ('WorkerRelative','findById','*','ALLOW','ROLE','hr'), + ('WorkerRelative','find','*','ALLOW','ROLE','hr'), + ('WorkerRelative','upsert','*','ALLOW','ROLE','hr'), + ('WorkerRelative','filter','*','ALLOW','ROLE','hr'), ('WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr'), ('WorkerIrpf','crud','*','ALLOW','ROLE','hr'), - ('WorkerRelative','findById','*','ALLOW','ROLE','hr'), + ('WorkerIrpf','findById','*','ALLOW','ROLE','hr'), + ('WorkerIrpf','find','*','ALLOW','ROLE','hr'), + ('WorkerIrpf','upsert','*','ALLOW','ROLE','hr'), + ('WorkerIrpf','filter','*','ALLOW','ROLE','hr'), ('DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr'), ('DisabilityGrade','crud','*','ALLOW','ROLE','hr'), - ('DisabilityGrade','findById','*','ALLOW','ROLE','hr'); + ('DisabilityGrade','findById','*','ALLOW','ROLE','hr'), + ('DisabilityGrade','find','*','ALLOW','ROLE','hr'), + ('DisabilityGrade','upsert','*','ALLOW','ROLE','hr'); From 830573e229985ec1d8871d1e96619334a94e880e Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 20 Nov 2024 14:49:55 +0100 Subject: [PATCH 15/24] refactor: refs #7690 remove modifications printQueue_check.sql --- db/routines/vn/events/printQueue_check.sql | 14 +++++++------- db/versions/11354-aquaMastic/00-firstScript.sql | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/events/printQueue_check.sql b/db/routines/vn/events/printQueue_check.sql index 8a2552423..cddba8cf8 100644 --- a/db/routines/vn/events/printQueue_check.sql +++ b/db/routines/vn/events/printQueue_check.sql @@ -33,10 +33,10 @@ DO BEGIN FROM printQueue WHERE statusCode = 'queued'; SELECT isAlreadyNotified INTO vIsAlreadyNotified - FROM printingQueueConfig; + FROM printingQueueCheck; - IF (SELECT lastCount FROM printingQueueConfig) = vCurrentCount AND - (SELECT lastCheckSum FROM printingQueueConfig) = vCheckSum AND + IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND + (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND vIsAlreadyNotified = FALSE AND vCurrentCount > 0 THEN @@ -67,16 +67,16 @@ DO BEGIN CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '') ); - UPDATE printingQueueConfig SET isAlreadyNotified = TRUE; + UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; END IF; - IF (SELECT lastCount FROM printingQueueConfig) > vCurrentCount AND + IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND vIsAlreadyNotified = TRUE THEN - UPDATE printingQueueConfig SET isAlreadyNotified = FALSE; + UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; END IF; - UPDATE printingQueueConfig + UPDATE printingQueueCheck SET lastCount = vCurrentCount, lastCheckSum = vCheckSum; diff --git a/db/versions/11354-aquaMastic/00-firstScript.sql b/db/versions/11354-aquaMastic/00-firstScript.sql index 98fe9d956..dda3f4752 100644 --- a/db/versions/11354-aquaMastic/00-firstScript.sql +++ b/db/versions/11354-aquaMastic/00-firstScript.sql @@ -1,4 +1,2 @@ RENAME TABLE vn.workerTimeControlParams TO vn.workerTimeControlParams__; -ALTER TABLE vn.workerTimeControlParams__ COMMENT='@deprecated 2024-11-19'; - -RENAME TABLE vn.printingQueueCheck TO vn.printingQueueConfig; \ No newline at end of file +ALTER TABLE vn.workerTimeControlParams__ COMMENT='@deprecated 2024-11-19'; \ No newline at end of file From 031c4398aea2607553126ecc1237384bd87398bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 20 Nov 2024 19:19:03 +0100 Subject: [PATCH 16/24] refactor: refs #8210 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 1a1e1ff07..31e0c24e7 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -18,7 +18,7 @@ BEGIN DECLARE vDefaultPackingType VARCHAR(1); DECLARE vHasOriginalPackingType BOOLEAN; DECLARE vNewTicketFk INT; - DECLARE vThrowAway INT; + DECLARE vTicketFk INT; DECLARE vItemPackingTypes CURSOR FOR SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove; @@ -37,15 +37,12 @@ BEGIN itemPackingTypeFk VARCHAR(1) ) ENGINE=MEMORY; - SELECT defaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1; - - START TRANSACTION; - - SELECT t.id INTO vThrowAway - FROM ticket t - JOIN sale s ON s.id = t.id - WHERE t.id = vSelf - FOR UPDATE; + SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType + FROM vn.sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk + WHERE s.ticketFk = vSelf + GROUP BY s.ticketFk; SELECT EXISTS ( SELECT TRUE @@ -59,6 +56,14 @@ BEGIN SET vOriginalItemPackingTypeFk = vDefaultPackingType; END IF; + START TRANSACTION; + + SELECT t.id INTO vTicketFk + FROM ticket t + JOIN sale s ON s.id = t.id + WHERE t.id = vSelf + FOR UPDATE; + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) SELECT s.id, i.itemPackingTypeFk FROM sale s @@ -77,7 +82,7 @@ BEGIN CALL ticket_Clone(vSelf, vNewTicketFk); - SELECT id INTO vThrowAway + SELECT id INTO vTicketFk FROM ticket t WHERE t.id = vNewTicketFk FOR UPDATE; From b3ce3a0cc260d327cc511ab27efaa63c8979f8c5 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 21 Nov 2024 09:12:04 +0100 Subject: [PATCH 17/24] feat: refs #7821 with test --- back/methods/collection/spec/assign.spec.js | 3 +- .../vn/procedures/entry_isEditable.sql | 14 +-- modules/entry/back/models/specs/entry.spec.js | 97 +++++++++++++++++++ 3 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 modules/entry/back/models/specs/entry.spec.js diff --git a/back/methods/collection/spec/assign.spec.js b/back/methods/collection/spec/assign.spec.js index 745343819..b00631d22 100644 --- a/back/methods/collection/spec/assign.spec.js +++ b/back/methods/collection/spec/assign.spec.js @@ -28,9 +28,10 @@ describe('ticket assign()', () => { await tx.rollback(); }); - it('should throw an error when there is not picking tickets', async() => { + it('should throw an error when there are no picking tickets', async() => { try { await models.Collection.assign(ctx, options); + fail('Expected an error to be thrown, but none was thrown.'); } catch (e) { expect(e.message).toEqual('There are not picking tickets'); } diff --git a/db/routines/vn/procedures/entry_isEditable.sql b/db/routines/vn/procedures/entry_isEditable.sql index 22cb25ba5..c417f6789 100644 --- a/db/routines/vn/procedures/entry_isEditable.sql +++ b/db/routines/vn/procedures/entry_isEditable.sql @@ -9,16 +9,18 @@ BEGIN * * @param vSelf Id de entrada */ - DECLARE vIsNotEditable BOOL; + DECLARE vIsNotEditable BOOL DEFAULT FALSE; - SELECT (e.typeFk IS NULL OR NOT et.isInformal) INTO vIsNotEditable + SELECT TRUE INTO vIsNotEditable FROM `entry` e LEFT JOIN entryType et ON et.code = e.typeFk WHERE e.id = vSelf - AND e.isBooked; + AND e.isBooked + AND (e.typeFk IS NULL OR NOT et.isInformal); + + IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); + END IF; - IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); - END IF; END$$ DELIMITER ; diff --git a/modules/entry/back/models/specs/entry.spec.js b/modules/entry/back/models/specs/entry.spec.js new file mode 100644 index 000000000..15a8202c4 --- /dev/null +++ b/modules/entry/back/models/specs/entry.spec.js @@ -0,0 +1,97 @@ +const {models} = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); + +describe('entry_isEditable trigger', () => { + const activeCtx = { + accessToken: {userId: 5}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + const ctx = {req: activeCtx}; + const entryId = 1; + let tx; + let options; + let entry; + + beforeEach(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Entry.beginTransaction({}); + options = {transaction: tx}; + + entry = await models.Entry.findById(entryId, null, options); + }); + + afterEach(async() => { + await tx.rollback(); + }); + + async function prepareEntry(isBooked, typeFk) { + let newCreated = Date.vnNew(); + await entry.updateAttributes({isBooked, typeFk}, options); + await entry.updateAttributes({dated: newCreated}, options); + } + + it('should throw an error when entry is booked and typeFk is null', async() => { + let error; + try { + await prepareEntry(true, null); + } catch (e) { + error = e; + } + + expect(error.message).toContain(`Entry ${entryId} is not editable`); + }); + + it('should throw an error when entry is booked and typeFk is not informal', async() => { + let error; + try { + const type = await models.EntryType.findOne({where: {isInformal: false}}, options); + await prepareEntry(true, type.code); + } catch (e) { + error = e; + } + + expect(error.message).toContain(`Entry ${entryId} is not editable`); + }); + + it('should not throw an error when entry is booked and typeFk is informal', async() => { + let error; + try { + const type = await models.EntryType.findOne({where: {isInformal: true}}, options); + await prepareEntry(true, type.code); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + }); + + it('should not throw an error when entry is not booked', async() => { + let error; + try { + const type = await models.EntryType.findOne({}, options); + await prepareEntry(false, type.code); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + }); + + it('should not throw an error when @isModeInventory is true', async() => { + let error; + try { + await models.Application.rawSql('SET @isModeInventory = TRUE;', null, options); + await prepareEntry(true, null); + } catch (e) { + error = e; + } finally { + await models.Application.rawSql('SET @isModeInventory = FALSE;', null, options); + } + + expect(error).toBeUndefined(); + }); +}); From 2978af834103a3075db6fab85dde611781ac6e24 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 21 Nov 2024 10:18:17 +0100 Subject: [PATCH 18/24] fix: hotfix errorMyTeam --- modules/order/back/methods/order/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index f8df6e10e..b60fab6a9 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -79,12 +79,12 @@ module.exports = Self => { const models = Self.app.models; const conn = Self.dataSource.connector; const myOptions = {}; + const userId = ctx.req.accessToken.userId; if (typeof options == 'object') Object.assign(myOptions, options); const args = ctx.args; - // Apply filter by team const teamMembersId = []; if (args.myTeam != null) { @@ -102,7 +102,7 @@ module.exports = Self => { } if (args && args.myTeam) - args.teamIds = teamIds; + args.teamIds = teamMembersId; const where = buildFilter(args, (param, value) => { switch (param) { From 512b4a54df001787eb100aeb2f3c7f29be3d9389 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 21 Nov 2024 11:28:25 +0100 Subject: [PATCH 19/24] fix: refs #7920 refs#7920 itemShelvingLog --- db/routines/vn/procedures/itemShelving_get.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 7e59a5cfc..0038257c2 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -22,7 +22,7 @@ BEGIN ic.url, ish.available, ish.buyFk, - sh.shelvingFk + ish.shelvingFk FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON s.id = ish.shelvingFk From 0870a1c3d612f31424754dbabd0f40409378e250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 21 Nov 2024 15:09:58 +0100 Subject: [PATCH 20/24] refs#8087 Redadas en travel test --- db/dump/fixtures.before.sql | 34 +++++++++---------- .../procedures/availableNoRaids_refresh.sql | 2 +- .../triggers/supplyResponse_afterUpdate.sql | 2 +- .../hedera/procedures/item_getVisible.sql | 4 +-- .../stock/procedures/log_refreshBuy.sql | 6 ++-- .../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_checkRaid.sql | 17 ++++++++++ .../vn/procedures/travel_moveRaids.sql | 17 +++++----- .../vn/triggers/entry_beforeUpdate.sql | 6 ++-- db/routines/vn/triggers/town_beforeUpdate.sql | 10 ------ .../vn/triggers/travel_beforeInsert.sql | 6 +++- .../vn/triggers/travel_beforeUpdate.sql | 20 ++++++----- 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 +- .../11357-whiteGerbera/00-firstScript.sql | 4 +++ loopback/locale/en.json | 1 + loopback/locale/es.json | 3 +- modules/entry/back/locale/entry/en.yml | 1 + modules/entry/back/locale/entry/es.yml | 1 + modules/entry/back/methods/entry/filter.js | 1 + modules/entry/back/methods/entry/getEntry.js | 4 +-- 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 ++ 38 files changed, 114 insertions(+), 83 deletions(-) create mode 100644 db/routines/vn/procedures/travel_checkRaid.sql delete mode 100644 db/routines/vn/triggers/town_beforeUpdate.sql create mode 100644 db/versions/11357-whiteGerbera/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 48e886ac9..878f146d1 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 @@ -4012,10 +4012,10 @@ INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pin INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1); -INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk) +INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk) VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), (1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), - (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), (3, 1400, 0, 450, 13000, 1, 0, 1, '01B', 1, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), (4, 0, 500, 500, 13000, 1, 4, 1, '02A', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL), (5, 1400, 500, 500, 13000, 1, 4, 1, '02B', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL), @@ -4026,9 +4026,9 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c (10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL); -INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, '1169'), (8, '1183'); -INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) - VALUES ('saysimle-url-mock', 1320); \ No newline at end of file +INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) + VALUES ('saysimle-url-mock', 1320); 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..c21de9c08 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -11,7 +11,7 @@ BEGIN 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 +50,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 +65,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_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql new file mode 100644 index 000000000..64f3355e2 --- /dev/null +++ b/db/routines/vn/procedures/travel_checkRaid.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`( + vIsRaid BOOL, + vDaysInForward INT +) +BEGIN +/** + * Check if the values of isRaid and daysInforward are correct + * + * @param vIsRaid idRaid value + * @param vDaysInForward daysInForward value + */ + IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN + CALL util.throw('The raid information is not correct'); + END IF; +END$$ +DELIMITER ; 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/triggers/town_beforeUpdate.sql b/db/routines/vn/triggers/town_beforeUpdate.sql deleted file mode 100644 index fc1410d5c..000000000 --- a/db/routines/vn/triggers/town_beforeUpdate.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeUpdate` - BEFORE UPDATE ON `town` - FOR EACH ROW -BEGIN - -- IF !(OLD.geoFk <=> NEW.geoFk) THEN - -- CALL zoneGeo_throwNotEditable; - -- END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 4563c9a81..5356ed537 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -8,7 +8,11 @@ BEGIN CALL travel_checkDates(NEW.shipped, NEW.landed); CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - + + IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NEW.awbFk IS NOT NULL THEN CALL travel_throwAwb(NEW.id); END IF; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 33578fea1..5a27b43b4 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -7,7 +7,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); - IF NOT (NEW.landed <=> OLD.landed) + IF NOT (NEW.landed <=> OLD.landed) OR NOT (NEW.shipped <=> OLD.shipped) THEN CALL travel_checkDates(NEW.shipped, NEW.landed); END IF; @@ -20,19 +20,23 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; + IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NOT (NEW.awbFk <=> OLD.awbFk)THEN - SELECT COUNT(*) INTO vHasAnyInvoiceBooked + SELECT COUNT(*) INTO vHasAnyInvoiceBooked FROM travel t - JOIN entry e ON e.travelFk = t.id - JOIN invoiceIn ii ON ii.id = e.invoiceInFk + JOIN entry e ON e.travelFk = t.id + JOIN invoiceIn ii ON ii.id = e.invoiceInFk WHERE t.id = NEW.id - AND ii.isBooked; - + AND ii.isBooked; + IF vHasAnyInvoiceBooked THEN CALL util.throw('The travel has entries with booked invoices'); END IF; - END IF; - + END IF; + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN CALL travel_throwAwb(NEW.id); 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/11357-whiteGerbera/00-firstScript.sql b/db/versions/11357-whiteGerbera/00-firstScript.sql new file mode 100644 index 000000000..c10ec4d26 --- /dev/null +++ b/db/versions/11357-whiteGerbera/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.travel ADD IF NOT EXISTS 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. NULL si no es una redada'; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 2471d3170..15f69d05f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -244,6 +244,7 @@ "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "Payment method is required": "Payment method is required", + "The raid information is not correct": "The raid information is not correct", "Sales already moved": "Sales already moved" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 160a81c56..4e691f375 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -387,5 +387,6 @@ "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas" + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta" } 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..d7740dd4e 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -194,6 +194,7 @@ module.exports = Self => { e.evaNotes observation, e.isConfirmed, e.isOrdered, + t.isRaid, t.daysInForward, e.commission, e.created, 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/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 40625a4d5..eae9cb034 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">