Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4856-worker.time-control
This commit is contained in:
commit
a87e0c52d2
|
@ -10,6 +10,7 @@ RUN apt-get update \
|
||||||
curl \
|
curl \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
gnupg2 \
|
gnupg2 \
|
||||||
|
graphicsmagick \
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
|
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
|
||||||
&& apt-get install -y --no-install-recommends nodejs \
|
&& apt-get install -y --no-install-recommends nodejs \
|
||||||
&& npm install -g npm@8.19.2
|
&& npm install -g npm@8.19.2
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('previousLabel', {
|
Self.remoteMethodCtx('previousLabel', {
|
||||||
description: 'Returns the previa label pdf',
|
description: 'Returns the previa label pdf',
|
||||||
|
@ -33,17 +31,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.previousLabel = async(ctx, id) => {
|
Self.previousLabel = (ctx, id) => Self.printReport(ctx, id, 'previa-label');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('previa-label', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="previa-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
const {Report, Email} = require('vn-print');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.printReport = async function(ctx, id, reportName) {
|
||||||
|
const args = Object.assign({}, ctx.args);
|
||||||
|
const params = {lang: ctx.req.getLocale()};
|
||||||
|
|
||||||
|
delete args.ctx;
|
||||||
|
for (const param in args)
|
||||||
|
params[param] = args[param];
|
||||||
|
|
||||||
|
const report = new Report(reportName, params);
|
||||||
|
const stream = await report.toPdfStream();
|
||||||
|
|
||||||
|
let fileName = `${reportName}`;
|
||||||
|
if (id) fileName += `-${id}`;
|
||||||
|
|
||||||
|
return [stream, 'application/pdf', `filename="${fileName}.pdf"`];
|
||||||
|
};
|
||||||
|
|
||||||
|
Self.printEmail = async function(ctx, id, templateName) {
|
||||||
|
const {accessToken} = ctx.req;
|
||||||
|
const args = Object.assign({}, ctx.args);
|
||||||
|
const params = {lang: ctx.req.getLocale()};
|
||||||
|
|
||||||
|
delete args.ctx;
|
||||||
|
for (const param in args)
|
||||||
|
params[param] = args[param];
|
||||||
|
|
||||||
|
params.isPreview = true;
|
||||||
|
params.access_token = accessToken.id;
|
||||||
|
|
||||||
|
const report = new Email(templateName, params);
|
||||||
|
const html = await report.render();
|
||||||
|
|
||||||
|
let fileName = `${templateName}`;
|
||||||
|
if (id) fileName += `-${id}`;
|
||||||
|
|
||||||
|
return [html, 'text/html', `filename=${fileName}.pdf"`];
|
||||||
|
};
|
||||||
|
|
||||||
|
Self.sendTemplate = async function(ctx, templateName) {
|
||||||
|
const args = Object.assign({}, ctx.args);
|
||||||
|
const params = {
|
||||||
|
recipient: args.recipient,
|
||||||
|
lang: ctx.req.getLocale()
|
||||||
|
};
|
||||||
|
|
||||||
|
delete args.ctx;
|
||||||
|
for (const param in args)
|
||||||
|
params[param] = args[param];
|
||||||
|
|
||||||
|
const email = new Email(templateName, params);
|
||||||
|
|
||||||
|
return email.send();
|
||||||
|
};
|
||||||
|
};
|
|
@ -7,6 +7,7 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
require('../methods/vn-model/getSetValues')(Self);
|
require('../methods/vn-model/getSetValues')(Self);
|
||||||
require('../methods/vn-model/getEnumValues')(Self);
|
require('../methods/vn-model/getEnumValues')(Self);
|
||||||
|
require('../methods/vn-model/printService')(Self);
|
||||||
|
|
||||||
Object.assign(Self, {
|
Object.assign(Self, {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const { Report } = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('claimPickupPdf', {
|
Self.remoteMethodCtx('claimPickupPdf', {
|
||||||
description: 'Returns the claim pickup order pdf',
|
description: 'Returns the claim pickup order pdf',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.claimPickupPdf = async(ctx, id) => {
|
Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('claim-pickup-order', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,20 @@
|
||||||
icon="icon-ticket">
|
icon="icon-ticket">
|
||||||
</vn-quick-link>
|
</vn-quick-link>
|
||||||
</div>
|
</div>
|
||||||
<div ng-transclude="btnThree"></div>
|
<div ng-transclude="btnThree">
|
||||||
|
<vn-quick-link
|
||||||
|
tooltip="Sale tracking"
|
||||||
|
state="['ticket.card.saleTracking', {id: $ctrl.claim.ticketFk}]"
|
||||||
|
icon="assignment">
|
||||||
|
</vn-quick-link>
|
||||||
|
</div>
|
||||||
|
<div ng-transclude="btnFour">
|
||||||
|
<vn-quick-link
|
||||||
|
tooltip="Ticket tracking"
|
||||||
|
state="['ticket.card.tracking.index', {id: $ctrl.claim.ticketFk}]"
|
||||||
|
icon="icon-eye">
|
||||||
|
</vn-quick-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</slot-body>
|
</slot-body>
|
||||||
</vn-descriptor-content>
|
</vn-descriptor-content>
|
||||||
|
|
|
@ -18,3 +18,5 @@ Claim deleted!: Reclamación eliminada!
|
||||||
claim: reclamación
|
claim: reclamación
|
||||||
Photos: Fotos
|
Photos: Fotos
|
||||||
Go to the claim: Ir a la reclamación
|
Go to the claim: Ir a la reclamación
|
||||||
|
Sale tracking: Líneas preparadas
|
||||||
|
Ticket tracking: Estados del ticket
|
||||||
|
|
|
@ -51,19 +51,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.campaignMetricsEmail = async ctx => {
|
Self.campaignMetricsEmail = ctx => Self.sendTemplate(ctx, 'campaign-metrics');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {
|
|
||||||
recipient: args.recipient,
|
|
||||||
lang: ctx.req.getLocale()
|
|
||||||
};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const email = new Email('campaign-metrics', params);
|
|
||||||
|
|
||||||
return email.send();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('campaignMetricsPdf', {
|
Self.remoteMethodCtx('campaignMetricsPdf', {
|
||||||
description: 'Returns the campaign metrics pdf',
|
description: 'Returns the campaign metrics pdf',
|
||||||
|
@ -50,17 +48,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.campaignMetricsPdf = async(ctx, id) => {
|
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('campaign-metrics', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,19 +46,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientDebtStatementEmail = async ctx => {
|
Self.clientDebtStatementEmail = ctx => Self.sendTemplate(ctx, 'client-debt-statement');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('clientDebtStatementHtml', {
|
Self.remoteMethodCtx('clientDebtStatementHtml', {
|
||||||
description: 'Returns the client debt statement email preview',
|
description: 'Returns the client debt statement email preview',
|
||||||
|
@ -45,21 +43,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientDebtStatementHtml = async(ctx, id) => {
|
Self.clientDebtStatementHtml = (ctx, id) => Self.printEmail(ctx, id, 'client-debt-statement');
|
||||||
const {accessToken} = ctx.req;
|
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
params.isPreview = true;
|
|
||||||
params.access_token = accessToken.id;
|
|
||||||
|
|
||||||
const report = new Email('client-debt-statement', params);
|
|
||||||
const html = await report.render();
|
|
||||||
|
|
||||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('clientDebtStatementPdf', {
|
Self.remoteMethodCtx('clientDebtStatementPdf', {
|
||||||
description: 'Returns the client debt statement pdf',
|
description: 'Returns the client debt statement pdf',
|
||||||
|
@ -45,17 +43,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientDebtStatementPdf = async(ctx, id) => {
|
Self.clientDebtStatementPdf = (ctx, id) => Self.printReport(ctx, id, 'client-debt-statement');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('client-debt-statement', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('clientWelcomeEmail', {
|
Self.remoteMethodCtx('clientWelcomeEmail', {
|
||||||
description: 'Sends the client welcome email with an attached PDF',
|
description: 'Sends the client welcome email with an attached PDF',
|
||||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientWelcomeEmail = async ctx => {
|
Self.clientWelcomeEmail = ctx => Self.sendTemplate(ctx, 'client-welcome');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('clientWelcomeHtml', {
|
Self.remoteMethodCtx('clientWelcomeHtml', {
|
||||||
description: 'Returns the client welcome email preview',
|
description: 'Returns the client welcome email preview',
|
||||||
|
@ -40,19 +38,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientWelcomeHtml = async(ctx, id) => {
|
Self.clientWelcomeHtml = (ctx, id) => Self.printEmail(ctx, id, 'client-welcome');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('clientCreditEmail', {
|
Self.remoteMethodCtx('clientCreditEmail', {
|
||||||
description: 'Sends the credit request email with an attached PDF',
|
description: 'Sends the credit request email with an attached PDF',
|
||||||
|
@ -10,7 +8,7 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The client id',
|
description: 'The client id',
|
||||||
http: {source: 'path'}
|
http: {source: 'path'},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'recipient',
|
arg: 'recipient',
|
||||||
|
@ -22,38 +20,25 @@ module.exports = Self => {
|
||||||
arg: 'replyTo',
|
arg: 'replyTo',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The sender email to reply to',
|
description: 'The sender email to reply to',
|
||||||
required: false
|
required: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'recipientId',
|
arg: 'recipientId',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The recipient id to send to the recipient preferred language',
|
description:
|
||||||
required: false
|
'The recipient id to send to the recipient preferred language',
|
||||||
}
|
required: false,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
root: true
|
root: true,
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/credit-request-email',
|
path: '/:id/credit-request-email',
|
||||||
verb: 'POST'
|
verb: 'POST',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clientCreditEmail = async ctx => {
|
Self.clientCreditEmail = ctx => Self.sendTemplate(ctx, 'credit-request');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('creditRequestHtml', {
|
Self.remoteMethodCtx('creditRequestHtml', {
|
||||||
description: 'Returns the credit request email preview',
|
description: 'Returns the credit request email preview',
|
||||||
|
@ -40,21 +38,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.creditRequestHtml = async(ctx, id) => {
|
Self.creditRequestHtml = (ctx, id) => Self.printEmail(ctx, id, 'credit-request');
|
||||||
const {accessToken} = ctx.req;
|
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
params.isPreview = true;
|
|
||||||
params.access_token = accessToken.id;
|
|
||||||
|
|
||||||
const report = new Email('credit-request', params);
|
|
||||||
const html = await report.render();
|
|
||||||
|
|
||||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('creditRequestPdf', {
|
Self.remoteMethodCtx('creditRequestPdf', {
|
||||||
description: 'Returns the credit request pdf',
|
description: 'Returns the credit request pdf',
|
||||||
|
@ -40,17 +38,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.creditRequestPdf = async(ctx, id) => {
|
Self.creditRequestPdf = (ctx, id) => Self.printReport(ctx, id, 'credit-request');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('credit-request', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -97,7 +97,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT
|
`SELECT
|
||||||
c.id,
|
c.id,
|
||||||
c.name,
|
c.name,
|
||||||
c.socialName,
|
c.socialName,
|
||||||
|
|
|
@ -80,7 +80,7 @@ module.exports = function(Self) {
|
||||||
const data = await Self.rawSql(query, [id, date], myOptions);
|
const data = await Self.rawSql(query, [id, date], myOptions);
|
||||||
|
|
||||||
client.debt = data[0].debt;
|
client.debt = data[0].debt;
|
||||||
client.unpaid = await Self.app.models.ClientUnpaid.findOne({id}, myOptions);
|
client.unpaid = await Self.app.models.ClientUnpaid.findById(id, null, myOptions);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('incotermsAuthorizationEmail', {
|
Self.remoteMethodCtx('incotermsAuthorizationEmail', {
|
||||||
description: 'Sends the incoterms authorization email with an attached PDF',
|
description: 'Sends the incoterms authorization email with an attached PDF',
|
||||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.incotermsAuthorizationEmail = async ctx => {
|
Self.incotermsAuthorizationEmail = ctx => Self.sendTemplate(ctx, 'incoterms-authorization');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('incotermsAuthorizationHtml', {
|
Self.remoteMethodCtx('incotermsAuthorizationHtml', {
|
||||||
description: 'Returns the incoterms authorization email preview',
|
description: 'Returns the incoterms authorization email preview',
|
||||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.incotermsAuthorizationHtml = async(ctx, id) => {
|
Self.incotermsAuthorizationHtml = (ctx, id) => Self.printEmail(ctx, id, 'incoterms-authorization');
|
||||||
const {accessToken} = ctx.req;
|
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
params.isPreview = true;
|
|
||||||
params.access_token = accessToken.id;
|
|
||||||
|
|
||||||
const report = new Email('incoterms-authorization', params);
|
|
||||||
const html = await report.render();
|
|
||||||
|
|
||||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('incotermsAuthorizationPdf', {
|
Self.remoteMethodCtx('incotermsAuthorizationPdf', {
|
||||||
description: 'Returns the incoterms authorization pdf',
|
description: 'Returns the incoterms authorization pdf',
|
||||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.incotermsAuthorizationPdf = async(ctx, id) => {
|
Self.incotermsAuthorizationPdf = (ctx, id) => Self.printReport(ctx, id, 'incoterms-authorization');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('incoterms-authorization', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('letterDebtorNdEmail', {
|
Self.remoteMethodCtx('letterDebtorNdEmail', {
|
||||||
description: 'Sends the second debtor letter email with an attached PDF',
|
description: 'Sends the second debtor letter email with an attached PDF',
|
||||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.letterDebtorNdEmail = async ctx => {
|
Self.letterDebtorNdEmail = ctx => Self.sendTemplate(ctx, 'letter-debtor-nd');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('letterDebtorNdHtml', {
|
Self.remoteMethodCtx('letterDebtorNdHtml', {
|
||||||
description: 'Returns the second letter debtor email preview',
|
description: 'Returns the second letter debtor email preview',
|
||||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.letterDebtorNdHtml = async(ctx, id) => {
|
Self.letterDebtorNdHtml = (ctx, id) => Self.printEmail(ctx, id, 'letter-debtor-nd');
|
||||||
const {accessToken} = ctx.req;
|
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
params.isPreview = true;
|
|
||||||
params.access_token = accessToken.id;
|
|
||||||
|
|
||||||
const report = new Email('letter-debtor-nd', params);
|
|
||||||
const html = await report.render();
|
|
||||||
|
|
||||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('letterDebtorPdf', {
|
Self.remoteMethodCtx('letterDebtorPdf', {
|
||||||
description: 'Returns the letter debtor pdf',
|
description: 'Returns the letter debtor pdf',
|
||||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.letterDebtorPdf = async(ctx, id) => {
|
Self.letterDebtorPdf = (ctx, id) => Self.printReport(ctx, id, 'letter-debtor');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('letter-debtor', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('letterDebtorStEmail', {
|
Self.remoteMethodCtx('letterDebtorStEmail', {
|
||||||
description: 'Sends the printer setup email with an attached PDF',
|
description: 'Sends the printer setup email with an attached PDF',
|
||||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.letterDebtorStEmail = async ctx => {
|
Self.letterDebtorStEmail = ctx => Self.sendTemplate(ctx, 'letter-debtor-st');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('letterDebtorStHtml', {
|
Self.remoteMethodCtx('letterDebtorStHtml', {
|
||||||
description: 'Returns the letter debtor email preview',
|
description: 'Returns the letter debtor email preview',
|
||||||
|
@ -46,21 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.letterDebtorStHtml = async(ctx, id) => {
|
Self.letterDebtorStHtml = (ctx, id) => Self.printEmail(ctx, id, 'letter-debtor-st');
|
||||||
const {accessToken} = ctx.req;
|
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
params.isPreview = true;
|
|
||||||
params.access_token = accessToken.id;
|
|
||||||
|
|
||||||
const report = new Email('letter-debtor-st', params);
|
|
||||||
const html = await report.render();
|
|
||||||
|
|
||||||
return [html, 'text/html', `filename="mail-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('printerSetupEmail', {
|
Self.remoteMethodCtx('printerSetupEmail', {
|
||||||
description: 'Sends the printer setup email with an attached PDF',
|
description: 'Sends the printer setup email with an attached PDF',
|
||||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.printerSetupEmail = async ctx => {
|
Self.printerSetupEmail = ctx => Self.sendTemplate(ctx, 'printer-setup');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('printerSetupHtml', {
|
Self.remoteMethodCtx('printerSetupHtml', {
|
||||||
description: 'Returns the printer setup email preview',
|
description: 'Returns the printer setup email preview',
|
||||||
|
@ -40,19 +38,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.printerSetupHtml = async(ctx, id) => {
|
Self.printerSetupHtml = (ctx, id) => Self.printEmail(ctx, id, 'printer-setup');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('sepaCoreEmail', {
|
Self.remoteMethodCtx('sepaCoreEmail', {
|
||||||
description: 'Sends the campaign metrics email with an attached PDF',
|
description: 'Sends the campaign metrics email with an attached PDF',
|
||||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.sepaCoreEmail = async ctx => {
|
Self.sepaCoreEmail = ctx => Self.sendTemplate(ctx, 'sepa-core');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const { Report } = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('balanceCompensationPdf', {
|
Self.remoteMethodCtx('balanceCompensationPdf', {
|
||||||
description: 'Returns the the debit balances compensation pdf',
|
description: 'Returns the the debit balances compensation pdf',
|
||||||
|
@ -10,7 +8,7 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The receipt id',
|
description: 'The receipt id',
|
||||||
http: { source: 'path' }
|
http: {source: 'path'}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: [
|
returns: [
|
||||||
|
@ -34,17 +32,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.balanceCompensationPdf = async(ctx, id) => {
|
Self.balanceCompensationPdf = (ctx, id) => Self.printReport(ctx, id, 'balance-compensation');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('balance-compensation', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('receiptPdf', {
|
Self.remoteMethodCtx('receiptPdf', {
|
||||||
description: 'Returns the receipt pdf',
|
description: 'Returns the receipt pdf',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.receiptPdf = async(ctx, id) => {
|
Self.receiptPdf = (ctx, id) => Self.printReport(ctx, id, 'receipt');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('receipt', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,11 +70,12 @@
|
||||||
icon="icon-no036"
|
icon="icon-no036"
|
||||||
ng-if="$ctrl.client.isTaxDataChecked == false">
|
ng-if="$ctrl.client.isTaxDataChecked == false">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon-button
|
||||||
vn-tooltip="{{$ctrl.clientUnpaid()}}"
|
vn-tooltip="{{$ctrl.clientUnpaid()}}"
|
||||||
icon="icon-clientUnpaid"
|
icon="icon-clientUnpaid"
|
||||||
|
ui-sref="client.card.unpaid"
|
||||||
ng-if="$ctrl.client.unpaid">
|
ng-if="$ctrl.client.unpaid">
|
||||||
</vn-icon>
|
</vn-icon-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="quicklinks">
|
<div class="quicklinks">
|
||||||
<div ng-transclude="btnOne">
|
<div ng-transclude="btnOne">
|
||||||
|
|
|
@ -46,8 +46,9 @@ class Controller extends Descriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientUnpaid() {
|
clientUnpaid() {
|
||||||
return this.$t(`Unpaid Dated`, {dated: this.client.unpaid.dated}) +
|
return this.$t(`Unpaid`) + '<br/>'
|
||||||
'<br/>' + this.$t(`Unpaid Amount`, {amount: this.client.unpaid.amount});
|
+ this.$t(`Unpaid Dated`, {dated: this.client.unpaid.dated}) + '<br/>'
|
||||||
|
+ this.$t(`Unpaid Amount`, {amount: this.client.unpaid.amount});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form
|
<form
|
||||||
name="form"
|
name="form"
|
||||||
ng-submit="watcher.submit()"
|
ng-submit="$ctrl.onSubmit()"
|
||||||
class="vn-w-md">
|
class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Unpaid client"
|
label="Unpaid client"
|
||||||
ng-model="watcher.hasData"
|
ng-model="watcher.hasData"
|
||||||
on-change="$ctrl.setDefaultDate(watcher.hasData)">
|
on-change="$ctrl.setDefaultDate(watcher.hasData)">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
|
@ -48,4 +48,4 @@
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,9 +6,17 @@ export default class Controller extends Section {
|
||||||
if (hasData && !this.clientUnpaid.dated)
|
if (hasData && !this.clientUnpaid.dated)
|
||||||
this.clientUnpaid.dated = Date.vnNew();
|
this.clientUnpaid.dated = Date.vnNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.submit()
|
||||||
|
.then(() => this.card.reload());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnClientUnpaid', {
|
ngModule.vnComponent('vnClientUnpaid', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller
|
controller: Controller,
|
||||||
|
require: {
|
||||||
|
card: '^vnClientCard'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('entryOrderPdf', {
|
Self.remoteMethodCtx('entryOrderPdf', {
|
||||||
description: 'Returns the entry order pdf',
|
description: 'Returns the entry order pdf',
|
||||||
|
@ -38,17 +36,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.entryOrderPdf = async(ctx, id) => {
|
Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('invoiceInEmail', {
|
Self.remoteMethodCtx('invoiceInEmail', {
|
||||||
description: 'Sends the invoice in email with an attached PDF',
|
description: 'Sends the invoice in email with an attached PDF',
|
||||||
|
@ -35,19 +33,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.invoiceInEmail = async ctx => {
|
Self.invoiceInEmail = ctx => Self.sendTemplate(ctx, 'invoiceIn');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {
|
|
||||||
recipient: args.recipient,
|
|
||||||
lang: ctx.req.getLocale()
|
|
||||||
};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const email = new Email('invoiceIn', params);
|
|
||||||
|
|
||||||
return email.send();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('invoiceInPdf', {
|
Self.remoteMethodCtx('invoiceInPdf', {
|
||||||
description: 'Returns the invoiceIn pdf',
|
description: 'Returns the invoiceIn pdf',
|
||||||
|
@ -34,17 +32,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.invoiceInPdf = async(ctx, id) => {
|
Self.invoiceInPdf = (ctx, id) => Self.printReport(ctx, id, 'invoiceIn');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
delete args.ctx;
|
|
||||||
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('invoiceIn', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('exportationPdf', {
|
Self.remoteMethodCtx('exportationPdf', {
|
||||||
description: 'Returns the exportation pdf',
|
description: 'Returns the exportation pdf',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.exportationPdf = async(ctx, reference) => {
|
Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('exportation', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${reference}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
const axios = require('axios');
|
||||||
|
const uuid = require('uuid');
|
||||||
|
const fs = require('fs/promises');
|
||||||
|
const { createWriteStream } = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const gm = require('gm');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('download', {
|
||||||
|
description: 'Processes the image download queue',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
http: {
|
||||||
|
path: `/download`,
|
||||||
|
verb: 'POST',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.download = async () => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const tempContainer = await models.TempContainer.container(
|
||||||
|
'salix-image'
|
||||||
|
);
|
||||||
|
const tempPath = path.join(
|
||||||
|
tempContainer.client.root,
|
||||||
|
tempContainer.name
|
||||||
|
);
|
||||||
|
const maxAttempts = 3;
|
||||||
|
const collectionName = 'catalog';
|
||||||
|
|
||||||
|
const tx = await Self.beginTransaction({});
|
||||||
|
|
||||||
|
let tempFilePath;
|
||||||
|
let queueRow;
|
||||||
|
try {
|
||||||
|
const myOptions = { transaction: tx };
|
||||||
|
|
||||||
|
queueRow = await Self.findOne(
|
||||||
|
{
|
||||||
|
fields: ['id', 'itemFk', 'url', 'attempts'],
|
||||||
|
where: {
|
||||||
|
url: { neq: null },
|
||||||
|
attempts: {
|
||||||
|
lt: maxAttempts,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order: 'priority, attempts, updated',
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!queueRow) return;
|
||||||
|
|
||||||
|
const collection = await models.ImageCollection.findOne(
|
||||||
|
{
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'maxWidth',
|
||||||
|
'maxHeight',
|
||||||
|
'model',
|
||||||
|
'property',
|
||||||
|
],
|
||||||
|
where: { name: collectionName },
|
||||||
|
include: {
|
||||||
|
relation: 'sizes',
|
||||||
|
scope: {
|
||||||
|
fields: ['width', 'height', 'crop'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
const fileName = `${uuid.v4()}.png`;
|
||||||
|
tempFilePath = path.join(tempPath, fileName);
|
||||||
|
|
||||||
|
// Insert image row
|
||||||
|
await models.Image.create(
|
||||||
|
{
|
||||||
|
name: fileName,
|
||||||
|
collectionFk: collectionName,
|
||||||
|
updated: Date.vnNow(),
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update item
|
||||||
|
const model = models[collection.model];
|
||||||
|
if (!model) throw new Error('No matching model found');
|
||||||
|
|
||||||
|
const item = await model.findById(queueRow.itemFk, null, myOptions);
|
||||||
|
if (item) {
|
||||||
|
await item.updateAttribute(
|
||||||
|
collection.property,
|
||||||
|
fileName,
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download remote image
|
||||||
|
const response = await axios.get(queueRow.url, {
|
||||||
|
responseType: 'stream',
|
||||||
|
});
|
||||||
|
|
||||||
|
const writeStream = createWriteStream(tempFilePath);
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
writeStream.on('open', () => response.data.pipe(writeStream));
|
||||||
|
writeStream.on('finish', () => resolve());
|
||||||
|
writeStream.on('error', error => reject(error));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Resize
|
||||||
|
const container = await models.ImageContainer.container(
|
||||||
|
collectionName
|
||||||
|
);
|
||||||
|
const rootPath = container.client.root;
|
||||||
|
const collectionDir = path.join(rootPath, collectionName);
|
||||||
|
|
||||||
|
// To max size
|
||||||
|
const { maxWidth, maxHeight } = collection;
|
||||||
|
const fullSizePath = path.join(collectionDir, 'full');
|
||||||
|
const toFullSizePath = `${fullSizePath}/${fileName}`;
|
||||||
|
|
||||||
|
await fs.mkdir(fullSizePath, { recursive: true });
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
gm(tempFilePath)
|
||||||
|
.resize(maxWidth, maxHeight, '>')
|
||||||
|
.setFormat('png')
|
||||||
|
.write(toFullSizePath, function (err) {
|
||||||
|
if (err) reject(err);
|
||||||
|
if (!err) resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// To collection sizes
|
||||||
|
for (const size of collection.sizes()) {
|
||||||
|
const { width, height } = size;
|
||||||
|
|
||||||
|
const sizePath = path.join(collectionDir, `${width}x${height}`);
|
||||||
|
const toSizePath = `${sizePath}/${fileName}`;
|
||||||
|
|
||||||
|
await fs.mkdir(sizePath, { recursive: true });
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
const gmInstance = gm(tempFilePath);
|
||||||
|
|
||||||
|
if (size.crop) {
|
||||||
|
gmInstance
|
||||||
|
.resize(width, height, '^')
|
||||||
|
.gravity('Center')
|
||||||
|
.crop(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!size.crop) gmInstance.resize(width, height, '>');
|
||||||
|
|
||||||
|
gmInstance
|
||||||
|
.setFormat('png')
|
||||||
|
.write(toSizePath, function (err) {
|
||||||
|
if (err) reject(err);
|
||||||
|
if (!err) resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.unlink(tempFilePath);
|
||||||
|
} catch (error) { }
|
||||||
|
|
||||||
|
await queueRow.destroy(myOptions);
|
||||||
|
|
||||||
|
// Restart queue
|
||||||
|
Self.download();
|
||||||
|
|
||||||
|
await tx.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await tx.rollback();
|
||||||
|
|
||||||
|
if (queueRow.attempts < maxAttempts) {
|
||||||
|
await queueRow.updateAttributes({
|
||||||
|
error: error,
|
||||||
|
attempts: queueRow.attempts + 1,
|
||||||
|
updated: Date.vnNew(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.unlink(tempFilePath);
|
||||||
|
} catch (error) { }
|
||||||
|
|
||||||
|
Self.download();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -62,7 +62,7 @@ module.exports = Self => {
|
||||||
writeStream.on('open', () => response.pipe(writeStream));
|
writeStream.on('open', () => response.pipe(writeStream));
|
||||||
writeStream.on('error', async error =>
|
writeStream.on('error', async error =>
|
||||||
await errorHandler(image.itemFk, error, filePath));
|
await errorHandler(image.itemFk, error, filePath));
|
||||||
writeStream.on('finish', writeStream.end());
|
writeStream.on('finish', () => writeStream.end());
|
||||||
|
|
||||||
writeStream.on('close', async function() {
|
writeStream.on('close', async function() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('labelPdf', {
|
Self.remoteMethodCtx('labelPdf', {
|
||||||
description: 'Returns the item label pdf',
|
description: 'Returns the item label pdf',
|
||||||
|
@ -56,17 +54,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.labelPdf = async(ctx, id) => {
|
Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('item-label', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="item-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/item-image-queue/downloadImages')(Self);
|
require('../methods/item-image-queue/download')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('driverRouteEmail', {
|
Self.remoteMethodCtx('driverRouteEmail', {
|
||||||
description: 'Sends the driver route email with an attached PDF',
|
description: 'Sends the driver route email with an attached PDF',
|
||||||
|
@ -41,19 +39,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.driverRouteEmail = async ctx => {
|
Self.driverRouteEmail = ctx => Self.sendTemplate(ctx, 'driver-route');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('driverRoutePdf', {
|
Self.remoteMethodCtx('driverRoutePdf', {
|
||||||
description: 'Returns the driver route pdf',
|
description: 'Returns the driver route pdf',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.driverRoutePdf = async(ctx, id) => {
|
Self.driverRoutePdf = (ctx, id) => Self.printReport(ctx, id, 'driver-route');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('campaignMetricsPdf', {
|
Self.remoteMethodCtx('campaignMetricsPdf', {
|
||||||
description: 'Returns the campaign metrics pdf',
|
description: 'Returns the campaign metrics pdf',
|
||||||
|
@ -49,17 +47,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.campaignMetricsPdf = async(ctx, id) => {
|
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('collectionLabel', {
|
Self.remoteMethodCtx('collectionLabel', {
|
||||||
description: 'Returns the collection label',
|
description: 'Returns the collection label',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.collectionLabel = async(ctx, id) => {
|
Self.collectionLabel = (ctx, id) => Self.printReport(ctx, id, 'collection-label');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('collection-label', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('deliveryNoteEmail', {
|
Self.remoteMethodCtx('deliveryNoteEmail', {
|
||||||
description: 'Sends the delivery note email with an attached PDF',
|
description: 'Sends the delivery note email with an attached PDF',
|
||||||
|
@ -47,19 +45,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deliveryNoteEmail = async ctx => {
|
Self.deliveryNoteEmail = ctx => Self.sendTemplate(ctx, 'delivery-note');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {
|
|
||||||
recipient: args.recipient,
|
|
||||||
lang: ctx.req.getLocale()
|
|
||||||
};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const email = new Email('delivery-note', params);
|
|
||||||
|
|
||||||
return email.send();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('deliveryNotePdf', {
|
Self.remoteMethodCtx('deliveryNotePdf', {
|
||||||
description: 'Returns the delivery note pdf',
|
description: 'Returns the delivery note pdf',
|
||||||
|
@ -46,17 +44,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deliveryNotePdf = async(ctx, id) => {
|
Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('delivery-note', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('expeditionPalletLabel', {
|
Self.remoteMethodCtx('expeditionPalletLabel', {
|
||||||
description: 'Returns the expedition pallet label',
|
description: 'Returns the expedition pallet label',
|
||||||
|
@ -39,17 +37,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.expeditionPalletLabel = async(ctx, id) => {
|
Self.expeditionPalletLabel = (ctx, id) => Self.printReport(ctx, id, 'expedition-pallet-label');
|
||||||
const args = Object.assign({}, ctx.args);
|
|
||||||
const params = {lang: ctx.req.getLocale()};
|
|
||||||
|
|
||||||
delete args.ctx;
|
|
||||||
for (const param in args)
|
|
||||||
params[param] = args[param];
|
|
||||||
|
|
||||||
const report = new Report('expedition-pallet-label', params);
|
|
||||||
const stream = await report.toPdfStream();
|
|
||||||
|
|
||||||
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Email} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('extraCommunityEmail', {
|
Self.remoteMethodCtx('extraCommunityEmail', {
|
||||||
description: 'Sends the extra community email with an attached PDF',
|
description: 'Sends the extra community email with an attached PDF',
|
||||||
|
@ -74,19 +72,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.extraCommunityEmail = async ctx => {
|
Self.extraCommunityEmail = ctx => Self.sendTemplate(ctx, 'extra-community');
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const {Report} = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('extraCommunityPdf', {
|
Self.remoteMethodCtx('extraCommunityPdf', {
|
||||||
description: 'Returns the extra community pdf',
|
description: 'Returns the extra community pdf',
|
||||||
|
@ -11,6 +9,16 @@ module.exports = Self => {
|
||||||
description: 'The recipient id',
|
description: 'The recipient id',
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'search',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Searchs the travel by id'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'landedTo',
|
arg: 'landedTo',
|
||||||
type: 'date'
|
type: 'date'
|
||||||
|
@ -73,17 +81,5 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.extraCommunityPdf = async ctx => {
|
Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community');
|
||||||
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"`];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="Travels/extraCommunityFilter"
|
url="Travels/extraCommunityFilter"
|
||||||
filter="::$ctrl.filter"
|
user-params="::$ctrl.defaultFilter"
|
||||||
data="travels"
|
data="travels"
|
||||||
order="shipped ASC, landed ASC, travelFk, loadPriority, agencyModeFk, evaNotes"
|
order="shipped ASC, landed ASC, travelFk, loadPriority, agencyModeFk, evaNotes"
|
||||||
limit="20"
|
limit="20"
|
||||||
|
|
|
@ -141,8 +141,11 @@ class Controller extends Section {
|
||||||
|
|
||||||
get reportParams() {
|
get reportParams() {
|
||||||
const userParams = this.$.model.userParams;
|
const userParams = this.$.model.userParams;
|
||||||
|
const currentFilter = this.$.model.currentFilter;
|
||||||
|
|
||||||
return Object.assign({
|
return Object.assign({
|
||||||
authorization: this.vnToken.token
|
authorization: this.vnToken.token,
|
||||||
|
filter: currentFilter
|
||||||
}, userParams);
|
}, userParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,20 @@ export default class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get ibanCountry() {
|
||||||
|
if (!this.worker || !this.worker.iban) return false;
|
||||||
|
|
||||||
|
let countryCode = this.worker.iban.substr(0, 2);
|
||||||
|
|
||||||
|
return countryCode;
|
||||||
|
}
|
||||||
|
|
||||||
autofillBic() {
|
autofillBic() {
|
||||||
if (!this.worker || !this.worker.iban) return;
|
if (!this.worker || !this.worker.iban) return;
|
||||||
|
|
||||||
let bankEntityId = parseInt(this.worker.iban.substr(4, 4));
|
let bankEntityId = parseInt(this.worker.iban.substr(4, 4));
|
||||||
let filter = {where: {id: bankEntityId}};
|
let filter = {where: {id: bankEntityId}};
|
||||||
|
|
||||||
if (this.ibanCountry != 'ES') return;
|
|
||||||
|
|
||||||
this.$http.get(`BankEntities`, {filter}).then(response => {
|
this.$http.get(`BankEntities`, {filter}).then(response => {
|
||||||
const hasData = response.data && response.data[0];
|
const hasData = response.data && response.data[0];
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
"inflation": {
|
"inflation": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"m3Max": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"itemMaxSize": {
|
"itemMaxSize": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,21 @@
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
vn-one
|
vn-one
|
||||||
label="Maximum m³"
|
label="Max m³"
|
||||||
ng-model="$ctrl.zone.itemMaxSize"
|
ng-model="$ctrl.zone.itemMaxSize"
|
||||||
min="0"
|
min="0"
|
||||||
step="0.01"
|
vn-acl="deliveryBoss"
|
||||||
vn-acl="deliveryBoss"
|
rule>
|
||||||
rule>
|
</vn-input-number>
|
||||||
</vn-input-number>
|
<vn-input-number
|
||||||
|
vn-one
|
||||||
|
label="Maximum m³"
|
||||||
|
ng-model="$ctrl.zone.m3Max"
|
||||||
|
min="0"
|
||||||
|
vn-acl="deliveryBoss"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
|
|
|
@ -13,6 +13,7 @@ Indefinitely: Indefinido
|
||||||
Inflation: Inflación
|
Inflation: Inflación
|
||||||
Locations: Localizaciones
|
Locations: Localizaciones
|
||||||
Maximum m³: M³ máximo
|
Maximum m³: M³ máximo
|
||||||
|
Max m³: Medida máxima
|
||||||
New zone: Nueva zona
|
New zone: Nueva zona
|
||||||
One day: Un día
|
One day: Un día
|
||||||
Pick up: Recogida
|
Pick up: Recogida
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^5.0.0",
|
||||||
"ftps": "^1.2.0",
|
"ftps": "^1.2.0",
|
||||||
|
"gm": "^1.25.0",
|
||||||
"got": "^10.7.0",
|
"got": "^10.7.0",
|
||||||
"helmet": "^3.21.2",
|
"helmet": "^3.21.2",
|
||||||
"i18n": "^0.8.4",
|
"i18n": "^0.8.4",
|
||||||
|
@ -3625,6 +3626,16 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/array-parallel": {
|
||||||
|
"version": "0.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-parallel/-/array-parallel-0.1.3.tgz",
|
||||||
|
"integrity": "sha512-TDPTwSWW5E4oiFiKmz6RGJ/a80Y91GuLgUYuLd49+XBS75tYo8PNgaT2K/OxuQYqkoI852MDGBorg9OcUSTQ8w=="
|
||||||
|
},
|
||||||
|
"node_modules/array-series": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-series/-/array-series-0.1.5.tgz",
|
||||||
|
"integrity": "sha512-L0XlBwfx9QetHOsbLDrE/vh2t018w9462HM3iaFfxRiK83aJjAt/Ja3NMkOW7FICwWTlQBa3ZbL5FKhuQWkDrg=="
|
||||||
|
},
|
||||||
"node_modules/array-slice": {
|
"node_modules/array-slice": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -9284,6 +9295,67 @@
|
||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/gm": {
|
||||||
|
"version": "1.25.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/gm/-/gm-1.25.0.tgz",
|
||||||
|
"integrity": "sha512-4kKdWXTtgQ4biIo7hZA396HT062nDVVHPjQcurNZ3o/voYN+o5FUC5kOwuORbpExp3XbTJ3SU7iRipiIhQtovw==",
|
||||||
|
"dependencies": {
|
||||||
|
"array-parallel": "~0.1.3",
|
||||||
|
"array-series": "~0.1.5",
|
||||||
|
"cross-spawn": "^4.0.0",
|
||||||
|
"debug": "^3.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/cross-spawn": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^4.0.1",
|
||||||
|
"which": "^1.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/debug": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/lru-cache": {
|
||||||
|
"version": "4.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||||
|
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
|
||||||
|
"dependencies": {
|
||||||
|
"pseudomap": "^1.0.2",
|
||||||
|
"yallist": "^2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/ms": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/which": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"isexe": "^2.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"which": "bin/which"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/gm/node_modules/yallist": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A=="
|
||||||
|
},
|
||||||
"node_modules/google-auth-library": {
|
"node_modules/google-auth-library": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
@ -28673,6 +28745,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"array-parallel": {
|
||||||
|
"version": "0.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-parallel/-/array-parallel-0.1.3.tgz",
|
||||||
|
"integrity": "sha512-TDPTwSWW5E4oiFiKmz6RGJ/a80Y91GuLgUYuLd49+XBS75tYo8PNgaT2K/OxuQYqkoI852MDGBorg9OcUSTQ8w=="
|
||||||
|
},
|
||||||
|
"array-series": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-series/-/array-series-0.1.5.tgz",
|
||||||
|
"integrity": "sha512-L0XlBwfx9QetHOsbLDrE/vh2t018w9462HM3iaFfxRiK83aJjAt/Ja3NMkOW7FICwWTlQBa3ZbL5FKhuQWkDrg=="
|
||||||
|
},
|
||||||
"array-slice": {
|
"array-slice": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -32611,6 +32693,63 @@
|
||||||
"sparkles": "^1.0.0"
|
"sparkles": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"gm": {
|
||||||
|
"version": "1.25.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/gm/-/gm-1.25.0.tgz",
|
||||||
|
"integrity": "sha512-4kKdWXTtgQ4biIo7hZA396HT062nDVVHPjQcurNZ3o/voYN+o5FUC5kOwuORbpExp3XbTJ3SU7iRipiIhQtovw==",
|
||||||
|
"requires": {
|
||||||
|
"array-parallel": "~0.1.3",
|
||||||
|
"array-series": "~0.1.5",
|
||||||
|
"cross-spawn": "^4.0.0",
|
||||||
|
"debug": "^3.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==",
|
||||||
|
"requires": {
|
||||||
|
"lru-cache": "^4.0.1",
|
||||||
|
"which": "^1.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lru-cache": {
|
||||||
|
"version": "4.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||||
|
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
|
||||||
|
"requires": {
|
||||||
|
"pseudomap": "^1.0.2",
|
||||||
|
"yallist": "^2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
|
},
|
||||||
|
"which": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||||
|
"requires": {
|
||||||
|
"isexe": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"yallist": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"google-auth-library": {
|
"google-auth-library": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^5.0.0",
|
||||||
"ftps": "^1.2.0",
|
"ftps": "^1.2.0",
|
||||||
|
"gm": "^1.25.0",
|
||||||
"got": "^10.7.0",
|
"got": "^10.7.0",
|
||||||
"helmet": "^3.21.2",
|
"helmet": "^3.21.2",
|
||||||
"i18n": "^0.8.4",
|
"i18n": "^0.8.4",
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<td>{{entry.supplierName}}</td>
|
<td>{{entry.supplierName}}</td>
|
||||||
<td>{{entry.reference}}</td>
|
<td>{{entry.reference}}</td>
|
||||||
<td class="number">{{entry.volumeKg | number($i18n.locale)}}</td>
|
<td class="number">{{entry.volumeKg | number($i18n.locale)}}</td>
|
||||||
<td class="number">{{entry.loadedKg | number($i18n.locale)}}</td>
|
<td class="number">{{entry.loadedkg | number($i18n.locale)}}</td>
|
||||||
<td class="number">{{entry.stickers}}</td>
|
<td class="number">{{entry.stickers}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="!travel.entries">
|
<tr v-if="!travel.entries">
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
const vnReport = require('../../../core/mixins/vn-report.js');
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const db = require(`vn-print/core/database`);
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'extra-community',
|
name: 'extra-community',
|
||||||
mixins: [vnReport],
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
const args = {
|
const args = {
|
||||||
|
search: this.search,
|
||||||
landedTo: this.landedEnd,
|
landedTo: this.landedEnd,
|
||||||
shippedFrom: this.shippedStart,
|
shippedFrom: this.shippedStart,
|
||||||
continent: this.continent,
|
continent: this.continent,
|
||||||
|
@ -17,76 +18,24 @@ module.exports = {
|
||||||
ref: this.ref,
|
ref: this.ref,
|
||||||
cargoSupplierFk: this.cargoSupplierFk
|
cargoSupplierFk: this.cargoSupplierFk
|
||||||
};
|
};
|
||||||
|
const ctx = {args: args};
|
||||||
const travels = await this.fetchTravels(args);
|
this.travels = await app.models.Travel.extraCommunityFilter(ctx, this.filter);
|
||||||
this.checkMainEntity(travels);
|
|
||||||
const travelIds = travels.map(travel => travel.id);
|
|
||||||
const entries = await this.rawSqlFromDef('entries', [travelIds]);
|
|
||||||
|
|
||||||
const map = new Map();
|
|
||||||
for (let travel of travels)
|
|
||||||
map.set(travel.id, travel);
|
|
||||||
|
|
||||||
for (let entry of entries) {
|
|
||||||
const travel = map.get(entry.travelFk);
|
|
||||||
if (!travel.entries) travel.entries = [];
|
|
||||||
travel.entries.push(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.travels = travels;
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
landedEnd: function() {
|
landedEnd: function() {
|
||||||
if (!this.landedTo) return;
|
if (!this.landedTo) return;
|
||||||
return formatDate(this.landedTo, '%Y-%m-%d');
|
return this.formatDate(this.landedTo, '%Y-%m-%d');
|
||||||
},
|
},
|
||||||
shippedStart: function() {
|
shippedStart: function() {
|
||||||
if (!this.shippedFrom) return;
|
if (!this.shippedFrom) return;
|
||||||
return formatDate(this.shippedFrom, '%Y-%m-%d');
|
return this.formatDate(this.shippedFrom, '%Y-%m-%d');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchTravels(args) {
|
|
||||||
const where = db.buildWhere(args, (key, value) => {
|
|
||||||
switch (key) {
|
|
||||||
case 'shippedFrom':
|
|
||||||
return `t.shipped >= ${value}`;
|
|
||||||
case 'landedTo':
|
|
||||||
return `t.landed <= ${value}`;
|
|
||||||
case 'continent':
|
|
||||||
return `cnt.code = ${value}`;
|
|
||||||
case 'ref':
|
|
||||||
return {'t.ref': {like: `%${value}%`}};
|
|
||||||
case 'id':
|
|
||||||
return `t.id = ${value}`;
|
|
||||||
case 'agencyModeFk':
|
|
||||||
return `am.id = ${value}`;
|
|
||||||
case 'warehouseOutFk':
|
|
||||||
return `wo.id = ${value}`;
|
|
||||||
case 'warehouseInFk':
|
|
||||||
return `w.id = ${value}`;
|
|
||||||
case 'cargoSupplierFk':
|
|
||||||
return `s.id = ${value}`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
|
||||||
`);
|
|
||||||
|
|
||||||
return this.rawSql(query);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
props: [
|
props: [
|
||||||
|
'filter',
|
||||||
|
'search',
|
||||||
'landedTo',
|
'landedTo',
|
||||||
'shippedFrom',
|
'shippedFrom',
|
||||||
'continent',
|
'continent',
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
SELECT
|
|
||||||
e.id,
|
|
||||||
e.travelFk,
|
|
||||||
e.reference,
|
|
||||||
s.name AS supplierName,
|
|
||||||
SUM(b.stickers) AS stickers,
|
|
||||||
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
|
|
||||||
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg
|
|
||||||
FROM travel t
|
|
||||||
JOIN entry e ON e.travelFk = t.id
|
|
||||||
JOIN buy b ON b.entryFk = e.id
|
|
||||||
JOIN packaging pkg ON pkg.id = b.packageFk
|
|
||||||
JOIN item i ON i.id = b.itemFk
|
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
|
||||||
JOIN vn.volumeConfig vc
|
|
||||||
WHERE t.id IN(?)
|
|
||||||
GROUP BY e.id
|
|
|
@ -1,23 +0,0 @@
|
||||||
SELECT
|
|
||||||
t.id,
|
|
||||||
t.ref,
|
|
||||||
t.shipped,
|
|
||||||
t.landed,
|
|
||||||
t.kg,
|
|
||||||
am.id AS agencyModeFk,
|
|
||||||
SUM(b.stickers) AS stickers,
|
|
||||||
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
|
|
||||||
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg
|
|
||||||
FROM travel t
|
|
||||||
JOIN volumeConfig vc
|
|
||||||
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
|
|
||||||
LEFT JOIN entry e ON e.travelFk = t.id
|
|
||||||
LEFT JOIN buy b ON b.entryFk = e.id
|
|
||||||
LEFT JOIN packaging pkg ON pkg.id = b.packageFk
|
|
||||||
LEFT JOIN item i ON i.id = b.itemFk
|
|
||||||
LEFT JOIN itemType it ON it.id = i.typeFk
|
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
|
||||||
JOIN warehouse wo ON wo.id = t.warehouseOutFk
|
|
||||||
JOIN country c ON c.id = wo.countryFk
|
|
||||||
LEFT JOIN continent cnt ON cnt.id = c.continentFk
|
|
||||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
|
Loading…
Reference in New Issue