Merge pull request '2483 - Added replyTo param when sending an email to a client' (#597) from 2483-email_replyTo into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #597
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-04-13 08:57:59 +00:00
commit 8c9ad39762
7 changed files with 54 additions and 17 deletions

View File

@ -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*",

View File

@ -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*",

View File

@ -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;

View File

@ -32,6 +32,13 @@
info="Its only used when sample is sent">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
label="Reply to"
ng-model="$ctrl.clientSample.replyTo"
info="To who should the recipient reply?">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-id="sampleType"

View File

@ -18,8 +18,10 @@ class Controller extends Section {
set client(value) {
this._client = value;
if (value)
if (value) {
this.clientSample.recipient = value.email;
this.getWorkerEmail();
}
}
get companyId() {
@ -62,7 +64,8 @@ class Controller extends Section {
const sampleType = this.$.sampleType.selection;
const params = {
recipientId: this.$params.id,
recipient: this.clientSample.recipient
recipient: this.clientSample.recipient,
replyTo: this.clientSample.replyTo
};
if (!params.recipient)
@ -83,7 +86,17 @@ class Controller extends Section {
this.$http.get(query, {params}).then(cb);
}
getWorkerEmail() {
const userId = window.localStorage.currentUserWorkerId;
const params = {filter: {where: {userFk: userId}}};
this.$http.get('EmailUsers', params).then(res => {
const [worker] = res && res.data;
this.clientSample.replyTo = worker.email;
});
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnClientSampleCreate', {

View File

@ -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);
});
});
});
});

View File

@ -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
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?