2483 - Added replyTo param when sending an email to client
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2021-04-07 13:09:53 +02:00
parent f5b95a0c4d
commit 465955d0c5
5 changed files with 38 additions and 15 deletions

View File

@ -59,7 +59,7 @@
"Swift / BIC can't be empty": "Swift / BIC can't be empty", "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}}})", "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_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}}})", "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 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 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", "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}}})", "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_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}}})", "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 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 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; const salesPersonId = instance.salesPersonFk;
if (salesPersonId) { 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 fullUrl = `${origin}/#!/client/${instance.id}/billing-data`;
const message = $t('MESSAGE_CHANGED_PAYMETHOD', { const message = $t('Changed client paymethod', {
clientId: instance.id, clientId: instance.id,
clientName: instance.name, clientName: instance.name,
url: fullUrl url: fullUrl
}); });
await models.Chat.sendCheckingPresence(httpCtx, salesPersonId, message); 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; const workerIdBefore = oldInstance.salesPersonFk;

View File

@ -32,6 +32,13 @@
info="Its only used when sample is sent"> info="Its only used when sample is sent">
</vn-textfield> </vn-textfield>
</vn-horizontal> </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-horizontal>
<vn-autocomplete <vn-autocomplete
vn-id="sampleType" vn-id="sampleType"

View File

@ -9,6 +9,8 @@ class Controller extends Section {
clientFk: this.$params.id, clientFk: this.$params.id,
companyId: this.vnConfig.companyFk companyId: this.vnConfig.companyFk
}; };
this.getWorkerEmail();
} }
get client() { get client() {
@ -62,7 +64,8 @@ class Controller extends Section {
const sampleType = this.$.sampleType.selection; const sampleType = this.$.sampleType.selection;
const params = { const params = {
recipientId: this.$params.id, recipientId: this.$params.id,
recipient: this.clientSample.recipient recipient: this.clientSample.recipient,
replyTo: this.clientSample.replyTo
}; };
if (!params.recipient) if (!params.recipient)
@ -83,7 +86,17 @@ class Controller extends Section {
this.$http.get(query, {params}).then(cb); 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']; Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnClientSampleCreate', { ngModule.vnComponent('vnClientSampleCreate', {