From 38bf49c0b60cfb6d3eb637775b234ca4bb8a5e0b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Mar 2023 08:40:53 +0100 Subject: [PATCH 01/20] refs #5410 fix: se mantenien los checkbox marcados al paginar --- modules/client/front/defaulter/index.html | 32 ++++++++++++----------- modules/client/front/defaulter/index.js | 14 ++++++++++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 22b78594a..8f22629a9 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -5,6 +5,7 @@ limit="20" order="amount DESC" data="defaulters" + on-data-change="$ctrl.reCheck()" auto-load="true"> @@ -17,22 +18,22 @@ -
Total
-
- - @@ -56,25 +57,25 @@ Comercial - Balance D. - Author Last observation - L. O. Date - @@ -88,8 +89,9 @@ - @@ -150,7 +152,7 @@ - + @@ -160,7 +162,7 @@ id !== clientId) : [...this.checkedDefaulers, clientId]; + } + + reCheck() { + if (!this.$.model.data || !this.checkedDefaulers.length) return; + + this.$.model.data.forEach(defaulter => { + defaulter.checked = this.checkedDefaulers.includes(defaulter.clientFk); + }); + } + getBalanceDueTotal() { this.$http.get('Defaulters/filter') .then(res => { From bc47fc35d6c650ae3fec65a6b9b1e33b64296ffa Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 13:55:21 +0100 Subject: [PATCH 02/20] =?UTF-8?q?refs=20#5410=20feat:=20a=C3=B1adido=20fil?= =?UTF-8?q?tro=20a=20las=20columnas=20created=20y=20defaulterSinced?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/client/front/defaulter/index.js | 21 ++++++++++++++++++-- modules/client/front/defaulter/index.spec.js | 18 +++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 868e1b03f..48552f731 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -46,11 +46,11 @@ export default class Controller extends Section { }, { field: 'created', - searchable: false + datepicker: true }, { field: 'defaulterSinced', - searchable: false + datepicker: true } ] }; @@ -136,8 +136,25 @@ export default class Controller extends Section { case 'workerFk': case 'salesPersonFk': return {[`d.${param}`]: value}; + case 'created': + return {'d.created': { + between: this.dateRange(value)} + }; + case 'defaulterSinced': + return {'d.defaulterSinced': { + between: this.dateRange(value)} + }; } } + + dateRange(value) { + const minHour = new Date(value); + minHour.setHours(0, 0, 0, 0); + const maxHour = new Date(value); + maxHour.setHours(23, 59, 59, 59); + + return [minHour, maxHour]; + } } ngModule.vnComponent('vnClientDefaulter', { diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index f92378d08..6b80a7c36 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -117,5 +117,23 @@ describe('client defaulter', () => { expect(controller.balanceDueTotal).toEqual(875); }); }); + + describe('dateRange()', () => { + it('should return two dates with the hours at the start and end of the given date', () => { + const now = Date.vnNew(); + + const today = now.getDate(); + + const dateRange = controller.dateRange(now); + const start = dateRange[0].toString(); + const end = dateRange[1].toString(); + + expect(start).toContain(today); + expect(start).toContain('00:00:00'); + + expect(end).toContain(today); + expect(end).toContain('23:59:59'); + }); + }); }); }); From 98916bf5e13ab0e2f622fc932bbe2f81bf574df8 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 13:57:22 +0100 Subject: [PATCH 03/20] refs #5410 add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dde790aaa..708fd7bd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- +- (Clientes -> Morosos) Ahora se puede filtrar por las columnas "Desde" y "Fecha Ú. O." ### Changed - From 306573b1bf3a1c89d3fa1c866b6bd8556348db99 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 20 Mar 2023 15:11:55 +0100 Subject: [PATCH 04/20] refs #5439 campos fecha y salesperson --- back/methods/user-config/getUserConfig.js | 4 +++- modules/item/front/request-search-panel/index.html | 14 ++++++++++++++ .../monitor/front/index/search-panel/index.html | 12 ++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js index 4de8049e7..1ea723f52 100644 --- a/back/methods/user-config/getUserConfig.js +++ b/back/methods/user-config/getUserConfig.js @@ -33,7 +33,9 @@ module.exports = function(Self) { let newConfig = { warehouseFk: warehouse.id, companyFk: company.id, - userFk: ctx.req.accessToken.userId + userFk: ctx.req.accessToken.userId, + buyed: ticketResquest.buyed, + salesPersonCode: salesPersonNickname }; userConfig = await models.UserConfig.create(newConfig, myOptions); diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index 8c9d04b64..1572c6213 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -38,6 +38,20 @@ url="Warehouses"> + + + + + +
+ + + + Date: Tue, 21 Mar 2023 08:44:28 +0100 Subject: [PATCH 05/20] refs #5439 filtro comercial --- back/methods/user-config/getUserConfig.js | 2 -- .../front/request-search-panel/index.html | 21 ++++++++++++------- .../front/index/search-panel/index.html | 21 ++++++++++++------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js index 1ea723f52..c8aef963d 100644 --- a/back/methods/user-config/getUserConfig.js +++ b/back/methods/user-config/getUserConfig.js @@ -34,8 +34,6 @@ module.exports = function(Self) { warehouseFk: warehouse.id, companyFk: company.id, userFk: ctx.req.accessToken.userId, - buyed: ticketResquest.buyed, - salesPersonCode: salesPersonNickname }; userConfig = await models.UserConfig.create(newConfig, myOptions); diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index 1572c6213..f26c05a0b 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -39,17 +39,24 @@ - + ng-model="filter.salesPersonFk" + url="Workers/activeWithInheritedRole" + search-function="{firstName: $search}" + value-field="id" + where="{role: 'logistic'}" + label="Comercial"> + {{firstName}} {{name}} + ng-model="filter.saleFk" + url="Sales/created" + search-function="{id: $search}" + value-field="created" + label="Fecha"> + {{created}}
diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html index 5d4f97140..e2dbc2e87 100644 --- a/modules/monitor/front/index/search-panel/index.html +++ b/modules/monitor/front/index/search-panel/index.html @@ -93,16 +93,23 @@ + url="Workers/activeWithInheritedRole" + search-function="{firstName: $search}" + value-field="id" + where="{role: 'logistic'}" + label="Comercial"> + {{firstName}} {{name}} - + vn-one + ng-model="filter.saleFk" + url="Sales/created" + search-function="{id: $search}" + value-field="created" + label="Fecha"> + {{created}} + Date: Tue, 21 Mar 2023 14:53:36 +0100 Subject: [PATCH 06/20] =?UTF-8?q?refs=20#5410=20feat:=20envia=20email=20cu?= =?UTF-8?q?ando=20se=20a=C3=B1ade=20una=20nota?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/client/front/defaulter/index.js | 24 +++++++++++++++++++- modules/client/front/defaulter/locale/es.yml | 6 ++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 48552f731..d8bf12bff 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -123,11 +123,33 @@ export default class Controller extends Section { } this.$http.post(`ClientObservations`, params) .then(() => { - this.vnApp.showMessage(this.$t('Observation saved!')); + this.vnApp.showSuccess(this.$t('Observation saved!')); + this.sendMail(); this.$state.reload(); }); } + sendMail() { + const params = []; + for (let defaulter of this.checked) { + const body = this.$t('Added observation', { + salesPersonName: defaulter.salesPersonName, + text: this.defaulter.observation + }); + + params.push({ + subject: this.$t('Comment added to client', {clientFk: defaulter.clientFk}), + body: body, + receiver: `${defaulter.salesPersonName}@verdnatura.es`, + replyTo: `${window.localStorage.lastUser}@verdnatura.es` + }); + } + + this.$http.post(`Mails`, params) .then(() => { + this.vnApp.showMessage(this.$t('Email sended!')); + }); + } + exprBuilder(param, value) { switch (param) { case 'creditInsurance': diff --git a/modules/client/front/defaulter/locale/es.yml b/modules/client/front/defaulter/locale/es.yml index c3e1d4e19..a301a50e0 100644 --- a/modules/client/front/defaulter/locale/es.yml +++ b/modules/client/front/defaulter/locale/es.yml @@ -6,4 +6,8 @@ Last observation: Última observación L. O. Date: Fecha Ú. O. Last observation date: Fecha última observación Search client: Buscar clientes -Worker who made the last observation: Trabajador que ha realizado la última observación \ No newline at end of file +Worker who made the last observation: Trabajador que ha realizado la última observación +Added observation: '{{salesPersonName}} añadió esta observacion: {{text}}' +Comment added to client: Observación añadida al cliente {{clientFk}} +Email sended!: Email enviado! +Observation saved!: Observación añadida! From 1b1bca28bd429e246ff0af0cfc0488606baa6999 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 10:13:59 +0100 Subject: [PATCH 07/20] refs #5410 add frontTest --- CHANGELOG.md | 4 +- db/changes/231201/00-mailACL.sql | 2 + modules/client/front/defaulter/index.spec.js | 43 +++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 db/changes/231201/00-mailACL.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 708fd7bd9..65ed1f645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- (Clientes -> Morosos) Ahora se puede filtrar por las columnas "Desde" y "Fecha Ú. O." +- (Clientes -> Morosos) Ahora se puede filtrar por las columnas "Desde" y "Fecha Ú. O.". También se envia un email al comercial cuando se añade una nota. ### Changed - ### Fixed -- +- (Clientes -> Morosos) Ahora se mantienen los elementos seleccionados al hacer sroll. ## [2310.01] - 2023-03-23 diff --git a/db/changes/231201/00-mailACL.sql b/db/changes/231201/00-mailACL.sql new file mode 100644 index 000000000..ac687818d --- /dev/null +++ b/db/changes/231201/00-mailACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId) +VALUES('Mail', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index 6b80a7c36..30c40132d 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -80,15 +80,17 @@ describe('client defaulter', () => { controller.defaulter = {observation: 'My new observation'}; const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; + const mailParams = [{subject: 'Comment added to client', body: 'Added observation', receiver: 'undefined@verdnatura.es', replyTo: 'undefined@verdnatura.es'}]; jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('GET', `Defaulters/filter`).respond(200); $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); + $httpBackend.expect('POST', `Mails`, mailParams).respond(200); controller.onResponse(); $httpBackend.flush(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Observation saved!'); + expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Email sended!'); }); }); @@ -135,5 +137,44 @@ describe('client defaulter', () => { expect(end).toContain('23:59:59'); }); }); + + describe('reCheck()', () => { + it(`should recheck buys`, () => { + controller.$.model.data = [ + {checked: false, clientFk: 1}, + {checked: false, clientFk: 2}, + {checked: false, clientFk: 3}, + {checked: false, clientFk: 4}, + ]; + controller.checkedDefaulers = [1, 2]; + + controller.reCheck(); + + expect(controller.$.model.data[0].checked).toEqual(true); + expect(controller.$.model.data[1].checked).toEqual(true); + expect(controller.$.model.data[2].checked).toEqual(false); + expect(controller.$.model.data[3].checked).toEqual(false); + }); + }); + + describe('saveChecked()', () => { + it(`should check buy`, () => { + const buyCheck = 3; + controller.checkedDefaulers = [1, 2]; + + controller.saveChecked(buyCheck); + + expect(controller.checkedDefaulers[2]).toEqual(buyCheck); + }); + + it(`should uncheck buy`, () => { + const buyUncheck = 3; + controller.checkedDefaulers = [1, 2, 3]; + + controller.saveChecked(buyUncheck); + + expect(controller.checkedDefaulers[2]).toEqual(undefined); + }); + }); }); }); From 3fd1e7a0869d3644cd3be83a3492125af24c6b96 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 22 Mar 2023 15:41:36 +0100 Subject: [PATCH 08/20] =?UTF-8?q?refs=20#5439=20se=20elimina=20el=20filtro?= =?UTF-8?q?=20de=20fecha=20a=C3=B1adido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/item/front/request-search-panel/index.html | 9 --------- modules/monitor/front/index/search-panel/index.html | 9 --------- 2 files changed, 18 deletions(-) diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index f26c05a0b..921dec0c0 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -49,15 +49,6 @@ label="Comercial"> {{firstName}} {{name}} - - {{created}} -
diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html index e2dbc2e87..99c9dcd17 100644 --- a/modules/monitor/front/index/search-panel/index.html +++ b/modules/monitor/front/index/search-panel/index.html @@ -101,15 +101,6 @@ label="Comercial"> {{firstName}} {{name}} - - {{created}} - Date: Thu, 23 Mar 2023 08:26:06 +0100 Subject: [PATCH 09/20] refs #5439 role actualizado --- modules/item/front/request-search-panel/index.html | 2 +- modules/monitor/front/index/search-panel/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index 921dec0c0..ae7f9bcc5 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -45,7 +45,7 @@ url="Workers/activeWithInheritedRole" search-function="{firstName: $search}" value-field="id" - where="{role: 'logistic'}" + where="{role: 'salesPerson'}" label="Comercial"> {{firstName}} {{name}} diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html index 99c9dcd17..f478661c5 100644 --- a/modules/monitor/front/index/search-panel/index.html +++ b/modules/monitor/front/index/search-panel/index.html @@ -97,7 +97,7 @@ url="Workers/activeWithInheritedRole" search-function="{firstName: $search}" value-field="id" - where="{role: 'logistic'}" + where="{role: 'salesPerson'}" label="Comercial"> {{firstName}} {{name}} From a17016a1d8c1185e0498b05aa817ab0c8796b00a Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 23 Mar 2023 08:29:25 +0100 Subject: [PATCH 10/20] refs #5439 arreglo getUserConfig --- back/methods/user-config/getUserConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js index c8aef963d..4de8049e7 100644 --- a/back/methods/user-config/getUserConfig.js +++ b/back/methods/user-config/getUserConfig.js @@ -33,7 +33,7 @@ module.exports = function(Self) { let newConfig = { warehouseFk: warehouse.id, companyFk: company.id, - userFk: ctx.req.accessToken.userId, + userFk: ctx.req.accessToken.userId }; userConfig = await models.UserConfig.create(newConfig, myOptions); From fa78649607e71d224b9e604ffbb4f58b34cf4b18 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 24 Mar 2023 08:54:03 +0100 Subject: [PATCH 11/20] refs #5439 url filter --- modules/item/front/request-search-panel/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index ae7f9bcc5..6316cb32e 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -42,10 +42,9 @@ {{firstName}} {{name}} From f689d351007e4ef980ae8f661fd689d50a7f79ee Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 24 Mar 2023 10:05:17 +0100 Subject: [PATCH 12/20] refs #5410 fix test --- modules/client/front/defaulter/index.js | 4 +--- modules/client/front/defaulter/index.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index d8bf12bff..e084af650 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -145,9 +145,7 @@ export default class Controller extends Section { }); } - this.$http.post(`Mails`, params) .then(() => { - this.vnApp.showMessage(this.$t('Email sended!')); - }); + this.$http.post(`Mails`, params); } exprBuilder(param, value) { diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index 30c40132d..b9672802e 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -82,7 +82,7 @@ describe('client defaulter', () => { const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; const mailParams = [{subject: 'Comment added to client', body: 'Added observation', receiver: 'undefined@verdnatura.es', replyTo: 'undefined@verdnatura.es'}]; - jest.spyOn(controller.vnApp, 'showMessage'); + jest.spyOn(controller.vnApp, 'showSuccess'); $httpBackend.expect('GET', `Defaulters/filter`).respond(200); $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); $httpBackend.expect('POST', `Mails`, mailParams).respond(200); @@ -90,7 +90,7 @@ describe('client defaulter', () => { controller.onResponse(); $httpBackend.flush(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Email sended!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Observation saved!'); }); }); From 9380b88460e106320585d89b97a06d76afc87601 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 4 Apr 2023 12:40:03 +0200 Subject: [PATCH 13/20] refs #5437 back and test deprecated --- .../back/methods/client/checkDuplicated.js | 63 ------------------- .../client/specs/checkDuplicated.spec.js | 24 ------- modules/client/back/models/client-methods.js | 1 - modules/client/front/basic-data/index.js | 4 +- modules/client/front/create/index.js | 1 - 5 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 modules/client/back/methods/client/checkDuplicated.js delete mode 100644 modules/client/back/methods/client/specs/checkDuplicated.spec.js diff --git a/modules/client/back/methods/client/checkDuplicated.js b/modules/client/back/methods/client/checkDuplicated.js deleted file mode 100644 index 522cd088f..000000000 --- a/modules/client/back/methods/client/checkDuplicated.js +++ /dev/null @@ -1,63 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('checkDuplicatedData', { - description: 'Checks if a client has same email, mobile or phone than other client and send an email', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The client id' - }], - returns: { - type: 'object', - root: true - }, - http: { - verb: 'GET', - path: '/:id/checkDuplicatedData' - } - }); - - Self.checkDuplicatedData = async function(id, options) { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const client = await Self.app.models.Client.findById(id, myOptions); - - const findParams = []; - if (client.email) { - const emails = client.email.split(','); - for (let email of emails) - findParams.push({email: email}); - } - - if (client.phone) - findParams.push({phone: client.phone}); - - if (client.mobile) - findParams.push({mobile: client.mobile}); - - const filterObj = { - where: { - and: [ - {or: findParams}, - {id: {neq: client.id}} - ] - } - }; - - const clientSameData = await Self.findOne(filterObj, myOptions); - - if (clientSameData) { - await Self.app.models.Mail.create({ - receiver: 'direccioncomercial@verdnatura.es', - subject: `Cliente con email/teléfono/móvil duplicados`, - body: 'El cliente ' + client.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id + - '\n- Email: ' + client.email + - '\n- Teléfono: ' + client.phone + - '\n- Móvil: ' + client.mobile - }, myOptions); - } - }; -}; diff --git a/modules/client/back/methods/client/specs/checkDuplicated.spec.js b/modules/client/back/methods/client/specs/checkDuplicated.spec.js deleted file mode 100644 index 1b682ca35..000000000 --- a/modules/client/back/methods/client/specs/checkDuplicated.spec.js +++ /dev/null @@ -1,24 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('client checkDuplicated()', () => { - it('should send an mail if mobile/phone/email is duplicated', async() => { - const tx = await models.Client.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const id = 1110; - const mailModel = models.Mail; - spyOn(mailModel, 'create'); - - await models.Client.checkDuplicatedData(id, options); - - expect(mailModel.create).toHaveBeenCalled(); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/client/back/models/client-methods.js b/modules/client/back/models/client-methods.js index fc77fc090..3538dbeb8 100644 --- a/modules/client/back/models/client-methods.js +++ b/modules/client/back/models/client-methods.js @@ -2,7 +2,6 @@ module.exports = Self => { require('../methods/client/addressesPropagateRe')(Self); require('../methods/client/canBeInvoiced')(Self); require('../methods/client/canCreateTicket')(Self); - require('../methods/client/checkDuplicated')(Self); require('../methods/client/confirmTransaction')(Self); require('../methods/client/consumption')(Self); require('../methods/client/createAddress')(Self); diff --git a/modules/client/front/basic-data/index.js b/modules/client/front/basic-data/index.js index b08d642d1..ed34eefc4 100644 --- a/modules/client/front/basic-data/index.js +++ b/modules/client/front/basic-data/index.js @@ -9,9 +9,7 @@ export default class Controller extends Section { } onSubmit() { - return this.$.watcher.submit().then(() => { - this.$http.get(`Clients/${this.$params.id}/checkDuplicatedData`); - }); + return this.$.watcher.submit(); } } diff --git a/modules/client/front/create/index.js b/modules/client/front/create/index.js index 9ca58ed10..631029802 100644 --- a/modules/client/front/create/index.js +++ b/modules/client/front/create/index.js @@ -12,7 +12,6 @@ export default class Controller extends Section { onSubmit() { return this.$.watcher.submit().then(json => { this.$state.go('client.card.basicData', {id: json.data.id}); - this.$http.get(`Clients/${this.client.id}/checkDuplicatedData`); }); } From 3630c7d39832148dcf56963554422adbd56da084 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 4 Apr 2023 14:09:55 +0200 Subject: [PATCH 14/20] refs #5410 creada ruta de back para enviar emails --- loopback/locale/es.json | 8 +-- .../methods/defaulter/observationEmail.js | 52 +++++++++++++++++++ modules/client/back/models/defaulter.js | 1 + modules/client/front/defaulter/index.js | 21 ++------ modules/client/front/defaulter/index.spec.js | 3 +- modules/client/front/defaulter/locale/es.yml | 2 - 6 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 modules/client/back/methods/defaulter/observationEmail.js diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d6588c0b2..42276efe7 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -268,9 +268,11 @@ "Exists an invoice with a previous date": "Existe una factura con fecha anterior", "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", "Warehouse inventory not set": "El almacén inventario no está establecido", - "This locker has already been assigned": "Esta taquilla ya ha sido asignada", + "This locker has already been assigned": "Esta taquilla ya ha sido asignada", "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº {{id}}", "Not exist this branch": "La rama no existe", - "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", - "Insert a date range": "Inserte un rango de fechas" + "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", + "Insert a date range": "Inserte un rango de fechas", + "Added observation": "{{user}} añadió esta observacion: {{text}}", + "Comment added to client": "Observación añadida al cliente {{clientFk}}" } diff --git a/modules/client/back/methods/defaulter/observationEmail.js b/modules/client/back/methods/defaulter/observationEmail.js new file mode 100644 index 000000000..c3c96010e --- /dev/null +++ b/modules/client/back/methods/defaulter/observationEmail.js @@ -0,0 +1,52 @@ +module.exports = Self => { + Self.remoteMethodCtx('observationEmail', { + description: 'Send an email with the observation', + accessType: 'WRITE', + accepts: [ + { + arg: 'defaulters', + type: ['object'], + required: true, + description: 'The defaulters to send the email' + }, + { + arg: 'observation', + type: 'string', + required: true, + description: 'The observation' + }], + returns: { + arg: 'observationEmail' + }, + http: { + path: `/observationEmail`, + verb: 'POST' + } + }); + + Self.observationEmail = async(ctx, defaulters, observation, options) => { + const models = Self.app.models; + const $t = ctx.req.__; // $translate + const myOptions = {}; + const userId = ctx.req.accessToken.userId; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + for (const defaulter of defaulters) { + const user = await models.Account.findById(userId, {fields: ['name']}, myOptions); + + const body = $t('Added observation', { + user: user.name, + text: observation + }); + + await models.Mail.create({ + subject: $t('Comment added to client', {clientFk: defaulter.clientFk}), + body: body, + receiver: `${defaulter.salesPersonName}@verdnatura.es`, + replyTo: `${user.name}@verdnatura.es` + }, myOptions); + } + }; +}; diff --git a/modules/client/back/models/defaulter.js b/modules/client/back/models/defaulter.js index 13bb1a614..868d6cd0a 100644 --- a/modules/client/back/models/defaulter.js +++ b/modules/client/back/models/defaulter.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/defaulter/filter')(Self); + require('../methods/defaulter/observationEmail')(Self); }; diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index e084af650..6289f9202 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -130,22 +130,11 @@ export default class Controller extends Section { } sendMail() { - const params = []; - for (let defaulter of this.checked) { - const body = this.$t('Added observation', { - salesPersonName: defaulter.salesPersonName, - text: this.defaulter.observation - }); - - params.push({ - subject: this.$t('Comment added to client', {clientFk: defaulter.clientFk}), - body: body, - receiver: `${defaulter.salesPersonName}@verdnatura.es`, - replyTo: `${window.localStorage.lastUser}@verdnatura.es` - }); - } - - this.$http.post(`Mails`, params); + const params = { + defaulters: this.checked, + observation: this.defaulter.observation + }; + this.$http.post(`Defaulters/observationEmail`, params); } exprBuilder(param, value) { diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index b9672802e..b4a9df184 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -80,12 +80,11 @@ describe('client defaulter', () => { controller.defaulter = {observation: 'My new observation'}; const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; - const mailParams = [{subject: 'Comment added to client', body: 'Added observation', receiver: 'undefined@verdnatura.es', replyTo: 'undefined@verdnatura.es'}]; jest.spyOn(controller.vnApp, 'showSuccess'); $httpBackend.expect('GET', `Defaulters/filter`).respond(200); $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); - $httpBackend.expect('POST', `Mails`, mailParams).respond(200); + $httpBackend.expect('POST', `Defaulters/observationEmail`).respond(200); controller.onResponse(); $httpBackend.flush(); diff --git a/modules/client/front/defaulter/locale/es.yml b/modules/client/front/defaulter/locale/es.yml index a301a50e0..fe06a15a1 100644 --- a/modules/client/front/defaulter/locale/es.yml +++ b/modules/client/front/defaulter/locale/es.yml @@ -7,7 +7,5 @@ L. O. Date: Fecha Ú. O. Last observation date: Fecha última observación Search client: Buscar clientes Worker who made the last observation: Trabajador que ha realizado la última observación -Added observation: '{{salesPersonName}} añadió esta observacion: {{text}}' -Comment added to client: Observación añadida al cliente {{clientFk}} Email sended!: Email enviado! Observation saved!: Observación añadida! From 35d19e586a4ab686329734e1c2f4ef5371ac538b Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 4 Apr 2023 14:27:16 +0200 Subject: [PATCH 15/20] add translatiojn --- modules/supplier/front/agency-term/locale/es.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/supplier/front/agency-term/locale/es.yml b/modules/supplier/front/agency-term/locale/es.yml index f4ba7d87d..cdbd7c2ca 100644 --- a/modules/supplier/front/agency-term/locale/es.yml +++ b/modules/supplier/front/agency-term/locale/es.yml @@ -5,4 +5,5 @@ M3 Price: Precio M3 Route Price: Precio ruta Minimum Km: Km minimos Remove row: Eliminar fila -Add row: Añadir fila \ No newline at end of file +Add row: Añadir fila +New autonomous: Nuevo autónomo From 81cf35f2d3d50a8becba767926e24a842620ca76 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 4 Apr 2023 14:55:37 +0200 Subject: [PATCH 16/20] refs #5259 drop procedure invoiceOut_afterInsert --- db/changes/231401/00-invoiceOutAfterInsert.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/changes/231401/00-invoiceOutAfterInsert.sql diff --git a/db/changes/231401/00-invoiceOutAfterInsert.sql b/db/changes/231401/00-invoiceOutAfterInsert.sql new file mode 100644 index 000000000..24836e1fb --- /dev/null +++ b/db/changes/231401/00-invoiceOutAfterInsert.sql @@ -0,0 +1 @@ +DROP PROCEDURE IF EXISTS `vn`.`invoiceOut_afterInsert`; From 589e996b699565d4ebc2dec6113cb0874e40e326 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 4 Apr 2023 15:17:19 +0200 Subject: [PATCH 17/20] refs #5259 minor fix --- db/changes/231401/00-invoiceOutAfterInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/231401/00-invoiceOutAfterInsert.sql b/db/changes/231401/00-invoiceOutAfterInsert.sql index 24836e1fb..cf921fd17 100644 --- a/db/changes/231401/00-invoiceOutAfterInsert.sql +++ b/db/changes/231401/00-invoiceOutAfterInsert.sql @@ -1 +1 @@ -DROP PROCEDURE IF EXISTS `vn`.`invoiceOut_afterInsert`; +DROP TRIGGER IF EXISTS `vn`.`invoiceOut_afterInsert`; From 8f4de7e7e95a9082f82a7e3ad689f2839c47bcb1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 4 Apr 2023 15:27:10 +0200 Subject: [PATCH 18/20] refs #5259 undo delete, update trigger --- db/changes/231401/00-invoiceOutAfterInsert.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/db/changes/231401/00-invoiceOutAfterInsert.sql b/db/changes/231401/00-invoiceOutAfterInsert.sql index cf921fd17..adeaf9834 100644 --- a/db/changes/231401/00-invoiceOutAfterInsert.sql +++ b/db/changes/231401/00-invoiceOutAfterInsert.sql @@ -1 +1,13 @@ DROP TRIGGER IF EXISTS `vn`.`invoiceOut_afterInsert`; +USE vn; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_afterInsert` + AFTER INSERT ON `invoiceOut` + FOR EACH ROW +BEGIN + CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); +END$$ +DELIMITER ; + From 77b91b77b234b573724e1c2498647f198b8aff5a Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 5 Apr 2023 08:19:50 +0200 Subject: [PATCH 19/20] refs #5439 requesterFk solve --- modules/item/front/request-search-panel/index.html | 10 ++++++---- modules/ticket/back/methods/ticket-request/filter.js | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index 6316cb32e..a431d4fd6 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -39,16 +39,18 @@ - - {{firstName}} {{name}} + {{firstName}} {{lastName}} +
{ type: 'number', description: `Search requests attended by a given worker id` }, + { + arg: 'requesterFk', + type: 'number' + }, { arg: 'mine', type: 'boolean', @@ -89,6 +93,8 @@ module.exports = Self => { return {'t.id': value}; case 'attenderFk': return {'tr.attenderFk': value}; + case 'requesterFk': + return {'tr.requesterFk': value}; case 'state': switch (value) { case 'pending': @@ -125,6 +131,7 @@ module.exports = Self => { tr.description, tr.response, tr.saleFk, + tr.requesterFk, tr.isOk, s.quantity AS saleQuantity, s.itemFk, From 7d3c6a98f3578443e217651c04b14788192b1731 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 5 Apr 2023 08:48:15 +0200 Subject: [PATCH 20/20] refs #5439 search panel solve --- modules/monitor/front/index/search-panel/index.html | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html index f478661c5..5458202d2 100644 --- a/modules/monitor/front/index/search-panel/index.html +++ b/modules/monitor/front/index/search-panel/index.html @@ -91,16 +91,6 @@ ng-model="filter.provinceFk" url="Provinces"> - - {{firstName}} {{name}} -