From 31a6db5da0cc02f9062e17bb2a07f59632e1abbb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 12 Dec 2024 20:30:38 +0100 Subject: [PATCH 01/32] feat: refs #7569 refs#7569 sendMail --- loopback/locale/en.json | 8 +-- loopback/locale/es.json | 13 ++--- loopback/locale/fr.json | 12 +++-- loopback/locale/pt.json | 6 ++- .../ticket/back/methods/ticket/saveSign.js | 52 ++++++++++++++++++- .../methods/ticket/specs/saveSign.spec.js | 42 +++++++++++++++ 6 files changed, 116 insertions(+), 17 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 7372ac9a6..f5c27726b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,6 +246,8 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "Holidays to past days not available": "Holidays to past days not available" -} + "Sales already moved": "Sales already moved", + "Holidays to past days not available": "Holidays to past days not available", + "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", + "Ticket has been delivered out of order": "The ticket {{ ticket }} ({{ fullUrl }}) has been delivered out of order. Tickets that have not been delivered in their route are: {{ ticketsToMail }}" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0dc8e53a8..2a93407fc 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,10 +388,11 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "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", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" -} - + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", + "Ticket has been delivered out of order": "El ticket {{ ticket }} ({{ fullUrl }}) no ha sigo entregado en su orden. Los tickets de la ruta que no han sido entregados en su orden son: {{ ticketsToMail }}" +} \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 9941358be..719cbf99c 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -362,9 +362,11 @@ "The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré", "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", - "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé", + "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", + "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé", "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", - "The web user's email already exists": "L'email de l'internaute existe déjà" -} + "The web user's email already exists": "L'email de l'internaute existe déjà", + "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", + "Ticket has been delivered out of order": "Le ticket {{ticket}} ({{fullUrl}}) a été livré hors ordre. Les tickets qui n'ont pas été livrés dans leur itinéraire sont : {{ticketsToMail}}" +} \ No newline at end of file diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index e84b30f3d..5dfad3725 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -365,5 +365,7 @@ "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", "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", - "The web user's email already exists": "O e-mail do utilizador da web já existe." -} + "The web user's email already exists": "O e-mail do utilizador da web já existe.", + "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", + "Ticket has been delivered out of order": "O ticket {{ ticket }} ({{ fullUrl }}) foi entregue fora de ordem. Os tickets que não foram entregues na sua rota são: {{ ticketsToMail }}" +} \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index ac2a7bc66..eeb753614 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -28,7 +28,6 @@ module.exports = Self => { verb: 'POST' } }); - Self.saveSign = async(ctx, tickets, location, signedTime, options) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; @@ -111,6 +110,12 @@ module.exports = Self => { scope: { fields: ['id'] } + }, + { + relation: 'zone', + scope: { + fields: ['id', 'zoneFk,', 'name'] + } }] }, myOptions); @@ -151,6 +156,29 @@ module.exports = Self => { await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], myOptions); + if (stateCode == 'DELIVERED' && ticket.priority) { + const orderState = await models.State.findOne({ + where: {code: 'DELIVERED'}, + fields: ['id'] + }, myOptions); + + const ticketsToMail = await Self.rawSql(` + SELECT t.id + FROM ticket t + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state s ON s.code = ts.code + WHERE t.routeFk = ? + AND s.\`order\` < ? + AND priority <(SELECT t.priority + FROM ticket t + WHERE t.id = ?)` + , [ticket.routeFk, orderState.id, ticket.id], myOptions); + const ticketIds = ticketsToMail.map(row => row.id); + + if (ticketsToMail) + await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name, ticketIds); + } + if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) { await models.Ticket.saveCmr(ctx, [ticketId], myOptions); externalTickets.push(ticketId); @@ -163,4 +191,26 @@ module.exports = Self => { } await models.Ticket.sendCmrEmail(ctx, externalTickets); }; + + async function sendMail(ctx, route, ticket, zoneName, ticketsToMail) { + const $t = ctx.req.__; + const url = await Self.app.models.Url.getUrl(); + const sendTo = 'repartos@verdnatura.es'; + const fullUrl = `${url}route/${route}/summary`; + const emailSubject = $t('Incorrect delivery order alert on route', { + route: route, + zone: zoneName + }); + const emailBody = $t('Ticket has been delivered out of order', { + ticket: ticket, + fullUrl: fullUrl, + ticketsToMail: ticketsToMail, + }, {escape: false}); + + await Self.app.models.Mail.create({ + receiver: sendTo, + subject: emailSubject, + body: emailBody + }); + } }; diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index e93408973..559c413e5 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -51,4 +51,46 @@ describe('Ticket saveSign()', () => { expect(ticketTrackingAfter.name).toBe('Entregado en parte'); }); + + fit('should send an email to notify that the delivery order is not correct', async() => { + const tx = await models.Ticket.beginTransaction({}); + const ticketFk = 8; + const priority = 5; + const stateFk = 10; + const stateTicketFk = 2; + const expeditionFk = 11; + const expeditionStateFK = 2; + + let mailCountBefore; + let mailCountAfter; + spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]); + + const options = {transaction: tx}; + const tickets = [ticketFk]; + + const expedition = await models.Expedition.findById(expeditionFk, null, options); + expedition.updateAttribute('stateTypeFk', expeditionStateFK, options); + + const ticket = await models.Ticket.findById(ticketFk, null, options); + ticket.updateAttribute('priority', priority, options); + + const filter = {where: { + ticketFk: ticketFk, + stateFk: stateTicketFk} + }; + try { + const ticketTracking = await models.TicketTracking.findOne(filter, options); + ticketTracking.updateAttribute('stateFk', stateFk, options); + mailCountBefore = await models.Mail.count(options); + await models.Ticket.saveSign(ctx, tickets, null, null, options); + mailCountAfter = await models.Mail.count(options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(mailCountAfter).toBeGreaterThan(mailCountBefore); + }); }); From 2c672951c6428f27958ee850f11093db08748c5e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 12 Dec 2024 20:33:00 +0100 Subject: [PATCH 02/32] fix: refs #7569 refs#8188 add IfNotExists --- modules/ticket/back/methods/ticket/saveSign.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index eeb753614..6dc90e330 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -205,7 +205,7 @@ module.exports = Self => { ticket: ticket, fullUrl: fullUrl, ticketsToMail: ticketsToMail, - }, {escape: false}); + }); await Self.app.models.Mail.create({ receiver: sendTo, From 12fa87a93cbb53f7ce95b9cc257f522ff010fdbf Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 9 Jan 2025 16:15:29 +0100 Subject: [PATCH 03/32] =?UTF-8?q?fix:=20refs=20#7569=20refs=C2=B76861=20ti?= =?UTF-8?q?cketOrderReserve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- loopback/locale/fr.json | 2 +- modules/ticket/back/methods/ticket/saveSign.js | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index f5c27726b..0f53cf572 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -249,5 +249,5 @@ "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", - "Ticket has been delivered out of order": "The ticket {{ ticket }} ({{ fullUrl }}) has been delivered out of order. Tickets that have not been delivered in their route are: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order. Tickets that have not been delivered in their route are: {{ ticketsToMail }}" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 2a93407fc..163fbaa71 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -394,5 +394,5 @@ "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "El ticket {{ ticket }} ({{ fullUrl }}) no ha sigo entregado en su orden. Los tickets de la ruta que no han sido entregados en su orden son: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden. Los tickets de la ruta que no han sido entregados en su orden son: {{ ticketsToMail }}" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 719cbf99c..082aedd2b 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -368,5 +368,5 @@ "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", - "Ticket has been delivered out of order": "Le ticket {{ticket}} ({{fullUrl}}) a été livré hors ordre. Les tickets qui n'ont pas été livrés dans leur itinéraire sont : {{ticketsToMail}}" + "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre. Les tickets qui n'ont pas été livrés dans leur itinéraire sont : {{ticketsToMail}}" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 6dc90e330..443b2c1c7 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -198,13 +198,13 @@ module.exports = Self => { const sendTo = 'repartos@verdnatura.es'; const fullUrl = `${url}route/${route}/summary`; const emailSubject = $t('Incorrect delivery order alert on route', { - route: route, + route, zone: zoneName }); const emailBody = $t('Ticket has been delivered out of order', { - ticket: ticket, - fullUrl: fullUrl, - ticketsToMail: ticketsToMail, + ticket, + fullUrl, + ticketsToMail, }); await Self.app.models.Mail.create({ From a1e1d4fa72fd906a65659fbfb3425fd683c25652 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 10 Jan 2025 07:20:24 +0100 Subject: [PATCH 04/32] =?UTF-8?q?fix:=20refs=20#7569=20refs=C2=B76861=20ti?= =?UTF-8?q?cketOrderReserve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/pt.json | 2 +- modules/ticket/back/methods/ticket/specs/saveSign.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 5dfad3725..1fa16074f 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -367,5 +367,5 @@ "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "O ticket {{ ticket }} ({{ fullUrl }}) foi entregue fora de ordem. Os tickets que não foram entregues na sua rota são: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem. Os tickets que não foram entregues na sua rota são: {{ ticketsToMail }}" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 559c413e5..ed802e311 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -52,7 +52,7 @@ describe('Ticket saveSign()', () => { expect(ticketTrackingAfter.name).toBe('Entregado en parte'); }); - fit('should send an email to notify that the delivery order is not correct', async() => { + it('should send an email to notify that the delivery order is not correct', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketFk = 8; const priority = 5; From c4870d52de17c101e17d421f2dd633db8ba92f74 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 13 Jan 2025 14:37:27 +0100 Subject: [PATCH 05/32] feat: refs #257275 defaulterFilter --- modules/client/back/methods/defaulter/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 5359ce4a7..cf8bd855a 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -94,7 +94,7 @@ module.exports = Self => { AND r1.started = r2.maxStarted ) r ON r.clientFk = c.id LEFT JOIN workerDepartment wd ON wd.workerFk = u.id - JOIN department dp ON dp.id = wd.departmentFk + LEFT JOIN department dp ON dp.id = wd.departmentFk WHERE d.created = ? AND d.amount > 0 From e273733832016b0916fa7cccff42a46f1f89a5b6 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 14 Jan 2025 09:33:26 +0100 Subject: [PATCH 06/32] refactor: order by id --- modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index f66221409..78fce348e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -74,7 +74,8 @@ module.exports = Self => { AND t.companyFk = ? AND NOT t.isDeleted GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) - HAVING SUM(t.totalWithVat) > 0;`; + HAVING SUM(t.totalWithVat) > 0 + ORDER BY c.id`; const addresses = await Self.rawSql(query, [ minShipped, From 01072f7cbc394f4fa7f68768a0c3a5e6c081a417 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 14 Jan 2025 11:36:54 +0100 Subject: [PATCH 07/32] fix: hotfix 7366 6943 --- modules/client/back/models/client-credit.json | 5 ++++- modules/travel/back/methods/travel/filter.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/client/back/models/client-credit.json b/modules/client/back/models/client-credit.json index b92639b80..b57374dc3 100644 --- a/modules/client/back/models/client-credit.json +++ b/modules/client/back/models/client-credit.json @@ -19,6 +19,9 @@ }, "created": { "type": "date" + }, + "workerFk": { + "type": "number" } }, "relations": { @@ -33,4 +36,4 @@ "foreignKey": "workerFk" } } -} \ No newline at end of file +} diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 30c1a45fa..d10ff080b 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -91,6 +91,11 @@ module.exports = Self => { arg: 'landed', type: 'date', description: 'The landed date' + }, + { + arg: 'awbFk', + type: 'number', + description: 'The awbFk id' } ], returns: { @@ -168,7 +173,9 @@ module.exports = Self => { t.totalEntries, t.isRaid, t.daysInForward, + t.awbFk, am.name agencyModeName, + a.code awbCode, win.name warehouseInName, wout.name warehouseOutName, cnt.code continent @@ -176,6 +183,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.warehouse win ON win.id = t.warehouseInFk JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk + JOIN vn.awb a ON a.id = t.awbFk JOIN warehouse wo ON wo.id = t.warehouseOutFk JOIN country c ON c.id = wo.countryFk LEFT JOIN continent cnt ON cnt.id = c.continentFk) AS t` From c2ca9cfbe5ca58a699660d6dd437c4291a480f8e Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 15 Jan 2025 12:26:16 +0100 Subject: [PATCH 08/32] feat: refs #7531 Added address_hasDelivery --- .../vn/functions/address_hasDelivery.sql | 24 +++++++++++++++++++ .../vn/procedures/zone_getAddresses.sql | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/functions/address_hasDelivery.sql diff --git a/db/routines/vn/functions/address_hasDelivery.sql b/db/routines/vn/functions/address_hasDelivery.sql new file mode 100644 index 000000000..f37edbd34 --- /dev/null +++ b/db/routines/vn/functions/address_hasDelivery.sql @@ -0,0 +1,24 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(vSelf INT, vLanded DATE) + RETURNS BOOL + DETERMINISTIC +BEGIN +/** + * Retorna si hay reparto disponible para + * la dirección y fecha solicitada. + * + * @param vSelf Id de dirección de envío + * @param vLanded Fecha de entrega + * @return true|false + */ + DECLARE vHasDelivery BOOL; + + CALL zone_getAgency(vSelf, vLanded); + + SELECT EXISTS (SELECT TRUE FROM tmp.zoneGetAgency) INTO vHasDelivery; + + RETURN vHasDelivery; + + DROP TEMPORARY TABLE tmp.zoneGetAgency; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 2e5982c82..0e52abe1c 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -21,6 +21,7 @@ BEGIN SELECT clientFk FROM vn.ticket WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) + AND NOT isDeleted ) SELECT c.id, c.name, @@ -50,7 +51,8 @@ BEGIN AND c.isActive AND ct.code = 'normal' AND bt.code <> 'worker' - AND (d.id = vDepartmentFk OR NOT vDepartmentFk) + AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL) + AND vn.address_hasDelivery(c.defaultAddressFk, vShipped) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From c24b00856765fbd09c5d5a73182508619ddeb8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 15 Jan 2025 16:34:44 +0000 Subject: [PATCH 09/32] Actualizar modules/travel/back/methods/travel/filter.js --- modules/travel/back/methods/travel/filter.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index d10ff080b..837e30b30 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -179,11 +178,11 @@ module.exports = Self => { win.name warehouseInName, wout.name warehouseOutName, cnt.code continent - FROM vn.travel t - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.warehouse win ON win.id = t.warehouseInFk - JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk - JOIN vn.awb a ON a.id = t.awbFk + FROM travel t + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN warehouse win ON win.id = t.warehouseInFk + JOIN warehouse wout ON wout.id = t.warehouseOutFk + LEFT JOIN awb a ON a.id = t.awbFk JOIN warehouse wo ON wo.id = t.warehouseOutFk JOIN country c ON c.id = wo.countryFk LEFT JOIN continent cnt ON cnt.id = c.continentFk) AS t` From 69b78b6bf1b2b36822a043e36b58f04b5f6667d2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 16 Jan 2025 15:04:21 +0100 Subject: [PATCH 10/32] feat: refs #7531 Added address_hasDelivery --- db/routines/vn/functions/address_hasDelivery.sql | 12 ++++++++++-- db/routines/vn/procedures/zone_getAddresses.sql | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/address_hasDelivery.sql b/db/routines/vn/functions/address_hasDelivery.sql index f37edbd34..719cc14f0 100644 --- a/db/routines/vn/functions/address_hasDelivery.sql +++ b/db/routines/vn/functions/address_hasDelivery.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(vSelf INT, vLanded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`( + vSelf INT, + vAgencyModeFk INT, + vLanded DATE +) RETURNS BOOL DETERMINISTIC BEGIN @@ -15,7 +19,11 @@ BEGIN CALL zone_getAgency(vSelf, vLanded); - SELECT EXISTS (SELECT TRUE FROM tmp.zoneGetAgency) INTO vHasDelivery; + SELECT EXISTS( + SELECT TRUE + FROM tmp.zoneGetAgency + WHERE agencyModeFk = vAgencyModeFk + ) INTO vHasDelivery; RETURN vHasDelivery; diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 0e52abe1c..05267c14c 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, + vAgencyModeFk INT, vShipped DATE, vDepartmentFk INT ) @@ -52,7 +53,7 @@ BEGIN AND ct.code = 'normal' AND bt.code <> 'worker' AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL) - AND vn.address_hasDelivery(c.defaultAddressFk, vShipped) + AND vn.address_hasDelivery(c.defaultAddressFk, vAgencyModeFk, vShipped) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From 1aa1fbda6cc12818da9071ba0d779a6d440c7699 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 Jan 2025 08:10:26 +0100 Subject: [PATCH 11/32] feat: refs #7531 Added address_hasDelivery --- db/routines/vn/procedures/zone_getAddresses.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 05267c14c..90ad89bf3 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,7 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vAgencyModeFk INT, vShipped DATE, vDepartmentFk INT ) @@ -16,6 +15,12 @@ BEGIN * @param vDepartmentFk Id de departamento * @return Un select */ + DECLARE vAgencyModeFk INT; + + SELECT agencyModeFk INTO vAgencyModeFk + FROM `zone` + WHERE id = vSelf; + CALL zone_getPostalCode(vSelf); WITH clientWithTicket AS ( From a666cfa4cdbb442e524d7f55ab049669b8d8035d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 Jan 2025 09:40:07 +0100 Subject: [PATCH 12/32] feat: refs #7531 Added address_hasDelivery --- .../vn/functions/address_hasDelivery.sql | 9 ++++++++- .../vn/procedures/zone_getAddresses.sql | 18 ++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/functions/address_hasDelivery.sql b/db/routines/vn/functions/address_hasDelivery.sql index 719cc14f0..6b3962e1d 100644 --- a/db/routines/vn/functions/address_hasDelivery.sql +++ b/db/routines/vn/functions/address_hasDelivery.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`( vSelf INT, - vAgencyModeFk INT, + vZoneFk INT, vLanded DATE ) RETURNS BOOL @@ -12,10 +12,16 @@ BEGIN * la dirección y fecha solicitada. * * @param vSelf Id de dirección de envío + * @param vZoneFk Id de zona * @param vLanded Fecha de entrega * @return true|false */ DECLARE vHasDelivery BOOL; + DECLARE vAgencyModeFk INT; + + SELECT agencyModeFk INTO vAgencyModeFk + FROM `zone` + WHERE id = vZoneFk; CALL zone_getAgency(vSelf, vLanded); @@ -23,6 +29,7 @@ BEGIN SELECT TRUE FROM tmp.zoneGetAgency WHERE agencyModeFk = vAgencyModeFk + AND zoneFk = vZoneFk ) INTO vHasDelivery; RETURN vHasDelivery; diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 90ad89bf3..eeee6c598 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vShipped DATE, + vLanded DATE, vDepartmentFk INT ) BEGIN @@ -11,22 +11,16 @@ BEGIN * vender producto para esa zona. * * @param vSelf Id de zona - * @param vShipped Fecha de envio + * @param vLanded Fecha de entrega * @param vDepartmentFk Id de departamento * @return Un select */ - DECLARE vAgencyModeFk INT; - - SELECT agencyModeFk INTO vAgencyModeFk - FROM `zone` - WHERE id = vSelf; - CALL zone_getPostalCode(vSelf); WITH clientWithTicket AS ( - SELECT clientFk + SELECT DISTINCT clientFk FROM vn.ticket - WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) + WHERE shipped BETWEEN vLanded - INTERVAL 1 DAY AND util.dayEnd(vLanded - INTERVAL 1 DAY) AND NOT isDeleted ) SELECT c.id, @@ -37,7 +31,7 @@ BEGIN u.name username, aai.invoiced, cnb.lastShipped, - cwt.clientFk + IF(cwt.clientFk, TRUE, FALSE) hasTicket FROM vn.client c JOIN vn.worker w ON w.id = c.salesPersonFk JOIN vn.workerDepartment wd ON wd.workerFk = w.id @@ -58,7 +52,7 @@ BEGIN AND ct.code = 'normal' AND bt.code <> 'worker' AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL) - AND vn.address_hasDelivery(c.defaultAddressFk, vAgencyModeFk, vShipped) + AND vn.address_hasDelivery(c.defaultAddressFk, vSelf, vLanded) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From e636d43f0492bf161b181fe2d4f147e163652387 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 17 Jan 2025 09:42:15 +0100 Subject: [PATCH 13/32] feat: refs #7531 Added address_hasDelivery --- db/routines/vn/functions/address_hasDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/functions/address_hasDelivery.sql b/db/routines/vn/functions/address_hasDelivery.sql index 6b3962e1d..c4f1644ce 100644 --- a/db/routines/vn/functions/address_hasDelivery.sql +++ b/db/routines/vn/functions/address_hasDelivery.sql @@ -9,7 +9,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`( BEGIN /** * Retorna si hay reparto disponible para - * la dirección y fecha solicitada. + * la dirección, zona y fecha solicitada. * * @param vSelf Id de dirección de envío * @param vZoneFk Id de zona From 1cdeadb59de1288857e0df6ed058e08aa1375413 Mon Sep 17 00:00:00 2001 From: provira Date: Fri, 17 Jan 2025 13:20:45 +0100 Subject: [PATCH 14/32] feat: refs #8258 added uppercase validation on supplier create --- loopback/locale/es.json | 5 +++-- modules/supplier/back/methods/supplier/newSupplier.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index cde81e0cb..3183a9697 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -398,5 +398,6 @@ "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "All tickets have a route order": "Todos los tickets tienen orden de ruta", "Price cannot be blank": "Price cannot be blank", - "There are tickets to be invoiced": "La zona tiene tickets por facturar" -} + "There are tickets to be invoiced": "La zona tiene tickets por facturar", + "Social name should be uppercase": "La razón social debe ir en mayúscula" +} \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 3cca4195f..eb941ed69 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -28,6 +28,7 @@ module.exports = Self => { delete args.ctx; if (!args.name) throw new UserError('The social name cannot be empty'); + if (args.name !== args.name.toUpperCase()) throw new UserError('Social name should be uppercase'); const data = {...args, ...{nickname: args.name}}; const supplier = await models.Supplier.create(data, myOptions); From 5fe032ac75d893749bc31892b1d03bc3517d703f Mon Sep 17 00:00:00 2001 From: robert Date: Sun, 19 Jan 2025 08:30:14 +0100 Subject: [PATCH 15/32] feat: refs #8401 create triggers to itemTaxCountry --- db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql | 9 +++++++++ db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql b/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql new file mode 100644 index 000000000..d30cae7b8 --- /dev/null +++ b/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeDelete` + BEFORE DELETE ON `itemTaxCountry` + FOR EACH ROW +BEGIN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Records in this table cannot be deleted'; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql index ad7d6327b..2552b8914 100644 --- a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql @@ -4,5 +4,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeUp FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + IF NOT(NEW.countryFk <=> OLD.countryFk) THEN + CALL util.throw('Only the VAT can be modified'); + END IF; END$$ DELIMITER ; From 044a22bc3e209faf2ee04fd57de29f6d4776eed9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 Jan 2025 07:13:04 +0100 Subject: [PATCH 16/32] feat: refs #7531 Deleted address_hasDelivery --- .../vn/functions/address_hasDelivery.sql | 39 ------------------- .../vn/procedures/zone_getAddresses.sql | 1 - 2 files changed, 40 deletions(-) delete mode 100644 db/routines/vn/functions/address_hasDelivery.sql diff --git a/db/routines/vn/functions/address_hasDelivery.sql b/db/routines/vn/functions/address_hasDelivery.sql deleted file mode 100644 index c4f1644ce..000000000 --- a/db/routines/vn/functions/address_hasDelivery.sql +++ /dev/null @@ -1,39 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`( - vSelf INT, - vZoneFk INT, - vLanded DATE -) - RETURNS BOOL - DETERMINISTIC -BEGIN -/** - * Retorna si hay reparto disponible para - * la dirección, zona y fecha solicitada. - * - * @param vSelf Id de dirección de envío - * @param vZoneFk Id de zona - * @param vLanded Fecha de entrega - * @return true|false - */ - DECLARE vHasDelivery BOOL; - DECLARE vAgencyModeFk INT; - - SELECT agencyModeFk INTO vAgencyModeFk - FROM `zone` - WHERE id = vZoneFk; - - CALL zone_getAgency(vSelf, vLanded); - - SELECT EXISTS( - SELECT TRUE - FROM tmp.zoneGetAgency - WHERE agencyModeFk = vAgencyModeFk - AND zoneFk = vZoneFk - ) INTO vHasDelivery; - - RETURN vHasDelivery; - - DROP TEMPORARY TABLE tmp.zoneGetAgency; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index eeee6c598..45c82de07 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -52,7 +52,6 @@ BEGIN AND ct.code = 'normal' AND bt.code <> 'worker' AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL) - AND vn.address_hasDelivery(c.defaultAddressFk, vSelf, vLanded) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From e6abb1d759ac55f7b43b6d7452ee99c91a3ee4ab Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 Jan 2025 07:41:41 +0100 Subject: [PATCH 17/32] feat: refs #7531 Minor change --- db/routines/vn/procedures/zone_getAddresses.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 45c82de07..5a1380126 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -8,7 +8,7 @@ BEGIN /** * Devuelve un listado de todos los clientes activos * con consignatarios a los que se les puede - * vender producto para esa zona. + * entregar producto para esa zona. * * @param vSelf Id de zona * @param vLanded Fecha de entrega @@ -20,7 +20,7 @@ BEGIN WITH clientWithTicket AS ( SELECT DISTINCT clientFk FROM vn.ticket - WHERE shipped BETWEEN vLanded - INTERVAL 1 DAY AND util.dayEnd(vLanded - INTERVAL 1 DAY) + WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) AND NOT isDeleted ) SELECT c.id, From 934507569e8963141036197a44d6e539254c5a95 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 Jan 2025 07:48:43 +0100 Subject: [PATCH 18/32] feat: refs #7531 Added comment --- db/routines/vn/procedures/zone_getAddresses.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 5a1380126..9946b0b73 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -12,7 +12,7 @@ BEGIN * * @param vSelf Id de zona * @param vLanded Fecha de entrega - * @param vDepartmentFk Id de departamento + * @param vDepartmentFk Id de departamento | NULL para mostrar todos * @return Un select */ CALL zone_getPostalCode(vSelf); From 9584ffcf5bb113284d235e05802e2a038887e529 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 20 Jan 2025 08:10:12 +0100 Subject: [PATCH 19/32] feat: refs #7531 Added landed index --- db/versions/11415-chocolateTulip/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11415-chocolateTulip/00-firstScript.sql diff --git a/db/versions/11415-chocolateTulip/00-firstScript.sql b/db/versions/11415-chocolateTulip/00-firstScript.sql new file mode 100644 index 000000000..2ed7ec9b5 --- /dev/null +++ b/db/versions/11415-chocolateTulip/00-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ticket_landed_IDX USING BTREE ON vn.ticket (landed); From cb065f42cde28963df88b29f69a4dd02e7c21797 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 20 Jan 2025 11:19:24 +0100 Subject: [PATCH 20/32] feat: refs #8401 change request --- db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql b/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql index d30cae7b8..461b861f2 100644 --- a/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql +++ b/db/routines/vn/triggers/itemTaxCountry_beforeDelete.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeDe BEFORE DELETE ON `itemTaxCountry` FOR EACH ROW BEGIN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'Records in this table cannot be deleted'; + CALL util.throw('Records in this table cannot be deleted'); END$$ DELIMITER ; From 316a17304fd94988115d0b9f387edaf4ceb38540 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 20 Jan 2025 12:26:29 +0100 Subject: [PATCH 21/32] feat: refs #8401 restriction itemFk --- db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql index 2552b8914..5220028e8 100644 --- a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeUp BEGIN SET NEW.editorFk = account.myUser_getId(); - IF NOT(NEW.countryFk <=> OLD.countryFk) THEN + IF NOT(NEW.`countryFk` <=> OLD.`countryFk`) OR NOT(NEW.`itemFk` <=> OLD.`itemFk`) THEN CALL util.throw('Only the VAT can be modified'); END IF; END$$ From 0340612645ab456997ba034775c0de3cab70aff1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 Jan 2025 12:35:55 +0100 Subject: [PATCH 22/32] feat: refs #7569 refs#7569 sendEmailNotification --- loopback/locale/en.json | 2 +- loopback/locale/es.json | 3 ++- loopback/locale/fr.json | 2 +- loopback/locale/pt.json | 2 +- modules/ticket/back/methods/ticket/saveSign.js | 12 +++++------- .../back/methods/ticket/specs/saveSign.spec.js | 16 ++++++++++++---- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 0f53cf572..d39b1bac5 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -249,5 +249,5 @@ "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", - "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order. Tickets that have not been delivered in their route are: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order." } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 163fbaa71..b9207d9cf 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -394,5 +394,6 @@ "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden. Los tickets de la ruta que no han sido entregados en su orden son: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.", + "Price cannot be blank": "Price cannot be blank" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 082aedd2b..66098bac5 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -368,5 +368,5 @@ "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", - "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre. Les tickets qui n'ont pas été livrés dans leur itinéraire sont : {{ticketsToMail}}" + "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre." } \ No newline at end of file diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 1fa16074f..240d239d6 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -367,5 +367,5 @@ "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem. Os tickets que não foram entregues na sua rota são: {{ ticketsToMail }}" + "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem." } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 443b2c1c7..9c33797b6 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -162,7 +162,7 @@ module.exports = Self => { fields: ['id'] }, myOptions); - const ticketsToMail = await Self.rawSql(` + const ticketIncorrect = await Self.rawSql(` SELECT t.id FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id @@ -173,10 +173,9 @@ module.exports = Self => { FROM ticket t WHERE t.id = ?)` , [ticket.routeFk, orderState.id, ticket.id], myOptions); - const ticketIds = ticketsToMail.map(row => row.id); - if (ticketsToMail) - await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name, ticketIds); + if (ticketIncorrect && ticketIncorrect.length > 0) + await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name); } if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) { @@ -192,7 +191,7 @@ module.exports = Self => { await models.Ticket.sendCmrEmail(ctx, externalTickets); }; - async function sendMail(ctx, route, ticket, zoneName, ticketsToMail) { + async function sendMail(ctx, route, ticket, zoneName) { const $t = ctx.req.__; const url = await Self.app.models.Url.getUrl(); const sendTo = 'repartos@verdnatura.es'; @@ -203,8 +202,7 @@ module.exports = Self => { }); const emailBody = $t('Ticket has been delivered out of order', { ticket, - fullUrl, - ticketsToMail, + fullUrl }); await Self.app.models.Mail.create({ diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index ed802e311..7098ee1fc 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -1,14 +1,22 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('Ticket saveSign()', () => { let ctx = {req: { getLocale: () => { return 'en'; }, + __: () => {}, accessToken: {userId: 9} - }}; + } + }; + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: ctx + }); + }); - it(`should throw error if the ticket's alert level is lower than 2`, async() => { + fit(`should throw error if the ticket's alert level is lower than 2`, async() => { const tx = await models.TicketDms.beginTransaction({}); const ticketWithOkState = 12; let error; @@ -27,7 +35,7 @@ describe('Ticket saveSign()', () => { expect(error).toBeDefined(); }); - it('should change state for ticket', async() => { + fit('should change state for ticket', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketWithPackedState = 7; spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]); @@ -52,7 +60,7 @@ describe('Ticket saveSign()', () => { expect(ticketTrackingAfter.name).toBe('Entregado en parte'); }); - it('should send an email to notify that the delivery order is not correct', async() => { + fit('should send an email to notify that the delivery order is not correct', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketFk = 8; const priority = 5; From b5e27707a73f339e2d4d5fbe27d76b3765ca9041 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 Jan 2025 12:36:31 +0100 Subject: [PATCH 23/32] feat: refs #7569 refs#7569 sendEmailNotification --- modules/ticket/back/methods/ticket/specs/saveSign.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 7098ee1fc..9cc262ea0 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -16,7 +16,7 @@ describe('Ticket saveSign()', () => { }); }); - fit(`should throw error if the ticket's alert level is lower than 2`, async() => { + it(`should throw error if the ticket's alert level is lower than 2`, async() => { const tx = await models.TicketDms.beginTransaction({}); const ticketWithOkState = 12; let error; @@ -35,7 +35,7 @@ describe('Ticket saveSign()', () => { expect(error).toBeDefined(); }); - fit('should change state for ticket', async() => { + it('should change state for ticket', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketWithPackedState = 7; spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]); From ef68884fe0b5f656540cfeddf1d3a6f711bd6259 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 20 Jan 2025 16:27:35 +0100 Subject: [PATCH 24/32] feat: refs #7569 refs#7569 sendEmailNotification --- loopback/locale/es.json | 2 +- modules/ticket/back/methods/ticket/saveSign.js | 2 +- modules/ticket/back/methods/ticket/specs/saveSign.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b9207d9cf..eff238150 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -395,5 +395,5 @@ "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.", - "Price cannot be blank": "Price cannot be blank" + "Price cannot be blank": "El precio no puede estar en blanco" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 9c33797b6..f99311c39 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -174,7 +174,7 @@ module.exports = Self => { WHERE t.id = ?)` , [ticket.routeFk, orderState.id, ticket.id], myOptions); - if (ticketIncorrect && ticketIncorrect.length > 0) + if (ticketIncorrect?.length > 0) await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name); } diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 9cc262ea0..3b426c2cf 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -60,7 +60,7 @@ describe('Ticket saveSign()', () => { expect(ticketTrackingAfter.name).toBe('Entregado en parte'); }); - fit('should send an email to notify that the delivery order is not correct', async() => { + it('should send an email to notify that the delivery order is not correct', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketFk = 8; const priority = 5; From eee73f001de867f11a0e68f863a9f40bb0bc0b7e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 21 Jan 2025 07:00:02 +0100 Subject: [PATCH 25/32] Merge branch 'dev' of https: refs #7569//gitea.verdnatura.es/verdnatura/salix into 7569-sendEmailOrderTicket --- loopback/locale/en.json | 2 -- loopback/locale/es.json | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 4f6374a8f..2c180e204 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -247,8 +247,6 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "Holidays to past days not available": "Holidays to past days not available", "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "There are tickets to be invoiced", "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent""Sales already moved": "Sales already moved", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0203a3bc1..abd2f79a0 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -390,13 +390,11 @@ "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "All tickets have a route order": "Todos los tickets tienen orden de ruta", - "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "La zona tiene tickets por facturar", - "Social name should be uppercase": "La razón social debe ir en mayúscula""Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", + "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.", "Price cannot be blank": "El precio no puede estar en blanco" } \ No newline at end of file From c50ff6a43aa27323c9973b976c29da509920f4a6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 21 Jan 2025 07:05:42 +0100 Subject: [PATCH 26/32] feat: refs #7569 refs#7569 sendEmailNotification --- loopback/locale/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 2c180e204..06428475f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -249,7 +249,8 @@ "Payment method is required": "Payment method is required", "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "There are tickets to be invoiced", - "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent""Sales already moved": "Sales already moved", + "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent", + "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order." From 785a10a26aad2ffc70a8b55550dbd773fe979b1d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 21 Jan 2025 09:34:56 +0100 Subject: [PATCH 27/32] feat: refs #8447 create tables tag --- .../11418-goldenRuscus/00-firstScript.sql | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 db/versions/11418-goldenRuscus/00-firstScript.sql diff --git a/db/versions/11418-goldenRuscus/00-firstScript.sql b/db/versions/11418-goldenRuscus/00-firstScript.sql new file mode 100644 index 000000000..6c623d7b7 --- /dev/null +++ b/db/versions/11418-goldenRuscus/00-firstScript.sql @@ -0,0 +1,130 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS `vn`.`itemSoldOutTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Ultimas unidades'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Temporalmente'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Descatalogado'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta mayo'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta febrero'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta diciembre'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta enero'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta marzo'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta nueva temporada'); +INSERT IGNORE INTO `vn`.`itemSoldOutTag` (`name`) VALUES ('Hasta septiembre'); + +UPDATE vn.tag + SET isFree=FALSE, + sourceTable='itemSoldOutTag' + WHERE name= 'Agotado'; + + +CREATE TABLE IF NOT EXISTS `vn`.`itemDurationTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('11 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('12 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('13 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('17 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('7 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('16-20 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('17-21 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('19-23 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('3-4 semanas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('13-17 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14-16 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15-19 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('18-25 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('20 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10-13 días'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 meses'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('5 años'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('10 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('20 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('35 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('6 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('11 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('12 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('14 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('15 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('18 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('19 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('24 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('25 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('30 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('32 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('4 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('40 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('45 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('50 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('55 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('70 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('8 horas'); +INSERT IGNORE INTO `vn`.`itemDurationTag` (`name`) VALUES ('9 horas'); + +UPDATE vn.tag + SET isFree=FALSE, + sourceTable='itemDurationTag' + WHERE name= 'Duracion'; + + +CREATE TABLE IF NOT EXISTS `vn`.`itemGrowingTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-06'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('02-06'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-05'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-07'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-08'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('03-11'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-06'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-09'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('04-11'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-07'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-08'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-10'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('05-11'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-09'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-10'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('06-11'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-09'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-10'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-11'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('07-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('09-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-04 / 10-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-04 / 9-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05 / 10-12'); +INSERT IGNORE INTO `vn`.`itemGrowingTag` (`name`) VALUES ('01-05 / 11-12'); + +UPDATE vn.tag + SET isFree=FALSE, + sourceTable='itemGrowingTag' + WHERE name= 'Recolecta'; + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemSoldOutTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemDurationTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemGrowingTag TO logisticAssist; From 05b383ecb01ad4fc5606aa73bdff2cc2c9f1b1d6 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Jan 2025 10:57:40 +0100 Subject: [PATCH 28/32] test: refs #8448 fix e2e --- e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js | 16 +--------------- e2e/paths/05-ticket/06_basic_data_steps.spec.js | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index d9689e31a..af1dc56bc 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -238,25 +238,11 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.globalItems.cancelButton); }); - it('should select the third sale and create a claim of it', async() => { - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForNavigation(); - }); - - it('should search for a ticket then access to the sales section', async() => { - await page.goBack(); - await page.goBack(); + it('should select the third sale and delete it', async() => { await page.loginAndModule('salesPerson', 'ticket'); await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); - }); - it('should select the third sale and delete it', async() => { await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.deleteSaleButton); await page.waitToClick(selectors.globalItems.acceptButton); diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index 77f0e0459..0a3ae4edc 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -75,7 +75,7 @@ describe('Ticket Edit basic data path', () => { const result = await page .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); - expect(result).toContain('-€228.25'); + expect(result).toContain('-€111.75'); }); it(`should select a new reason for the changes made then click on finalize`, async() => { From 9d289fa11efcc41b8507710d8584807f9eb1bbd9 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Jan 2025 11:57:35 +0100 Subject: [PATCH 29/32] build: init version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e4cbf1406..72f8e2d1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "25.04.0", + "version": "25.06.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 0eff155dafa5da11e584bb093d9ee1f8e165d22e Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 22 Jan 2025 16:34:14 +0100 Subject: [PATCH 30/32] refactor: refs #7184 created myteam filter and modified filters where it is used --- modules/claim/back/methods/claim/filter.js | 22 +++------- .../back/methods/sales-monitor/salesFilter.js | 22 +++------- modules/order/back/methods/order/filter.js | 24 +++-------- .../back/methods/ticket-request/filter.js | 21 +++------ modules/ticket/back/methods/ticket/filter.js | 24 +++-------- modules/worker/back/methods/worker/filter.js | 17 ++++++++ modules/worker/back/methods/worker/myTeam.js | 43 +++++++++++++++++++ modules/worker/back/models/worker.js | 1 + 8 files changed, 86 insertions(+), 88 deletions(-) create mode 100644 modules/worker/back/methods/worker/myTeam.js diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index bacdd4021..2fea40425 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -109,6 +109,7 @@ module.exports = Self => { const args = ctx.args; const myOptions = {}; let to; + const myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -133,21 +134,8 @@ module.exports = Self => { claimIdsByClaimResponsibleFk = claims.map(claim => claim.claimFk); } - // Apply filter by team - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); const where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -184,9 +172,9 @@ module.exports = Self => { return {'t.zoneFk': value}; case 'myTeam': if (value) - return {'cl.workerFk': {inq: teamMembersId}}; + return {'cl.workerFk': {inq: myTeamIds.value}}; else - return {'cl.workerFk': {nin: teamMembersId}}; + return {'cl.workerFk': {nin: myTeamIds.value}}; } }); diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index ac8a722bd..3059154c5 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -123,25 +123,13 @@ module.exports = Self => { date.setHours(0, 0, 0, 0); const args = ctx.args; const myOptions = {}; + const myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); - // Apply filter by team - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); if (ctx.args && args.to) { const dateTo = args.to; @@ -163,9 +151,9 @@ module.exports = Self => { case 'mine': case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: teamMembersId}}; + return {'c.salesPersonFk': {inq: myTeamIds.value}}; else - return {'c.salesPersonFk': {nin: teamMembersId}}; + return {'c.salesPersonFk': {nin: myTeamIds.value}}; case 'id': case 'clientFk': param = `t.${param}`; diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 2aeb1aac5..465227621 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -80,29 +80,15 @@ module.exports = Self => { const conn = Self.dataSource.connector; const myOptions = {}; const userId = ctx.req.accessToken.userId; + const myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); const args = ctx.args; - // Apply filter by team - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } - - if (args?.myTeam) - args.teamIds = teamIds; + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); if (args?.to) args.to.setHours(23, 59, 0, 0); @@ -133,9 +119,9 @@ module.exports = Self => { return {'o.confirmed': value ? 1 : 0}; case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: teamMembersId}}; + return {'c.salesPersonFk': {inq: myTeamIds.value}}; else - return {'c.salesPersonFk': {nin: teamMembersId}}; + return {'c.salesPersonFk': {nin: myTeamIds.value}}; case 'showEmpty': return {'o.total': {neq: value}}; case 'id': diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index c2edcae81..4432a017a 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -87,6 +87,7 @@ module.exports = Self => { const myOptions = {}; const models = Self.app.models; const args = ctx.args; + const myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -94,20 +95,8 @@ module.exports = Self => { if (ctx.args.mine) ctx.args.attenderFk = userId; - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); const today = Date.vnNew(); const future = Date.vnNew(); @@ -145,9 +134,9 @@ module.exports = Self => { return {'c.salesPersonFk': value}; case 'myTeam': if (value) - return {'tr.requesterFk': {inq: teamMembersId}}; + return {'tr.requesterFk': {inq: myTeamIds.value}}; else - return {'tr.requesterFk': {nin: teamMembersId}}; + return {'tr.requesterFk': {nin: myTeamIds.value}}; case 'daysOnward': today.setHours(0, 0, 0, 0); future.setDate(today.getDate() + value); diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index c61223470..ba72f34ef 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -142,28 +142,14 @@ module.exports = Self => { date.setHours(0, 0, 0, 0); const models = Self.app.models; const args = ctx.args; - + const myTeamIds = []; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - // Apply filter by team - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); if (ctx.args && args.to) { const dateTo = args.to; @@ -195,9 +181,9 @@ module.exports = Self => { case 'mine': case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: teamMembersId}}; + return {'c.salesPersonFk': {inq: myTeamIds.value}}; else - return {'c.salesPersonFk': {nin: teamMembersId}}; + return {'c.salesPersonFk': {nin: myTeamIds.value}}; case 'alertLevel': return {'ts.alertLevel': value}; diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index 52c60572a..06c4a694e 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -73,6 +73,11 @@ module.exports = Self => { type: 'String', description: 'The user email', http: {source: 'query'} + }, + { + arg: 'myTeam', + type: 'boolean', + description: 'Whether to show only tickets for the current logged user team (currently user tickets)' } ], returns: { @@ -87,6 +92,13 @@ module.exports = Self => { Self.filter = async(ctx, filter) => { let conn = Self.dataSource.connector; + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const args = ctx.args; + const myTeamIds = []; + + if (args.myTeam != null) + myTeamIds.value = await models.Worker.myTeam(userId); let where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -117,6 +129,11 @@ module.exports = Self => { return {'u.name': {like: `%${value}%`}}; case 'email': return {'eu.email': {like: `%${value}%`}}; + case 'myTeam': + if (value) + return {'c.salesPersonFk': {inq: myTeamIds.value}}; + else + return {'c.salesPersonFk': {nin: myTeamIds.value}}; } }); diff --git a/modules/worker/back/methods/worker/myTeam.js b/modules/worker/back/methods/worker/myTeam.js new file mode 100644 index 000000000..25c5916fb --- /dev/null +++ b/modules/worker/back/methods/worker/myTeam.js @@ -0,0 +1,43 @@ +module.exports = Self => { + Self.remoteMethod('myTeam', { + description: 'Return the members of the user team', + accessType: 'READ', + accepts: [{ + arg: 'userId', + type: 'string', + required: true + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/myTeam`, + verb: 'GET' + } + }); + + Self.myTeam = async(userId, options) => { + const models = Self.app.models; + const myOptions = {}; + const teamMembersId = []; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const worker = await models.Worker.findById(userId, { + include: { + relation: 'collegues' + } + }, myOptions); + const collegues = worker.collegues() || []; + for (let collegue of collegues) + teamMembersId.push(collegue.collegueFk); + + if (teamMembersId.length == 0) + teamMembersId.push(userId); + + return teamMembersId; + }; +}; + diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 2e45b78da..97e6a283c 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -21,6 +21,7 @@ module.exports = Self => { require('../methods/worker/isAuthorized')(Self); require('../methods/worker/setPassword')(Self); require('../methods/worker/getAvailablePda')(Self); + require('../methods/worker/myTeam')(Self); Self.validateAsync('fi', tinIsValid, { message: 'Invalid TIN' From 6d5a329b49b1de5bfcdce2c124aa5591fb8a016d Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 22 Jan 2025 17:09:01 +0100 Subject: [PATCH 31/32] fix: refs #7184 fixed filter and test --- modules/worker/back/methods/worker/filter.js | 27 +++++--- .../back/methods/worker/specs/filter.spec.js | 68 +++++++++++++++---- 2 files changed, 72 insertions(+), 23 deletions(-) diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index 06c4a694e..38d0e7833 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -90,17 +90,21 @@ module.exports = Self => { } }); - Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; - const models = Self.app.models; + Self.filter = async(ctx, filter, options) => { const userId = ctx.req.accessToken.userId; + const conn = Self.dataSource.connector; + const models = Self.app.models; const args = ctx.args; const myTeamIds = []; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); if (args.myTeam != null) myTeamIds.value = await models.Worker.myTeam(userId); - let where = buildFilter(ctx.args, (param, value) => { + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -137,9 +141,9 @@ module.exports = Self => { } }); - filter = mergeFilters(ctx.args.filter, {where}); + filter = mergeFilters(filter, {where}); - let stmts = []; + const stmts = []; let stmt; stmt = new ParameterizedSQL( @@ -162,11 +166,12 @@ module.exports = Self => { LEFT JOIN account.emailUser eu ON eu.userFk = u.id` ); - stmt.merge(conn.makeSuffix(filter)); - let itemsIndex = stmts.push(stmt) - 1; + stmt.merge(conn.makeWhere(filter.where)); + stmts.push(stmt); - let sql = ParameterizedSQL.join(stmts, ';'); - let result = await conn.executeStmt(sql); - return itemsIndex === 0 ? result : result[itemsIndex]; + const itemsIndex = stmts.push(stmt) - 1; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + return result[itemsIndex]; }; }; diff --git a/modules/worker/back/methods/worker/specs/filter.spec.js b/modules/worker/back/methods/worker/specs/filter.spec.js index 2eb353576..27eb79cdb 100644 --- a/modules/worker/back/methods/worker/specs/filter.spec.js +++ b/modules/worker/back/methods/worker/specs/filter.spec.js @@ -1,25 +1,69 @@ +const models = require('vn-loopback/server/server').models; const app = require('vn-loopback/server/server'); describe('worker filter()', () => { - it('should return 1 result filtering by id', async() => { - let result = await app.models.Worker.filter({args: {filter: {}, search: 1}}); + const ctx = beforeAll.getCtx(); - expect(result.length).toEqual(1); - expect(result[0].id).toEqual(1); + it('should return 1 result filtering by id', async() => { + const tx = await models.Worker.beginTransaction({}); + + try { + const options = {transaction: tx}; + const filter = {}; + const args = {search: 1}; + ctx.args = args; + + let result = await app.models.Worker.filter(ctx, filter, options); + + expect(result.length).toEqual(1); + expect(result[0].id).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should return 1 result filtering by string', async() => { - let result = await app.models.Worker.filter({args: {filter: {}, search: 'administrativeNick'}}); + const tx = await models.Worker.beginTransaction({}); - expect(result.length).toEqual(1); - expect(result[0].id).toEqual(5); + try { + const options = {transaction: tx}; + const filter = {}; + const args = {search: 'administrativeNick'}; + ctx.args = args; + + let result = await app.models.Worker.filter(ctx, filter, options); + + expect(result.length).toEqual(1); + expect(result[0].id).toEqual(5); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); - it('should return 2 results filtering by name', async() => { - let result = await app.models.Worker.filter({args: {filter: {}, firstName: 'agency'}}); + it('should return 2 result filtering by name', async() => { + const tx = await models.Worker.beginTransaction({}); - expect(result.length).toEqual(2); - expect(result[0].nickname).toEqual('agencyNick'); - expect(result[1].nickname).toEqual('agencyBossNick'); + try { + const options = {transaction: tx}; + const filter = {}; + const args = {firstName: 'agency'}; + ctx.args = args; + + let result = await app.models.Worker.filter(ctx, filter, options); + + expect(result[0].nickname).toEqual('agencyNick'); + expect(result[1].nickname).toEqual('agencyBossNick'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); From 602e822599f9764e1beb8daaccdff02d4d8ca63b Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 23 Jan 2025 08:21:19 +0100 Subject: [PATCH 32/32] refactor: refs #7184 deleted .value --- modules/claim/back/methods/claim/filter.js | 8 ++++---- modules/monitor/back/methods/sales-monitor/salesFilter.js | 8 ++++---- modules/order/back/methods/order/filter.js | 8 ++++---- modules/ticket/back/methods/ticket-request/filter.js | 8 ++++---- modules/ticket/back/methods/ticket/filter.js | 8 ++++---- modules/worker/back/methods/worker/filter.js | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 2fea40425..bf9cd9441 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -109,7 +109,7 @@ module.exports = Self => { const args = ctx.args; const myOptions = {}; let to; - const myTeamIds = []; + let myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -135,7 +135,7 @@ module.exports = Self => { } if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); const where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -172,9 +172,9 @@ module.exports = Self => { return {'t.zoneFk': value}; case 'myTeam': if (value) - return {'cl.workerFk': {inq: myTeamIds.value}}; + return {'cl.workerFk': {inq: myTeamIds}}; else - return {'cl.workerFk': {nin: myTeamIds.value}}; + return {'cl.workerFk': {nin: myTeamIds}}; } }); diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 3059154c5..4947edeaf 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -123,13 +123,13 @@ module.exports = Self => { date.setHours(0, 0, 0, 0); const args = ctx.args; const myOptions = {}; - const myTeamIds = []; + let myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); if (ctx.args && args.to) { const dateTo = args.to; @@ -151,9 +151,9 @@ module.exports = Self => { case 'mine': case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: myTeamIds.value}}; + return {'c.salesPersonFk': {inq: myTeamIds}}; else - return {'c.salesPersonFk': {nin: myTeamIds.value}}; + return {'c.salesPersonFk': {nin: myTeamIds}}; case 'id': case 'clientFk': param = `t.${param}`; diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 465227621..f24d9b225 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -80,7 +80,7 @@ module.exports = Self => { const conn = Self.dataSource.connector; const myOptions = {}; const userId = ctx.req.accessToken.userId; - const myTeamIds = []; + let myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -88,7 +88,7 @@ module.exports = Self => { const args = ctx.args; if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); if (args?.to) args.to.setHours(23, 59, 0, 0); @@ -119,9 +119,9 @@ module.exports = Self => { return {'o.confirmed': value ? 1 : 0}; case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: myTeamIds.value}}; + return {'c.salesPersonFk': {inq: myTeamIds}}; else - return {'c.salesPersonFk': {nin: myTeamIds.value}}; + return {'c.salesPersonFk': {nin: myTeamIds}}; case 'showEmpty': return {'o.total': {neq: value}}; case 'id': diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 4432a017a..1318c1ab3 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -87,7 +87,7 @@ module.exports = Self => { const myOptions = {}; const models = Self.app.models; const args = ctx.args; - const myTeamIds = []; + let myTeamIds = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -96,7 +96,7 @@ module.exports = Self => { ctx.args.attenderFk = userId; if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); const today = Date.vnNew(); const future = Date.vnNew(); @@ -134,9 +134,9 @@ module.exports = Self => { return {'c.salesPersonFk': value}; case 'myTeam': if (value) - return {'tr.requesterFk': {inq: myTeamIds.value}}; + return {'tr.requesterFk': {inq: myTeamIds}}; else - return {'tr.requesterFk': {nin: myTeamIds.value}}; + return {'tr.requesterFk': {nin: myTeamIds}}; case 'daysOnward': today.setHours(0, 0, 0, 0); future.setDate(today.getDate() + value); diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index ba72f34ef..f125ac586 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -142,14 +142,14 @@ module.exports = Self => { date.setHours(0, 0, 0, 0); const models = Self.app.models; const args = ctx.args; - const myTeamIds = []; + let myTeamIds = []; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); if (ctx.args && args.to) { const dateTo = args.to; @@ -181,9 +181,9 @@ module.exports = Self => { case 'mine': case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: myTeamIds.value}}; + return {'c.salesPersonFk': {inq: myTeamIds}}; else - return {'c.salesPersonFk': {nin: myTeamIds.value}}; + return {'c.salesPersonFk': {nin: myTeamIds}}; case 'alertLevel': return {'ts.alertLevel': value}; diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index 38d0e7833..087f080bd 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -95,14 +95,14 @@ module.exports = Self => { const conn = Self.dataSource.connector; const models = Self.app.models; const args = ctx.args; - const myTeamIds = []; + let myTeamIds = []; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); if (args.myTeam != null) - myTeamIds.value = await models.Worker.myTeam(userId); + myTeamIds = await models.Worker.myTeam(userId); const where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -135,9 +135,9 @@ module.exports = Self => { return {'eu.email': {like: `%${value}%`}}; case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: myTeamIds.value}}; + return {'c.salesPersonFk': {inq: myTeamIds}}; else - return {'c.salesPersonFk': {nin: myTeamIds.value}}; + return {'c.salesPersonFk': {nin: myTeamIds}}; } });