From c5fb565484532e955e30cd7b1f3e54dc3fceaf85 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 15 Nov 2022 10:25:33 +0100 Subject: [PATCH 01/17] refs #4503 message added --- back/methods/chat/sendCheckingPresence.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429..075591969 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -43,6 +43,9 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); + if (process.env.NODE_ENV == 'test') + message = `[Test:Environment to user ${userId}] ` + message; + await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, From 6b76804913e5bf86dd014e326e43dd96f978f34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 28 Nov 2022 10:52:15 +0100 Subject: [PATCH 02/17] refs #4865 Sintaxis mensajes rocket --- loopback/locale/en.json | 8 ++++---- loopback/locale/es.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ad110ec98..2abf17b4b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -66,9 +66,9 @@ "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", - "Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*", - "Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*", + "Claim will be picked": "The product from the claim [{{claimId}}]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", + "Claim state has changed to incomplete": "The state of the claim [{{claimId}}]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*", + "Claim state has changed to canceled": "The state of the claim [{{claimId}}]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", @@ -134,7 +134,7 @@ "Password does not meet requirements": "Password does not meet requirements", "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", "Not enough privileges to edit a client": "Not enough privileges to edit a client", - "Claim pickup order sent": "Claim pickup order sent [({{claimId}})]({{{claimUrl}}}) to client *{{clientName}}*", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", "You don't have grant privilege": "You don't have grant privilege", "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) merged with [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ecaae31b9..c1e09e9f6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -134,9 +134,9 @@ "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", - "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", - "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", + "Claim will be picked": "Se recogerá el género de la reclamación [{{claimId}}]({{{claimUrl}}}) del cliente *{{clientName}}*", + "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [{{claimId}}]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", + "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [{{claimId}}]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", @@ -238,7 +238,7 @@ "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", "This route does not exists": "Esta ruta no existe", - "Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*", + "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", "You don't have grant privilege": "No tienes privilegios para dar privilegios", "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) fusionado con [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})", From c54844f7ffe38685a5dce8438b79e002fceaad23 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 1 Dec 2022 14:32:05 +0100 Subject: [PATCH 03/17] removed pending from working test --- .../invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js index 536fa07a0..08f049783 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js @@ -30,7 +30,6 @@ describe('InvoiceOut downloadZip()', () => { }); it('should return an error if the size of the files is too large', async() => { - pending('https://redmine.verdnatura.es/issues/4875'); const tx = await models.InvoiceOut.beginTransaction({}); let error; From 95967a29dbb13869aabc76cdb5fa265830dcb150 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 13 Dec 2022 11:50:17 +0100 Subject: [PATCH 04/17] refs #4928 email template added and proc modified --- db/changes/224702/00-notificationProc.sql | 7 +-- db/changes/225001/.gitkeep | 1 - .../225001/00-supplier_beforeUpdate.sql | 48 +++++++++++++++++++ .../assets/css/import.js | 11 +++++ .../supplier-pay-method-update/locale/en.yml | 3 ++ .../supplier-pay-method-update/locale/es.yml | 3 ++ .../supplier-pay-method-update.html | 8 ++++ .../supplier-pay-method-update.js | 23 +++++++++ 8 files changed, 97 insertions(+), 7 deletions(-) delete mode 100644 db/changes/225001/.gitkeep create mode 100644 db/changes/225001/00-supplier_beforeUpdate.sql create mode 100644 print/templates/email/supplier-pay-method-update/assets/css/import.js create mode 100644 print/templates/email/supplier-pay-method-update/locale/en.yml create mode 100644 print/templates/email/supplier-pay-method-update/locale/es.yml create mode 100644 print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html create mode 100755 print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js diff --git a/db/changes/224702/00-notificationProc.sql b/db/changes/224702/00-notificationProc.sql index 475b2e389..2cf11b4f1 100644 --- a/db/changes/224702/00-notificationProc.sql +++ b/db/changes/224702/00-notificationProc.sql @@ -12,14 +12,9 @@ BEGIN * @param vAuthorFk The notification author or %NULL if there is no author * @return The notification id */ - DECLARE vNotificationFk INT; - - SELECT id INTO vNotificationFk - FROM `notification` - WHERE `name` = vNotificationName; INSERT INTO notificationQueue - SET notificationFk = vNotificationFk, + SET notificationFk = vNotificationName, params = vParams, authorFk = vAuthorFk; diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep deleted file mode 100644 index 7a4187c02..000000000 --- a/db/changes/225001/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -Delete this file diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql new file mode 100644 index 000000000..857d3206f --- /dev/null +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -0,0 +1,48 @@ +DROP TRIGGER IF EXISTS vn.supplier_beforeUpdate; +USE vn; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` + BEFORE UPDATE ON `supplier` + FOR EACH ROW +BEGIN + DECLARE vHasChange BOOL DEFAULT FALSE; + DECLARE vPayMethodHasVerified BOOL; + DECLARE vParams JSON; + DECLARE vOldPayMethodName VARCHAR(20); + DECLARE vNewPayMethodName VARCHAR(20); + + SELECT hasVerified INTO vPayMethodHasVerified + FROM payMethod + WHERE id = NEW.payMethodFk; + + SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + + IF !vHasChange THEN + SELECT name INTO vOldPayMethodName + FROM payMethod + WHERE id = OLD.payMethodFk; + SELECT name INTO vNewPayMethodName + FROM payMethod + WHERE id = NEW.payMethodFk; + SET vParams = JSON_OBJECT( + 'name', NEW.name, + 'oldPayMethod', vOldPayMethodName, + 'newPayMethod', vNewPayMethodName + ); + SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id; + END IF; + + SET vHasChange = (NEW.payDemFk <=> OLD.payDemFk) OR (NEW.payDay <=> OLD.payDay); + + IF vPayMethodHasVerified AND !vHasChange THEN + SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + END IF; + + IF vHasChange THEN + SET NEW.isPayMethodChecked = FALSE; + END IF; + +END$$ +DELIMITER ; diff --git a/print/templates/email/supplier-pay-method-update/assets/css/import.js b/print/templates/email/supplier-pay-method-update/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/supplier-pay-method-update/locale/en.yml b/print/templates/email/supplier-pay-method-update/locale/en.yml new file mode 100644 index 000000000..f04ccc5ce --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/locale/en.yml @@ -0,0 +1,3 @@ +subject: Pay method updated +title: Pay method updated +description: The pay method of the supplier {0} has been updated from {1} to {2} diff --git a/print/templates/email/supplier-pay-method-update/locale/es.yml b/print/templates/email/supplier-pay-method-update/locale/es.yml new file mode 100644 index 000000000..59ee0e02f --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/locale/es.yml @@ -0,0 +1,3 @@ +subject: Método de pago actualizado +title: Método de pago actualizado +description: Se ha actualizado el método de pago del proveedor {0} de {1} a {2} diff --git a/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html new file mode 100644 index 000000000..df8543cd9 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html @@ -0,0 +1,8 @@ + +
+
+

{{ $t('title') }}

+

+
+
+
diff --git a/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js new file mode 100755 index 000000000..283b2689c --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js @@ -0,0 +1,23 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'supplier-pay-method-update', + components: { + 'email-body': emailBody.build(), + }, + props: { + name: { + type: String, + required: true + }, + oldPayMethod: { + type: String, + required: true + }, + newPayMethod: { + type: String, + required: true + } + } +}; From f00fdcff7cb20524141e9a704473c62ac2ea5abb Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 14 Dec 2022 08:06:02 +0100 Subject: [PATCH 05/17] refactor sql --- .../225001/00-supplier_beforeUpdate.sql | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index 857d3206f..08af8666b 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -1,5 +1,5 @@ -DROP TRIGGER IF EXISTS vn.supplier_beforeUpdate; -USE vn; +DROP TRIGGER IF EXISTS `vn`.`supplier_beforeUpdate`; +USE `vn`; DELIMITER $$ $$ @@ -7,7 +7,8 @@ CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` FOR EACH ROW BEGIN - DECLARE vHasChange BOOL DEFAULT FALSE; + DECLARE vHasChange BOOL; + DECLARE vPayMethodChanged BOOL; DECLARE vPayMethodHasVerified BOOL; DECLARE vParams JSON; DECLARE vOldPayMethodName VARCHAR(20); @@ -17,15 +18,16 @@ BEGIN FROM payMethod WHERE id = NEW.payMethodFk; - SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk); - IF !vHasChange THEN + IF vPayMethodChanged THEN SELECT name INTO vOldPayMethodName FROM payMethod WHERE id = OLD.payMethodFk; SELECT name INTO vNewPayMethodName FROM payMethod WHERE id = NEW.payMethodFk; + SET vParams = JSON_OBJECT( 'name', NEW.name, 'oldPayMethod', vOldPayMethodName, @@ -34,13 +36,9 @@ BEGIN SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id; END IF; - SET vHasChange = (NEW.payDemFk <=> OLD.payDemFk) OR (NEW.payDay <=> OLD.payDay); + SET vHasChange = NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged; - IF vPayMethodHasVerified AND !vHasChange THEN - SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); - END IF; - - IF vHasChange THEN + IF vHasChange AND vPayMethodHasVerified THEN SET NEW.isPayMethodChecked = FALSE; END IF; From 8d7757ddbe5db19c7785948f8638e807c3b592cb Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 15 Dec 2022 07:40:51 +0100 Subject: [PATCH 06/17] add reset-password --- front/salix/components/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/salix/components/app/app.js b/front/salix/components/app/app.js index 20f0ad969..91a8d2215 100644 --- a/front/salix/components/app/app.js +++ b/front/salix/components/app/app.js @@ -21,7 +21,7 @@ export default class App extends Component { get showLayout() { const state = this.$state.current.name || this.$location.$$path.substring(1).replace('/', '.'); - const outLayout = ['login', 'recoverPassword', 'resetPassword']; + const outLayout = ['login', 'recoverPassword', 'resetPassword', 'reset-password']; return state && !outLayout.some(ol => ol == state); } From 33196acac6b4ed31400ce63c38f4a30314744a8d Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 15 Dec 2022 08:31:47 +0100 Subject: [PATCH 07/17] refs #4928 fixture notification, fix test supplier --- .../225001/00-supplier_beforeUpdate.sql | 3 + .../back/models/specs/supplier.spec.js | 127 +++++++++++------- 2 files changed, 84 insertions(+), 46 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index 08af8666b..e87415659 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -44,3 +44,6 @@ BEGIN END$$ DELIMITER ; + +INSERT INTO `util`.`notification` (`id`, `name`,`description`) + VALUES (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 3140981c3..effb70e35 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -2,13 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('loopback model Supplier', () => { - let supplierOne; - let supplierTwo; - beforeAll(async() => { - supplierOne = await models.Supplier.findById(1); - supplierTwo = await models.Supplier.findById(442); - const activeCtx = { accessToken: {userId: 9}, http: { @@ -23,71 +17,112 @@ describe('loopback model Supplier', () => { }); }); - afterAll(async() => { - await supplierOne.updateAttribute('payMethodFk', supplierOne.payMethodFk); - await supplierTwo.updateAttribute('payMethodFk', supplierTwo.payMethodFk); - }); - describe('payMethodFk', () => { it('should throw an error when attempting to set an invalid payMethod id in the supplier', async() => { - let error; - const expectedError = 'You can not select this payment method without a registered bankery account'; - const supplier = await models.Supplier.findById(1); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - await supplier.updateAttribute('payMethodFk', 8) - .catch(e => { - error = e; + try { + let error; + const expectedError = 'You can not select this payment method without a registered bankery account'; + const supplier = await models.Supplier.findOne({where: {id: 1}}, options); - expect(error.message).toContain(expectedError); - }); + await supplier.updateAttribute('payMethodFk', 8, options) + .catch(e => { + error = e; - expect(error).toBeDefined(); + expect(error.message).toContain(expectedError); + }); + + expect(error).toBeDefined(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should not throw if the payMethod id is valid', async() => { - let error; - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('payMethodFk', 4) - .catch(e => { - error = e; - }); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - expect(error).not.toBeDefined(); + try { + let error; + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('payMethodFk', 4, options) + .catch(e => { + error = e; + }); + + expect(error).not.toBeDefined(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => { - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payMethodFk', 5); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - const result = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payMethodFk', 5, options); - expect(result.isPayMethodChecked).toEqual(true); + const result = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(result.isPayMethodChecked).toEqual(true); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => { - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payMethodFk', 2); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - const result = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payMethodFk', 2, options); - expect(result.isPayMethodChecked).toEqual(false); + const result = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(result.isPayMethodChecked).toEqual(false); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => { - const supplier = await models.Supplier.findById(442); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payDay', 5); - const firstResult = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('payMethodFk', 2, options); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payDemFk', 1); - const secondResult = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payDay', 5, options); + const firstResult = await models.Supplier.findOne({where: {id: 442}}, options); - expect(firstResult.isPayMethodChecked).toEqual(false); - expect(secondResult.isPayMethodChecked).toEqual(false); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payDemFk', 1, options); + const secondResult = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(firstResult.isPayMethodChecked).toEqual(false); + expect(secondResult.isPayMethodChecked).toEqual(false); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); }); From 522000cd04f06d05f19d3cc640df16960aaa77bb Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 15 Dec 2022 09:52:34 +0100 Subject: [PATCH 08/17] refs #4928 fix fixtures --- .../225001/00-supplier_beforeUpdate.sql | 3 -- db/dump/fixtures.sql | 4 ++- .../back/models/specs/supplier.spec.js | 33 +++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index e87415659..08af8666b 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -44,6 +44,3 @@ BEGIN END$$ DELIMITER ; - -INSERT INTO `util`.`notification` (`id`, `name`,`description`) - VALUES (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5b37338e4..68e2f7a8b 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2689,7 +2689,8 @@ INSERT INTO `util`.`notificationConfig` INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES - (1, 'print-email', 'notification fixture one'); + (1, 'print-email', 'notification fixture one'), + (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES @@ -2746,3 +2747,4 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) INSERT INTO `vn`.`payDemDetail` (`id`, `detail`) VALUES (1, 1); + diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index effb70e35..1e8efb4b1 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -2,7 +2,12 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('loopback model Supplier', () => { + let supplierOne; + let supplierTwo; + beforeAll(async() => { + supplierOne = await models.Supplier.findById(1); + supplierTwo = await models.Supplier.findById(442); const activeCtx = { accessToken: {userId: 9}, http: { @@ -25,9 +30,8 @@ describe('loopback model Supplier', () => { try { let error; const expectedError = 'You can not select this payment method without a registered bankery account'; - const supplier = await models.Supplier.findOne({where: {id: 1}}, options); - await supplier.updateAttribute('payMethodFk', 8, options) + await supplierOne.updateAttribute('payMethodFk', 8, options) .catch(e => { error = e; @@ -48,8 +52,7 @@ describe('loopback model Supplier', () => { try { let error; - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('payMethodFk', 4, options) + await supplierTwo.updateAttribute('payMethodFk', 4, options) .catch(e => { error = e; }); @@ -67,9 +70,8 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payMethodFk', 5, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payMethodFk', 5, options); const result = await models.Supplier.findOne({where: {id: 442}}, options); @@ -86,9 +88,8 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payMethodFk', 2, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payMethodFk', 2, options); const result = await models.Supplier.findOne({where: {id: 442}}, options); @@ -105,15 +106,13 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('payMethodFk', 2, options); - - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payDay', 5, options); + await supplierTwo.updateAttribute('payMethodFk', 2, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payDay', 5, options); const firstResult = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payDemFk', 1, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payDemFk', 1, options); const secondResult = await models.Supplier.findOne({where: {id: 442}}, options); expect(firstResult.isPayMethodChecked).toEqual(false); From 5cc8764a3f5f710e7c039ef42baa7b79d4811108 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 15 Dec 2022 13:54:17 +0100 Subject: [PATCH 09/17] acquireTimeout 10000 --- loopback/server/datasources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 00f6bf624..1e8e4820b 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -15,7 +15,7 @@ "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, - "acquireTimeout": 20000, + "acquireTimeout": 10000, "waitForConnections": true }, "osticket": { From bab6fa0c9d2644b9fedd20331e590d44758e8fab Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 15 Dec 2022 14:02:18 +0100 Subject: [PATCH 10/17] acquireTimeout: 60000 --- loopback/server/datasources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 1e8e4820b..f5f277ffc 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -15,7 +15,7 @@ "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, - "acquireTimeout": 10000, + "acquireTimeout": 60000, "waitForConnections": true }, "osticket": { From ed68637059c266911118148347d2cd904bfed61d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 15 Dec 2022 15:05:17 +0100 Subject: [PATCH 11/17] disable outLayout --- front/salix/components/app/app.html | 5 ++- front/salix/components/login/login.html | 57 ++++++++++++++----------- front/salix/routes.js | 4 +- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/front/salix/components/app/app.html b/front/salix/components/app/app.html index f14fab2dd..d32c9f68b 100644 --- a/front/salix/components/app/app.html +++ b/front/salix/components/app/app.html @@ -1,8 +1,9 @@ - - + diff --git a/front/salix/components/login/login.html b/front/salix/components/login/login.html index a078fa0af..807e4b284 100644 --- a/front/salix/components/login/login.html +++ b/front/salix/components/login/login.html @@ -1,27 +1,32 @@ - - - - - - -