feat: imprime las facturas
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
020068006c
commit
caff537f2e
|
@ -2351,11 +2351,11 @@ INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`)
|
|||
VALUES
|
||||
('aaa', 'android', '9');
|
||||
|
||||
INSERT INTO `vn`.`queuePriority`(`id`, `priority`)
|
||||
INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`)
|
||||
VALUES
|
||||
(1, 'Alta'),
|
||||
(2, 'Normal'),
|
||||
(3, 'Baja');
|
||||
(1, 'Alta', 'high'),
|
||||
(2, 'Normal', 'normal'),
|
||||
(3, 'Baja', 'low');
|
||||
|
||||
INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
|
||||
VALUES
|
||||
|
|
|
@ -135,6 +135,18 @@ module.exports = Self => {
|
|||
};
|
||||
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
||||
}
|
||||
|
||||
if (invoiceId && !invoiceOut.client().isToBeMailed) {
|
||||
const query = `CALL vn.report_print(
|
||||
'invoice',
|
||||
?,
|
||||
account.myUser_getId(),
|
||||
JSON_OBJECT('reference', ?),
|
||||
'normal'
|
||||
);`;
|
||||
await models.InvoiceOut.rawSql(query, [1 /* vPrinterFk */, invoiceOut.ref], myOptions);
|
||||
}
|
||||
|
||||
return invoiceId;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('invoicePdf', {
|
||||
description: 'Returns the invoice pdf',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'reference',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The invoice reference',
|
||||
http: {source: 'path'}
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
{
|
||||
arg: 'body',
|
||||
type: 'file',
|
||||
root: true
|
||||
}, {
|
||||
arg: 'Content-Type',
|
||||
type: 'String',
|
||||
http: {target: 'header'}
|
||||
}, {
|
||||
arg: 'Content-Disposition',
|
||||
type: 'String',
|
||||
http: {target: 'header'}
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: '/:reference/invoice',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.invoicePdf = async(ctx, reference) => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const report = new Report('invoice', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${reference}.pdf"`];
|
||||
};
|
||||
};
|
|
@ -15,4 +15,5 @@ module.exports = Self => {
|
|||
require('../methods/invoiceOut/exportationPdf')(Self);
|
||||
require('../methods/invoiceOut/invoiceCsv')(Self);
|
||||
require('../methods/invoiceOut/invoiceCsvEmail')(Self);
|
||||
require('../methods/invoiceOut/invoicePdf')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue