diff --git a/loopback/locale/en.json b/loopback/locale/en.json index f9fe40488..1e0607813 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -59,7 +59,7 @@ "Swift / BIC can't be empty": "Swift / BIC can't be empty", "Bought units from buy request": "Bought {{quantity}} units of {{concept}} [{{itemId}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", - "MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", + "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*", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5fdddc231..fdc1bd977 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -123,7 +123,7 @@ "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", "Bought units from buy request": "Se ha comprado {{quantity}} unidades de {{concept}} [{{itemId}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", - "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "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*", diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index e1de363b2..035074210 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -253,25 +253,28 @@ module.exports = Self => { const salesPersonId = instance.salesPersonFk; if (salesPersonId) { + // Send email to client + if (instance.email) { + const worker = await models.EmailUser.findById(salesPersonId); + const params = { + authorization: authorization, + recipientId: instance.id, + recipient: instance.email, + replyTo: worker.email + }; + await got.get(`${origin}/api/email/payment-update`, { + query: params + }); + } + const fullUrl = `${origin}/#!/client/${instance.id}/billing-data`; - const message = $t('MESSAGE_CHANGED_PAYMETHOD', { + const message = $t('Changed client paymethod', { clientId: instance.id, clientName: instance.name, url: fullUrl }); await models.Chat.sendCheckingPresence(httpCtx, salesPersonId, message); } - - // Send email to client - if (!instance.email) return; - const params = { - authorization: authorization, - recipientId: instance.id, - recipient: instance.email - }; - await got.get(`${origin}/api/email/payment-update`, { - query: params - }); } const workerIdBefore = oldInstance.salesPersonFk; diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html index f941e885a..e6733a656 100644 --- a/modules/client/front/sample/create/index.html +++ b/modules/client/front/sample/create/index.html @@ -32,6 +32,13 @@ info="Its only used when sample is sent"> + + + + { + const [worker] = res && res.data; + this.clientSample.replyTo = worker.email; + }); + } } + Controller.$inject = ['$element', '$scope']; ngModule.vnComponent('vnClientSampleCreate', { diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index 40fa237b6..37d322b5f 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -179,5 +179,17 @@ describe('Client', () => { expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); }); }); + + describe('getWorkerEmail()', () => { + it(`should perform a query and then set the replyTo property to the clientSample object`, () => { + const expectedEmail = 'batman@arkhamcity.com'; + const serializedParams = $httpParamSerializer({filter: {where: {}}}); + $httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]); + controller.getWorkerEmail(); + $httpBackend.flush(); + + expect(controller.clientSample.replyTo).toEqual(expectedEmail); + }); + }); }); }); diff --git a/modules/client/front/sample/create/locale/es.yml b/modules/client/front/sample/create/locale/es.yml index 6828e3e48..a534e05d4 100644 --- a/modules/client/front/sample/create/locale/es.yml +++ b/modules/client/front/sample/create/locale/es.yml @@ -2,4 +2,6 @@ Choose a sample: Selecciona una plantilla Choose a company: Selecciona una empresa Email cannot be blank: Debes introducir un email Recipient: Destinatario -Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla \ No newline at end of file +Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla +Reply to: Responder a +To who should the recipient reply?: ¿A quíen debería responder el destinatario? \ No newline at end of file