-
{{$t('Place')}} {{currentDate()}}
+
{{$t('Place')}} {{formatDate(new Date(), '%d-%m-%Y')}}
{{$t('Compensation') | uppercase}}
{{$t('In one hand')}}:
@@ -17,7 +17,7 @@
{{$t('Agree') | uppercase}}
- {{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
+ {{$t('Date')}} {{formatDate(client.payed, '%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
{{$t('From client')}} {{client.name}} {{$t('Toclient')}} {{company.name}}.
diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js
index 98a9cf577..bae7c5c3c 100644
--- a/print/templates/reports/balance-compensation/balance-compensation.js
+++ b/print/templates/reports/balance-compensation/balance-compensation.js
@@ -1,28 +1,12 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'balance-compensation',
+ mixins: [vnReport],
async serverPrefetch() {
- this.client = await this.fetchClient(this.id);
- this.company = await this.fetchCompany(this.id);
- },
- methods: {
- fetchClient(id) {
- return this.findOneFromDef('client', [id]);
- },
- fetchCompany(id) {
- return this.findOneFromDef('company', [id]);
- },
-
- currentDate() {
- const current = new Date();
- const date = `${current.getDate()}/${current.getMonth() + 1}/${current.getFullYear()}`;
- return date;
- }
- },
- components: {
- 'report-body': reportBody.build()
+ this.client = await this.findOneFromDef('client', [this.id]);
+ this.checkMainEntity(this.client);
+ this.company = await this.findOneFromDef('company', [this.id]);
},
props: {
id: {
diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html
index e86d4cd3b..57d616a29 100644
--- a/print/templates/reports/campaign-metrics/campaign-metrics.html
+++ b/print/templates/reports/campaign-metrics/campaign-metrics.html
@@ -13,11 +13,11 @@
{{$t('From')}} |
- {{from | date('%d-%m-%Y')}} |
+ {{formatDate(from, '%d-%m-%Y')}} |
{{$t('To')}} |
- {{to | date('%d-%m-%Y')}} |
+ {{formatDate(to, '%d-%m-%Y')}} |
diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js
index 14a4b6a9b..45bca88dc 100755
--- a/print/templates/reports/campaign-metrics/campaign-metrics.js
+++ b/print/templates/reports/campaign-metrics/campaign-metrics.js
@@ -1,27 +1,12 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'campaign-metrics',
+ mixins: [vnReport],
async serverPrefetch() {
- 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(id) {
- return this.findOneFromDef('client', [id]);
- },
- fetchSales(id, from, to) {
- return this.rawSqlFromDef('sales', [id, from, to]);
- },
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
+ this.client = await this.findOneFromDef('client', [this.id]);
+ this.checkMainEntity(this.client);
+ this.sales = await this.rawSqlFromDef('sales', [this.id, this.from, this.to]);
},
props: {
id: {
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 b14f5410c..000568ef2 100644
--- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html
+++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html
@@ -20,7 +20,7 @@
{{$t('date')}} |
- {{dated}} |
+ {{formatDate(new Date(), '%d-%m-%Y')}} |
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 5c7002e47..cc5cec1ea 100755
--- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js
+++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js
@@ -1,34 +1,12 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'claim-pickup-order',
+ mixins: [vnReport],
async serverPrefetch() {
- this.client = await this.fetchClient(this.id);
- this.sales = await this.fetchSales(this.id);
-
- if (!this.client)
- throw new Error('Something went wrong');
- },
- computed: {
- dated: function() {
- const filters = this.$options.filters;
-
- return filters.date(new Date(), '%d-%m-%Y');
- }
- },
- methods: {
- fetchClient(id) {
- return this.findOneFromDef('client', [id]);
- },
- fetchSales(id) {
- return this.rawSqlFromDef('sales', [id]);
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
+ this.client = await this.findOneFromDef('client', [this.id]);
+ this.checkMainEntity(this.client);
+ this.sales = await this.rawSqlFromDef('sales', [this.id]);
},
props: {
id: {
@@ -36,5 +14,5 @@ module.exports = {
required: true,
description: 'The claim id'
}
- }
+ },
};
diff --git a/print/templates/reports/client-debt-statement/client-debt-statement.html b/print/templates/reports/client-debt-statement/client-debt-statement.html
index 962af021d..fb7bfd625 100644
--- a/print/templates/reports/client-debt-statement/client-debt-statement.html
+++ b/print/templates/reports/client-debt-statement/client-debt-statement.html
@@ -13,7 +13,7 @@
{{$t('date')}} |
- {{dated}} |
+ {{formatDate(new Date(), '%d-%m-%Y');}} |
@@ -44,7 +44,7 @@
- {{sale.issued | date('%d-%m-%Y')}} |
+ {{formatDate(sale.issued, '%d-%m-%Y');}} |
{{sale.ref}} |
{{sale.debtOut}} |
{{sale.debtIn}} |
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 45b97518f..a74595200 100755
--- a/print/templates/reports/client-debt-statement/client-debt-statement.js
+++ b/print/templates/reports/client-debt-statement/client-debt-statement.js
@@ -1,44 +1,18 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'client-debt-statement',
+ mixins: [vnReport],
async serverPrefetch() {
- 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');
- },
- computed: {
- dated: function() {
- const filters = this.$options.filters;
-
- return filters.date(new Date(), '%d-%m-%Y');
- }
+ this.client = await this.findOneFromDef('client', [this.id]);
+ this.checkMainEntity(this.client);
+ this.sales = await this.rawSqlFromDef('sales',
+ [this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id]);
},
data() {
return {totalBalance: 0.00};
},
methods: {
- fetchClient(id) {
- return this.findOneFromDef('client', [id]);
- },
- fetchSales(id, from) {
- return this.rawSqlFromDef('sales', [
- from,
- id,
- from,
- id,
- from,
- id,
- from,
- id,
- from,
- id
- ]);
- },
getBalance(sale) {
if (sale.debtOut)
this.totalBalance += parseFloat(sale.debtOut);
@@ -63,10 +37,6 @@ module.exports = {
return debtIn.toFixed(2);
},
},
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
- },
props: {
id: {
type: Number,
diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js
index e73afaeea..74024bb56 100644
--- a/print/templates/reports/collection-label/collection-label.js
+++ b/print/templates/reports/collection-label/collection-label.js
@@ -1,11 +1,10 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom');
-const UserError = require('vn-loopback/util/user-error');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'collection-label',
+ mixins: [vnReport],
props: {
id: {
type: Number,
@@ -30,8 +29,7 @@ module.exports = {
ticketIds = [this.id];
this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
- if (!this.labelsData.length)
- throw new UserError('Empty data source');
+ this.checkMainEntity(this.labelsData);
},
methods: {
getBarcode(id) {
@@ -62,7 +60,4 @@ module.exports = {
return value;
},
},
- components: {
- 'report-body': reportBody.build()
- },
};
diff --git a/print/templates/reports/credit-request/credit-request.html b/print/templates/reports/credit-request/credit-request.html
index d5e336809..c8e3f8c34 100644
--- a/print/templates/reports/credit-request/credit-request.html
+++ b/print/templates/reports/credit-request/credit-request.html
@@ -159,6 +159,6 @@
-
+
diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js
index c1aa74e1b..75e0b2263 100755
--- a/print/templates/reports/credit-request/credit-request.js
+++ b/print/templates/reports/credit-request/credit-request.js
@@ -1,20 +1,7 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body')
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
-const rptCreditRequest = {
+module.exports = {
name: 'credit-request',
- computed: {
- dated: function() {
- const filters = this.$options.filters;
-
- return filters.date(new Date(), '%d-%m-%Y');
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
- }
+ mixins: [vnReport],
};
-module.exports = rptCreditRequest;
diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html
index 06653c949..9f217ba22 100644
--- a/print/templates/reports/delivery-note/delivery-note.html
+++ b/print/templates/reports/delivery-note/delivery-note.html
@@ -20,7 +20,7 @@
{{$t('date')}} |
- {{ticket.shipped | date('%d-%m-%Y')}} |
+ {{formatDate(ticket.shipped, '%d-%m-%Y')}} |
{{$t('packages')}} |
@@ -231,7 +231,7 @@
-
{{signature.created | date('%d-%m-%Y')}}
+
{{formatDate(signature.created, '%d-%m-%Y')}}
diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js
index 1a1a57c59..d9544a58c 100755
--- a/print/templates/reports/delivery-note/delivery-note.js
+++ b/print/templates/reports/delivery-note/delivery-note.js
@@ -1,25 +1,21 @@
const config = require(`vn-print/core/config`);
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportHeader = new Component('report-header');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
const md5 = require('md5');
const fs = require('fs-extra');
module.exports = {
name: 'delivery-note',
+ mixins: [vnReport],
async serverPrefetch() {
- 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');
+ this.ticket = await this.findOneFromDef('ticket', [this.id]);
+ this.checkMainEntity(this.ticket);
+ this.client = await this.findOneFromDef('client', [this.id]);
+ this.sales = await this.rawSqlFromDef('sales', [this.id]);
+ this.address = await this.findOneFromDef(`address`, [this.id]);
+ this.services = await this.rawSqlFromDef('services', [this.id]);
+ this.taxes = await this.rawSqlFromDef('taxes', [this.id]);
+ this.packagings = await this.rawSqlFromDef('packagings', [this.id]);
+ this.signature = await this.findOneFromDef('signature', [this.id]);
},
data() {
return {totalBalance: 0.00};
@@ -61,31 +57,6 @@ module.exports = {
}
},
methods: {
- fetchClient(id) {
- return this.findOneFromDef('client', [id]);
- },
- fetchTicket(id) {
- return this.findOneFromDef('ticket', [id]);
- },
- fetchAddress(id) {
- return this.findOneFromDef(`address`, [id]);
- },
- fetchSignature(id) {
- return this.findOneFromDef('signature', [id]);
- },
- fetchTaxes(id) {
- return this.findOneFromDef(`taxes`, [id]);
- },
- fetchSales(id) {
- return this.rawSqlFromDef('sales', [id]);
- },
- fetchPackagings(id) {
- return this.rawSqlFromDef('packagings', [id]);
- },
- fetchServices(id) {
- return this.rawSqlFromDef('services', [id]);
- },
-
getSubTotal() {
let subTotal = 0.00;
this.sales.forEach(sale => {
@@ -125,11 +96,6 @@ module.exports = {
).join(', ');
}
},
- components: {
- 'report-body': reportBody.build(),
- 'report-header': reportHeader.build(),
- 'report-footer': reportFooter.build()
- },
props: {
id: {
type: Number,
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html
index 48489de6f..1475b8e77 100644
--- a/print/templates/reports/driver-route/driver-route.html
+++ b/print/templates/reports/driver-route/driver-route.html
@@ -16,13 +16,13 @@
{{$t('date')}} |
- {{route.created | date('%d-%m-%Y')}} |
+ {{formatDate(route.created, '%d-%m-%Y')}} |
{{$t('vehicle')}} |
{{route.vehicleTradeMark}} {{route.vehicleModel}} |
{{$t('time')}} |
- {{route.time | date('%H:%M')}} |
+ {{formatDate(route.time, '%H:%M')}} |
|
{{route.plateNumber}} |
diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js
index 1b2e8871a..c166e3809 100755
--- a/print/templates/reports/driver-route/driver-route.js
+++ b/print/templates/reports/driver-route/driver-route.js
@@ -1,9 +1,8 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'driver-route',
+ mixins: [vnReport],
async serverPrefetch() {
let ids = this.id;
@@ -11,8 +10,8 @@ module.exports = {
if (hasMultipleRoutes)
ids = this.id.split(',');
- const routes = await this.fetchRoutes(ids);
- const tickets = await this.fetchTickets(ids);
+ const routes = await this.rawSqlFromDef('routes', [ids]);
+ const tickets = await this.rawSqlFromDef('tickets', [ids, ids]);
const map = new Map();
@@ -27,20 +26,7 @@ module.exports = {
this.routes = routes;
- if (!this.routes)
- throw new Error('Something went wrong');
- },
- methods: {
- fetchRoutes(ids) {
- return this.rawSqlFromDef('routes', [ids]);
- },
- fetchTickets(ids) {
- return this.rawSqlFromDef('tickets', [ids, ids]);
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
+ this.checkMainEntity(this.routes);
},
props: {
id: {
diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html
index 26294787b..5d362dea9 100644
--- a/print/templates/reports/entry-order/entry-order.html
+++ b/print/templates/reports/entry-order/entry-order.html
@@ -16,7 +16,7 @@
{{$t('date')}} |
- {{entry.landed | date('%d-%m-%Y')}} |
+ {{formatDate(entry.landed,'%d-%m-%Y')}} |
{{$t('ref')}} |
diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js
index 22c5b55fe..d31ad1a36 100755
--- a/print/templates/reports/entry-order/entry-order.js
+++ b/print/templates/reports/entry-order/entry-order.js
@@ -1,31 +1,18 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportHeader = new Component('report-header');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'entry-order',
+ mixins: [vnReport],
async serverPrefetch() {
- 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');
+ this.entry = await this.findOneFromDef('entry', [this.id]);
+ this.checkMainEntity(this.entry);
+ this.supplier = await this.findOneFromDef('supplier', [this.id]);
+ this.buys = await this.rawSqlFromDef('buys', [this.id]);
},
data() {
return {totalBalance: 0.00};
},
methods: {
- fetchSupplier(id) {
- return this.findOneFromDef('supplier', [id]);
- },
- fetchEntry(id) {
- return this.findOneFromDef('entry', [id]);
- },
- fetchBuys(id) {
- return this.rawSqlFromDef('buys', [id]);
- },
getTotal() {
let total = 0.00;
this.buys.forEach(buy => {
@@ -35,11 +22,6 @@ module.exports = {
return total;
}
},
- components: {
- 'report-body': reportBody.build(),
- 'report-header': reportHeader.build(),
- 'report-footer': reportFooter.build()
- },
props: {
id: {
type: Number,
diff --git a/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js b/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js
index 0e8c297e8..321862671 100644
--- a/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js
+++ b/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js
@@ -1,12 +1,11 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
+const vnReport = require('../../../core/mixins/vn-report.js');
const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom');
-const UserError = require('vn-loopback/util/user-error');
const qrcode = require('qrcode');
module.exports = {
name: 'expedition-pallet-label',
+ mixins: [vnReport],
props: {
id: {
type: Number,
@@ -33,8 +32,7 @@ module.exports = {
});
this.QR = await this.getQR(QRdata);
- if (!this.labelsData.length)
- throw new UserError('Empty data source');
+ this.checkMainEntity(this.labelsData);
},
methods: {
getQR(id) {
@@ -56,7 +54,4 @@ module.exports = {
return xmlSerializer.serializeToString(svgNode);
},
},
- components: {
- 'report-body': reportBody.build()
- },
};
diff --git a/print/templates/reports/exportation/exportation.html b/print/templates/reports/exportation/exportation.html
index 920e32a48..0800c024d 100644
--- a/print/templates/reports/exportation/exportation.html
+++ b/print/templates/reports/exportation/exportation.html
@@ -3,7 +3,7 @@
{{$t('title')}}
{{$t('toAttention')}}
-
+
-
@@ -32,4 +32,4 @@
-
\ No newline at end of file
+
diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js
index 9f39aa1a1..123b350ee 100755
--- a/print/templates/reports/exportation/exportation.js
+++ b/print/templates/reports/exportation/exportation.js
@@ -1,33 +1,13 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'exportation',
+ mixins: [vnReport],
async serverPrefetch() {
- this.invoice = await this.fetchInvoice(this.reference);
-
- if (!this.invoice)
- throw new Error('Something went wrong');
-
+ this.invoice = await this.findOneFromDef('invoice', [this.reference]);
+ this.checkMainEntity(this.invoice);
this.company = await this.findOneFromDef('company', [this.invoice.companyFk]);
},
- methods: {
- fetchInvoice(reference) {
- return this.findOneFromDef('invoice', [reference]);
- }
- },
- computed: {
- issued: function() {
- const filters = this.$options.filters;
-
- return filters.date(this.invoice.issued, '%d-%m-%Y');
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
- },
props: {
reference: {
type: Number,
diff --git a/print/templates/reports/extra-community/extra-community.html b/print/templates/reports/extra-community/extra-community.html
index 6a46cc689..cd61a4f4d 100644
--- a/print/templates/reports/extra-community/extra-community.html
+++ b/print/templates/reports/extra-community/extra-community.html
@@ -26,7 +26,7 @@
{{$t('shipped')}} |
- {{travel.shipped | date('%d-%m-%Y')}} |
+ {{formatDate(travel.shipped, '%d-%m-%Y')}} |
{{$t('physicalKg')}} |
{{travel.loadedKg | number($i18n.locale)}} |
@@ -62,6 +62,6 @@
-
+
diff --git a/print/templates/reports/extra-community/extra-community.js b/print/templates/reports/extra-community/extra-community.js
index 4dfe6e278..9941faa35 100755
--- a/print/templates/reports/extra-community/extra-community.js
+++ b/print/templates/reports/extra-community/extra-community.js
@@ -1,12 +1,10 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
const db = require(`vn-print/core/database`);
module.exports = {
name: 'extra-community',
+ mixins: [vnReport],
async serverPrefetch() {
- this.filters = this.$options.filters;
const args = {
landedTo: this.landedEnd,
shippedFrom: this.shippedStart,
@@ -21,8 +19,9 @@ module.exports = {
};
const travels = await this.fetchTravels(args);
+ this.checkMainEntity(travels);
const travelIds = travels.map(travel => travel.id);
- const entries = await this.fetchEntries(travelIds);
+ const entries = await this.rawSqlFromDef('entries', [travelIds]);
const map = new Map();
for (let travel of travels)
@@ -35,23 +34,15 @@ module.exports = {
}
this.travels = travels;
-
- if (!this.travels)
- throw new Error('Something went wrong');
},
computed: {
- dated: function() {
- return this.filters.date(new Date(), '%d-%m-%Y');
- },
landedEnd: function() {
if (!this.landedTo) return;
-
- return this.filters.date(this.landedTo, '%Y-%m-%d');
+ return formatDate(this.landedTo, '%Y-%m-%d');
},
shippedStart: function() {
if (!this.shippedFrom) return;
-
- return this.filters.date(this.shippedFrom, '%Y-%m-%d');
+ return formatDate(this.shippedFrom, '%Y-%m-%d');
}
},
methods: {
@@ -83,25 +74,17 @@ module.exports = {
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,
+ ORDER BY
+ shipped ASC,
+ landed ASC,
+ travelFk,
+ loadPriority,
+ agencyModeFk,
evaNotes
`);
return this.rawSql(query);
},
-
- fetchEntries(travelIds) {
- return this.rawSqlFromDef('entries', [travelIds]);
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
},
props: [
'landedTo',
diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
index bfe675985..53425487e 100755
--- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
@@ -1,23 +1,12 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'incoterms-authorization',
+ mixins: [vnReport],
async serverPrefetch() {
this.client = await this.findOneFromDef('client', [this.id]);
+ this.checkMainEntity(this.client);
this.company = await this.findOneFromDef('company', [this.companyId]);
- if (!this.client)
- throw new Error('Something went wrong');
- },
- computed: {
- issued: function() {
- return new Date();
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-footer': reportFooter.build()
},
props: {
id: {
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.html b/print/templates/reports/invoice-incoterms/invoice-incoterms.html
index 20c9ad440..1915828ba 100644
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.html
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.html
@@ -20,7 +20,7 @@
{{$t('date')}} |
- {{invoice.issued | date('%d-%m-%Y')}} |
+ {{formatDate(invoice.issued, '%d-%m-%Y')}} |
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
index 3afc50376..fcaffe5de 100755
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
@@ -1,34 +1,13 @@
-const Component = require(`vn-print/core/component`);
-const reportBody = new Component('report-body');
-const reportHeader = new Component('report-header');
+const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'invoice-incoterms',
+ mixins: [vnReport],
async serverPrefetch() {
- 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');
- },
- computed: {
-
- },
- methods: {
- fetchInvoice(reference) {
- return this.findOneFromDef('invoice', [reference]);
- },
- fetchClient(reference) {
- return this.findOneFromDef('client', [reference]);
- },
- fetchIncoterms(reference) {
- return this.findOneFromDef('incoterms', [reference, reference, reference]);
- }
- },
- components: {
- 'report-body': reportBody.build(),
- 'report-header': reportHeader.build()
+ this.invoice = await this.findOneFromDef('invoice', [this.reference]);
+ this.checkMainEntity(this.invoice);
+ this.client = await this.findOneFromDef('client', [this.reference]);
+ this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference]);
},
props: {
reference: {
diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html
index d23bba1e9..60d06d528 100644
--- a/print/templates/reports/invoice/invoice.html
+++ b/print/templates/reports/invoice/invoice.html
@@ -21,7 +21,7 @@
{{$t('date')}} |
- {{invoice.issued | date('%d-%m-%Y')}} |
+ {{formatDate(invoice.issued, '%d-%m-%Y')}} |
@@ -53,7 +53,7 @@
{{row.ref}} |
- {{row.issued | date}} |
+ {{formatDate(row.issued, '%d-%m-%Y')}} |
{{row.amount | currency('EUR', $i18n.locale)}} |
{{row.description}} |
@@ -75,7 +75,7 @@
- {{ticket.shipped | date}}
+ {{formatDate(ticket.shipped, '%d-%m-%Y')}}
diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js
index f7011ad81..7b572d970 100755
--- a/print/templates/reports/invoice/invoice.js
+++ b/print/templates/reports/invoice/invoice.js
@@ -1,22 +1,21 @@
-const Component = require(`vn-print/core/component`);
const Report = require(`vn-print/core/report`);
-const reportBody = new Component('report-body');
-const reportHeader = new Component('report-header');
-const reportFooter = new Component('report-footer');
+const vnReport = require('../../../core/mixins/vn-report.js');
const invoiceIncoterms = new Report('invoice-incoterms');
module.exports = {
name: 'invoice',
+ mixins: [vnReport],
async serverPrefetch() {
- 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);
+ this.invoice = await this.findOneFromDef('invoice', [this.reference]);
+ this.checkMainEntity(this.invoice);
+ this.client = await this.findOneFromDef('client', [this.reference]);
+ this.taxes = await this.rawSqlFromDef(`taxes`, [this.reference]);
+ this.intrastat = await this.rawSqlFromDef(`intrastat`, [this.reference, this.reference, this.reference]);
+ this.rectified = await this.rawSqlFromDef(`rectified`, [this.reference]);
+ this.hasIncoterms = await this.findValueFromDef(`hasIncoterms`, [this.reference]);
- const tickets = await this.fetchTickets(this.reference);
- const sales = await this.fetchSales(this.reference);
+ const tickets = await this.rawSqlFromDef('tickets', [this.reference]);
+ const sales = await this.rawSqlFromDef('sales', [this.reference, this.reference]);
const map = new Map();
@@ -33,9 +32,6 @@ module.exports = {
}
this.tickets = tickets;
-
- if (!this.invoice)
- throw new Error('Something went wrong');
},
data() {
return {totalBalance: 0.00};
@@ -66,30 +62,6 @@ module.exports = {
}
},
methods: {
- fetchInvoice(reference) {
- return this.findOneFromDef('invoice', [reference]);
- },
- fetchClient(reference) {
- return this.findOneFromDef('client', [reference]);
- },
- fetchTickets(reference) {
- return this.rawSqlFromDef('tickets', [reference]);
- },
- fetchSales(reference) {
- return this.rawSqlFromDef('sales', [reference, reference]);
- },
- fetchTaxes(reference) {
- return this.rawSqlFromDef(`taxes`, [reference]);
- },
- fetchIntrastat(reference) {
- return this.rawSqlFromDef(`intrastat`, [reference, reference, reference]);
- },
- fetchRectified(reference) {
- return this.rawSqlFromDef(`rectified`, [reference]);
- },
- fetchHasIncoterms(reference) {
- return this.findValueFromDef(`hasIncoterms`, [reference]);
- },
saleImport(sale) {
const price = sale.quantity * sale.price;
@@ -111,9 +83,6 @@ module.exports = {
}
},
components: {
- 'report-body': reportBody.build(),
- 'report-header': reportHeader.build(),
- 'report-footer': reportFooter.build(),
'invoice-incoterms': invoiceIncoterms.build()
},
props: {
diff --git a/print/templates/reports/invoiceIn/invoiceIn.html b/print/templates/reports/invoiceIn/invoiceIn.html
index f101f7408..22988b654 100644
--- a/print/templates/reports/invoiceIn/invoiceIn.html
+++ b/print/templates/reports/invoiceIn/invoiceIn.html
@@ -19,7 +19,7 @@
{{$t('date')}} |
- {{invoice.created | date('%d-%m-%Y')}} |
+ {{formatDate(invoice.created, '%d-%m-%Y')}} |
@@ -54,7 +54,7 @@