+
\ No newline at end of file
diff --git a/print/core/components/attachment/attachment.js b/print/core/components/attachment/attachment.js
index 5c78a895c..30e1944a4 100755
--- a/print/core/components/attachment/attachment.js
+++ b/print/core/components/attachment/attachment.js
@@ -4,10 +4,10 @@ module.exports = {
attachmentPath() {
const filename = this.attachment.filename;
const component = this.attachment.component;
- if (this.attachment.cid)
+ if (this.attachment.cid && component)
return `/api/${component}/assets/files/${filename}`;
- else
- return `/api/report/${component}?${this.getHttpParams()}`;
+ else if (this.attachment.path)
+ return `/api/${this.attachment.path}?${this.getHttpParams()}`;
}
},
methods: {
@@ -15,7 +15,7 @@ module.exports = {
const props = this.args;
let query = '';
for (let param in props) {
- if (!(props[param] instanceof Object)) {
+ if (props[param] && !(props[param] instanceof Object)) {
if (query != '') query += '&';
query += `${param}=${props[param]}`;
}
diff --git a/print/core/components/email-footer/assets/css/import.js b/print/core/components/email-footer/assets/css/import.js
index c742fdf90..4f6f631f7 100644
--- a/print/core/components/email-footer/assets/css/import.js
+++ b/print/core/components/email-footer/assets/css/import.js
@@ -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/email.css`,
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`])
- .mergeStyles();
+ .mergeStyles();
\ No newline at end of file
diff --git a/print/core/components/email-header/assets/css/import.js b/print/core/components/email-header/assets/css/import.js
index c742fdf90..4f6f631f7 100644
--- a/print/core/components/email-header/assets/css/import.js
+++ b/print/core/components/email-header/assets/css/import.js
@@ -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/email.css`,
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`])
- .mergeStyles();
+ .mergeStyles();
\ No newline at end of file
diff --git a/print/core/components/report-footer/assets/css/import.js b/print/core/components/report-footer/assets/css/import.js
index a2a9334cb..71fa00f4b 100644
--- a/print/core/components/report-footer/assets/css/import.js
+++ b/print/core/components/report-footer/assets/css/import.js
@@ -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/layout.css`,
- `${appPath}/common/css/report.css`,
- `${appPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/report.css`,
+ `${vnPrintPath}/common/css/misc.css`,
`${__dirname}/style.css`])
- .mergeStyles();
+ .mergeStyles();
\ No newline at end of file
diff --git a/print/core/components/report-header/assets/css/import.js b/print/core/components/report-header/assets/css/import.js
index a2a9334cb..e21d3821a 100644
--- a/print/core/components/report-header/assets/css/import.js
+++ b/print/core/components/report-header/assets/css/import.js
@@ -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/layout.css`,
- `${appPath}/common/css/report.css`,
- `${appPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/report.css`,
+ `${vnPrintPath}/common/css/misc.css`,
`${__dirname}/style.css`])
.mergeStyles();
diff --git a/print/core/database.js b/print/core/database.js
index 6c690afc6..0e81806f2 100644
--- a/print/core/database.js
+++ b/print/core/database.js
@@ -1,21 +1,22 @@
const mysql = require('mysql2');
const config = require('./config.js');
const fs = require('fs-extra');
-const PoolConnection = mysql.PoolConnection;
module.exports = {
- init() {
- if (!this.pool) {
- const datasources = config.datasources;
- const pool = mysql.createPoolCluster();
+ defaultDataSource: 'vn',
- for (let datasource of datasources)
- pool.add(datasource.name, datasource.options);
+ init(dataSource) {
+ if (!this.connections) {
+ this.connections = [];
- this.pool = pool;
+ const dataSources = ['vn', 'osticket'];
+ for (const name of dataSources)
+ this.connections[name] = dataSource[name].connector.client;
+
+ this.pool = this.connections[this.defaultDataSource];
}
- return this.pool;
+ return this.connections;
},
/**
@@ -24,15 +25,8 @@ module.exports = {
*
* @return {Object} - Pool connection
*/
- getConnection(name = 'default') {
- let pool = this.pool;
- return new Promise((resolve, reject) => {
- pool.getConnection(name, function(error, connection) {
- if (error) return reject(error);
-
- resolve(connection);
- });
- });
+ getConnection(name = this.defaultDataSource) {
+ return this.connections[name];
},
/**
@@ -44,28 +38,14 @@ module.exports = {
* @return {Object} - Result promise
*/
rawSql(query, params, connection) {
- let pool = this.pool;
- if (params instanceof PoolConnection)
- connection = params;
- if (connection) pool = connection;
-
return new Promise((resolve, reject) => {
- if (!connection) {
- pool.getConnection('default', function(error, conn) {
- if (error) return reject(error);
+ let db = this.getConnection();
+ if (connection) db = connection;
- conn.query(query, params, (error, rows) => {
- if (error) return reject(error);
- conn.release();
- resolve(rows);
- });
- });
- } else {
- connection.query(query, params, (error, rows) => {
- if (error) return reject(error);
- resolve(rows);
- });
- }
+ db.query(query, params, (error, rows) => {
+ if (error) return reject(error);
+ resolve(rows);
+ });
});
},
@@ -87,22 +67,25 @@ module.exports = {
* Returns the first row from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
+ * @param {Object} connection - Optional pool connection
*
* @return {Object} - Result promise
*/
- findOne(query, params) {
- return this.rawSql(query, params).then(([row]) => row);
+ findOne(query, params, connection) {
+ return this.rawSql(query, params, connection)
+ .then(([row]) => row);
},
/**
* Returns the first row from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
+ * @param {Object} connection - Optional pool connection
*
* @return {Object} - Result promise
*/
- findOneFromDef(queryName, params) {
- return this.rawSqlFromDef(queryName, params)
+ findOneFromDef(queryName, params, connection) {
+ return this.rawSqlFromDef(queryName, params, connection)
.then(([row]) => row);
},
@@ -110,11 +93,12 @@ module.exports = {
* Returns the first property from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
+ * @param {Object} connection - Optional pool connection
*
* @return {Object} - Result promise
*/
- findValue(query, params) {
- return this.findOne(query, params).then(row => {
+ findValue(query, params, connection) {
+ return this.findOne(query, params, connection).then(row => {
return Object.values(row)[0];
});
},
@@ -123,13 +107,13 @@ module.exports = {
* Returns the first property from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
+ * @param {Object} connection - Optional pool connection
*
* @return {Object} - Result promise
*/
- findValueFromDef(queryName, params) {
- return this.findOneFromDef(queryName, params).then(row => {
- return Object.values(row)[0];
- });
+ findValueFromDef(queryName, params, connection) {
+ return this.findOneFromDef(queryName, params, connection)
+ .then(row => Object.values(row)[0]);
},
/**
diff --git a/print/core/directives/index.js b/print/core/directives/index.js
deleted file mode 100644
index 3ba4d8895..000000000
--- a/print/core/directives/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// Import global directives
-require('./pin');
diff --git a/print/core/directives/pin.js b/print/core/directives/pin.js
deleted file mode 100644
index bf4bb6e6e..000000000
--- a/print/core/directives/pin.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// DIRECTIVES NOT WORKING
-const Vue = require('vue');
-Vue.directive('pin', {
- bind: function(el, binding, vnode) {
- el.style.position = 'fixed';
- el.style.top = binding.value + 'px';
- el.style.backgroundColor = 'red';
- }
-});
diff --git a/print/core/email.js b/print/core/email.js
index bc8345cab..0184e360c 100644
--- a/print/core/email.js
+++ b/print/core/email.js
@@ -1,6 +1,5 @@
const path = require('path');
const smtp = require('./smtp');
-const config = require('./config');
const Component = require('./component');
const Report = require('./report');
@@ -73,10 +72,9 @@ class Email extends Component {
}
const localeSubject = await this.getSubject();
- const replyTo = this.args.replyTo || this.args.auth.email;
const mailOptions = {
to: this.args.recipient,
- replyTo: replyTo,
+ replyTo: this.args.replyTo || '',
subject: localeSubject,
html: rendered,
attachments: attachments
diff --git a/print/core/mixins/prop-validator.js b/print/core/mixins/prop-validator.js
index 16c71a6db..cb41d3dd8 100644
--- a/print/core/mixins/prop-validator.js
+++ b/print/core/mixins/prop-validator.js
@@ -4,7 +4,7 @@ const validator = {
const props = this.$options.props;
const invalidProps = [];
- for (prop in props) {
+ for (const prop in props) {
const isObject = typeof props[prop] === 'object';
const isRequired = props[prop].required;
const isNotDefined = this[prop] === undefined;
@@ -19,7 +19,7 @@ const validator = {
throw new Error(`Required properties not found [${required}]`);
}
},
- props: ['isPreview', 'authorization']
+ props: ['isPreview', 'access_token']
};
Vue.mixin(validator);
diff --git a/print/core/mixins/user-locale.js b/print/core/mixins/user-locale.js
index 0e4727334..18b4c68c5 100644
--- a/print/core/mixins/user-locale.js
+++ b/print/core/mixins/user-locale.js
@@ -24,7 +24,7 @@ const userLocale = {
});
}
},
- props: ['auth', 'recipientId']
+ props: ['recipientId']
};
Vue.mixin(userLocale);
diff --git a/print/core/router.js b/print/core/router.js
deleted file mode 100644
index cd64ba07e..000000000
--- a/print/core/router.js
+++ /dev/null
@@ -1,62 +0,0 @@
-const db = require('./database');
-
-module.exports = app => {
- const routes = require('../methods/routes');
-
- const paths = routes.map(route => route.url);
-
- app.use(paths, async function(request, response, next) {
- try {
- const token = getToken(request);
- const query = `SELECT at.id, at.userId, eu.email, u.lang, at.ttl, at.created
- FROM salix.AccessToken at
- JOIN account.user u ON u.id = at.userid
- JOIN account.emailUser eu ON eu.userFk = u.id
- WHERE at.id = ?`;
-
- const auth = await db.findOne(query, [token]);
-
- if (!auth || isTokenExpired(auth.created, auth.ttl))
- throw new Error('Invalid authorization token');
-
- const args = Object.assign({}, request.query);
- const props = Object.assign(args, request.body);
- props.authorization = auth.id;
-
- response.locals = props;
- response.locals.auth = {
- userId: auth.userId,
- token: auth.id,
- email: auth.email,
- locale: auth.lang
- };
-
- next();
- } catch (error) {
- next(error);
- }
- });
-
- // Register routes
- for (let route of routes)
- app.use(route.url, route.cb);
-
- function getToken(request) {
- const headers = request.headers;
- const queryParams = request.query;
-
- return headers.authorization || queryParams.authorization;
- }
-
- function isTokenExpired(created, ttl) {
- const date = new Date(created);
- const currentDate = new Date();
-
- date.setSeconds(date.getSeconds() + ttl);
-
- if (currentDate > date)
- return true;
-
- return false;
- }
-};
diff --git a/print/core/stylesheet.js b/print/core/stylesheet.js
index 42a44fb57..195044f02 100644
--- a/print/core/stylesheet.js
+++ b/print/core/stylesheet.js
@@ -1,4 +1,5 @@
const fs = require('fs-extra');
+const path = require('path');
class Stylesheet {
constructor(files) {
@@ -7,8 +8,9 @@ class Stylesheet {
}
mergeStyles() {
- for (const file of this.files)
+ for (const file of this.files) {
this.css.push(fs.readFileSync(file));
+ }
return this.css.join('\n');
}
diff --git a/print/index.js b/print/index.js
new file mode 100644
index 000000000..484aba00e
--- /dev/null
+++ b/print/index.js
@@ -0,0 +1,48 @@
+const express = require('express');
+const path = require('path');
+const fs = require('fs');
+
+const templatesPath = path.resolve(__dirname, './templates');
+const componentsPath = path.resolve(__dirname, './core/components');
+
+module.exports = {
+ async boot(app) {
+ // Init database instance
+
+ require('./core/database').init(app.dataSources);
+ require('./core/smtp').init();
+ require('./core/mixins');
+ require('./core/filters');
+
+ const componentsDir = fs.readdirSync(componentsPath);
+ componentsDir.forEach(componentName => {
+ const componentDir = path.join(componentsPath, '/', componentName);
+ const assetsDir = `${componentDir}/assets`;
+
+ app.use(`/api/${componentName}/assets`, express.static(assetsDir));
+ });
+
+ /**
+ * Serve static files
+ */
+ const templatesDir = fs.readdirSync(templatesPath);
+ templatesDir.forEach(directory => {
+ const templateTypeDir = path.join(templatesPath, '/', directory);
+ const templates = fs.readdirSync(templateTypeDir);
+
+ templates.forEach(templateName => {
+ const templateDir = path.join(templatesPath, '/', directory, '/', templateName);
+ const assetsDir = `${templateDir}/assets`;
+
+ app.use(`/api/${templateName}/assets`, express.static(assetsDir));
+ });
+ });
+
+ return true;
+ },
+ Email: require('./core/email'),
+ Report: require('./core/report'),
+ storage: require('./core/storage'),
+ smtp: require('./core/smtp'),
+ db: require('./core/database')
+};
diff --git a/print/methods/closure/closeByAgency.js b/print/methods/closure/closeByAgency.js
deleted file mode 100644
index bbf72f137..000000000
--- a/print/methods/closure/closeByAgency.js
+++ /dev/null
@@ -1,59 +0,0 @@
-const db = require('vn-print/core/database');
-const closure = require('./closure');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.body;
-
- if (!reqArgs.agencyModeId)
- throw new Error('The argument agencyModeId is required');
-
- if (!reqArgs.warehouseId)
- throw new Error('The argument warehouseId is required');
-
- if (!reqArgs.to)
- throw new Error('The argument to is required');
-
- const agencyIds = reqArgs.agencyModeId.split(',');
- const tickets = await db.rawSql(`
- SELECT
- t.id,
- t.clientFk,
- t.companyFk,
- c.name clientName,
- c.email recipient,
- c.salesPersonFk,
- c.isToBeMailed,
- c.hasToInvoice,
- co.hasDailyInvoice,
- eu.email salesPersonEmail
- FROM expedition e
- JOIN ticket t ON t.id = e.ticketFk
- JOIN ticketState ts ON ts.ticketFk = t.id
- JOIN alertLevel al ON al.id = ts.alertLevel
- JOIN client c ON c.id = t.clientFk
- JOIN province p ON p.id = c.provinceFk
- JOIN country co ON co.id = p.countryFk
- LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
- WHERE al.code = 'PACKED'
- AND t.agencyModeFk IN(?)
- AND t.warehouseFk = ?
- AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
- AND util.dayEnd(?)
- AND t.refFk IS NULL
- GROUP BY e.ticketFk`, [
- agencyIds,
- reqArgs.warehouseId,
- reqArgs.to,
- reqArgs.to
- ]);
-
- await closure.start(tickets, response.locals);
-
- response.status(200).json({
- message: 'Success'
- });
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/closure/closure.js b/print/methods/closure/closure.js
deleted file mode 100644
index fe5aba5e7..000000000
--- a/print/methods/closure/closure.js
+++ /dev/null
@@ -1,183 +0,0 @@
-const db = require('vn-print/core/database');
-const Report = require('vn-print/core/report');
-const Email = require('vn-print/core/email');
-const smtp = require('vn-print/core/smtp');
-const config = require('vn-print/core/config');
-const storage = require('vn-print/core/storage');
-
-module.exports = {
- async start(tickets, reqArgs) {
- console.log(tickets);
- if (tickets.length == 0) return;
-
- const failedtickets = [];
- for (const ticket of tickets) {
- try {
- console.log(`Closing ticket id ${ticket.id}...`);
- await db.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]);
-
- const invoiceOut = await db.findOne(`
- SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued
- FROM ticket t
- JOIN invoiceOut io ON io.ref = t.refFk
- JOIN company cny ON cny.id = io.companyFk
- WHERE t.id = ?
- `, [ticket.id]);
-
- const mailOptions = {
- overrideAttachments: true,
- attachments: []
- };
-
- const isToBeMailed = ticket.recipient && ticket.salesPersonFk && ticket.isToBeMailed;
-
- if (invoiceOut) {
- const args = Object.assign({
- refFk: invoiceOut.ref,
- recipientId: ticket.clientFk,
- recipient: ticket.recipient,
- replyTo: ticket.salesPersonEmail
- }, reqArgs);
-
- const invoiceReport = new Report('invoice', args);
- const stream = await invoiceReport.toPdfStream();
-
- const issued = invoiceOut.issued;
- const year = issued.getFullYear().toString();
- const month = (issued.getMonth() + 1).toString();
- const day = issued.getDate().toString();
-
- const fileName = `${year}${invoiceOut.ref}.pdf`;
-
- // Store invoice
- storage.write(stream, {
- type: 'invoice',
- path: `${year}/${month}/${day}`,
- fileName: fileName
- });
-
- await db.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]);
-
- if (isToBeMailed) {
- const invoiceAttachment = {
- filename: fileName,
- content: stream
- };
-
- if (invoiceOut.serial == 'E' && invoiceOut.companyCode == 'VNL') {
- const exportation = new Report('exportation', args);
- const stream = await exportation.toPdfStream();
- const fileName = `CITES-${invoiceOut.ref}.pdf`;
-
- mailOptions.attachments.push({
- filename: fileName,
- content: stream
- });
- }
-
- mailOptions.attachments.push(invoiceAttachment);
-
- const email = new Email('invoice', args);
- await email.send(mailOptions);
- }
- } else if (isToBeMailed) {
- const args = Object.assign({
- ticketId: ticket.id,
- recipientId: ticket.clientFk,
- recipient: ticket.recipient,
- replyTo: ticket.salesPersonEmail
- }, reqArgs);
-
- const email = new Email('delivery-note-link', args);
- await email.send();
- }
-
- // Incoterms authorization
- const {firstOrder} = await db.findOne(`
- SELECT COUNT(*) as firstOrder
- FROM ticket t
- JOIN client c ON c.id = t.clientFk
- WHERE t.clientFk = ?
- AND NOT t.isDeleted
- AND c.isVies
- `, [ticket.clientFk]);
-
- if (firstOrder == 1) {
- const args = Object.assign({
- ticketId: ticket.id,
- recipientId: ticket.clientFk,
- recipient: ticket.recipient,
- replyTo: ticket.salesPersonEmail
- }, reqArgs);
-
- const email = new Email('incoterms-authorization', args);
- await email.send();
-
- const sample = await db.findOne(
- `SELECT id
- FROM sample
- WHERE code = 'incoterms-authorization'`);
-
- await db.rawSql(`
- INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?)
- `, [ticket.clientFk, sample.id, ticket.companyFk]);
- }
- } catch (error) {
- // Domain not found
- if (error.responseCode == 450)
- return invalidEmail(ticket);
-
- // Save tickets on a list of failed ids
- failedtickets.push({
- id: ticket.id,
- stacktrace: error
- });
- }
- }
-
- // Send email with failed tickets
- if (failedtickets.length > 0) {
- let body = 'This following tickets have failed:
';
-
- for (const ticket of failedtickets) {
- body += `Ticket:
${ticket.id}
-
${ticket.stacktrace}`;
- }
-
- smtp.send({
- to: config.app.reportEmail,
- subject: '[API] Nightly ticket closure report',
- html: body
- });
- }
- },
-};
-
-async function invalidEmail(ticket) {
- await db.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [
- ticket.clientFk
- ]);
-
- const oldInstance = `{"email": "${ticket.recipient}"}`;
- const newInstance = `{"email": ""}`;
- await db.rawSql(`
- INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance)
- VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [
- ticket.clientFk,
- oldInstance,
- newInstance
- ]);
-
- const body = `No se ha podido enviar el albarán
${ticket.id}
- al cliente
${ticket.clientFk} - ${ticket.clientName}
- porque la dirección de email
"${ticket.recipient}" no es correcta
- o no está disponible.
- Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente.
- Actualiza la dirección de email con una correcta.`;
-
- smtp.send({
- to: ticket.salesPersonEmail,
- subject: 'No se ha podido enviar el albarán',
- html: body
- });
-}
diff --git a/print/methods/closure/index.js b/print/methods/closure/index.js
deleted file mode 100644
index 2d5eaf4c5..000000000
--- a/print/methods/closure/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const express = require('express');
-const router = new express.Router();
-
-router.post('/all', require('./closeAll'));
-router.post('/by-ticket', require('./closeByTicket'));
-router.post('/by-agency', require('./closeByAgency'));
-router.post('/by-route', require('./closeByRoute'));
-
-module.exports = router;
diff --git a/print/methods/csv/delivery-note/download.js b/print/methods/csv/delivery-note/download.js
deleted file mode 100644
index d369d5f4a..000000000
--- a/print/methods/csv/delivery-note/download.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const path = require('path');
-const db = require('vn-print/core/database');
-
-const {toCSV} = require('../csv');
-const sqlPath = path.join(__dirname, 'sql');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.query;
- if (!reqArgs.ticketId)
- throw new Error('The argument ticketId is required');
-
- const ticketId = reqArgs.ticketId;
- const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [ticketId]);
- const content = toCSV(sales);
- const fileName = `ticket_${ticketId}.csv`;
-
- response.setHeader('Content-type', 'text/csv');
- response.setHeader('Content-Disposition', `inline; filename="${fileName}"`);
- response.end(content);
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/csv/delivery-note/send.js b/print/methods/csv/delivery-note/send.js
deleted file mode 100644
index 478f20f57..000000000
--- a/print/methods/csv/delivery-note/send.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const path = require('path');
-const db = require('vn-print/core/database');
-const Email = require('vn-print/core/email');
-
-const {toCSV} = require('../csv');
-const sqlPath = path.join(__dirname, 'sql');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.query;
- if (!reqArgs.ticketId)
- throw new Error('The argument ticketId is required');
-
- const ticketId = reqArgs.ticketId;
- const ticket = await db.findOneFromDef(`${sqlPath}/ticket`, [ticketId]);
- const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [ticketId]);
-
- const args = Object.assign({
- ticketId: (String(ticket.id)),
- recipientId: ticket.clientFk,
- recipient: ticket.recipient,
- replyTo: ticket.salesPersonEmail
- }, response.locals);
-
- const content = toCSV(sales);
- const fileName = `ticket_${ticketId}.csv`;
- const email = new Email('delivery-note', args);
- await email.send({
- overrideAttachments: true,
- attachments: [{
- filename: fileName,
- content: content
- }]
- });
-
- response.status(200).json({message: 'Success'});
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/csv/delivery-note/sql/sales.sql b/print/methods/csv/delivery-note/sql/sales.sql
deleted file mode 100644
index e5b419571..000000000
--- a/print/methods/csv/delivery-note/sql/sales.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-SELECT io.ref Invoice,
- io.issued InvoiceDate,
- s.ticketFk Ticket,
- s.itemFk Item,
- s.concept Description,
- i.size,
- i.subName Producer,
- s.quantity Quantity,
- s.price Price,
- s.discount Discount,
- s.created Created,
- tc.code Taxcode,
- tc.description TaxDescription,
- i.tag5,
- i.value5,
- i.tag6,
- i.value6,
- i.tag7,
- i.value7,
- i.tag8,
- i.value8,
- i.tag9,
- i.value9,
- i.tag10,
- i.value10
-FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.supplier s2 ON s2.id = t.companyFk
- JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
- AND itc.countryFk = s2.countryFk
- JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
- LEFT JOIN vn.invoiceOut io ON io.id = t.refFk
-WHERE s.ticketFk = ?
-ORDER BY s.ticketFk, s.created
\ No newline at end of file
diff --git a/print/methods/csv/delivery-note/sql/ticket.sql b/print/methods/csv/delivery-note/sql/ticket.sql
deleted file mode 100644
index b80c7c42c..000000000
--- a/print/methods/csv/delivery-note/sql/ticket.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-SELECT
- t.id,
- t.clientFk,
- c.email recipient,
- eu.email salesPersonEmail
-FROM ticket t
- JOIN client c ON c.id = t.clientFk
- LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
-WHERE t.id = ?
\ No newline at end of file
diff --git a/print/methods/csv/index.js b/print/methods/csv/index.js
deleted file mode 100644
index 6bdd1b60d..000000000
--- a/print/methods/csv/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const express = require('express');
-const router = new express.Router();
-
-router.get('/delivery-note/download', require('./delivery-note/download'));
-router.get('/delivery-note/send', require('./delivery-note/send'));
-router.get('/invoice/download', require('./invoice/download'));
-router.get('/invoice/send', require('./invoice/send'));
-
-module.exports = router;
diff --git a/print/methods/csv/invoice/download.js b/print/methods/csv/invoice/download.js
deleted file mode 100644
index 9cca99f2d..000000000
--- a/print/methods/csv/invoice/download.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const path = require('path');
-const db = require('vn-print/core/database');
-
-const {toCSV} = require('../csv');
-const sqlPath = path.join(__dirname, 'sql');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.query;
- if (!reqArgs.refFk)
- throw new Error('The argument refFk is required');
-
- const refFk = reqArgs.refFk;
- const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [refFk]);
- const content = toCSV(sales);
- const fileName = `invoice_${refFk}.csv`;
-
- response.setHeader('Content-type', 'text/csv');
- response.setHeader('Content-Disposition', `inline; filename="${fileName}"`);
- response.end(content);
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/csv/invoice/send.js b/print/methods/csv/invoice/send.js
deleted file mode 100644
index 2729e4a2b..000000000
--- a/print/methods/csv/invoice/send.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const path = require('path');
-const db = require('vn-print/core/database');
-const Email = require('vn-print/core/email');
-
-const {toCSV} = require('../csv');
-const sqlPath = path.join(__dirname, 'sql');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.query;
- if (!reqArgs.refFk)
- throw new Error('The argument refFk is required');
-
- const refFk = reqArgs.refFk;
- const invoice = await db.findOneFromDef(`${sqlPath}/invoice`, [refFk]);
- const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [refFk]);
-
- const args = Object.assign({
- refFk: invoice.refFk,
- recipientId: invoice.clientFk,
- recipient: invoice.recipient,
- replyTo: invoice.salesPersonEmail
- }, response.locals);
-
- const content = toCSV(sales);
- const fileName = `invoice_${refFk}.csv`;
- const email = new Email('invoice', args);
- await email.send({
- overrideAttachments: true,
- attachments: [{
- filename: fileName,
- content: content
- }]
- });
-
- response.status(200).json({message: 'Success'});
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/csv/invoice/sql/invoice.sql b/print/methods/csv/invoice/sql/invoice.sql
deleted file mode 100644
index d484766a0..000000000
--- a/print/methods/csv/invoice/sql/invoice.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-SELECT
- io.id,
- io.clientFk,
- c.email recipient,
- eu.email salesPersonEmail
-FROM invoiceOut io
- JOIN client c ON c.id = io.clientFk
- LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
- LEFT JOIN ticket t ON t.refFk = io.ref
-WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/methods/csv/invoice/sql/sales.sql b/print/methods/csv/invoice/sql/sales.sql
deleted file mode 100644
index 33fe62476..000000000
--- a/print/methods/csv/invoice/sql/sales.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-SELECT io.ref Invoice,
- io.issued InvoiceDate,
- s.ticketFk Ticket,
- s.itemFk Item,
- s.concept Description,
- i.size,
- i.subName Producer,
- s.quantity Quantity,
- s.price Price,
- s.discount Discount,
- s.created Created,
- tc.code Taxcode,
- tc.description TaxDescription,
- i.tag5,
- i.value5,
- i.tag6,
- i.value6,
- i.tag7,
- i.value7,
- i.tag8,
- i.value8,
- i.tag9,
- i.value9,
- i.tag10,
- i.value10
-FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN supplier s2 ON s2.id = t.companyFk
- JOIN itemTaxCountry itc ON itc.itemFk = i.id
- AND itc.countryFk = s2.countryFk
- JOIN taxClass tc ON tc.id = itc.taxClassFk
- JOIN invoiceOut io ON io.ref = t.refFk
-WHERE t.refFk = ?
-ORDER BY s.ticketFk, s.created
\ No newline at end of file
diff --git a/print/methods/email/email.js b/print/methods/email/email.js
deleted file mode 100644
index 5d6882f7d..000000000
--- a/print/methods/email/email.js
+++ /dev/null
@@ -1,16 +0,0 @@
-const Email = require('vn-print/core/email');
-
-module.exports = async function(request, response, next) {
- try {
- const templateName = request.params.name;
- const args = response.locals;
- const email = new Email(templateName, args);
- await email.send();
-
- response.status(200).json({
- message: 'Sent'
- });
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/email/index.js b/print/methods/email/index.js
deleted file mode 100644
index 10c2d2325..000000000
--- a/print/methods/email/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const express = require('express');
-const router = new express.Router();
-
-router.get('/:name', require('./email'));
-router.get('/:name/preview', require('./preview'));
-
-module.exports = router;
diff --git a/print/methods/email/preview.js b/print/methods/email/preview.js
deleted file mode 100644
index e6a1aaf35..000000000
--- a/print/methods/email/preview.js
+++ /dev/null
@@ -1,14 +0,0 @@
-const Email = require('vn-print/core/email');
-
-module.exports = async function(request, response, next) {
- try {
- const templateName = request.params.name;
- const args = Object.assign({isPreview: true}, response.locals);
- const email = new Email(templateName, args);
- const template = await email.render();
-
- response.send(template);
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/report/document.js b/print/methods/report/document.js
deleted file mode 100644
index b24abf4ac..000000000
--- a/print/methods/report/document.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const Report = require('vn-print/core/report');
-
-module.exports = async function(request, response, next) {
- try {
- const reportName = request.params.name;
- const args = response.locals;
- const report = new Report(reportName, args);
- const stream = await report.toPdfStream();
- const fileName = await report.getFileName();
-
- response.setHeader('Content-type', 'application/pdf');
- response.setHeader('Content-Disposition', `inline; filename="${fileName}"`);
- response.end(stream);
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/report/index.js b/print/methods/report/index.js
deleted file mode 100644
index c422c76df..000000000
--- a/print/methods/report/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const express = require('express');
-const router = new express.Router();
-
-router.get('/:name', require('./document'));
-router.get('/:name/preview', require('./preview'));
-
-module.exports = router;
diff --git a/print/methods/report/preview.js b/print/methods/report/preview.js
deleted file mode 100644
index 0d6ad6f43..000000000
--- a/print/methods/report/preview.js
+++ /dev/null
@@ -1,13 +0,0 @@
-const Report = require('vn-print/core/report');
-
-module.exports = async function(request, response, next) {
- try {
- const reportName = request.params.name;
- const report = new Report(reportName, request.query);
- const template = await report.render();
-
- response.send(template);
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/routes.js b/print/methods/routes.js
deleted file mode 100644
index 28671b3da..000000000
--- a/print/methods/routes.js
+++ /dev/null
@@ -1,22 +0,0 @@
-module.exports = [
- {
- url: '/api/report',
- cb: require('./report')
- },
- {
- url: '/api/email',
- cb: require('./email')
- },
- {
- url: '/api/csv',
- cb: require('./csv')
- },
- {
- url: '/api/closure',
- cb: require('./closure')
- },
- {
- url: '/api/schedule',
- cb: require('./schedule')
- }
-];
diff --git a/print/methods/schedule/consumption.js b/print/methods/schedule/consumption.js
deleted file mode 100644
index 39d39105b..000000000
--- a/print/methods/schedule/consumption.js
+++ /dev/null
@@ -1,58 +0,0 @@
-const db = require('vn-print/core/database');
-const Email = require('vn-print/core/email');
-
-module.exports = async function(request, response, next) {
- try {
- const reqArgs = request.body;
-
- if (!reqArgs.clientIds)
- throw new Error('The argument clientIds is required');
- if (!reqArgs.from)
- throw new Error('The argument from is required');
- if (!reqArgs.to)
- throw new Error('The argument to is required');
-
- response.status(200).json({
- message: 'Success'
- });
-
- const clientIds = reqArgs.clientIds;
-
- const clients = await db.rawSql(`
- SELECT
- c.id,
- c.email,
- eu.email salesPersonEmail
- FROM client c
- JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
- JOIN ticket t ON t.clientFk = c.id
- JOIN sale s ON s.ticketFk = t.id
- JOIN item i ON i.id = s.itemFk
- JOIN itemType it ON it.id = i.typeFk
- WHERE c.id IN(?)
- AND it.isPackaging = FALSE
- AND DATE(t.shipped) BETWEEN ? AND ?
- GROUP BY c.id`, [clientIds, reqArgs.from, reqArgs.to]);
-
- const clientData = new Map();
- for (const client of clients)
- clientData.set(client.id, client);
-
- for (const clientId of reqArgs.clientIds) {
- const client = clientData.get(clientId);
-
- if (client) {
- const args = Object.assign({
- recipientId: clientId,
- recipient: client.email,
- replyTo: client.salesPersonEmail
- }, response.locals);
-
- const email = new Email('campaign-metrics', args);
- await email.send();
- }
- }
- } catch (error) {
- next(error);
- }
-};
diff --git a/print/methods/schedule/index.js b/print/methods/schedule/index.js
deleted file mode 100644
index 05d54b2ed..000000000
--- a/print/methods/schedule/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const express = require('express');
-const router = new express.Router();
-
-router.post('/consumption', require('./consumption'));
-router.post('/invoice', require('./invoice'));
-
-module.exports = router;
diff --git a/print/templates/email/buyer-week-waste/assets/css/import.js b/print/templates/email/buyer-week-waste/assets/css/import.js
index c742fdf90..7360587f7 100644
--- a/print/templates/email/buyer-week-waste/assets/css/import.js
+++ b/print/templates/email/buyer-week-waste/assets/css/import.js
@@ -1,9 +1,13 @@
-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`,
`${__dirname}/style.css`])
.mergeStyles();
+
diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.js b/print/templates/email/buyer-week-waste/buyer-week-waste.js
index 9af477e82..05a80ac6a 100755
--- a/print/templates/email/buyer-week-waste/buyer-week-waste.js
+++ b/print/templates/email/buyer-week-waste/buyer-week-waste.js
@@ -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');
diff --git a/print/templates/email/campaign-metrics/assets/css/import.js b/print/templates/email/campaign-metrics/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/campaign-metrics/assets/css/import.js
+++ b/print/templates/email/campaign-metrics/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/campaign-metrics/campaign-metrics.js b/print/templates/email/campaign-metrics/campaign-metrics.js
index 2bd93b725..0c3a01991 100755
--- a/print/templates/email/campaign-metrics/campaign-metrics.js
+++ b/print/templates/email/campaign-metrics/campaign-metrics.js
@@ -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
},
diff --git a/print/templates/email/claim-pickup-order/assets/css/import.js b/print/templates/email/claim-pickup-order/assets/css/import.js
index b44d6bd37..1582b82c5 100644
--- a/print/templates/email/claim-pickup-order/assets/css/import.js
+++ b/print/templates/email/claim-pickup-order/assets/css/import.js
@@ -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/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();
+
diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js
index cf4ba7d12..d3836db39 100755
--- a/print/templates/email/claim-pickup-order/claim-pickup-order.js
+++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js
@@ -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');
@@ -9,7 +9,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- claimId: {
+ id: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/client-debt-statement/assets/css/import.js b/print/templates/email/client-debt-statement/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/client-debt-statement/assets/css/import.js
+++ b/print/templates/email/client-debt-statement/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/client-debt-statement/attachments.json b/print/templates/email/client-debt-statement/attachments.json
deleted file mode 100644
index 9cc4911e6..000000000
--- a/print/templates/email/client-debt-statement/attachments.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "filename": "client-debt-statement.pdf",
- "component": "client-debt-statement"
- }
-]
\ No newline at end of file
diff --git a/print/templates/email/client-debt-statement/client-debt-statement.js b/print/templates/email/client-debt-statement/client-debt-statement.js
index f32f9e239..85b3c5cc3 100755
--- a/print/templates/email/client-debt-statement/client-debt-statement.js
+++ b/print/templates/email/client-debt-statement/client-debt-statement.js
@@ -1,8 +1,7 @@
-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');
const attachment = new Component('attachment');
-const attachments = require('./attachments.json');
module.exports = {
name: 'client-debt-statement',
@@ -12,10 +11,18 @@ module.exports = {
'attachment': attachment.build()
},
data() {
- return {attachments};
+ return {
+ attachments: [
+ {
+ filename: 'client-debt-statement.pdf',
+ type: 'pdf',
+ path: `Clients/${this.id}/client-debt-statement-pdf`
+ }
+ ]
+ };
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
required: true
},
diff --git a/print/templates/email/client-welcome/assets/css/import.js b/print/templates/email/client-welcome/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/client-welcome/assets/css/import.js
+++ b/print/templates/email/client-welcome/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/client-welcome/client-welcome.js b/print/templates/email/client-welcome/client-welcome.js
index eeb11bb78..380837877 100755
--- a/print/templates/email/client-welcome/client-welcome.js
+++ b/print/templates/email/client-welcome/client-welcome.js
@@ -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: 'client-welcome',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId);
+ this.client = await this.fetchClient(this.id);
},
methods: {
- fetchClient(clientId) {
- return this.findOneFromDef('client', [clientId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
},
components: {
@@ -17,7 +17,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/credit-request/assets/css/import.js b/print/templates/email/credit-request/assets/css/import.js
index b44d6bd37..89b2afaa5 100644
--- a/print/templates/email/credit-request/assets/css/import.js
+++ b/print/templates/email/credit-request/assets/css/import.js
@@ -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`])
- .mergeStyles();
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`])
+ .mergeStyles();
\ No newline at end of file
diff --git a/print/templates/email/credit-request/credit-request.js b/print/templates/email/credit-request/credit-request.js
index 69463f43a..8f68d56c0 100755
--- a/print/templates/email/credit-request/credit-request.js
+++ b/print/templates/email/credit-request/credit-request.js
@@ -1,8 +1,7 @@
-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');
const attachment = new Component('attachment');
-const attachments = require('./attachments.json');
module.exports = {
name: 'credit-request',
@@ -12,6 +11,20 @@ module.exports = {
'attachment': attachment.build()
},
data() {
- return {attachments};
+ return {
+ attachments: [
+ {
+ filename: 'credit-request.pdf',
+ type: 'pdf',
+ path: `Clients/${this.id}/credit-request-pdf`
+ }
+ ]
+ };
},
+ props: {
+ id: {
+ type: Number,
+ required: true
+ }
+ }
};
diff --git a/print/templates/email/delivery-note-link/assets/css/import.js b/print/templates/email/delivery-note-link/assets/css/import.js
index c742fdf90..fec23d870 100644
--- a/print/templates/email/delivery-note-link/assets/css/import.js
+++ b/print/templates/email/delivery-note-link/assets/css/import.js
@@ -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/email.css`,
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`,
`${__dirname}/style.css`])
.mergeStyles();
diff --git a/print/templates/email/delivery-note-link/delivery-note-link.html b/print/templates/email/delivery-note-link/delivery-note-link.html
index ab58cbb24..1d4906261 100644
--- a/print/templates/email/delivery-note-link/delivery-note-link.html
+++ b/print/templates/email/delivery-note-link/delivery-note-link.html
@@ -30,7 +30,7 @@
{{ $t('title') }}
{{$t('dear')}}
-
+
@@ -38,7 +38,7 @@
{{ $t('title') }}
{{$t('dear')}},
-
+
diff --git a/print/templates/email/delivery-note/delivery-note.js b/print/templates/email/delivery-note/delivery-note.js
index ffd2fe202..ba3d44001 100755
--- a/print/templates/email/delivery-note/delivery-note.js
+++ b/print/templates/email/delivery-note/delivery-note.js
@@ -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');
@@ -9,7 +9,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- ticketId: {
+ id: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/driver-route/assets/css/import.js b/print/templates/email/driver-route/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/driver-route/assets/css/import.js
+++ b/print/templates/email/driver-route/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/driver-route/driver-route.js b/print/templates/email/driver-route/driver-route.js
index 378cd82ce..0895ccc8c 100755
--- a/print/templates/email/driver-route/driver-route.js
+++ b/print/templates/email/driver-route/driver-route.js
@@ -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');
@@ -9,7 +9,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- routeId: {
+ id: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/incoterms-authorization/assets/css/import.js b/print/templates/email/incoterms-authorization/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/incoterms-authorization/assets/css/import.js
+++ b/print/templates/email/incoterms-authorization/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/incoterms-authorization/attachments.json b/print/templates/email/incoterms-authorization/attachments.json
deleted file mode 100644
index 9dfd945db..000000000
--- a/print/templates/email/incoterms-authorization/attachments.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "filename": "incoterms-authorization.pdf",
- "component": "incoterms-authorization"
- }
-]
\ No newline at end of file
diff --git a/print/templates/email/incoterms-authorization/incoterms-authorization.js b/print/templates/email/incoterms-authorization/incoterms-authorization.js
index bac40d331..b1c7286dd 100755
--- a/print/templates/email/incoterms-authorization/incoterms-authorization.js
+++ b/print/templates/email/incoterms-authorization/incoterms-authorization.js
@@ -1,13 +1,20 @@
-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');
const attachment = new Component('attachment');
-const attachments = require('./attachments.json');
module.exports = {
name: 'incoterms-authorization',
data() {
- return {attachments};
+ return {
+ attachments: [
+ {
+ filename: 'incoterms-authorization.pdf',
+ type: 'pdf',
+ path: `Clients/${this.id}/incoterms-authorization-pdf`
+ }
+ ]
+ };
},
components: {
'email-header': emailHeader.build(),
@@ -15,9 +22,10 @@ module.exports = {
'attachment': attachment.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
companyId: {
type: [Number, String],
diff --git a/print/templates/email/invoice/assets/css/import.js b/print/templates/email/invoice/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/invoice/assets/css/import.js
+++ b/print/templates/email/invoice/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/invoice/invoice.js b/print/templates/email/invoice/invoice.js
index 6f6ea8683..fe66062aa 100755
--- a/print/templates/email/invoice/invoice.js
+++ b/print/templates/email/invoice/invoice.js
@@ -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.reference);
},
methods: {
- fetchInvoice(refFk) {
- return this.findOneFromDef('invoice', [refFk]);
+ fetchInvoice(reference) {
+ return this.findOneFromDef('invoice', [reference]);
},
},
components: {
@@ -17,7 +17,7 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- refFk: {
+ reference: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/letter-debtor-nd/assets/css/import.js b/print/templates/email/letter-debtor-nd/assets/css/import.js
index 624404a6c..1582b82c5 100644
--- a/print/templates/email/letter-debtor-nd/assets/css/import.js
+++ b/print/templates/email/letter-debtor-nd/assets/css/import.js
@@ -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/email.css`])
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`])
.mergeStyles();
diff --git a/print/templates/email/letter-debtor-nd/attachments.json b/print/templates/email/letter-debtor-nd/attachments.json
deleted file mode 100644
index 1e21ea343..000000000
--- a/print/templates/email/letter-debtor-nd/attachments.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "filename": "letter-debtor.pdf",
- "component": "letter-debtor"
- }
-]
\ No newline at end of file
diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js
index 5e010d1ba..cf9cc7ddd 100755
--- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js
+++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js
@@ -1,23 +1,30 @@
-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');
const attachment = new Component('attachment');
-const attachments = require('./attachments.json');
module.exports = {
name: 'letter-debtor-nd',
async serverPrefetch() {
- this.debtor = await this.fetchDebtor(this.recipientId, this.companyId);
+ this.debtor = await this.fetchDebtor(this.id, this.companyId);
if (!this.debtor)
throw new Error('Something went wrong');
},
data() {
- return {attachments};
+ return {
+ attachments: [
+ {
+ filename: 'letter-debtor.pdf',
+ type: 'pdf',
+ path: `Clients/${this.id}/letter-debtor-pdf`
+ }
+ ]
+ };
},
methods: {
- fetchDebtor(clientId, companyId) {
- return this.findOneFromDef('client', [clientId, companyId]);
+ fetchDebtor(id, companyId) {
+ return this.findOneFromDef('client', [id, companyId]);
}
},
components: {
@@ -26,10 +33,7 @@ module.exports = {
'attachment': attachment.build()
},
props: {
- authorization: {
- required: true
- },
- recipientId: {
+ id: {
type: [Number, String],
required: true
},
diff --git a/print/templates/email/letter-debtor-nd/sql/client.sql b/print/templates/email/letter-debtor-nd/sql/client.sql
index 479bfac5e..d5da5d0d5 100644
--- a/print/templates/email/letter-debtor-nd/sql/client.sql
+++ b/print/templates/email/letter-debtor-nd/sql/client.sql
@@ -5,7 +5,6 @@ SELECT
be.name AS bankName
FROM client c
JOIN company AS cny
- JOIN supplierAccount AS sa ON
- IF (ct.code = 'PT', sa.id = 907, sa.id = cny.supplierAccountFk)
+ JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?
\ No newline at end of file
diff --git a/print/templates/email/letter-debtor-st/assets/css/import.js b/print/templates/email/letter-debtor-st/assets/css/import.js
index 624404a6c..1582b82c5 100644
--- a/print/templates/email/letter-debtor-st/assets/css/import.js
+++ b/print/templates/email/letter-debtor-st/assets/css/import.js
@@ -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/email.css`])
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`])
.mergeStyles();
diff --git a/print/templates/email/letter-debtor-st/attachments.json b/print/templates/email/letter-debtor-st/attachments.json
deleted file mode 100644
index 1e21ea343..000000000
--- a/print/templates/email/letter-debtor-st/attachments.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "filename": "letter-debtor.pdf",
- "component": "letter-debtor"
- }
-]
\ No newline at end of file
diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js
index a514097cf..1a6555673 100755
--- a/print/templates/email/letter-debtor-st/letter-debtor-st.js
+++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js
@@ -1,23 +1,30 @@
-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');
const attachment = new Component('attachment');
-const attachments = require('./attachments.json');
module.exports = {
name: 'letter-debtor-st',
async serverPrefetch() {
- this.debtor = await this.fetchDebtor(this.recipientId, this.companyId);
+ this.debtor = await this.fetchDebtor(this.id, this.companyId);
if (!this.debtor)
throw new Error('Something went wrong');
},
data() {
- return {attachments};
+ return {
+ attachments: [
+ {
+ filename: 'letter-debtor.pdf',
+ type: 'pdf',
+ path: `Clients/${this.id}/letter-debtor-pdf`
+ }
+ ]
+ };
},
methods: {
- fetchDebtor(clientId, companyId) {
- return this.findOneFromDef('client', [clientId, companyId]);
+ fetchDebtor(id, companyId) {
+ return this.findOneFromDef('client', [id, companyId]);
}
},
components: {
@@ -26,7 +33,7 @@ module.exports = {
'attachment': attachment.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
required: true
},
diff --git a/print/templates/email/letter-debtor-st/sql/client.sql b/print/templates/email/letter-debtor-st/sql/client.sql
index 479bfac5e..d5da5d0d5 100644
--- a/print/templates/email/letter-debtor-st/sql/client.sql
+++ b/print/templates/email/letter-debtor-st/sql/client.sql
@@ -5,7 +5,6 @@ SELECT
be.name AS bankName
FROM client c
JOIN company AS cny
- JOIN supplierAccount AS sa ON
- IF (ct.code = 'PT', sa.id = 907, sa.id = cny.supplierAccountFk)
+ JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?
\ No newline at end of file
diff --git a/print/templates/email/osticket-report/assets/css/import.js b/print/templates/email/osticket-report/assets/css/import.js
index c742fdf90..7360587f7 100644
--- a/print/templates/email/osticket-report/assets/css/import.js
+++ b/print/templates/email/osticket-report/assets/css/import.js
@@ -1,9 +1,13 @@
-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`,
`${__dirname}/style.css`])
.mergeStyles();
+
diff --git a/print/templates/email/osticket-report/osticket-report.js b/print/templates/email/osticket-report/osticket-report.js
index 45fadd4f1..48e2202f8 100755
--- a/print/templates/email/osticket-report/osticket-report.js
+++ b/print/templates/email/osticket-report/osticket-report.js
@@ -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');
diff --git a/print/templates/email/payment-update/assets/css/import.js b/print/templates/email/payment-update/assets/css/import.js
index b44d6bd37..1582b82c5 100644
--- a/print/templates/email/payment-update/assets/css/import.js
+++ b/print/templates/email/payment-update/assets/css/import.js
@@ -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/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();
+
diff --git a/print/templates/email/payment-update/payment-update.js b/print/templates/email/payment-update/payment-update.js
index 2b92976a3..a9d99d4ef 100755
--- a/print/templates/email/payment-update/payment-update.js
+++ b/print/templates/email/payment-update/payment-update.js
@@ -1,11 +1,11 @@
-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: 'payment-update',
async serverPrefetch() {
- this.payMethod = await this.fetchPayMethod(this.recipientId);
+ this.payMethod = await this.fetchPayMethod(this.id);
if (!this.payMethod)
throw new Error('Something went wrong');
@@ -16,8 +16,8 @@ module.exports = {
},
},
methods: {
- fetchPayMethod(clientId) {
- return this.findOneFromDef('payMethod', [clientId]);
+ fetchPayMethod(id) {
+ return this.findOneFromDef('payMethod', [id]);
}
},
components: {
@@ -25,9 +25,10 @@ module.exports = {
'email-footer': emailFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
}
}
};
diff --git a/print/templates/email/printer-setup/assets/css/import.js b/print/templates/email/printer-setup/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/printer-setup/assets/css/import.js
+++ b/print/templates/email/printer-setup/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/printer-setup/printer-setup.js b/print/templates/email/printer-setup/printer-setup.js
index 95dff8ebb..a7d3c40bf 100755
--- a/print/templates/email/printer-setup/printer-setup.js
+++ b/print/templates/email/printer-setup/printer-setup.js
@@ -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');
const attachment = new Component('attachment');
@@ -7,14 +7,14 @@ const attachments = require('./attachments.json');
module.exports = {
name: 'printer-setup',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId);
+ this.client = await this.fetchClient(this.id);
},
data() {
return {attachments};
},
methods: {
- fetchClient(clientId) {
- return this.findOneFromDef('client', [clientId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
}
},
components: {
@@ -23,7 +23,7 @@ module.exports = {
'attachment': attachment.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
required: true
}
diff --git a/print/templates/email/sepa-core/assets/css/import.js b/print/templates/email/sepa-core/assets/css/import.js
index b44d6bd37..1582b82c5 100644
--- a/print/templates/email/sepa-core/assets/css/import.js
+++ b/print/templates/email/sepa-core/assets/css/import.js
@@ -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/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();
+
diff --git a/print/templates/email/sepa-core/sepa-core.js b/print/templates/email/sepa-core/sepa-core.js
index 743c6719c..00cc527dc 100755
--- a/print/templates/email/sepa-core/sepa-core.js
+++ b/print/templates/email/sepa-core/sepa-core.js
@@ -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');
const attachment = new Component('attachment');
@@ -15,7 +15,7 @@ module.exports = {
'attachment': attachment.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
required: true
},
diff --git a/print/templates/email/supplier-campaign-metrics/assets/css/import.js b/print/templates/email/supplier-campaign-metrics/assets/css/import.js
index b44d6bd37..4b4bb7086 100644
--- a/print/templates/email/supplier-campaign-metrics/assets/css/import.js
+++ b/print/templates/email/supplier-campaign-metrics/assets/css/import.js
@@ -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();
diff --git a/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js b/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js
index 3cf290e4d..9cb9210ef 100755
--- a/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js
+++ b/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js
@@ -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
},
diff --git a/print/templates/reports/campaign-metrics/assets/css/import.js b/print/templates/reports/campaign-metrics/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/campaign-metrics/assets/css/import.js
+++ b/print/templates/reports/campaign-metrics/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js
index 6669ce067..b60a2b7eb 100755
--- a/print/templates/reports/campaign-metrics/campaign-metrics.js
+++ b/print/templates/reports/campaign-metrics/campaign-metrics.js
@@ -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: 'campaign-metrics',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId);
- this.sales = await this.fetchSales(this.recipientId, this.from, this.to);
+ this.client = await this.fetchClient(this.id);
+ this.sales = await this.fetchSales(this.id, this.from, this.to);
if (!this.client)
throw new Error('Something went wrong');
},
methods: {
- fetchClient(clientId) {
- return this.findOneFromDef('client', [clientId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
- fetchSales(clientId, from, to) {
- return this.rawSqlFromDef('sales', [clientId, from, to]);
+ fetchSales(id, from, to) {
+ return this.rawSqlFromDef('sales', [id, from, to]);
},
},
components: {
@@ -24,9 +24,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
from: {
required: true
diff --git a/print/templates/reports/claim-pickup-order/assets/css/import.js b/print/templates/reports/claim-pickup-order/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/claim-pickup-order/assets/css/import.js
+++ b/print/templates/reports/claim-pickup-order/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html
index 1f6db4966..6764344b5 100644
--- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html
+++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html
@@ -17,7 +17,7 @@
{{$t('claimId')}} |
- {{claimId}} |
+ {{id}} |
{{$t('clientId')}} |
@@ -85,7 +85,7 @@
diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js
index bf975e9f2..f7d21a2d3 100755
--- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js
+++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js
@@ -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: 'claim-pickup-order',
async serverPrefetch() {
- this.client = await this.fetchClient(this.claimId);
- this.sales = await this.fetchSales(this.claimId);
+ this.client = await this.fetchClient(this.id);
+ this.sales = await this.fetchSales(this.id);
this.claimConfig = await this.fetchClaimConfig();
if (!this.client)
@@ -20,11 +20,11 @@ module.exports = {
}
},
methods: {
- fetchClient(claimId) {
- return this.findOneFromDef('client', [claimId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
- fetchSales(claimId) {
- return this.rawSqlFromDef('sales', [claimId]);
+ fetchSales(id) {
+ return this.rawSqlFromDef('sales', [id]);
},
fetchClaimConfig() {
return this.findOneFromDef('claimConfig');
@@ -35,9 +35,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- claimId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The claim id'
}
}
};
diff --git a/print/templates/reports/client-debt-statement/assets/css/import.js b/print/templates/reports/client-debt-statement/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/client-debt-statement/assets/css/import.js
+++ b/print/templates/reports/client-debt-statement/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/client-debt-statement/client-debt-statement.js b/print/templates/reports/client-debt-statement/client-debt-statement.js
index f006b0a92..80c83b494 100755
--- a/print/templates/reports/client-debt-statement/client-debt-statement.js
+++ b/print/templates/reports/client-debt-statement/client-debt-statement.js
@@ -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: 'client-debt-statement',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId);
- this.sales = await this.fetchSales(this.recipientId, this.from);
+ this.client = await this.fetchClient(this.id);
+ this.sales = await this.fetchSales(this.id, this.from);
if (!this.client)
throw new Error('Something went wrong');
@@ -22,21 +22,21 @@ module.exports = {
return {totalBalance: 0.00};
},
methods: {
- fetchClient(clientId) {
- return this.findOneFromDef('client', [clientId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
- fetchSales(clientId, from) {
+ fetchSales(id, from) {
return this.rawSqlFromDef('sales', [
from,
- clientId,
+ id,
from,
- clientId,
+ id,
from,
- clientId,
+ id,
from,
- clientId,
+ id,
from,
- clientId
+ id
]);
},
getBalance(sale) {
@@ -68,9 +68,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
from: {
required: true
diff --git a/print/templates/reports/credit-request/assets/css/import.js b/print/templates/reports/credit-request/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/credit-request/assets/css/import.js
+++ b/print/templates/reports/credit-request/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js
index d04106493..7de1060ca 100755
--- a/print/templates/reports/credit-request/credit-request.js
+++ b/print/templates/reports/credit-request/credit-request.js
@@ -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');
diff --git a/print/templates/reports/delivery-note/assets/css/import.js b/print/templates/reports/delivery-note/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/delivery-note/assets/css/import.js
+++ b/print/templates/reports/delivery-note/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html
index 35f9a2960..d166f3307 100644
--- a/print/templates/reports/delivery-note/delivery-note.html
+++ b/print/templates/reports/delivery-note/delivery-note.html
@@ -15,7 +15,7 @@
-
{{$t(type)}}
+
{{$t(deliverNoteType)}}
@@ -23,7 +23,7 @@
{{client.id}} |
- {{$t(type)}} |
+ {{$t(deliverNoteType)}} |
{{ticket.id}} |
diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js
index f9dba0578..1037e5129 100755
--- a/print/templates/reports/delivery-note/delivery-note.js
+++ b/print/templates/reports/delivery-note/delivery-note.js
@@ -1,5 +1,5 @@
-const config = require(`${appPath}/core/config`);
-const Component = require(`${appPath}/core/component`);
+const config = require(`vn-print/core/config`);
+const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const md5 = require('md5');
@@ -7,19 +7,15 @@ const fs = require('fs-extra');
module.exports = {
name: 'delivery-note',
- created() {
- if (!this.type)
- this.type = 'deliveryNote';
- },
async serverPrefetch() {
- this.client = await this.fetchClient(this.ticketId);
- this.ticket = await this.fetchTicket(this.ticketId);
- this.sales = await this.fetchSales(this.ticketId);
- this.address = await this.fetchAddress(this.ticketId);
- this.services = await this.fetchServices(this.ticketId);
- this.taxes = await this.fetchTaxes(this.ticketId);
- this.packagings = await this.fetchPackagings(this.ticketId);
- this.signature = await this.fetchSignature(this.ticketId);
+ this.client = await this.fetchClient(this.id);
+ this.ticket = await this.fetchTicket(this.id);
+ this.sales = await this.fetchSales(this.id);
+ this.address = await this.fetchAddress(this.id);
+ this.services = await this.fetchServices(this.id);
+ this.taxes = await this.fetchTaxes(this.id);
+ this.packagings = await this.fetchPackagings(this.id);
+ this.signature = await this.fetchSignature(this.id);
if (!this.ticket)
throw new Error('Something went wrong');
@@ -41,6 +37,9 @@ module.exports = {
return `data:image/png;base64, ${base64}`;
},
+ deliverNoteType() {
+ return this.type ? this.type : 'deliveryNote';
+ },
serviceTotal() {
let total = 0.00;
this.services.forEach(service => {
@@ -50,37 +49,37 @@ module.exports = {
return total;
},
showPrices() {
- return this.type != 'withoutPrices';
+ return this.deliverNoteType != 'withoutPrices';
},
footerType() {
- const translatedType = this.$t(this.type);
- return `${translatedType} ${this.ticketId}`;
+ const translatedType = this.$t(this.deliverNoteType);
+ return `${translatedType} ${this.id}`;
}
},
methods: {
- fetchClient(ticketId) {
- return this.findOneFromDef('client', [ticketId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
- fetchTicket(ticketId) {
- return this.findOneFromDef('ticket', [ticketId]);
+ fetchTicket(id) {
+ return this.findOneFromDef('ticket', [id]);
},
- fetchAddress(ticketId) {
- return this.findOneFromDef(`address`, [ticketId]);
+ fetchAddress(id) {
+ return this.findOneFromDef(`address`, [id]);
},
- fetchSignature(ticketId) {
- return this.findOneFromDef('signature', [ticketId]);
+ fetchSignature(id) {
+ return this.findOneFromDef('signature', [id]);
},
- fetchTaxes(ticketId) {
- return this.findOneFromDef(`taxes`, [ticketId]);
+ fetchTaxes(id) {
+ return this.findOneFromDef(`taxes`, [id]);
},
- fetchSales(ticketId) {
- return this.rawSqlFromDef('sales', [ticketId]);
+ fetchSales(id) {
+ return this.rawSqlFromDef('sales', [id]);
},
- fetchPackagings(ticketId) {
- return this.rawSqlFromDef('packagings', [ticketId]);
+ fetchPackagings(id) {
+ return this.rawSqlFromDef('packagings', [id]);
},
- fetchServices(ticketId) {
- return this.rawSqlFromDef('services', [ticketId]);
+ fetchServices(id) {
+ return this.rawSqlFromDef('services', [id]);
},
getSubTotal() {
@@ -127,9 +126,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- ticketId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The ticket id'
},
type: {
type: String,
diff --git a/print/templates/reports/driver-route/assets/css/import.js b/print/templates/reports/driver-route/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/driver-route/assets/css/import.js
+++ b/print/templates/reports/driver-route/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html
index 600c49970..96fb6e957 100644
--- a/print/templates/reports/driver-route/driver-route.html
+++ b/print/templates/reports/driver-route/driver-route.html
@@ -141,7 +141,7 @@
-
@@ -150,7 +150,7 @@
diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js
index c34de37cc..2de3d5192 100755
--- a/print/templates/reports/driver-route/driver-route.js
+++ b/print/templates/reports/driver-route/driver-route.js
@@ -1,13 +1,18 @@
-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: 'driver-route',
async serverPrefetch() {
- const routesId = this.routeId.split(',');
- const routes = await this.fetchRoutes(routesId);
- const tickets = await this.fetchTickets(routesId);
+ let ids = this.id;
+
+ const hasMultipleRoutes = String(this.id).includes(',');
+ if (hasMultipleRoutes)
+ ids = this.id.split(',');
+
+ const routes = await this.fetchRoutes(ids);
+ const tickets = await this.fetchTickets(ids);
const map = new Map();
@@ -26,11 +31,11 @@ module.exports = {
throw new Error('Something went wrong');
},
methods: {
- fetchRoutes(routesId) {
- return this.rawSqlFromDef('routes', [routesId]);
+ fetchRoutes(ids) {
+ return this.rawSqlFromDef('routes', [ids]);
},
- fetchTickets(routesId) {
- return this.rawSqlFromDef('tickets', [routesId, routesId]);
+ fetchTickets(ids) {
+ return this.rawSqlFromDef('tickets', [ids, ids]);
}
},
components: {
@@ -38,9 +43,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- routeId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The route id'
}
}
};
diff --git a/print/templates/reports/entry-order/assets/css/import.js b/print/templates/reports/entry-order/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/entry-order/assets/css/import.js
+++ b/print/templates/reports/entry-order/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js
index 52a56bf03..ff4a65e0c 100755
--- a/print/templates/reports/entry-order/entry-order.js
+++ b/print/templates/reports/entry-order/entry-order.js
@@ -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'
}
}
};
diff --git a/print/templates/reports/exportation/assets/css/import.js b/print/templates/reports/exportation/assets/css/import.js
index a2a9334cb..37a98dfdd 100644
--- a/print/templates/reports/exportation/assets/css/import.js
+++ b/print/templates/reports/exportation/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/exportation/exportation.html b/print/templates/reports/exportation/exportation.html
index f08af2cdb..252999467 100644
--- a/print/templates/reports/exportation/exportation.html
+++ b/print/templates/reports/exportation/exportation.html
@@ -31,9 +31,9 @@
({{$t('signature')}})
-
{{$t('signer.name')}}: JUAN VICENTE FERRER ROIG
-
{{$t('signer.ID')}}: 73943586N
-
{{$t('signer.position')}}: ADMINISTRADOR
+
{{$t('signer.name')}}: {{company.manager}}
+
{{$t('signer.ID')}}: {{company.managerFi}}
+
{{$t('signer.position')}}: {{$t('manager')}}
diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js
index a7e018c48..630baf421 100755
--- a/print/templates/reports/exportation/exportation.js
+++ b/print/templates/reports/exportation/exportation.js
@@ -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.reference);
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(reference) {
+ return this.findOneFromDef('invoice', [reference]);
}
},
computed: {
@@ -27,9 +29,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- refFk: {
+ reference: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The invoice ref'
}
}
};
diff --git a/print/templates/reports/exportation/locale/es.yml b/print/templates/reports/exportation/locale/es.yml
index a689e245b..230263cb9 100644
--- a/print/templates/reports/exportation/locale/es.yml
+++ b/print/templates/reports/exportation/locale/es.yml
@@ -36,6 +36,7 @@ signer:
name: Nombre del firmante
ID: DNI del firmante
position: Cargo del firmante
+manager: Gerente
months:
- 'Enero'
- 'Febrero'
diff --git a/print/templates/reports/exportation/sql/company.sql b/print/templates/reports/exportation/sql/company.sql
new file mode 100644
index 000000000..3ecef2071
--- /dev/null
+++ b/print/templates/reports/exportation/sql/company.sql
@@ -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 = ?
\ No newline at end of file
diff --git a/print/templates/reports/exportation/sql/invoice.sql b/print/templates/reports/exportation/sql/invoice.sql
index 7ea55e481..14e1568e2 100644
--- a/print/templates/reports/exportation/sql/invoice.sql
+++ b/print/templates/reports/exportation/sql/invoice.sql
@@ -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 = ?
\ No newline at end of file
diff --git a/print/templates/reports/extra-community/assets/css/import.js b/print/templates/reports/extra-community/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/extra-community/assets/css/import.js
+++ b/print/templates/reports/extra-community/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/extra-community/extra-community.js b/print/templates/reports/extra-community/extra-community.js
index 4dad5dfff..dec89648a 100755
--- a/print/templates/reports/extra-community/extra-community.js
+++ b/print/templates/reports/extra-community/extra-community.js
@@ -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);
},
@@ -99,7 +107,7 @@ module.exports = {
'landedTo',
'shippedFrom',
'continent',
- 'ref',
+ 'reference',
'id',
'agencyModeFk',
'warehouseOutFk',
diff --git a/print/templates/reports/incoterms-authorization/assets/css/import.js b/print/templates/reports/incoterms-authorization/assets/css/import.js
index a2a9334cb..37a98dfdd 100644
--- a/print/templates/reports/incoterms-authorization/assets/css/import.js
+++ b/print/templates/reports/incoterms-authorization/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
index 656a9d7b0..26637b8c2 100755
--- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
@@ -1,11 +1,11 @@
-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: 'incoterms-authorization',
async serverPrefetch() {
- this.client = await this.findOneFromDef('client', [this.recipientId]);
+ this.client = await this.findOneFromDef('client', [this.id]);
this.company = await this.findOneFromDef('company', [this.companyId]);
if (!this.client)
throw new Error('Something went wrong');
@@ -20,9 +20,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
companyId: {
type: [Number, String],
diff --git a/print/templates/reports/invoice-incoterms/assets/css/import.js b/print/templates/reports/invoice-incoterms/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/invoice-incoterms/assets/css/import.js
+++ b/print/templates/reports/invoice-incoterms/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
index 99a4e2e73..3dbe76ac3 100755
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
@@ -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.reference);
+ this.client = await this.fetchClient(this.reference);
+ this.incoterms = await this.fetchIncoterms(this.reference);
if (!this.invoice)
throw new Error('Something went wrong');
@@ -16,14 +16,14 @@ module.exports = {
},
methods: {
- fetchInvoice(refFk) {
- return this.findOneFromDef('invoice', [refFk]);
+ fetchInvoice(reference) {
+ return this.findOneFromDef('invoice', [reference]);
},
- fetchClient(refFk) {
- return this.findOneFromDef('client', [refFk]);
+ fetchClient(reference) {
+ return this.findOneFromDef('client', [reference]);
},
- fetchIncoterms(refFk) {
- return this.findOneFromDef('incoterms', [refFk, refFk, refFk]);
+ fetchIncoterms(reference) {
+ return this.findOneFromDef('incoterms', [reference, reference, reference]);
}
},
components: {
@@ -31,9 +31,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- refFk: {
+ reference: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The invoice ref'
}
}
};
diff --git a/print/templates/reports/invoice/assets/css/import.js b/print/templates/reports/invoice/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/invoice/assets/css/import.js
+++ b/print/templates/reports/invoice/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js
index fd4acd4b5..db94a7a12 100755
--- a/print/templates/reports/invoice/invoice.js
+++ b/print/templates/reports/invoice/invoice.js
@@ -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.reference);
+ this.client = await this.fetchClient(this.reference);
+ this.taxes = await this.fetchTaxes(this.reference);
+ this.intrastat = await this.fetchIntrastat(this.reference);
+ this.rectified = await this.fetchRectified(this.reference);
+ this.hasIncoterms = await this.fetchHasIncoterms(this.reference);
- const tickets = await this.fetchTickets(this.refFk);
- const sales = await this.fetchSales(this.refFk);
+ const tickets = await this.fetchTickets(this.reference);
+ const sales = await this.fetchSales(this.reference);
const map = new Map();
@@ -65,29 +65,29 @@ module.exports = {
}
},
methods: {
- fetchInvoice(refFk) {
- return this.findOneFromDef('invoice', [refFk]);
+ fetchInvoice(reference) {
+ return this.findOneFromDef('invoice', [reference]);
},
- fetchClient(refFk) {
- return this.findOneFromDef('client', [refFk]);
+ fetchClient(reference) {
+ return this.findOneFromDef('client', [reference]);
},
- fetchTickets(refFk) {
- return this.rawSqlFromDef('tickets', [refFk]);
+ fetchTickets(reference) {
+ return this.rawSqlFromDef('tickets', [reference]);
},
- fetchSales(refFk) {
- return this.rawSqlFromDef('sales', [refFk, refFk]);
+ fetchSales(reference) {
+ return this.rawSqlFromDef('sales', [reference, reference]);
},
- fetchTaxes(refFk) {
- return this.rawSqlFromDef(`taxes`, [refFk]);
+ fetchTaxes(reference) {
+ return this.rawSqlFromDef(`taxes`, [reference]);
},
- fetchIntrastat(refFk) {
- return this.rawSqlFromDef(`intrastat`, [refFk, refFk, refFk]);
+ fetchIntrastat(reference) {
+ return this.rawSqlFromDef(`intrastat`, [reference, reference, reference]);
},
- fetchRectified(refFk) {
- return this.rawSqlFromDef(`rectified`, [refFk]);
+ fetchRectified(reference) {
+ return this.rawSqlFromDef(`rectified`, [reference]);
},
- fetchHasIncoterms(refFk) {
- return this.findValueFromDef(`hasIncoterms`, [refFk]);
+ fetchHasIncoterms(reference) {
+ return this.findValueFromDef(`hasIncoterms`, [reference]);
},
saleImport(sale) {
const price = sale.quantity * sale.price;
@@ -115,8 +115,9 @@ module.exports = {
'invoice-incoterms': invoiceIncoterms.build()
},
props: {
- refFk: {
- type: String
+ reference: {
+ type: String,
+ description: 'The invoice ref'
}
}
};
diff --git a/print/templates/reports/item-label/assets/css/import.js b/print/templates/reports/item-label/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/item-label/assets/css/import.js
+++ b/print/templates/reports/item-label/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/item-label/item-label.js b/print/templates/reports/item-label/item-label.js
index 730d8ad99..d03d03cfa 100755
--- a/print/templates/reports/item-label/item-label.js
+++ b/print/templates/reports/item-label/item-label.js
@@ -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,18 @@ 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) {
+ const data = String(id);
+
+ return qrcode.toDataURL(data, {margin: 0});
},
packing() {
const stems = this.item.stems ? this.item.stems : 1;
@@ -52,17 +54,20 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- itemId: {
- required: true
+ id: {
+ type: Number,
+ required: true,
+ description: 'The item id'
},
warehouseId: {
+ type: Number,
required: true
},
labelNumber: {
- type: String
+ type: Number
},
totalLabels: {
- type: String
+ type: Number
}
}
};
diff --git a/print/templates/reports/letter-debtor/assets/css/import.js b/print/templates/reports/letter-debtor/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/letter-debtor/assets/css/import.js
+++ b/print/templates/reports/letter-debtor/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/letter-debtor/letter-debtor.js b/print/templates/reports/letter-debtor/letter-debtor.js
index 354b1d8d8..80d4cba9b 100755
--- a/print/templates/reports/letter-debtor/letter-debtor.js
+++ b/print/templates/reports/letter-debtor/letter-debtor.js
@@ -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: 'letter-debtor',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId);
- this.sales = await this.fetchSales(this.recipientId, this.companyId);
+ this.client = await this.fetchClient(this.id);
+ this.sales = await this.fetchSales(this.id, this.companyId);
if (!this.client)
throw new Error('Something went wrong');
@@ -22,12 +22,12 @@ module.exports = {
return {totalBalance: 0.00};
},
methods: {
- fetchClient(clientId) {
- return this.findOneFromDef('client', [clientId]);
+ fetchClient(id) {
+ return this.findOneFromDef('client', [id]);
},
- fetchSales(clientId, companyId) {
+ fetchSales(id, companyId) {
return this.findOneFromDef('sales', [
- clientId,
+ id,
companyId
]);
},
@@ -62,9 +62,10 @@ module.exports = {
'report-footer': reportFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
companyId: {
type: [Number, String],
diff --git a/print/templates/reports/receipt/assets/css/import.js b/print/templates/reports/receipt/assets/css/import.js
index a2a9334cb..37a98dfdd 100644
--- a/print/templates/reports/receipt/assets/css/import.js
+++ b/print/templates/reports/receipt/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/receipt/receipt.js b/print/templates/reports/receipt/receipt.js
index d7f4dd6da..401aa1ef3 100755
--- a/print/templates/reports/receipt/receipt.js
+++ b/print/templates/reports/receipt/receipt.js
@@ -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'
}
}
};
diff --git a/print/templates/reports/sepa-core/assets/css/import.js b/print/templates/reports/sepa-core/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/sepa-core/assets/css/import.js
+++ b/print/templates/reports/sepa-core/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js
index 7e3dd3566..73e0beaaa 100755
--- a/print/templates/reports/sepa-core/sepa-core.js
+++ b/print/templates/reports/sepa-core/sepa-core.js
@@ -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');
const rptSepaCore = {
name: 'sepa-core',
async serverPrefetch() {
- this.client = await this.fetchClient(this.recipientId, this.companyId);
- this.supplier = await this.fetchSupplier(this.recipientId, this.companyId);
+ this.client = await this.fetchClient(this.id, this.companyId);
+ this.supplier = await this.fetchSupplier(this.id, this.companyId);
if (!this.client)
throw new Error('Something went wrong');
@@ -19,18 +19,18 @@ const rptSepaCore = {
}
},
methods: {
- fetchClient(clientId, companyId) {
+ fetchClient(id, companyId) {
return this.findOneFromDef('client', [
companyId,
companyId,
- clientId
+ id
]);
},
- fetchSupplier(clientId, companyId) {
+ fetchSupplier(id, companyId) {
return this.findOneFromDef('supplier', [
companyId,
companyId,
- clientId
+ id
]);
}
},
@@ -39,9 +39,10 @@ const rptSepaCore = {
'report-footer': reportFooter.build()
},
props: {
- recipientId: {
+ id: {
type: [Number, String],
- required: true
+ required: true,
+ description: 'The client id'
},
companyId: {
type: [Number, String],
diff --git a/print/templates/reports/supplier-campaign-metrics/assets/css/import.js b/print/templates/reports/supplier-campaign-metrics/assets/css/import.js
index fd8796c2b..37a98dfdd 100644
--- a/print/templates/reports/supplier-campaign-metrics/assets/css/import.js
+++ b/print/templates/reports/supplier-campaign-metrics/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js b/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js
index 1a460daa9..6a58cbd0e 100755
--- a/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js
+++ b/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js
@@ -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
diff --git a/print/templates/reports/zone/assets/css/import.js b/print/templates/reports/zone/assets/css/import.js
index a2a9334cb..37a98dfdd 100644
--- a/print/templates/reports/zone/assets/css/import.js
+++ b/print/templates/reports/zone/assets/css/import.js
@@ -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();
diff --git a/print/templates/reports/zone/zone.js b/print/templates/reports/zone/zone.js
index d611e1e53..bbce9df36 100755
--- a/print/templates/reports/zone/zone.js
+++ b/print/templates/reports/zone/zone.js
@@ -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'
}
}
};