send closure error by email
This commit is contained in:
parent
ed5458a264
commit
f9deb9f52d
|
@ -62,13 +62,13 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`,
|
||||||
(19,'Francia', 1, 'FR', 1, 27),
|
(19,'Francia', 1, 'FR', 1, 27),
|
||||||
(30,'Canarias', 1, 'IC', 1, 24);
|
(30,'Canarias', 1, 'IC', 1, 24);
|
||||||
|
|
||||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`)
|
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Warehouse One', 1, 1, 1, 1, 1, 1),
|
(1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1),
|
||||||
(2, 'Warehouse Two', 1, 1, 1, 1, 0, 0),
|
(2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1),
|
||||||
(3, 'Warehouse Three', 1, 1, 1, 1, 0, 0),
|
(3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0),
|
||||||
(4, 'Warehouse Four', 1, 1, 1, 1, 0, 0),
|
(4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0),
|
||||||
(5, 'Warehouse Five', 1, 1, 1, 1, 0, 0);
|
(5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0);
|
||||||
|
|
||||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`)
|
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -16,8 +16,7 @@ module.exports = app => {
|
||||||
JOIN client c ON c.id = t.clientFk
|
JOIN client c ON c.id = t.clientFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk AND hasComission
|
JOIN warehouse w ON w.id = t.warehouseFk AND hasComission
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
WHERE
|
WHERE ts.code = 'PACKED'
|
||||||
ts.alertLevel = 2
|
|
||||||
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
|
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
GROUP BY e.ticketFk`);
|
GROUP BY e.ticketFk`);
|
||||||
|
@ -37,22 +36,30 @@ module.exports = app => {
|
||||||
await email.send();
|
await email.send();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Save tickets on a list of failed ids
|
// Save tickets on a list of failed ids
|
||||||
failedtickets.push(ticket.id);
|
failedtickets.push({
|
||||||
|
id: ticket.id,
|
||||||
|
stacktrace: error
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send email with failed tickets
|
// Send email with failed tickets
|
||||||
if (failedtickets.length > 0) {
|
if (failedtickets.length > 0) {
|
||||||
const ticketList = failedtickets.join(', ');
|
let body = 'This following tickets has failed:<br/><br/>';
|
||||||
|
|
||||||
|
for (ticket of failedtickets) {
|
||||||
|
body += `Ticket: <strong>${ticket.id}</strong>
|
||||||
|
<br/> <strong>${ticket.stacktrace}</strong><br/><br/>`;
|
||||||
|
}
|
||||||
|
|
||||||
smtp.send({
|
smtp.send({
|
||||||
to: config.app.reportEmail,
|
to: config.app.reportEmail,
|
||||||
subject: 'Nightly ticket closure has failed',
|
subject: '[API] Nightly ticket closure has failed',
|
||||||
text: `This following tickets has failed: ${ticketList}`
|
html: body
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
statusCode: 200,
|
|
||||||
message: 'Closure executed successfully'
|
message: 'Closure executed successfully'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
title: Bon de livraison
|
||||||
|
ticketId: Bon de livraison
|
||||||
|
clientId: Client
|
||||||
|
deliveryAddress: Addresse de livraison
|
||||||
|
fiscalData: Datos fiscales
|
||||||
|
saleLines: Líneas de pedido
|
||||||
|
date: Date
|
||||||
|
reference: Ref.
|
||||||
|
quantity: Cant.
|
||||||
|
concept: Concepto
|
||||||
|
price: PVP/u
|
||||||
|
discount: Dto.
|
||||||
|
vat: IVA
|
||||||
|
amount: Importe
|
||||||
|
type: Tipo
|
||||||
|
taxBase: Base imp.
|
||||||
|
tax: Tasa
|
||||||
|
fee: Cuota
|
||||||
|
total: Total
|
||||||
|
subtotal: Subtotal
|
||||||
|
taxBreakdown: Répartition de la taxe
|
||||||
|
packagings: Seaux et emballages
|
||||||
|
services: Servicios
|
||||||
|
vatType: Tipo de IVA
|
||||||
|
digitalSignature: Firma digital
|
||||||
|
ticket: Albarán {0}
|
Loading…
Reference in New Issue