parent
10a25ff590
commit
807596f735
|
@ -295,5 +295,6 @@
|
|||
"Ticket does not exist": "Este ticket no existe",
|
||||
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
||||
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||
"Error while generating PDF": "Error while generating PDF"
|
||||
"Error while generating PDF": "Error al generar PDF",
|
||||
"Error when sending mail to client": "Error al enviar el correo al cliente"
|
||||
}
|
|
@ -131,9 +131,9 @@ module.exports = Self => {
|
|||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await Self.makePdf(invoiceId);
|
||||
await Self.makePdf(invoiceId, myOptions);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new UserError('Error while generating PDF', 'pdfError');
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('InvoiceOut invoiceClient()', () => {
|
|||
const ctx = {req: activeCtx};
|
||||
|
||||
it('should make a global invoicing', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
spyOn(models.InvoiceOut, 'invoiceEmail');
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
|
|
|
@ -23,9 +23,19 @@ module.exports = Self => {
|
|||
require('../methods/invoiceOut/negativeBasesCsv')(Self);
|
||||
|
||||
Self.makePdf = async function(id, options) {
|
||||
const fields = ['id', 'hasPdf', 'ref', 'issued'];
|
||||
const invoiceOut = await Self.findById(id, {fields}, 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 invoiceReport = new print.Report('invoice', {
|
||||
reference: invoiceOut.ref
|
||||
});
|
||||
|
@ -42,7 +52,7 @@ module.exports = Self => {
|
|||
|
||||
await invoiceOut.updateAttributes({
|
||||
hasPdf: true
|
||||
}, options);
|
||||
}, myOptions);
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
await print.storage.write(buffer, {
|
||||
|
|
Loading…
Reference in New Issue