refs #5772 refactor: movido codigo para enviar rocket al back
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
9d1a181b73
commit
591fc14ffa
|
@ -175,5 +175,6 @@
|
|||
"Pass expired": "The password has expired, change it from Salix",
|
||||
"Can't transfer claimed sales": "Can't transfer claimed sales",
|
||||
"Invalid quantity": "Invalid quantity",
|
||||
"Failed to upload delivery note": "Error to upload delivery note {{id}}"
|
||||
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
|
||||
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address"
|
||||
}
|
||||
|
|
|
@ -296,5 +296,7 @@
|
|||
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
||||
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||
"Error while generating PDF": "Error al generar PDF",
|
||||
"Error when sending mail to client": "Error al enviar el correo al cliente"
|
||||
}
|
||||
"Error when sending mail to client": "Error al enviar el correo al cliente",
|
||||
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico"
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ module.exports = Self => {
|
|||
const args = ctx.args;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const $t = ctx.req.__; // $translate
|
||||
const origin = ctx.req.headers.origin;
|
||||
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
@ -119,7 +122,7 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['email', 'isToBeMailed']
|
||||
fields: ['email', 'isToBeMailed', 'salesPersonFk']
|
||||
}
|
||||
}
|
||||
}, myOptions);
|
||||
|
@ -131,21 +134,34 @@ module.exports = Self => {
|
|||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await Self.makePdf(invoiceId, myOptions);
|
||||
await Self.makePdf(invoiceId);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new UserError('Error while generating PDF', 'pdfError');
|
||||
}
|
||||
|
||||
if (invoiceOut.client().isToBeMailed) {
|
||||
ctx.args = {
|
||||
reference: invoiceOut.ref,
|
||||
recipientId: args.clientId,
|
||||
recipient: invoiceOut.client().email
|
||||
};
|
||||
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
||||
try {
|
||||
ctx.args = {
|
||||
reference: invoiceOut.ref,
|
||||
recipientId: args.clientId,
|
||||
recipient: invoiceOut.client().email
|
||||
};
|
||||
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
||||
} catch (err) {
|
||||
const message = $t('Mail not sent', {
|
||||
clientId: args.clientId,
|
||||
clientUrl: `${origin}/#!/claim/${args.id}/summary`
|
||||
});
|
||||
const salesPersonId = invoiceOut.client().salesPersonFk;
|
||||
|
||||
if (salesPersonId)
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||
|
||||
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||
}
|
||||
} else {
|
||||
const query = `
|
||||
CALL vn.report_print(
|
||||
|
|
|
@ -77,7 +77,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
return email.send(mailOptions);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,19 +23,8 @@ module.exports = Self => {
|
|||
require('../methods/invoiceOut/negativeBasesCsv')(Self);
|
||||
|
||||
Self.makePdf = async function(id, options) {
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
const fields = ['id', 'hasPdf', 'ref', 'issued'];
|
||||
const invoiceOut = await Self.findById(id, {fields}, myOptions);
|
||||
const invoiceOut = await Self.findById(id, {fields}, options);
|
||||
const invoiceReport = new print.Report('invoice', {
|
||||
reference: invoiceOut.ref
|
||||
});
|
||||
|
@ -52,7 +41,7 @@ module.exports = Self => {
|
|||
|
||||
await invoiceOut.updateAttributes({
|
||||
hasPdf: true
|
||||
}, myOptions);
|
||||
}, options);
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
await print.storage.write(buffer, {
|
||||
|
@ -61,5 +50,5 @@ module.exports = Self => {
|
|||
fileName: fileName
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -118,25 +118,7 @@ class Controller extends Section {
|
|||
};
|
||||
switch (error?.code) {
|
||||
case 'pdfError':
|
||||
isWarning = true;
|
||||
break;
|
||||
case 'mailNotSent':
|
||||
this.$http.get(`Clients/findOne`, {filter})
|
||||
.then(res => {
|
||||
const salesPersonFk = res.data.salesPersonFk;
|
||||
if (!salesPersonFk) return;
|
||||
|
||||
const message = this.$t('Mail not sent', {
|
||||
clientId: address.clientId,
|
||||
clientUrl: `${window.location.origin}/#!/client/${this.clientId}/summary`
|
||||
});
|
||||
|
||||
const params = {
|
||||
workerId: salesPersonFk,
|
||||
message: message,
|
||||
};
|
||||
this.$http.post('Chats/sendCheckingPresence', params);
|
||||
});
|
||||
isWarning = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Mail not sent: There has been an error sending the invoice to the client {{clientId}} {{clientUrl}}, please check the email address
|
|
@ -19,4 +19,3 @@ One client: Un solo cliente
|
|||
Choose a valid client: Selecciona un cliente válido
|
||||
Stop: Parar
|
||||
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido
|
||||
Mail not sent: Se ha producido un fallo al enviar la factura al cliente {{clientId}} {{clientUrl}}, por favor revisa la dirección de correo electrónico
|
||||
|
|
Loading…
Reference in New Issue