4481- Print service refactor #1064

Merged
joan merged 27 commits from 4481-print_library2 into dev 2022-10-05 09:56:51 +00:00
61 changed files with 1220 additions and 235 deletions
Showing only changes of commit 85698410db - Show all commits

View File

@ -3,4 +3,15 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Ticket', 'deliveryNoteEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Ticket', 'deliveryNoteEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'campaignMetricsEmail', 'READ', 'ALLOW', 'ROLE', 'employee'); ('Client', 'campaignMetricsEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientWelcomeEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'printerSetupEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'sepaCoreEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorStEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorNdEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementEmail', 'READ', 'ALLOW', 'ROLE', 'employee');

View File

@ -1,17 +1,32 @@
alter table `vn`.`sample` alter table `vn`.`sample`
add model VARCHAR(25) null comment 'Model name in plural'; add model VARCHAR(25) null comment 'Model name in plural';
alter table `vn`.`sample`
add property VARCHAR(25) null comment 'Remote method property name';
UPDATE vn.sample t UPDATE vn.sample t
SET t.model = 'Clients', SET t.model = 'Clients'
t.property = 'printerSetup'
WHERE t.id = 13; WHERE t.id = 13;
UPDATE vn.sample t UPDATE vn.sample t
SET t.model = 'Clients', SET t.model = 'Clients'
t.property = 'clientWelcome'
WHERE t.id = 12; WHERE t.id = 12;
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 14;
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 15;
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 18;
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 19;
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 16;

View File

@ -1,4 +1,4 @@
const {Report, Email, smtp} = require('vn-print'); const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('campaignMetricsEmail', { Self.remoteMethodCtx('campaignMetricsEmail', {
@ -50,7 +50,7 @@ module.exports = Self => {
} }
}); });
Self.campaignMetricsEmail = async(ctx, id) => { Self.campaignMetricsEmail = async ctx => {
const args = Object.assign({}, ctx.args); const args = Object.assign({}, ctx.args);
const params = { const params = {
recipient: args.recipient, recipient: args.recipient,

View File

@ -1,8 +1,8 @@
const { Report } = require('vn-print'); const {Report} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('campaignMetricsPdf', { Self.remoteMethodCtx('campaignMetricsPdf', {
description: 'Returns the campaign metrics note pdf', description: 'Returns the campaign metrics pdf',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',

View File

@ -0,0 +1,63 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('clientDebtStatementEmail', {
description: 'Sends the client debt statement email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
},
{
arg: 'from',
type: 'string',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/client-debt-statement-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,62 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('clientDebtStatementHtml', {
description: 'Returns the client debt statement email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
},
{
arg: 'from',
type: 'string',
required: true
}
],
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: '/:id/client-debt-statement-html',
verb: 'GET'
}
});
Self.clientDebtStatementHtml = 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-debt-statement', params);
const html = await report.render();
return [html, 'text/html', `filename="mail-${id}.pdf"`];
};
};

View File

@ -0,0 +1,58 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('clientWelcomeEmail', {
description: 'Sends the client welcome email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/client-welcome-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,57 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('clientWelcomeHtml', {
description: 'Returns the client welcome email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
}
],
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: '/:id/client-welcome-html',
verb: 'GET'
}
});
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"`];
};
};

View File

@ -0,0 +1,58 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('clientCreditEmail', {
description: 'Sends the credit request email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/credit-request-email',
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();
};
};

View File

@ -0,0 +1,57 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('creditRequestHtml', {
description: 'Returns the credit request email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
}
],
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: '/:id/credit-request-html',
verb: 'GET'
}
});
Self.creditRequestHtml = 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('credit-request', params);
const html = await report.render();
return [html, 'text/html', `filename="mail-${id}.pdf"`];
};
};

View File

@ -0,0 +1,64 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('letterDebtorNdEmail', {
description: 'Sends the second debtor letter email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/letter-debtor-nd-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,63 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('letterDebtorNdHtml', {
description: 'Returns the second letter debtor email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
}
],
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: '/:id/letter-debtor-nd-html',
verb: 'GET'
}
});
Self.letterDebtorNdHtml = 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('letter-debtor-nd', params);
const html = await report.render();
return [html, 'text/html', `filename="mail-${id}.pdf"`];
};
};

View File

@ -0,0 +1,64 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('letterDebtorStEmail', {
description: 'Sends the printer setup email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/letter-debtor-st-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,63 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('letterDebtorStHtml', {
description: 'Returns the letter debtor email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
}
],
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: '/:id/letter-debtor-st-html',
verb: 'GET'
}
});
Self.letterDebtorStHtml = 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('letter-debtor-st', params);
const html = await report.render();
return [html, 'text/html', `filename="mail-${id}.pdf"`];
};
};

View File

@ -0,0 +1,58 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('printerSetupEmail', {
description: 'Sends the printer setup email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/printer-setup-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,57 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('printerSetupHtml', {
description: 'Returns the printer setup email preview',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
}
],
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: '/:id/printer-setup-html',
verb: 'GET'
}
});
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"`];
};
};

View File

@ -0,0 +1,64 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('sepaCoreEmail', {
description: 'Sends the campaign metrics email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/sepa-core-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,43 @@
module.exports = Self => {
require('../methods/client/addressesPropagateRe')(Self);
require('../methods/client/canBeInvoiced')(Self);
require('../methods/client/canCreateTicket')(Self);
require('../methods/client/checkDuplicated')(Self);
require('../methods/client/confirmTransaction')(Self);
require('../methods/client/consumption')(Self);
require('../methods/client/createAddress')(Self);
require('../methods/client/createReceipt')(Self);
require('../methods/client/createWithUser')(Self);
require('../methods/client/extendedListFilter')(Self);
require('../methods/client/getAverageInvoiced')(Self);
require('../methods/client/getCard')(Self);
require('../methods/client/getDebt')(Self);
require('../methods/client/getMana')(Self);
require('../methods/client/getTransactions')(Self);
require('../methods/client/hasCustomerRole')(Self);
require('../methods/client/isValidClient')(Self);
require('../methods/client/lastActiveTickets')(Self);
require('../methods/client/sendSms')(Self);
require('../methods/client/setPassword')(Self);
require('../methods/client/summary')(Self);
require('../methods/client/updateAddress')(Self);
require('../methods/client/updateFiscalData')(Self);
require('../methods/client/updatePortfolio')(Self);
require('../methods/client/updateUser')(Self);
require('../methods/client/uploadFile')(Self);
require('../methods/client/campaignMetricsPdf')(Self);
require('../methods/client/campaignMetricsEmail')(Self);
require('../methods/client/clientWelcomeHtml')(Self);
require('../methods/client/clientWelcomeEmail')(Self);
require('../methods/client/printerSetupHtml')(Self);
require('../methods/client/printerSetupEmail')(Self);
require('../methods/client/sepaCoreEmail')(Self);
require('../methods/client/letterDebtorStHtml')(Self);
require('../methods/client/letterDebtorStEmail')(Self);
require('../methods/client/letterDebtorNdHtml')(Self);
require('../methods/client/letterDebtorNdEmail')(Self);
require('../methods/client/clientDebtStatementHtml')(Self);
require('../methods/client/clientDebtStatementEmail')(Self);
require('../methods/client/creditRequestHtml')(Self);
require('../methods/client/creditRequestEmail')(Self);
};

View File

@ -8,34 +8,7 @@ const LoopBackContext = require('loopback-context');
module.exports = Self => { module.exports = Self => {
// Methods // Methods
require('../methods/client/addressesPropagateRe')(Self); require('./client-methods')(Self);
require('../methods/client/canBeInvoiced')(Self);
require('../methods/client/canCreateTicket')(Self);
require('../methods/client/checkDuplicated')(Self);
require('../methods/client/confirmTransaction')(Self);
require('../methods/client/consumption')(Self);
require('../methods/client/createAddress')(Self);
require('../methods/client/createReceipt')(Self);
require('../methods/client/createWithUser')(Self);
require('../methods/client/extendedListFilter')(Self);
require('../methods/client/getAverageInvoiced')(Self);
require('../methods/client/getCard')(Self);
require('../methods/client/getDebt')(Self);
require('../methods/client/getMana')(Self);
require('../methods/client/getTransactions')(Self);
require('../methods/client/hasCustomerRole')(Self);
require('../methods/client/isValidClient')(Self);
require('../methods/client/lastActiveTickets')(Self);
require('../methods/client/sendSms')(Self);
require('../methods/client/setPassword')(Self);
require('../methods/client/summary')(Self);
require('../methods/client/updateAddress')(Self);
require('../methods/client/updateFiscalData')(Self);
require('../methods/client/updatePortfolio')(Self);
require('../methods/client/updateUser')(Self);
require('../methods/client/uploadFile')(Self);
require('../methods/client/campaignMetricsPdf')(Self);
require('../methods/client/campaignMetricsEmail')(Self);
// Validations // Validations

View File

@ -7,6 +7,15 @@
<vn-crud-model <vn-crud-model
auto-load="true" auto-load="true"
url="Samples/visible" url="Samples/visible"
fields="[
'id',
'code',
'description',
'model',
'hasCompany',
'hasPreview',
'datepickerEnabled'
]"
data="samplesVisible" data="samplesVisible"
order="description"> order="description">
</vn-crud-model> </vn-crud-model>
@ -31,7 +40,6 @@
ng-model="$ctrl.clientSample.typeFk" ng-model="$ctrl.clientSample.typeFk"
model="ClientSample.typeFk" model="ClientSample.typeFk"
data="samplesVisible" data="samplesVisible"
fields="['id', 'description', 'model']"
show-field="description" show-field="description"
label="Sample" label="Sample"
required="true"> required="true">

View File

@ -3,12 +3,13 @@ import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends Section {
constructor($element, $) { constructor($element, $, vnEmail) {
super($element, $); super($element, $);
this.clientSample = { this.clientSample = {
clientFk: this.$params.id, clientFk: this.$params.id,
companyId: this.vnConfig.companyFk companyId: this.vnConfig.companyFk
}; };
this.vnEmail = vnEmail;
} }
get client() { get client() {
@ -36,9 +37,7 @@ class Controller extends Section {
onSubmit() { onSubmit() {
this.$.watcher.check(); this.$.watcher.check();
this.$.watcher.realSubmit().then(() => this.$.watcher.realSubmit().then(() => this.send());
this.sendSample()
);
} }
// showPreview() { // showPreview() {
@ -93,16 +92,39 @@ class Controller extends Section {
// this.$http.get(query, {params}).then(cb); // this.$http.get(query, {params}).then(cb);
// } // }
validateParams(params) {
const sampleType = this.$.sampleType.selection;
if (!params.recipient)
return this.vnApp.showError(this.$t('Email cannot be blank'));
if (!sampleType)
return this.vnApp.showError(this.$t('Choose a sample'));
if (sampleType.hasCompany && !this.clientSample.companyFk)
return this.vnApp.showError(this.$t('Choose a company'));
if (sampleType.hasCompany)
params.companyId = this.clientSample.companyFk;
if (sampleType.datepickerEnabled && !this.clientSample.from)
return this.vnApp.showError(this.$t('Choose a date'));
if (sampleType.datepickerEnabled)
params.from = this.clientSample.from;
}
preview() { preview() {
const sampleType = this.$.sampleType.selection; const sampleType = this.$.sampleType.selection;
const params = { const params = {
recipientId: this.$params.id, recipientId: this.$params.id,
recipient: this.clientSample.recipient, recipient: this.clientSample.recipient
replyTo: this.clientSample.replyTo
}; };
const path = `${sampleType.model}/${this.$params.id}/${sampleType.property}Html`; this.validateParams(params);
const path = `${sampleType.model}/${this.$params.id}/${sampleType.code}-html`;
this.$http.get(path, {params}) this.$http.get(path, {params})
.then(response => { .then(response => {
this.$.showPreview.show(); this.$.showPreview.show();
@ -116,10 +138,19 @@ class Controller extends Section {
} }
send() { send() {
this.vnEmail.send(`tickets/${this.id}/credit-request-email`, { const sampleType = this.$.sampleType.selection;
recipientId: this.ticket.client.id,
recipient: $data.email const params = {
}); recipientId: this.client.id,
recipient: this.clientSample.recipient,
replyTo: this.clientSample.replyTo
};
this.validateParams(params);
const path = `${sampleType.model}/${this.$params.id}/${sampleType.code}-email`;
this.vnEmail.send(path, params)
.then(() => this.$state.go('client.card.sample.index'));
} }
getWorkerEmail() { getWorkerEmail() {
@ -132,7 +163,7 @@ class Controller extends Section {
} }
} }
Controller.$inject = ['$element', '$scope']; Controller.$inject = ['$element', '$scope', 'vnEmail'];
ngModule.vnComponent('vnClientSampleCreate', { ngModule.vnComponent('vnClientSampleCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -22,11 +22,3 @@ vn-item-product {
margin-top: 9px; margin-top: 9px;
} }
} }
table {
img {
border-radius: 50%;
width: 50px;
height: 50px;
}
}

View File

@ -0,0 +1,58 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('driverRouteEmail', {
description: 'Sends the driver route email with an attached PDF',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
required: false
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
required: false
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/driver-route-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,55 @@
const {Report} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('driverRoutePdf', {
description: 'Returns the driver route pdf',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
}
],
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: '/:id/driver-route-pdf',
verb: 'GET'
}
});
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"`];
};
};

View File

@ -10,6 +10,8 @@ module.exports = Self => {
require('../methods/route/getSuggestedTickets')(Self); require('../methods/route/getSuggestedTickets')(Self);
require('../methods/route/unlink')(Self); require('../methods/route/unlink')(Self);
require('../methods/route/updateWorkCenter')(Self); require('../methods/route/updateWorkCenter')(Self);
require('../methods/route/driverRoutePdf')(Self);
require('../methods/route/driverRouteEmail')(Self);
Self.validate('kmStart', validateDistance, { Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000' message: 'Distance must be lesser than 1000'

View File

@ -1,6 +1,5 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section { class Controller extends Section {
constructor($element, $) { constructor($element, $) {

View File

@ -1,32 +0,0 @@
@import "variables";
vn-item-product {
display: block;
.id {
background-color: $color-main;
color: $color-font-dark;
margin-bottom: 0;
}
.image {
height: 112px;
width: 112px;
& > img {
max-height: 100%;
max-width: 100%;
border-radius: 3px;
}
}
vn-label-value:first-of-type section{
margin-top: 9px;
}
}
table {
img {
border-radius: 50%;
width: 50px;
height: 50px;
}
}

View File

@ -11,16 +11,16 @@ class Controller extends Descriptor {
} }
showRouteReport() { showRouteReport() {
this.vnReport.show('driver-route', { this.vnReport.show(`Routes/${this.id}/driver-route-pdf`, {
routeId: this.id id: this.id
}); });
} }
sendRouteReport() { sendRouteReport() {
const workerUser = this.route.worker.user; const workerUser = this.route.worker.user;
this.vnEmail.send('driver-route', { this.vnEmail.send(`Routes/${this.id}/driver-route-email`, {
recipient: workerUser.emailUser.email, recipient: workerUser.emailUser.email,
routeId: this.id id: this.id
}); });
} }

View File

@ -1,4 +1,4 @@
const { Email } = require('vn-print'); const {Email} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deliveryNoteEmail', { Self.remoteMethodCtx('deliveryNoteEmail', {
@ -46,7 +46,7 @@ module.exports = Self => {
} }
}); });
Self.deliveryNoteEmail = async(ctx, id) => { Self.deliveryNoteEmail = async ctx => {
const args = Object.assign({}, ctx.args); const args = Object.assign({}, ctx.args);
const params = { const params = {
recipient: args.recipient, recipient: args.recipient,

View File

@ -1,4 +1,4 @@
const {Report, Email, smtp} = require('vn-print'); const {Report} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deliveryNotePdf', { Self.remoteMethodCtx('deliveryNotePdf', {

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`, `${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -9,3 +9,4 @@ module.exports = new Stylesheet([
`${vnPrintPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,8 +1,11 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,15 +1,15 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
module.exports = { module.exports = {
name: 'client-welcome', name: 'client-welcome',
async serverPrefetch() { async serverPrefetch() {
this.client = await this.fetchClient(this.recipientId); this.client = await this.fetchClient(this.id);
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(id) {
return this.findOneFromDef('client', [clientId]); return this.findOneFromDef('client', [id]);
}, },
}, },
components: { components: {
@ -17,7 +17,7 @@ module.exports = {
'email-footer': emailFooter.build() 'email-footer': emailFooter.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
} }

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`, `${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -9,7 +9,7 @@ module.exports = {
'email-footer': emailFooter.build() 'email-footer': emailFooter.build()
}, },
props: { props: {
ticketId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
} }

View File

@ -1,8 +1,11 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -9,7 +9,7 @@ module.exports = {
'email-footer': emailFooter.build() 'email-footer': emailFooter.build()
}, },
props: { props: {
routeId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
} }

View File

@ -1,8 +1,11 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-report/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -15,7 +15,7 @@ module.exports = {
'attachment': attachment.build() 'attachment': attachment.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -7,7 +7,7 @@ const attachments = require('./attachments.json');
module.exports = { module.exports = {
name: 'letter-debtor-nd', name: 'letter-debtor-nd',
async serverPrefetch() { async serverPrefetch() {
this.debtor = await this.fetchDebtor(this.recipientId, this.companyId); this.debtor = await this.fetchDebtor(this.id, this.companyId);
if (!this.debtor) if (!this.debtor)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -16,8 +16,8 @@ module.exports = {
return {attachments}; return {attachments};
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(id, companyId) {
return this.findOneFromDef('client', [clientId, companyId]); return this.findOneFromDef('client', [id, companyId]);
} }
}, },
components: { components: {
@ -26,10 +26,7 @@ module.exports = {
'attachment': attachment.build() 'attachment': attachment.build()
}, },
props: { props: {
authorization: { id: {
required: true
},
recipientId: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -5,7 +5,6 @@ SELECT
be.name AS bankName be.name AS bankName
FROM client c FROM client c
JOIN company AS cny JOIN company AS cny
JOIN supplierAccount AS sa ON JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
IF (ct.code = 'PT', sa.id = 907, sa.id = cny.supplierAccountFk)
JOIN bankEntity be ON be.id = sa.bankEntityFk JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ? WHERE c.id = ? AND cny.id = ?

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -7,7 +7,7 @@ const attachments = require('./attachments.json');
module.exports = { module.exports = {
name: 'letter-debtor-st', name: 'letter-debtor-st',
async serverPrefetch() { async serverPrefetch() {
this.debtor = await this.fetchDebtor(this.recipientId, this.companyId); this.debtor = await this.fetchDebtor(this.id, this.companyId);
if (!this.debtor) if (!this.debtor)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -16,8 +16,8 @@ module.exports = {
return {attachments}; return {attachments};
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(id, companyId) {
return this.findOneFromDef('client', [clientId, companyId]); return this.findOneFromDef('client', [id, companyId]);
} }
}, },
components: { components: {
@ -26,7 +26,7 @@ module.exports = {
'attachment': attachment.build() 'attachment': attachment.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -5,7 +5,6 @@ SELECT
be.name AS bankName be.name AS bankName
FROM client c FROM client c
JOIN company AS cny JOIN company AS cny
JOIN supplierAccount AS sa ON JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
IF (ct.code = 'PT', sa.id = 907, sa.id = cny.supplierAccountFk)
JOIN bankEntity be ON be.id = sa.bankEntityFk JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ? WHERE c.id = ? AND cny.id = ?

View File

@ -1,8 +1,11 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -7,14 +7,14 @@ const attachments = require('./attachments.json');
module.exports = { module.exports = {
name: 'printer-setup', name: 'printer-setup',
async serverPrefetch() { async serverPrefetch() {
this.client = await this.fetchClient(this.recipientId); this.client = await this.fetchClient(this.id);
}, },
data() { data() {
return {attachments}; return {attachments};
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(id) {
return this.findOneFromDef('client', [clientId]); return this.findOneFromDef('client', [id]);
} }
}, },
components: { components: {
@ -23,7 +23,7 @@ module.exports = {
'attachment': attachment.build() 'attachment': attachment.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
} }

View File

@ -1,8 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`]) `${vnPrintPath}/common/css/email.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -15,7 +15,7 @@ module.exports = {
'attachment': attachment.build() 'attachment': attachment.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`, `${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -141,7 +141,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div v-if="ticket.description class="text-area"> <div v-if="ticket.description" class="text-area">
<p>{{ticket.description}}</p> <p>{{ticket.description}}</p>
</div> </div>
</div> </div>

View File

@ -1,13 +1,18 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
module.exports = { module.exports = {
name: 'driver-route', name: 'driver-route',
async serverPrefetch() { async serverPrefetch() {
const routesId = this.routeId.split(','); let ids = this.id;
const routes = await this.fetchRoutes(routesId);
const tickets = await this.fetchTickets(routesId); const hasMultipleRoutes = String(this.id).includes(',');
if (hasMultipleRoutes)
ids = this.id.split(',');
const routes = await this.fetchRoutes(ids);
const tickets = await this.fetchTickets(ids);
const map = new Map(); const map = new Map();
@ -26,11 +31,11 @@ module.exports = {
throw new Error('Something went wrong'); throw new Error('Something went wrong');
}, },
methods: { methods: {
fetchRoutes(routesId) { fetchRoutes(ids) {
return this.rawSqlFromDef('routes', [routesId]); return this.rawSqlFromDef('routes', [ids]);
}, },
fetchTickets(routesId) { fetchTickets(ids) {
return this.rawSqlFromDef('tickets', [routesId, routesId]); return this.rawSqlFromDef('tickets', [ids, ids]);
} }
}, },
components: { components: {
@ -38,7 +43,7 @@ module.exports = {
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
}, },
props: { props: {
routeId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
} }

View File

@ -1,8 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/report.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,11 +1,11 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
module.exports = { module.exports = {
name: 'incoterms-authorization', name: 'incoterms-authorization',
async serverPrefetch() { async serverPrefetch() {
this.client = await this.findOneFromDef('client', [this.recipientId]); this.client = await this.findOneFromDef('client', [this.id]);
this.company = await this.findOneFromDef('company', [this.companyId]); this.company = await this.findOneFromDef('company', [this.companyId]);
if (!this.client) if (!this.client)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -20,7 +20,7 @@ module.exports = {
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`, `${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,12 +1,12 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
module.exports = { module.exports = {
name: 'letter-debtor', name: 'letter-debtor',
async serverPrefetch() { async serverPrefetch() {
this.client = await this.fetchClient(this.recipientId); this.client = await this.fetchClient(this.id);
this.sales = await this.fetchSales(this.recipientId, this.companyId); this.sales = await this.fetchSales(this.id, this.companyId);
if (!this.client) if (!this.client)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -22,12 +22,12 @@ module.exports = {
return {totalBalance: 0.00}; return {totalBalance: 0.00};
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(id) {
return this.findOneFromDef('client', [clientId]); return this.findOneFromDef('client', [id]);
}, },
fetchSales(clientId, companyId) { fetchSales(id, companyId) {
return this.findOneFromDef('sales', [ return this.findOneFromDef('sales', [
clientId, id,
companyId companyId
]); ]);
}, },
@ -62,7 +62,7 @@ module.exports = {
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },

View File

@ -1,9 +1,12 @@
const Stylesheet = require(`${appPath}/core/stylesheet`); const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([ module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`, `${vnPrintPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`, `${vnPrintPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`, `${vnPrintPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`, `${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`]) `${__dirname}/style.css`])
.mergeStyles(); .mergeStyles();

View File

@ -1,12 +1,12 @@
const Component = require(`${appPath}/core/component`); const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
const rptSepaCore = { const rptSepaCore = {
name: 'sepa-core', name: 'sepa-core',
async serverPrefetch() { async serverPrefetch() {
this.client = await this.fetchClient(this.recipientId, this.companyId); this.client = await this.fetchClient(this.id, this.companyId);
this.supplier = await this.fetchSupplier(this.recipientId, this.companyId); this.supplier = await this.fetchSupplier(this.id, this.companyId);
if (!this.client) if (!this.client)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
@ -19,18 +19,18 @@ const rptSepaCore = {
} }
}, },
methods: { methods: {
fetchClient(clientId, companyId) { fetchClient(id, companyId) {
return this.findOneFromDef('client', [ return this.findOneFromDef('client', [
companyId, companyId,
companyId, companyId,
clientId id
]); ]);
}, },
fetchSupplier(clientId, companyId) { fetchSupplier(id, companyId) {
return this.findOneFromDef('supplier', [ return this.findOneFromDef('supplier', [
companyId, companyId,
companyId, companyId,
clientId id
]); ]);
} }
}, },
@ -39,7 +39,7 @@ const rptSepaCore = {
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
}, },
props: { props: {
recipientId: { id: {
type: [Number, String], type: [Number, String],
required: true required: true
}, },