From a15b7e0eb845960d83a522edee0a3ab6aed93887 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 25 Apr 2024 10:44:08 +0200 Subject: [PATCH 01/15] fix(util_log): refs #7268 fix getChanges when is datestring --- loopback/util/log.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loopback/util/log.js b/loopback/util/log.js index 76e87781d..d2b78ce70 100644 --- a/loopback/util/log.js +++ b/loopback/util/log.js @@ -85,8 +85,12 @@ exports.translateValues = async(instance, changes, options = {}) => { exports.getChanges = (original, changes) => { const oldChanges = {}; const newChanges = {}; + const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/; for (let property in changes) { + if (dateRegex.test(original[property])) + original[property] = new Date(Date.parse(original[property])); + const firstChar = property.substring(0, 1); const isPrivate = firstChar == '$'; if (isPrivate) return; From 3c0dc48dd0dcd4ad7e6096ed8f7ade2aa855d3b9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 7 May 2024 09:42:53 +0000 Subject: [PATCH 02/15] Actualizar front/salix/components/upload-photo/index.js --- front/salix/components/upload-photo/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/front/salix/components/upload-photo/index.js b/front/salix/components/upload-photo/index.js index c9774d037..7779c81e1 100644 --- a/front/salix/components/upload-photo/index.js +++ b/front/salix/components/upload-photo/index.js @@ -164,6 +164,7 @@ export default class UploadPhoto extends Component { const options = { type: 'blob', + size: 'original' }; return this.editor.result(options) .then(blob => this.newPhoto.blob = blob) From 9ee05860f6a1f10aa6dbe4b40ebad3f3710b6b50 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 28 May 2024 12:19:54 +0200 Subject: [PATCH 03/15] feat: #6408 tests --- loopback/locale/en.json | 4 +- loopback/locale/es.json | 7 +- loopback/locale/fr.json | 7 +- loopback/locale/pt.json | 5 +- .../importToNewRefundTicket.spec.js | 1 + .../specs/setDelivered.spec.js | 5 +- .../back/methods/ticket/specs/state.spec.js | 72 ++++++++++++++++--- modules/ticket/back/methods/ticket/state.js | 58 ++++++++++++++- .../methods/zone/specs/deleteZone.spec.js | 23 +++--- 9 files changed, 146 insertions(+), 36 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 412a7a17e..cb9e1d12c 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -61,7 +61,8 @@ "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*", "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", @@ -230,4 +231,3 @@ "You can only have one PDA": "You can only have one PDA", "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member" } -} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fff7ebf70..5f9ec9db3 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -124,7 +124,8 @@ "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", "State": "Estado", "regular": "normal", "reserved": "reservado", @@ -358,7 +359,7 @@ "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", - "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", - "You can only have one PDA": "Solo puedes tener un PDA", + "This PDA is already assigned to another user": "Esta PDA ya está asignado a otro usuario", + "You can only have one PDA": "Solo puedes tener una PDA", "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE" } diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 44f5e35d3..6f3919e18 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,8 +123,9 @@ "Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "J'ai changé le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "J'ai changé la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}} du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",, + "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}", "State": "État", "regular": "normal", "reserved": "réservé", @@ -357,4 +358,4 @@ "This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence", "Select ticket or client": "Choisissez un ticket ou un client", "It was not able to create the invoice": "Il n'a pas été possible de créer la facture" -} \ No newline at end of file +} diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index b11eeefc6..3c156506c 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -124,7 +124,8 @@ "Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "Quantidade da venda alterada para [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* no ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ", "State": "Estado", "regular": "normal", "reserved": "reservado", @@ -357,4 +358,4 @@ "This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência", "Select ticket or client": "Selecione um ticket ou cliente", "It was not able to create the invoice": "Não foi possível criar a fatura" -} \ No newline at end of file +} diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index b05b2ac15..156caaeec 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -6,6 +6,7 @@ describe('claimBeginning', () => { const claimManagerId = 72; const activeCtx = { accessToken: {userId: claimManagerId}, + __: value => value }; const ctx = {req: activeCtx}; diff --git a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js index 3d37221c4..90d92dfa6 100644 --- a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js +++ b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js @@ -2,9 +2,10 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('ticket setDelivered()', () => { - const userId = 50; + const userId = 49; const activeCtx = { accessToken: {userId: userId}, + __: value => value }; beforeAll(async() => { @@ -19,8 +20,6 @@ describe('ticket setDelivered()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 49}}}; - const originalTicketOne = await models.Ticket.findById(8, null, options); const originalTicketTwo = await models.Ticket.findById(10, null, options); diff --git a/modules/ticket/back/methods/ticket/specs/state.spec.js b/modules/ticket/back/methods/ticket/specs/state.spec.js index 947e72b79..d908aa2ef 100644 --- a/modules/ticket/back/methods/ticket/specs/state.spec.js +++ b/modules/ticket/back/methods/ticket/specs/state.spec.js @@ -7,6 +7,7 @@ describe('ticket state()', () => { const productionId = 49; const activeCtx = { accessToken: {userId: 9}, + __: value => value }; const ctx = {req: activeCtx}; const now = Date.vnNew(); @@ -88,7 +89,8 @@ describe('ticket state()', () => { const ticket = await models.Ticket.create(sampleTicket, options); activeCtx.accessToken.userId = productionId; - const params = {ticketFk: ticket.id, stateFk: 3}; + const stateOk = await models.State.findOne({where: {code: 'OK'}}, options); + const params = {ticketFk: ticket.id, stateFk: stateOk.id}; const ticketTracking = await models.Ticket.state(ctx, params, options); @@ -112,16 +114,68 @@ describe('ticket state()', () => { const options = {transaction: tx}; const ticket = await models.Ticket.create(sampleTicket, options); - const ctx = {req: {accessToken: {userId: 18}}}; + activeCtx.accessToken.userId = salesPersonId; const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options); - const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; - const res = await models.Ticket.state(ctx, params, options); + const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; + const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options); - expect(res.ticketFk).toBe(params.ticketFk); - expect(res.stateFk).toBe(params.stateFk); - expect(res.userFk).toBe(params.userFk); - expect(res.userFk).toBe(1); - expect(res.id).toBeDefined(); + expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk); + expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk); + expect(resAssigned.userFk).toBe(paramsAssigned.userFk); + expect(resAssigned.userFk).toBe(1); + expect(resAssigned.id).toBeDefined(); + + activeCtx.accessToken.userId = productionId; + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId}; + const resPacked = await models.Ticket.state(ctx, paramsPacked, options); + + expect(resPacked.stateFk).toBe(paramsPacked.stateFk); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should equalize the quantities of quantity and originalQuantity' + + ' if they are different', async() => { + const tx = await models.TicketTracking.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ticket = await models.Ticket.create(sampleTicket, options); + activeCtx.accessToken.userId = salesPersonId; + + const sampleSale = { + ticketFk: ticket.id, + itemFk: 1, + concept: 'Test', + quantity: 10, + originalQuantity: 6 + }; + await models.Sale.create(sampleSale, options); + const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options); + const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; + const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options); + + expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk); + expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk); + expect(resAssigned.userFk).toBe(paramsAssigned.userFk); + expect(resAssigned.userFk).toBe(1); + expect(resAssigned.id).toBeDefined(); + + activeCtx.accessToken.userId = productionId; + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId}; + const resPacked = await models.Ticket.state(ctx, paramsPacked, options); + + const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options); + + expect(resPacked.stateFk).toBe(paramsPacked.stateFk); + expect(sale.quantity).toBe(sale.originalQuantity); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/state.js b/modules/ticket/back/methods/ticket/state.js index fea9475f8..f75a98354 100644 --- a/modules/ticket/back/methods/ticket/state.js +++ b/modules/ticket/back/methods/ticket/state.js @@ -64,7 +64,63 @@ module.exports = Self => { if ((ticketState && !oldStateAllowed) || !newStateAllowed) throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED'); - await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions); + const ticket = await models.Ticket.findById(params.ticketFk, { + include: [{ + relation: 'client', + scope: { + fields: ['salesPersonFk'] + } + }], + fields: ['id', 'clientFk'] + }, myOptions); + + const salesPersonFk = ticket.client().salesPersonFk; + if (salesPersonFk) { + const sales = await Self.rawSql(` + SELECT DISTINCT s.id, + s.itemFk, + s.concept, + s.originalQuantity AS oldQuantity, + s.quantity AS newQuantity + FROM vn.sale s + JOIN vn.saleTracking st ON st.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state s2 ON s2.id = ts.stateFk + WHERE s.ticketFk = ? + AND st.isChecked + AND s.originalQuantity IS NOT NULL + AND s.originalQuantity <> s.quantity + AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'PACKING') + ORDER BY st.created DESC + `, [params.ticketFk], myOptions); + + let changes = ''; + const url = await models.Url.getUrl(); + const $t = ctx.req.__; + for (let sale of sales) { + changes += `\r\n-` + $t('Changes in sales', { + itemId: sale.itemFk, + concept: sale.concept, + oldQuantity: sale.oldQuantity, + newQuantity: sale.newQuantity, + itemUrl: `${url}item/${sale.itemFk}/summary` + }); + const currentSale = await models.Sale.findById(sale.id, null, myOptions); + await currentSale.updateAttributes({ + originalQuantity: currentSale.quantity + }, myOptions); + } + + const message = $t('Changed sale quantity', { + ticketId: ticket.id, + changes: changes, + ticketUrl: `${url}ticket/${ticket.id}/sale` + }); + await models.Chat.sendCheckingPresence(ctx, salesPersonFk, message, myOptions); + } + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticket.id, params.code], myOptions); const ticketTracking = await models.TicketTracking.findOne({ where: {ticketFk: params.ticketFk}, diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 968685fec..08dafd181 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -5,6 +5,7 @@ describe('zone deletezone()', () => { const userId = 9; const activeCtx = { accessToken: {userId: userId}, + __: value => value }; const ctx = {req: activeCtx}; const zoneId = 9; @@ -15,19 +16,15 @@ describe('zone deletezone()', () => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); - try { - const originalTickets = await models.Ticket.find({ - where: { - zoneFk: zoneId - } - }); - ticketIDs = originalTickets.map(ticket => ticket.id); - originalTicketStates = await models.TicketState.find({where: { - ticketFk: {inq: ticketIDs}, - code: 'FIXING'}}); - } catch (error) { - console.error(error); - } + const originalTickets = await models.Ticket.find({ + where: { + zoneFk: zoneId + } + }); + ticketIDs = originalTickets.map(ticket => ticket.id); + originalTicketStates = await models.TicketState.find({where: { + ticketFk: {inq: ticketIDs}, + code: 'FIXING'}}); }); it('should delete a zone and update their tickets', async() => { From f9d25ccd6c4f36d472d3651cffe192c091a7a55e Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 30 May 2024 08:14:10 +0200 Subject: [PATCH 04/15] hotFix(updateClaim): salesPerson undefined --- .../claim/back/methods/claim/updateClaim.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index a206d7f3e..c99e0e2f1 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -88,15 +88,17 @@ module.exports = Self => { const updatedClaim = await claim.updateAttributes(args, myOptions); // When pickup has been changed - if (salesPerson && changedPickup && updatedClaim.pickup) - await notifyPickUp(ctx, salesPerson.id, claim); + if (salesPerson) { + if (changedPickup && updatedClaim.pickup) + await notifyPickUp(ctx, salesPerson.id, claim); - // When claimState has been changed - if (args.claimStateFk) { - const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions); - await notifyStateChange(ctx, salesPerson.id, claim, newState.description); - if (newState.code == 'canceled') - await notifyStateChange(ctx, claim.workerFk, claim, newState.description); + // When claimState has been changed + if (args.claimStateFk) { + const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions); + await notifyStateChange(ctx, salesPerson.id, claim, newState.description); + if (newState.code == 'canceled') + await notifyStateChange(ctx, claim.workerFk, claim, newState.description); + } } if (tx) await tx.commit(); From ce2721ca470bef18b3398152bc610abef6e315c0 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 30 May 2024 08:16:57 +0200 Subject: [PATCH 05/15] deploy: increase version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 661d5b8b9..c40f39e43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.2", + "version": "24.22.3", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 5e55f2d92d61ff6a996753b0d21b348227fb398b Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 30 May 2024 09:35:42 +0200 Subject: [PATCH 06/15] feat: refs # 6408 test ok --- .../back/methods/ticket-tracking/specs/setDelivered.spec.js | 1 + modules/ticket/back/methods/ticket/state.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js index 90d92dfa6..3d39ea278 100644 --- a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js +++ b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js @@ -7,6 +7,7 @@ describe('ticket setDelivered()', () => { accessToken: {userId: userId}, __: value => value }; + const ctx = {req: activeCtx}; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ diff --git a/modules/ticket/back/methods/ticket/state.js b/modules/ticket/back/methods/ticket/state.js index f75a98354..9b0b862f2 100644 --- a/modules/ticket/back/methods/ticket/state.js +++ b/modules/ticket/back/methods/ticket/state.js @@ -92,7 +92,7 @@ module.exports = Self => { AND st.isChecked AND s.originalQuantity IS NOT NULL AND s.originalQuantity <> s.quantity - AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'PACKING') + AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'CHECKED') ORDER BY st.created DESC `, [params.ticketFk], myOptions); From 6dca7915c84e7a7d21e2f898f636cb5a0abc9c09 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 30 May 2024 10:17:02 +0200 Subject: [PATCH 07/15] deploy: increase version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c40f39e43..6a86bcbf0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.3", + "version": "24.22.4", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From db1c352be375526c7b7267940d3719041181c3ab Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 30 May 2024 18:06:35 +0200 Subject: [PATCH 08/15] feat: packaging refs #4021 --- modules/entry/back/model-config.json | 5 +++- modules/entry/back/models/entry-type.json | 25 +++++++++++++++++++ modules/entry/back/models/entry.json | 19 ++++++++------ .../methods/supplier/getItemsPackaging.js | 3 ++- 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 modules/entry/back/models/entry-type.json diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 7b6e23685..dc7fd86be 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -22,5 +22,8 @@ }, "EntryObservation": { "dataSource": "vn" + }, + "EntryType": { + "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/entry/back/models/entry-type.json b/modules/entry/back/models/entry-type.json new file mode 100644 index 000000000..989aa3a8a --- /dev/null +++ b/modules/entry/back/models/entry-type.json @@ -0,0 +1,25 @@ +{ + "name": "EntryType", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "entryType" + } + }, + "properties": { + "code": { + "type": "string", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string" + }, + "isInformal": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index ab451219e..833edf14d 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -35,9 +35,9 @@ }, "isVirtual": { "type": "boolean", - "mysql": { - "columnName": "isRaid" - } + "mysql": { + "columnName": "isRaid" + } }, "isRaid": { "type": "boolean" @@ -53,9 +53,9 @@ }, "observation": { "type": "string", - "mysql": { - "columnName": "evaNotes" - } + "mysql": { + "columnName": "evaNotes" + } }, "loadPriority": { "type": "number" @@ -101,6 +101,11 @@ "type": "belongsTo", "model": "Account", "foreignKey": "observationEditorFk" + }, + "entryType": { + "type": "belongsTo", + "model": "EntryType", + "foreignKey": "typeFk" } } -} +} \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index c06195a55..8a27c89c4 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -33,7 +33,7 @@ module.exports = Self => { JOIN vn.item i ON i.id = b.itemFk WHERE e.id = ? AND e.supplierFk = ? GROUP BY i.id - ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers + ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers, ic.url FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk JOIN vn.entry e ON e.id = b.entryFk @@ -41,6 +41,7 @@ module.exports = Self => { JOIN vn.buyConfig bc ON bc.monthsAgo JOIN vn.travel t ON t.id = e.travelFk LEFT JOIN entryTmp et ON et.id = i.id + JOIN hedera.imageConfig ic WHERE e.supplierFk = ? AND i.family IN ('EMB', 'CONT') AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) From d901584c3f64ed38bc4adfa6c3c039d47b8e2c9e Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 30 May 2024 18:39:06 +0200 Subject: [PATCH 09/15] feat: refs #6404 add deadline field --- back/methods/mrw-config/createShipment.ejs | 2 +- db/versions/11079-goldenFern/00-firstScript.sql | 3 +++ package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 db/versions/11079-goldenFern/00-firstScript.sql diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index b7a1cd897..e29d3df7e 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -29,7 +29,7 @@ <%= expeditionData.created %> - <%= expeditionData.expeditionDataId %> + <%= expeditionData.expeditionId %> <%= expeditionData.serviceType %> 1 <%= expeditionData.weekDays %> diff --git a/db/versions/11079-goldenFern/00-firstScript.sql b/db/versions/11079-goldenFern/00-firstScript.sql new file mode 100644 index 000000000..14d9ddb5f --- /dev/null +++ b/db/versions/11079-goldenFern/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS expeditionDeadLine TIME NULL +COMMENT 'This field stores the latest time by which expeditions can be generated to be sent today'; \ No newline at end of file diff --git a/package.json b/package.json index 661d5b8b9..c40f39e43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.2", + "version": "24.22.3", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From eac3fa1e2f00af07345ed3e975ed402f266fa165 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 30 May 2024 19:09:29 +0200 Subject: [PATCH 10/15] feat: refs #6404 fix packagejson --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c40f39e43..d7927a6b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.3", + "version": "24.22.5", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 85c328e522800fa6746a1b71a7b7b7b935f27c4c Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 31 May 2024 10:07:27 +0200 Subject: [PATCH 11/15] fix: refs #7039 hotFixcountry --- modules/worker/front/basic-data/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index aa3f6ca79..bece1b6fd 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -54,8 +54,8 @@ From 94cc233852d50122f09569ee7f3336db1fbad64d Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 31 May 2024 10:17:21 +0200 Subject: [PATCH 12/15] deploy: increase version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d7927a6b5..6872fee36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.5", + "version": "24.22.6", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 884b5f8475b0bfabec4990ca7084a6f4b869dfd2 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 31 May 2024 11:51:32 +0200 Subject: [PATCH 13/15] feat: refs #6404 add cero filler to counter --- back/methods/mrw-config/createShipment.ejs | 3 ++- back/methods/mrw-config/createShipment.js | 14 ++++++++++---- .../11080-maroonAnthurium/00-firstScript.sql | 9 +++++++++ package.json | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 db/versions/11080-maroonAnthurium/00-firstScript.sql diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index e29d3df7e..7468218f2 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -26,10 +26,11 @@ <%= expeditionData.fi %> <%= expeditionData.clientName %> <%= expeditionData.phone %> + <%= expeditionData.deliveryObservation %> <%= expeditionData.created %> - <%= expeditionData.expeditionId %> + <%= expeditionData.reference %> <%= expeditionData.serviceType %> 1 <%= expeditionData.weekDays %> diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 081a83382..1bbfeaab2 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -45,7 +45,7 @@ module.exports = Self => { `SELECT CASE co.code WHEN 'ES' THEN a.postalCode - WHEN 'PT' THEN LEFT(a.postalCode, 4) + WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim) WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') END postalCode, a.city, @@ -56,9 +56,10 @@ module.exports = Self => { c.phone, DATE_FORMAT(t.shipped, '%d/%m/%Y') created, t.shipped, - e.id expeditionId, - LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType, - IF(mw.weekdays, 'S', 'N') weekDays + CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, + LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType, + IF(mw.weekdays, 'S', 'N') weekDays, + oa.description deliveryObservation FROM expedition e JOIN ticket t ON e.ticketFk = t.id JOIN agencyMode am ON am.id = t.agencyModeFk @@ -66,8 +67,12 @@ module.exports = Self => { LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a') JOIN client c ON t.clientFk = c.id JOIN address a ON t.addressFk = a.id + LEFT JOIN addressObservation oa ON oa.addressFk = a.id + LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk + AND ot.code = 'delivery' JOIN province p ON a.provinceFk = p.id JOIN country co ON co.id = p.countryFk + JOIN mrwConfig mc WHERE e.id = ? LIMIT 1`; @@ -92,6 +97,7 @@ module.exports = Self => { if (tx) await tx.commit(); + console.log('file: ', file); return {shipmentId, file}; }; diff --git a/db/versions/11080-maroonAnthurium/00-firstScript.sql b/db/versions/11080-maroonAnthurium/00-firstScript.sql new file mode 100644 index 000000000..651cd4c7c --- /dev/null +++ b/db/versions/11080-maroonAnthurium/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS counterWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS serviceTypeWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS portugalPostCodeTrim INT UNSIGNED NULL + COMMENT 'It will trim the last characters of the postal code'; diff --git a/package.json b/package.json index 6872fee36..4df55c492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.6", + "version": "24.22.7", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 988b3cbbee67f94e10897f35c117bece50cd9c80 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 31 May 2024 11:53:55 +0200 Subject: [PATCH 14/15] fix: refs #6404 ref #6404 remove console.log --- back/methods/mrw-config/createShipment.js | 1 - 1 file changed, 1 deletion(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 1bbfeaab2..dd2ed883a 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -97,7 +97,6 @@ module.exports = Self => { if (tx) await tx.commit(); - console.log('file: ', file); return {shipmentId, file}; }; From d27bbd9a8f77aa40162eef0997259a905a7f344c Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 31 May 2024 12:28:47 +0200 Subject: [PATCH 15/15] hotfix: ticket 189567 --- db/routines/vn/functions/client_getFromPhone.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/functions/client_getFromPhone.sql b/db/routines/vn/functions/client_getFromPhone.sql index c6ded691b..5e4daa532 100644 --- a/db/routines/vn/functions/client_getFromPhone.sql +++ b/db/routines/vn/functions/client_getFromPhone.sql @@ -11,10 +11,7 @@ BEGIN */ DECLARE vClient INT DEFAULT NULL; - -- SET vPhone = vPhone COLLATE 'utf8_unicode_ci'; - - DROP TEMPORARY TABLE IF EXISTS tClient; - CREATE TEMPORARY TABLE tClient + CREATE OR REPLACE TEMPORARY TABLE tClient ENGINE = MEMORY SELECT id clientFk FROM `client` @@ -27,13 +24,14 @@ BEGIN OR mobile = vPhone UNION SELECT clientFk - FROM vn.clientContact + FROM clientContact WHERE phone = vPhone; SELECT t.clientFk INTO vClient FROM tClient t JOIN `client` c ON c.id = t.clientFk WHERE c.isActive + AND c.salesPersonFk LIMIT 1; DROP TEMPORARY TABLE tClient;