refs #5772 feat: si falla al enviar el pdf, envia un rocket al comercial
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-06-22 11:10:56 +02:00
parent 807596f735
commit 9d1a181b73
3 changed files with 49 additions and 24 deletions

View File

@ -7,29 +7,29 @@ class Controller extends Section {
$onInit() { $onInit() {
const date = Date.vnNew(); const date = Date.vnNew();
Object.assign(this, { Object.assign(this, {
maxShipped: new Date(date.getFullYear(), date.getMonth(), 0), maxShipped: new Date(date.getFullYear(), date.getMonth(), 0),
clientsToInvoice: 'all', clientsToInvoice: 'all',
}); });
this.$http.get('UserConfigs/getUserConfig') this.$http.get('UserConfigs/getUserConfig')
.then(res => { .then(res => {
this.companyFk = res.data.companyFk; this.companyFk = res.data.companyFk;
this.getInvoiceDate(this.companyFk); this.getInvoiceDate(this.companyFk);
}); });
} }
getInvoiceDate(companyFk) { getInvoiceDate(companyFk) {
const params = { companyFk: companyFk }; const params = {companyFk: companyFk};
this.fetchInvoiceDate(params); this.fetchInvoiceDate(params);
} }
fetchInvoiceDate(params) { fetchInvoiceDate(params) {
this.$http.get('InvoiceOuts/getInvoiceDate', { params }) this.$http.get('InvoiceOuts/getInvoiceDate', {params})
.then(res => { .then(res => {
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
this.invoiceDate = this.minInvoicingDate; this.invoiceDate = this.minInvoicingDate;
}); });
} }
stopInvoicing() { stopInvoicing() {
this.status = 'stopping'; this.status = 'stopping';
@ -111,11 +111,34 @@ class Controller extends Section {
if (res.status >= 400 && res.status < 500) { if (res.status >= 400 && res.status < 500) {
const error = res.data?.error; const error = res.data?.error;
let isWarning; let isWarning;
switch(error?.code) { const filter = {
case 'pdfError': where: {
case 'mailNotSent': id: address.clientId
isWarning = true; }
break; };
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;
} }
const message = error?.message || res.message; const message = error?.message || res.message;
@ -126,7 +149,7 @@ class Controller extends Section {
this.status = 'done'; this.status = 'done';
throw new UserError(`Critical invoicing error, proccess stopped`); throw new UserError(`Critical invoicing error, proccess stopped`);
} }
}) });
} }
invoiceNext() { invoiceNext() {

View File

@ -0,0 +1 @@
Mail not sent: There has been an error sending the invoice to the client {{clientId}} {{clientUrl}}, please check the email address

View File

@ -19,3 +19,4 @@ One client: Un solo cliente
Choose a valid client: Selecciona un cliente válido Choose a valid client: Selecciona un cliente válido
Stop: Parar Stop: Parar
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido 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