Merge pull request 'feat(print): added reusable pdf print functions' (!1390) from 5182-print_publish into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1390 Reviewed-by: Alexandre Riera <alexandre@verdnatura.es> Reviewed-by: Vicent Llopis <vicent@verdnatura.es>
This commit is contained in:
commit
1f52326091
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('previousLabel', {
|
||||
description: 'Returns the previa label pdf',
|
||||
|
@ -33,17 +31,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.previousLabel = async(ctx, id) => {
|
||||
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('previa-label', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="previa-${id}.pdf"`];
|
||||
};
|
||||
Self.previousLabel = (ctx, id) => Self.printReport(ctx, id, 'previa-label');
|
||||
};
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
const {Report, Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.printReport = async function(ctx, id, reportName) {
|
||||
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(reportName, params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
let fileName = `${reportName}`;
|
||||
if (id) fileName += `-${id}`;
|
||||
|
||||
return [stream, 'application/pdf', `filename="${fileName}.pdf"`];
|
||||
};
|
||||
|
||||
Self.printEmail = async function(ctx, id, templateName) {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email(templateName, params);
|
||||
const html = await report.render();
|
||||
|
||||
let fileName = `${templateName}`;
|
||||
if (id) fileName += `-${id}`;
|
||||
|
||||
return [html, 'text/html', `filename=${fileName}.pdf"`];
|
||||
};
|
||||
|
||||
Self.sendTemplate = async function(ctx, templateName) {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email(templateName, params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
};
|
|
@ -7,6 +7,7 @@ module.exports = function(Self) {
|
|||
|
||||
require('../methods/vn-model/getSetValues')(Self);
|
||||
require('../methods/vn-model/getEnumValues')(Self);
|
||||
require('../methods/vn-model/printService')(Self);
|
||||
|
||||
Object.assign(Self, {
|
||||
setup() {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const { Report } = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('claimPickupPdf', {
|
||||
description: 'Returns the claim pickup order pdf',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.claimPickupPdf = async(ctx, id) => {
|
||||
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('claim-pickup-order', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order');
|
||||
};
|
||||
|
|
|
@ -51,19 +51,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.campaignMetricsEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('campaign-metrics', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.campaignMetricsEmail = ctx => Self.sendTemplate(ctx, 'campaign-metrics');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('campaignMetricsPdf', {
|
||||
description: 'Returns the campaign metrics pdf',
|
||||
|
@ -50,17 +48,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.campaignMetricsPdf = async(ctx, id) => {
|
||||
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('campaign-metrics', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics');
|
||||
};
|
||||
|
|
|
@ -46,19 +46,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clientDebtStatementEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('client-debt-statement', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.clientDebtStatementEmail = ctx => Self.sendTemplate(ctx, 'client-debt-statement');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientDebtStatementHtml', {
|
||||
description: 'Returns the client debt statement email preview',
|
||||
|
@ -45,21 +43,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clientDebtStatementHtml = async(ctx, id) => {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email('client-debt-statement', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.clientDebtStatementHtml = (ctx, id) => Self.printEmail(ctx, id, 'client-debt-statement');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientDebtStatementPdf', {
|
||||
description: 'Returns the client debt statement pdf',
|
||||
|
@ -45,17 +43,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clientDebtStatementPdf = async(ctx, id) => {
|
||||
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('client-debt-statement', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.clientDebtStatementPdf = (ctx, id) => Self.printReport(ctx, id, 'client-debt-statement');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientWelcomeEmail', {
|
||||
description: 'Sends the client welcome email with an attached PDF',
|
||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clientWelcomeEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('client-welcome', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.clientWelcomeEmail = ctx => Self.sendTemplate(ctx, 'client-welcome');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientWelcomeHtml', {
|
||||
description: 'Returns the client welcome email preview',
|
||||
|
@ -40,19 +38,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clientWelcomeHtml = async(ctx, id) => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
|
||||
const report = new Email('client-welcome', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.clientWelcomeHtml = (ctx, id) => Self.printEmail(ctx, id, 'client-welcome');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientCreditEmail', {
|
||||
description: 'Sends the credit request email with an attached PDF',
|
||||
|
@ -10,7 +8,7 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
required: true,
|
||||
description: 'The client id',
|
||||
http: {source: 'path'}
|
||||
http: {source: 'path'},
|
||||
},
|
||||
{
|
||||
arg: 'recipient',
|
||||
|
@ -22,38 +20,25 @@ module.exports = Self => {
|
|||
arg: 'replyTo',
|
||||
type: 'string',
|
||||
description: 'The sender email to reply to',
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
arg: 'recipientId',
|
||||
type: 'number',
|
||||
description: 'The recipient id to send to the recipient preferred language',
|
||||
required: false
|
||||
}
|
||||
description:
|
||||
'The recipient id to send to the recipient preferred language',
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
root: true,
|
||||
},
|
||||
http: {
|
||||
path: '/:id/credit-request-email',
|
||||
verb: 'POST'
|
||||
}
|
||||
verb: 'POST',
|
||||
},
|
||||
});
|
||||
|
||||
Self.clientCreditEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('credit-request', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.clientCreditEmail = ctx => Self.sendTemplate(ctx, 'credit-request');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('creditRequestHtml', {
|
||||
description: 'Returns the credit request email preview',
|
||||
|
@ -40,21 +38,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.creditRequestHtml = async(ctx, id) => {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email('credit-request', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.creditRequestHtml = (ctx, id) => Self.printEmail(ctx, id, 'credit-request');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('creditRequestPdf', {
|
||||
description: 'Returns the credit request pdf',
|
||||
|
@ -40,17 +38,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.creditRequestPdf = async(ctx, id) => {
|
||||
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('credit-request', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.creditRequestPdf = (ctx, id) => Self.printReport(ctx, id, 'credit-request');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('incotermsAuthorizationEmail', {
|
||||
description: 'Sends the incoterms authorization email with an attached PDF',
|
||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.incotermsAuthorizationEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('incoterms-authorization', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.incotermsAuthorizationEmail = ctx => Self.sendTemplate(ctx, 'incoterms-authorization');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('incotermsAuthorizationHtml', {
|
||||
description: 'Returns the incoterms authorization email preview',
|
||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.incotermsAuthorizationHtml = async(ctx, id) => {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email('incoterms-authorization', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.incotermsAuthorizationHtml = (ctx, id) => Self.printEmail(ctx, id, 'incoterms-authorization');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('incotermsAuthorizationPdf', {
|
||||
description: 'Returns the incoterms authorization pdf',
|
||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.incotermsAuthorizationPdf = async(ctx, id) => {
|
||||
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('incoterms-authorization', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.incotermsAuthorizationPdf = (ctx, id) => Self.printReport(ctx, id, 'incoterms-authorization');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('letterDebtorNdEmail', {
|
||||
description: 'Sends the second debtor letter email with an attached PDF',
|
||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.letterDebtorNdEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('letter-debtor-nd', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.letterDebtorNdEmail = ctx => Self.sendTemplate(ctx, 'letter-debtor-nd');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('letterDebtorNdHtml', {
|
||||
description: 'Returns the second letter debtor email preview',
|
||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.letterDebtorNdHtml = async(ctx, id) => {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email('letter-debtor-nd', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.letterDebtorNdHtml = (ctx, id) => Self.printEmail(ctx, id, 'letter-debtor-nd');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('letterDebtorPdf', {
|
||||
description: 'Returns the letter debtor pdf',
|
||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.letterDebtorPdf = async(ctx, id) => {
|
||||
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('letter-debtor', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.letterDebtorPdf = (ctx, id) => Self.printReport(ctx, id, 'letter-debtor');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('letterDebtorStEmail', {
|
||||
description: 'Sends the printer setup email with an attached PDF',
|
||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.letterDebtorStEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('letter-debtor-st', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.letterDebtorStEmail = ctx => Self.sendTemplate(ctx, 'letter-debtor-st');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('letterDebtorStHtml', {
|
||||
description: 'Returns the letter debtor email preview',
|
||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.letterDebtorStHtml = async(ctx, id) => {
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
params.access_token = accessToken.id;
|
||||
|
||||
const report = new Email('letter-debtor-st', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.letterDebtorStHtml = (ctx, id) => Self.printEmail(ctx, id, 'letter-debtor-st');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('printerSetupEmail', {
|
||||
description: 'Sends the printer setup email with an attached PDF',
|
||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.printerSetupEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('printer-setup', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.printerSetupEmail = ctx => Self.sendTemplate(ctx, 'printer-setup');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('printerSetupHtml', {
|
||||
description: 'Returns the printer setup email preview',
|
||||
|
@ -40,19 +38,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.printerSetupHtml = async(ctx, id) => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
params.isPreview = true;
|
||||
|
||||
const report = new Email('printer-setup', params);
|
||||
const html = await report.render();
|
||||
|
||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
||||
};
|
||||
Self.printerSetupHtml = (ctx, id) => Self.printEmail(ctx, id, 'printer-setup');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('sepaCoreEmail', {
|
||||
description: 'Sends the campaign metrics email with an attached PDF',
|
||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.sepaCoreEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('sepa-core', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.sepaCoreEmail = ctx => Self.sendTemplate(ctx, 'sepa-core');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const { Report } = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('balanceCompensationPdf', {
|
||||
description: 'Returns the the debit balances compensation pdf',
|
||||
|
@ -10,7 +8,7 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
required: true,
|
||||
description: 'The receipt id',
|
||||
http: { source: 'path' }
|
||||
http: {source: 'path'}
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
|
@ -34,17 +32,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.balanceCompensationPdf = async(ctx, id) => {
|
||||
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('balance-compensation', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.balanceCompensationPdf = (ctx, id) => Self.printReport(ctx, id, 'balance-compensation');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('receiptPdf', {
|
||||
description: 'Returns the receipt pdf',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.receiptPdf = async(ctx, id) => {
|
||||
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('receipt', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.receiptPdf = (ctx, id) => Self.printReport(ctx, id, 'receipt');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('entryOrderPdf', {
|
||||
description: 'Returns the entry order pdf',
|
||||
|
@ -38,17 +36,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.entryOrderPdf = async(ctx, id) => {
|
||||
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('entry-order', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('invoiceInEmail', {
|
||||
description: 'Sends the invoice in email with an attached PDF',
|
||||
|
@ -35,19 +33,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.invoiceInEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('invoiceIn', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.invoiceInEmail = ctx => Self.sendTemplate(ctx, 'invoiceIn');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('invoiceInPdf', {
|
||||
description: 'Returns the invoiceIn pdf',
|
||||
|
@ -34,17 +32,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.invoiceInPdf = async(ctx, id) => {
|
||||
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('invoiceIn', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.invoiceInPdf = (ctx, id) => Self.printReport(ctx, id, 'invoiceIn');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('exportationPdf', {
|
||||
description: 'Returns the exportation pdf',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.exportationPdf = 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('exportation', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${reference}.pdf"`];
|
||||
};
|
||||
Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('labelPdf', {
|
||||
description: 'Returns the item label pdf',
|
||||
|
@ -56,17 +54,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.labelPdf = async(ctx, id) => {
|
||||
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('item-label', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="item-${id}.pdf"`];
|
||||
};
|
||||
Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('driverRouteEmail', {
|
||||
description: 'Sends the driver route email with an attached PDF',
|
||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.driverRouteEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('driver-route', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.driverRouteEmail = ctx => Self.sendTemplate(ctx, 'driver-route');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('driverRoutePdf', {
|
||||
description: 'Returns the driver route pdf',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.driverRoutePdf = async(ctx, id) => {
|
||||
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('driver-route', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.driverRoutePdf = (ctx, id) => Self.printReport(ctx, id, 'driver-route');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('campaignMetricsPdf', {
|
||||
description: 'Returns the campaign metrics pdf',
|
||||
|
@ -49,17 +47,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.campaignMetricsPdf = async(ctx, id) => {
|
||||
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('supplier-campaign-metrics', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('collectionLabel', {
|
||||
description: 'Returns the collection label',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.collectionLabel = async(ctx, id) => {
|
||||
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('collection-label', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.collectionLabel = (ctx, id) => Self.printReport(ctx, id, 'collection-label');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('deliveryNoteEmail', {
|
||||
description: 'Sends the delivery note email with an attached PDF',
|
||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.deliveryNoteEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('delivery-note', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.deliveryNoteEmail = ctx => Self.sendTemplate(ctx, 'delivery-note');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('deliveryNotePdf', {
|
||||
description: 'Returns the delivery note pdf',
|
||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.deliveryNotePdf = async(ctx, id) => {
|
||||
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('delivery-note', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('expeditionPalletLabel', {
|
||||
description: 'Returns the expedition pallet label',
|
||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.expeditionPalletLabel = async(ctx, id) => {
|
||||
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('expedition-pallet-label', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||
};
|
||||
Self.expeditionPalletLabel = (ctx, id) => Self.printReport(ctx, id, 'expedition-pallet-label');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('extraCommunityEmail', {
|
||||
description: 'Sends the extra community email with an attached PDF',
|
||||
|
@ -74,19 +72,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.extraCommunityEmail = async ctx => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('extra-community', params);
|
||||
|
||||
return email.send();
|
||||
};
|
||||
Self.extraCommunityEmail = ctx => Self.sendTemplate(ctx, 'extra-community');
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const {Report} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('extraCommunityPdf', {
|
||||
description: 'Returns the extra community pdf',
|
||||
|
@ -73,17 +71,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.extraCommunityPdf = async ctx => {
|
||||
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('extra-community', params);
|
||||
const stream = await report.toPdfStream();
|
||||
|
||||
return [stream, 'application/pdf', `filename="extra-community.pdf"`];
|
||||
};
|
||||
Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community');
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue