4481- Print service refactor #1064

Merged
joan merged 27 commits from 4481-print_library2 into dev 2022-10-05 09:56:51 +00:00
58 changed files with 883 additions and 218 deletions
Showing only changes of commit 7f78286d6b - Show all commits

View File

@ -14,4 +14,13 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'letterDebtorNdEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'clientDebtStatementEmail', 'READ', 'ALLOW', 'ROLE', 'employee');
('Client', 'clientDebtStatementEmail', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('InvoiceOut', 'invoiceEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('InvoiceOut', 'exportationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Supplier', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Supplier', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Travel', 'extraCommunityPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee');

View File

@ -2,31 +2,5 @@ alter table `vn`.`sample`
add model VARCHAR(25) null comment 'Model name in plural';
UPDATE vn.sample t
SET t.model = 'Clients'
WHERE t.id = 13;
UPDATE vn.sample t
SET t.model = 'Clients'
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;
SET t.model = 'Clients'
WHERE t.id IN(13, 14, 15, 16, 18, 19, 20);

View File

@ -1765,11 +1765,6 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`)
(4, 'Reclam.PRAG', 12),
(5, 'Corregido', 11);
INSERT INTO `vn`.`claimResponsible`(`id`, `description`, `responsability`)
VALUES
(1, 'Buyers', 0),
(7, 'Quality', 0);
INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`)
VALUES
(1, 1, 1, 21, 1, 1, 2, 5),

View File

@ -0,0 +1,65 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('incotermsAuthorizationEmail', {
description: 'Sends the incoterms authorization email with an attached PDF',
accessType: 'WRITE',
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/incoterms-authorization-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,64 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('incotermsAuthorizationHtml', {
description: 'Returns the incoterms authorization email preview',
accessType: 'READ',
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/incoterms-authorization-html',
verb: 'GET'
}
});
Self.incotermsAuthorizationHtml = 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('incoterms-authorization', params);
const html = await report.render();
return [html, 'text/html', `filename="mail-${id}.pdf"`];
};
};

View File

@ -40,4 +40,6 @@ module.exports = Self => {
require('../methods/client/clientDebtStatementEmail')(Self);
require('../methods/client/creditRequestHtml')(Self);
require('../methods/client/creditRequestEmail')(Self);
require('../methods/client/incotermsAuthorizationHtml')(Self);
require('../methods/client/incotermsAuthorizationEmail')(Self);
};

View File

@ -1,4 +1,5 @@
const UserError = require('vn-loopback/util/user-error');
const LoopBackContext = require('loopback-context');
module.exports = Self => {
Self.validatesPresenceOf('typeFk', {
@ -6,10 +7,10 @@ module.exports = Self => {
});
Self.observe('before save', async function(ctx) {
let models = Self.app.models;
let changes = ctx.data || ctx.instance;
const models = Self.app.models;
const changes = ctx.data || ctx.instance;
let sample = await models.Sample.findById(changes.typeFk);
const sample = await models.Sample.findById(changes.typeFk);
if (sample.hasCompany && !changes.companyFk)
throw new UserError('Choose a company');
@ -25,11 +26,11 @@ module.exports = Self => {
// Renew mandate
if (mandate) {
let mandateType = await models.MandateType.findOne({
const mandateType = await models.MandateType.findOne({
where: {name: mandate.type}
});
let oldMandate = await models.Mandate.findOne({
const oldMandate = await models.Mandate.findOne({
where: {
clientFk: changes.clientFk,
companyFk: changes.companyFk,
@ -50,10 +51,8 @@ module.exports = Self => {
});
}
// Apply workerFk
let filter = {where: {userFk: ctx.options.accessToken.userId}};
let worker = await Self.app.models.Worker.findOne(filter);
const loopBackContext = LoopBackContext.getCurrentContext();
changes.workerFk = worker.id;
changes.userFk = loopBackContext.active.accessToken.userId;
});
};

View File

@ -32,9 +32,6 @@
},
"model": {
"type": "string"
},
"property": {
"type": "string"
}
},
"scopes": {

View File

@ -0,0 +1,54 @@
const {Report} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('entryOrderPdf', {
description: 'Returns the entry order pdf',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
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/entry-order-pdf',
verb: 'GET'
}
});
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"`];
};
};

View File

@ -6,4 +6,5 @@ module.exports = Self => {
require('../methods/entry/importBuys')(Self);
require('../methods/entry/importBuysPreview')(Self);
require('../methods/entry/lastItemBuys')(Self);
require('../methods/entry/entryOrderPdf')(Self);
};

View File

@ -86,9 +86,7 @@ class Controller extends Descriptor {
}
showEntryReport() {
this.vnReport.show('entry-order', {
entryId: this.entry.id
});
this.vnReport.show(`Entries/${this.id}/entry-order-pdf`);
}
}

View File

@ -0,0 +1,54 @@
const {Report} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('exportationPdf', {
description: 'Returns the exportation pdf',
accepts: [
{
arg: 'ref',
type: 'string',
required: true,
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: '/:ref/exportation-pdf',
verb: 'GET'
}
});
Self.exportationPdf = async(ctx, ref) => {
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-${ref}.pdf"`];
};
};

View File

@ -0,0 +1,58 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('invoiceEmail', {
description: 'Sends the invoice email with an attached PDF',
accessType: 'WRITE',
accepts: [
{
arg: 'ref',
type: 'string',
required: true,
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: '/:ref/invoice-email',
verb: 'POST'
}
});
Self.invoiceEmail = 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('invoice', params);
return email.send();
};
};

View File

@ -9,4 +9,6 @@ module.exports = Self => {
require('../methods/invoiceOut/createManualInvoice')(Self);
require('../methods/invoiceOut/globalInvoicing')(Self);
require('../methods/invoiceOut/refund')(Self);
require('../methods/invoiceOut/invoiceEmail')(Self);
require('../methods/invoiceOut/exportationPdf')(Self);
};

View File

@ -92,10 +92,9 @@ class Controller extends Section {
if (!$data.email)
return this.vnApp.showError(this.$t(`The email can't be empty`));
return this.vnEmail.send('invoice', {
return this.vnEmail.send(`InvoiceOuts/${this.invoiceOut.ref}/invoice-email`, {
recipientId: this.invoiceOut.client.id,
recipient: $data.email,
refFk: this.invoiceOut.ref
recipient: $data.email
});
}
@ -111,7 +110,7 @@ class Controller extends Section {
}
showExportationLetter() {
this.vnReport.show('exportation', {
this.vnReport.show(`InvoiceOuts/${this.invoiceOut.ref}/exportation-pdf`, {
recipientId: this.invoiceOut.client.id,
refFk: this.invoiceOut.ref
});

View File

@ -0,0 +1,68 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('campaignMetricsEmail', {
description: 'Sends the campaign metrics email with an attached PDF',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
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
},
{
arg: 'to',
type: 'string',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/campaign-metrics-email',
verb: 'POST'
}
});
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('supplier-campaign-metrics', params);
return email.send();
};
};

View File

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

View File

@ -8,6 +8,8 @@ module.exports = Self => {
require('../methods/supplier/updateFiscalData')(Self);
require('../methods/supplier/consumption')(Self);
require('../methods/supplier/freeAgencies')(Self);
require('../methods/supplier/campaignMetricsPdf')(Self);
require('../methods/supplier/campaignMetricsEmail')(Self);
Self.validatesPresenceOf('name', {
message: 'The social name cannot be empty'

View File

@ -33,7 +33,8 @@ class Controller extends Section {
}
showReport() {
this.vnReport.show('supplier-campaign-metrics', this.reportParams);
const path = `Suppliers/${this.supplier.id}/campaign-metrics-pdf`;
this.vnReport.show(path, this.reportParams);
}
sendEmail() {
@ -52,7 +53,9 @@ class Controller extends Section {
const params = Object.assign({
recipient: contact.email
}, this.reportParams);
this.vnEmail.send('supplier-campaign-metrics', params);
const path = `Suppliers/${this.supplier.id}/campaign-metrics-email`;
this.vnEmail.send(path, params);
} else {
const message = this.$t(`This supplier doesn't have a contact with an email address`);
this.vnApp.showError(message);

View File

@ -0,0 +1,92 @@
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('extraCommunityEmail', {
description: 'Sends the extra community email with an attached PDF',
accessType: 'WRITE',
accepts: [
{
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: 'landedTo',
type: 'date'
},
{
arg: 'shippedFrom',
type: 'date'
},
{
arg: 'continent',
type: 'string'
},
{
arg: 'ref',
type: 'string'
},
{
arg: 'id',
type: 'number'
},
{
arg: 'agencyModeFk',
type: 'number'
},
{
arg: 'warehouseOutFk',
type: 'number'
},
{
arg: 'warehouseInFk',
type: 'number'
},
{
arg: 'totalEntries',
type: 'number'
},
{
arg: 'cargoSupplierFk',
type: 'number'
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: '/extra-community-email',
verb: 'POST'
}
});
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();
};
};

View File

@ -0,0 +1,89 @@
const {Report} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('extraCommunityPdf', {
description: 'Returns the extra community pdf',
accessType: 'READ',
accepts: [
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
},
{
arg: 'landedTo',
type: 'date'
},
{
arg: 'shippedFrom',
type: 'date'
},
{
arg: 'continent',
type: 'string'
},
{
arg: 'ref',
type: 'string'
},
{
arg: 'id',
type: 'number'
},
{
arg: 'agencyModeFk',
type: 'number'
},
{
arg: 'warehouseOutFk',
type: 'number'
},
{
arg: 'warehouseInFk',
type: 'number'
},
{
arg: 'totalEntries',
type: 'number'
},
{
arg: 'cargoSupplierFk',
type: 'number'
}
],
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: '/extra-community-pdf',
verb: 'GET'
}
});
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"`];
};
};

View File

@ -10,6 +10,8 @@ module.exports = Self => {
require('../methods/travel/extraCommunityFilter')(Self);
require('../methods/travel/getAverageDays')(Self);
require('../methods/travel/cloneWithEntries')(Self);
require('../methods/travel/extraCommunityPdf')(Self);
require('../methods/travel/extraCommunityEmail')(Self);
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')

View File

@ -157,7 +157,7 @@ class Controller extends Section {
}
showReport() {
this.vnReport.show('extra-community', this.reportParams);
this.vnReport.show(`Travels/extra-community-pdf`, this.reportParams);
}
}

View File

@ -1,4 +1,4 @@
const Component = require(`vn-report/core/component`);
const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
const attachment = new Component('attachment');

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`])
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/email.css`])
.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 emailFooter = new Component('email-footer');
module.exports = {
name: 'invoice',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.refFk);
this.invoice = await this.fetchInvoice(this.ref);
},
methods: {
fetchInvoice(refFk) {
return this.findOneFromDef('invoice', [refFk]);
fetchInvoice(ref) {
return this.findOneFromDef('invoice', [ref]);
},
},
components: {
@ -17,7 +17,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
refFk: {
ref: {
type: [Number, String],
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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`])
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/email.css`])
.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 emailFooter = new Component('email-footer');
@ -20,7 +20,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
recipientId: {
id: {
type: [Number, String],
required: true
},

View File

@ -26,7 +26,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The client id'
},
from: {
required: true

View File

@ -37,7 +37,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The claim id'
}
}
};

View File

@ -70,7 +70,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The client id'
},
from: {
required: true

View File

@ -128,7 +128,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The ticket id'
},
type: {
type: String,

View File

@ -45,7 +45,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The route 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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,13 +1,13 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'entry-order',
async serverPrefetch() {
this.supplier = await this.fetchSupplier(this.entryId);
this.entry = await this.fetchEntry(this.entryId);
this.buys = await this.fetchBuys(this.entryId);
this.supplier = await this.fetchSupplier(this.id);
this.entry = await this.fetchEntry(this.id);
this.buys = await this.fetchBuys(this.id);
if (!this.entry)
throw new Error('Something went wrong');
@ -16,14 +16,14 @@ module.exports = {
return {totalBalance: 0.00};
},
methods: {
fetchSupplier(entryId) {
return this.findOneFromDef('supplier', [entryId]);
fetchSupplier(id) {
return this.findOneFromDef('supplier', [id]);
},
fetchEntry(entryId) {
return this.findOneFromDef('entry', [entryId]);
fetchEntry(id) {
return this.findOneFromDef('entry', [id]);
},
fetchBuys(entryId) {
return this.rawSqlFromDef('buys', [entryId]);
fetchBuys(id) {
return this.rawSqlFromDef('buys', [id]);
},
getTotal() {
let total = 0.00;
@ -39,9 +39,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
entryId: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The entry id'
}
}
};

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([
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${appPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -31,9 +31,9 @@
<p><em>({{$t('signature')}})</em></p>
<img v-bind:src="getReportSrc('signature.png')">
<p>
<div>{{$t('signer.name')}}: JUAN VICENTE FERRER ROIG</div>
<div>{{$t('signer.ID')}}: 73943586N</div>
<div>{{$t('signer.position')}}: ADMINISTRADOR</div>
<div>{{$t('signer.name')}}: {{company.manager}}</div>
<div>{{$t('signer.ID')}}: {{company.managerFi}}</div>
<div>{{$t('signer.position')}}: {{$t('manager')}}</div>
</p>
</div>
</div>

View File

@ -1,18 +1,20 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'exportation',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.refFk);
this.invoice = await this.fetchInvoice(this.ref);
if (!this.invoice)
throw new Error('Something went wrong');
this.company = await this.findOneFromDef('company', [this.invoice.companyFk]);
},
methods: {
fetchInvoice(refFk) {
return this.findOneFromDef('invoice', [refFk]);
fetchInvoice(ref) {
return this.findOneFromDef('invoice', [ref]);
}
},
computed: {
@ -27,9 +29,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
refFk: {
ref: {
type: [Number, String],
required: true
required: true,
description: 'The invoice ref'
}
}
};

View File

@ -36,6 +36,7 @@ signer:
name: Nombre del firmante
ID: DNI del firmante
position: Cargo del firmante
manager: Gerente
months:
- 'Enero'
- 'Febrero'

View File

@ -0,0 +1,9 @@
SELECT
s.name,
s.city,
cl.name AS manager,
cl.fi AS managerFi
FROM company c
JOIN supplier s ON s.id = c.id
JOIN client cl ON cl.id = c.workerManagerFk
WHERE c.id = ?

View File

@ -1,7 +1,8 @@
SELECT
io.id,
io.ref,
io.issued
io.issued,
io.companyFk
FROM invoiceOut io
LEFT JOIN ticket t ON t.refFk = io.ref
WHERE t.refFk = ?

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,7 +1,7 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const db = require(`${appPath}/core/database`);
const db = require(`vn-print/core/database`);
module.exports = {
name: 'extra-community',
@ -82,7 +82,15 @@ module.exports = {
let query = this.getSqlFromDef('travels');
query = db.merge(query, where);
query = db.merge(query, 'GROUP BY t.id');
query = db.merge(query, 'ORDER BY `shipped` ASC, `landed` ASC, `travelFk`, `loadPriority`, `agencyModeFk`, `evaNotes`');
query = db.merge(query, `
ORDER BY
shipped ASC,
landed ASC,
travelFk,
loadPriority,
agencyModeFk,
evaNotes
`);
return this.rawSql(query);
},

View File

@ -22,7 +22,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The client id'
},
companyId: {
type: [Number, String],

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,13 +1,13 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'invoice-incoterms',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.refFk);
this.client = await this.fetchClient(this.refFk);
this.incoterms = await this.fetchIncoterms(this.refFk);
this.invoice = await this.fetchInvoice(this.ref);
this.client = await this.fetchClient(this.ref);
this.incoterms = await this.fetchIncoterms(this.ref);
if (!this.invoice)
throw new Error('Something went wrong');
@ -16,14 +16,14 @@ module.exports = {
},
methods: {
fetchInvoice(refFk) {
return this.findOneFromDef('invoice', [refFk]);
fetchInvoice(ref) {
return this.findOneFromDef('invoice', [ref]);
},
fetchClient(refFk) {
return this.findOneFromDef('client', [refFk]);
fetchClient(ref) {
return this.findOneFromDef('client', [ref]);
},
fetchIncoterms(refFk) {
return this.findOneFromDef('incoterms', [refFk, refFk, refFk]);
fetchIncoterms(ref) {
return this.findOneFromDef('incoterms', [ref, ref, ref]);
}
},
components: {
@ -31,9 +31,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
refFk: {
ref: {
type: [Number, String],
required: true
required: true,
description: 'The invoice ref'
}
}
};

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,5 +1,5 @@
const Component = require(`${appPath}/core/component`);
const Report = require(`${appPath}/core/report`);
const Component = require(`vn-print/core/component`);
const Report = require(`vn-print/core/report`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const invoiceIncoterms = new Report('invoice-incoterms');
@ -7,15 +7,15 @@ const invoiceIncoterms = new Report('invoice-incoterms');
module.exports = {
name: 'invoice',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.refFk);
this.client = await this.fetchClient(this.refFk);
this.taxes = await this.fetchTaxes(this.refFk);
this.intrastat = await this.fetchIntrastat(this.refFk);
this.rectified = await this.fetchRectified(this.refFk);
this.hasIncoterms = await this.fetchHasIncoterms(this.refFk);
this.invoice = await this.fetchInvoice(this.ref);
this.client = await this.fetchClient(this.ref);
this.taxes = await this.fetchTaxes(this.ref);
this.intrastat = await this.fetchIntrastat(this.ref);
this.rectified = await this.fetchRectified(this.ref);
this.hasIncoterms = await this.fetchHasIncoterms(this.ref);
const tickets = await this.fetchTickets(this.refFk);
const sales = await this.fetchSales(this.refFk);
const tickets = await this.fetchTickets(this.ref);
const sales = await this.fetchSales(this.ref);
const map = new Map();
@ -65,29 +65,29 @@ module.exports = {
}
},
methods: {
fetchInvoice(refFk) {
return this.findOneFromDef('invoice', [refFk]);
fetchInvoice(ref) {
return this.findOneFromDef('invoice', [ref]);
},
fetchClient(refFk) {
return this.findOneFromDef('client', [refFk]);
fetchClient(ref) {
return this.findOneFromDef('client', [ref]);
},
fetchTickets(refFk) {
return this.rawSqlFromDef('tickets', [refFk]);
fetchTickets(ref) {
return this.rawSqlFromDef('tickets', [ref]);
},
fetchSales(refFk) {
return this.rawSqlFromDef('sales', [refFk, refFk]);
fetchSales(ref) {
return this.rawSqlFromDef('sales', [ref, ref]);
},
fetchTaxes(refFk) {
return this.rawSqlFromDef(`taxes`, [refFk]);
fetchTaxes(ref) {
return this.rawSqlFromDef(`taxes`, [ref]);
},
fetchIntrastat(refFk) {
return this.rawSqlFromDef(`intrastat`, [refFk, refFk, refFk]);
fetchIntrastat(ref) {
return this.rawSqlFromDef(`intrastat`, [ref, ref, ref]);
},
fetchRectified(refFk) {
return this.rawSqlFromDef(`rectified`, [refFk]);
fetchRectified(ref) {
return this.rawSqlFromDef(`rectified`, [ref]);
},
fetchHasIncoterms(refFk) {
return this.findValueFromDef(`hasIncoterms`, [refFk]);
fetchHasIncoterms(ref) {
return this.findValueFromDef(`hasIncoterms`, [ref]);
},
saleImport(sale) {
const price = sale.quantity * sale.price;
@ -115,8 +115,9 @@ module.exports = {
'invoice-incoterms': invoiceIncoterms.build()
},
props: {
refFk: {
type: String
ref: {
type: String,
description: 'The invoice ref'
}
}
};

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,4 +1,4 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const qrcode = require('qrcode');
@ -6,9 +6,9 @@ const qrcode = require('qrcode');
module.exports = {
name: 'item-label',
async serverPrefetch() {
this.item = await this.fetchItem(this.itemId, this.warehouseId);
this.tags = await this.fetchItemTags(this.itemId);
this.barcode = await this.getBarcodeBase64(this.itemId);
this.item = await this.fetchItem(this.id, this.warehouseId);
this.tags = await this.fetchItemTags(this.id);
this.barcode = await this.getBarcodeBase64(this.id);
if (!this.item)
throw new Error('Something went wrong');
@ -31,16 +31,16 @@ module.exports = {
fetchItem(id, warehouseId) {
return this.findOneFromDef('item', [id, warehouseId]);
},
fetchItemTags(itemId) {
return this.rawSqlFromDef('itemTags', [itemId]).then(rows => {
fetchItemTags(id) {
return this.rawSqlFromDef('itemTags', [id]).then(rows => {
const tags = {};
rows.forEach(row => tags[row.code] = row.value);
return tags;
});
},
getBarcodeBase64(itemId) {
return qrcode.toDataURL(itemId, {margin: 0});
getBarcodeBase64(id) {
return qrcode.toDataURL(id, {margin: 0});
},
packing() {
const stems = this.item.stems ? this.item.stems : 1;
@ -52,8 +52,9 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
itemId: {
required: true
id: {
required: true,
description: 'The item id'
},
warehouseId: {
required: true

View File

@ -64,7 +64,8 @@ module.exports = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The client id'
},
companyId: {
type: [Number, String],

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([
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${appPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,22 +1,22 @@
const Component = require(`${appPath}/core/component`);
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'receipt',
async serverPrefetch() {
this.client = await this.fetchClient(this.receiptId);
this.receipt = await this.fetchReceipt(this.receiptId);
this.client = await this.fetchClient(this.id);
this.receipt = await this.fetchReceipt(this.id);
if (!this.receipt)
throw new Error('Something went wrong');
},
methods: {
fetchClient(receiptId) {
return this.findOneFromDef('client', [receiptId]);
fetchClient(id) {
return this.findOneFromDef('client', [id]);
},
fetchReceipt(receiptId) {
return this.findOneFromDef('receipt', [receiptId]);
fetchReceipt(id) {
return this.findOneFromDef('receipt', [id]);
}
},
components: {
@ -24,9 +24,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
receiptId: {
id: {
type: [Number, String],
required: true
required: true,
description: 'Receipt id'
}
}
};

View File

@ -41,7 +41,8 @@ const rptSepaCore = {
props: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The client id'
},
companyId: {
type: [Number, String],

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([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.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 reportFooter = new Component('report-footer');
module.exports = {
name: 'supplier-campaign-metrics',
async serverPrefetch() {
this.supplier = await this.fetchSupplier(this.recipientId);
let entries = await this.fetchEntries(this.recipientId, this.from, this.to);
this.supplier = await this.fetchSupplier(this.id);
let entries = await this.fetchEntries(this.id, this.from, this.to);
const entriesId = [];
@ -48,9 +48,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
recipientId: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The supplier id'
},
from: {
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([
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/report.css`,
`${appPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -1,20 +1,21 @@
module.exports = {
name: 'zone',
async serverPrefetch() {
this.zone = await this.fetchZone(this.routeId);
this.zone = await this.fetchZone(this.id);
if (!this.zone)
throw new Error('Something went wrong');
},
methods: {
fetchZone(routeId) {
return this.findOneFromDef('zone', [routeId]);
fetchZone(id) {
return this.findOneFromDef('zone', [id]);
}
},
props: {
routeId: {
id: {
type: [Number, String],
required: true
required: true,
description: 'The zone id'
}
}
};