-
-
{{$t('fiscalAddress')}}
{{$t('disclaimer')}}
{{$t('privacy')}}
-
\ No newline at end of file
diff --git a/print/core/email.js b/print/core/email.js
index 5de13099a7..a0bcf91221 100644
--- a/print/core/email.js
+++ b/print/core/email.js
@@ -2,6 +2,7 @@ const path = require('path');
const smtp = require('./smtp');
const Component = require('./component');
const Report = require('./report');
+const UserError = require('vn-loopback/util/user-error');
if (!process.env.OPENSSL_CONF)
process.env.OPENSSL_CONF = '/etc/ssl/';
@@ -9,7 +10,6 @@ if (!process.env.OPENSSL_CONF)
class Email extends Component {
constructor(name, args) {
super(name);
-
this.args = args;
}
@@ -88,7 +88,11 @@ class Email extends Component {
force: options.force
};
- return await smtp.send(mailOptions);
+ try {
+ return await smtp.send(mailOptions);
+ } catch (error) {
+ throw new UserError('Cannot send mail');
+ }
}
}
diff --git a/print/templates/email/mrw-deadline/assets/css/import.js b/print/templates/email/mrw-deadline/assets/css/import.js
new file mode 100644
index 0000000000..4b4bb70869
--- /dev/null
+++ b/print/templates/email/mrw-deadline/assets/css/import.js
@@ -0,0 +1,11 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${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/mrw-deadline/locale/en.yml b/print/templates/email/mrw-deadline/locale/en.yml
new file mode 100644
index 0000000000..e10ec9e58b
--- /dev/null
+++ b/print/templates/email/mrw-deadline/locale/en.yml
@@ -0,0 +1,5 @@
+subject: Exceeding MRW Cut-off Time
+title: Exceeding MRW Cut-off Time
+greeting: Dear Team.
+body: Please be informed that we have exceeded the cut-off time indicated by MRW. From this moment, all generated labels will have a delivery date for tomorrow.It is necessary to contact the MRW representatives to manage any urgencies or clarifications that may arise.
+footer: Best regards.
diff --git a/print/templates/email/mrw-deadline/locale/es.yml b/print/templates/email/mrw-deadline/locale/es.yml
new file mode 100644
index 0000000000..656639fc33
--- /dev/null
+++ b/print/templates/email/mrw-deadline/locale/es.yml
@@ -0,0 +1,5 @@
+subject: Superación de la Hora de Corte de MRW
+title: Superación de la Hora de Corte de MRW
+greeting: Estimado equipo.
+body: Les informo que hemos superado la hora de corte indicada por MRW. A partir de este momento, todas las etiquetas generadas tendrán fecha de entrega para mañana.Es necesario que se pongan en contacto con los responsables de MRW para gestionar cualquier urgencia o aclaración que puedan necesitar.
+footer: Saludos cordiales.
diff --git a/print/templates/email/mrw-deadline/mrw-deadline.html b/print/templates/email/mrw-deadline/mrw-deadline.html
new file mode 100644
index 0000000000..adcf0228c8
--- /dev/null
+++ b/print/templates/email/mrw-deadline/mrw-deadline.html
@@ -0,0 +1,10 @@
+
+
+
+
{{ $t('title') }}
+
{{$t('greeting')}}
+
{{$t('body')}}
+
{{$t('footer')}}
+
+
+
diff --git a/print/templates/email/mrw-deadline/mrw-deadline.js b/print/templates/email/mrw-deadline/mrw-deadline.js
new file mode 100755
index 0000000000..574d88a0dc
--- /dev/null
+++ b/print/templates/email/mrw-deadline/mrw-deadline.js
@@ -0,0 +1,9 @@
+const Component = require(`vn-print/core/component`);
+const emailBody = new Component('email-body');
+
+module.exports = {
+ name: 'mrw-deadline',
+ components: {
+ 'email-body': emailBody.build(),
+ }
+};
diff --git a/print/templates/reports/buy-label/assets/css/import.js b/print/templates/reports/buy-label/assets/css/import.js
new file mode 100644
index 0000000000..37a98dfddb
--- /dev/null
+++ b/print/templates/reports/buy-label/assets/css/import.js
@@ -0,0 +1,12 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${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/buy-label/assets/css/style.css b/print/templates/reports/buy-label/assets/css/style.css
new file mode 100644
index 0000000000..0d4a2891da
--- /dev/null
+++ b/print/templates/reports/buy-label/assets/css/style.css
@@ -0,0 +1,41 @@
+html {
+ font-family: "Roboto", "Helvetica", "Arial", sans-serif;
+ margin-top: -7px;
+ font-size: 28px;
+}
+table {
+ border: 1px solid;
+ width: 100%;
+ font-size: inherit;
+}
+td {
+ border: 1px solid;
+ padding: 5px;
+ width: 100%;
+}
+span {
+ font-size: 48px;
+ font-weight: bold;
+}
+.lbl {
+ color: gray;
+ font-weight: lighter;
+ font-size: 18px;
+ display: block;
+}
+.cell {
+ width: 157px;
+ height: 50px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.barcode {
+ text-align: center;
+}
+#variant {
+ width: 314px;
+}
+#producer {
+ width: 471px;
+}
\ No newline at end of file
diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html
new file mode 100644
index 0000000000..494cdcbc58
--- /dev/null
+++ b/print/templates/reports/buy-label/buy-label.html
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+ {{$t('variety')}}
+ {{buy.name}}
+
+ |
+
+
+ {{$t('size')}}
+ {{buy.size}}
+
+ |
+
+
+
+
+ {{$t('category')}}
+ {{buy.category}}
+
+ |
+
+
+ {{$t('color')}}
+ {{buy.color}}
+
+ |
+
+
+ {{$t('origin')}}
+ {{buy.code}}
+
+ |
+
+
+
+
+ {{$t('packing')}}
+ {{buy.packing}}
+
+ |
+
+
+ {{$t('grouping')}}
+ {{buy.grouping}}
+
+ |
+
+
+ {{$t('saleUnit')}}
+ {{buy.stems}}
+
+ |
+
+
+
+
+ {{buy.id}}
+ |
+
+
+
+
+ {{$t('producer')}}
+ {{buy.producer}}
+
+ |
+
+
+
+
+ {{$t('control')}}
+ {{`${weekNum} / ${dayNum}`}}
+
+ |
+
+
+ {{$t('boxNum')}}
+ {{`${buy.labelNum} / ${maxLabelNum}`}}
+
+ |
+
+
+
+
diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js
new file mode 100755
index 0000000000..b6e0a50316
--- /dev/null
+++ b/print/templates/reports/buy-label/buy-label.js
@@ -0,0 +1,39 @@
+const vnReport = require('../../../core/mixins/vn-report.js');
+const {DOMImplementation, XMLSerializer} = require('xmldom');
+const jsBarcode = require('jsbarcode');
+const moment = require('moment');
+
+module.exports = {
+ name: 'buy-label',
+ mixins: [vnReport],
+ async serverPrefetch() {
+ this.buys = await this.rawSqlFromDef('buys', [this.id]);
+ this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum));
+ const date = new Date();
+ this.weekNum = moment(date).isoWeek();
+ this.dayNum = moment(date).day();
+ },
+ methods: {
+ getBarcode(id) {
+ const xmlSerializer = new XMLSerializer();
+ const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
+ const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+
+ jsBarcode(svgNode, id, {
+ xmlDocument: document,
+ format: 'code128',
+ displayValue: false,
+ width: 3.8,
+ height: 115,
+ });
+ return xmlSerializer.serializeToString(svgNode);
+ }
+ },
+ props: {
+ id: {
+ type: Number,
+ required: true,
+ description: 'The entry id'
+ }
+ }
+};
diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label/locale/en.yml
new file mode 100644
index 0000000000..d48d007717
--- /dev/null
+++ b/print/templates/reports/buy-label/locale/en.yml
@@ -0,0 +1,12 @@
+reportName: Entry buys
+variety: Bariety
+size: Size
+category: Category
+color: Color
+origin: Origin
+packing: Packing
+grouping: Grouping
+unitSale: Un. sale
+producer: Producer
+control: Control
+boxNum: Box no.
\ No newline at end of file
diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label/locale/es.yml
new file mode 100644
index 0000000000..33a4a499d7
--- /dev/null
+++ b/print/templates/reports/buy-label/locale/es.yml
@@ -0,0 +1,12 @@
+reportName: Etiqueta de compras
+variety: Variedad
+size: Medida
+category: Categoría
+color: Color
+origin: Origen
+packing: Packing
+grouping: Grouping
+saleUnit: Sale un.
+producer: Productor
+control: Control
+boxNum: Caja nº
\ No newline at end of file
diff --git a/print/templates/reports/buy-label/options.json b/print/templates/reports/buy-label/options.json
new file mode 100644
index 0000000000..4ed0461b30
--- /dev/null
+++ b/print/templates/reports/buy-label/options.json
@@ -0,0 +1,11 @@
+{
+ "width": "10cm",
+ "height": "10cm",
+ "margin": {
+ "top": "0.17cm",
+ "right": "0.2cm",
+ "bottom": "0cm",
+ "left": "0cm"
+ },
+ "printBackground": true
+}
\ No newline at end of file
diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql
new file mode 100644
index 0000000000..50b34bd03f
--- /dev/null
+++ b/print/templates/reports/buy-label/sql/buys.sql
@@ -0,0 +1,17 @@
+SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
+ i.name,
+ i.`size`,
+ i.category,
+ ink.id color,
+ o.code,
+ b.packing,
+ b.`grouping`,
+ i.stems,
+ b.id,
+ p.name producer
+ FROM buy b
+ JOIN item i ON i.id = b.itemFk
+ LEFT JOIN producer p ON p.id = i.producerFk
+ LEFT JOIN ink ON ink.id = i.inkFk
+ LEFT JOIN origin o ON o.id = i.originFk
+ WHERE b.entryFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/cmr/sql/data.sql b/print/templates/reports/cmr/sql/data.sql
index 42231709a7..31620a80d8 100644
--- a/print/templates/reports/cmr/sql/data.sql
+++ b/print/templates/reports/cmr/sql/data.sql
@@ -39,8 +39,7 @@ SELECT c.id cmrFk,
LEFT JOIN supplier s ON s.id = c.supplierFk
LEFT JOIN country cou ON cou.id = s.countryFk
LEFT JOIN company co ON co.id = c.companyFk
- LEFT JOIN supplierAccount sa ON sa.id = co.supplierAccountFk
- LEFT JOIN supplier s2 ON s2.id = sa.supplierFk
+ LEFT JOIN supplier s2 ON s2.id = c.companyFk
LEFT JOIN country cou2 ON cou2.id = s2.countryFk
LEFT JOIN `address` a ON a.id = c.addressToFk
LEFT JOIN province p ON p.id = a.provinceFk
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
index cfe29169b2..ebeaf4d7c3 100755
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
@@ -9,7 +9,7 @@ module.exports = {
this.checkMainEntity(this.invoice);
this.client = await this.findOneFromDef('client', [this.reference]);
this.incoterms =
- await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
+ await this.findOneFromDef('incoterms', [this.reference]);
if (!this.incoterms)
throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`);
},
diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
index 81c0ec189f..016a8342ec 100644
--- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql
+++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
@@ -1,52 +1,31 @@
-SELECT pack.packages,
- a.incotermsFk,
- ic.name incotermsName,
- t.weight,
- ca.fiscalName customsAgentName,
- ca.street customsAgentStreet,
- ca.nif customsAgentNif,
- ca.phone customsAgentPhone,
- ca.email customsAgentEmail,
- CAST(vol.volume AS DECIMAL (10,2)) volume,
- intr.intrastat
- FROM vn.invoiceOut io
- JOIN vn.supplier su ON su.id = io.companyFk
- JOIN vn.client c ON c.id = io.clientFk
- LEFT JOIN vn.province p ON p.id = c.provinceFk
- JOIN vn.ticket t ON t.refFk = io.ref
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.incoterms ic ON ic.code = a.incotermsFk
- LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN (
- SELECT SUM(volume) volume, COUNT(*) packages
- FROM vn.invoiceOut io
- JOIN vn.ticket t ON t.refFk = io.ref
- JOIN vn.saleVolume sv ON sv.ticketFk = t.id
- WHERE t.refFk = ?
- ) vol
- JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
- AND itc.itemFk = s.itemFk
- JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
- JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
- AND ios.taxAreaFk = 'WORLD'
- JOIN vn.country cty ON cty.id = c.countryFk
- JOIN vn.payMethod pm ON pm.id = c .payMethodFk
- JOIN vn.company co ON co.id=io.companyFk
- JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk
- JOIN (
- SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
- FROM vn.ticket t
- JOIN vn.invoiceOut io ON io.ref = t.refFk
- JOIN vn.sale s ON t.id = s.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.intrastat ir ON ir.id = i.intrastatFk
- WHERE t.refFk = ?
- ) intr
- JOIN (
- SELECT SUM(packages) packages
- FROM ticket
- WHERE refFk = ?
- ) pack
- WHERE t.refFk = ?
- LIMIT 1
+WITH tickets AS(
+SELECT id, packages, addressFk, weight
+ FROM ticket
+ WHERE refFk= ?
+), volume AS(
+SELECT SUM(volume) volume
+ FROM tickets t
+ JOIN vn.saleVolume sv ON sv.ticketFk = t.id
+), intrastat AS(
+SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
+ FROM tickets t
+ JOIN vn.sale s ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.intrastat ir ON ir.id = i.intrastatFk
+)SELECT SUM(t.packages) packages,
+ a.incotermsFk,
+ ic.name incotermsName,
+ MAX(t.weight) weight,
+ ca.fiscalName customsAgentName,
+ ca.street customsAgentStreet,
+ ca.nif customsAgentNif,
+ ca.phone customsAgentPhone,
+ ca.email customsAgentEmail,
+ CAST(v.volume AS DECIMAL (10,2)) volume,
+ i.intrastat
+ FROM tickets t
+ JOIN vn.address a ON a.id = t.addressFk
+ JOIN vn.incoterms ic ON ic.code = a.incotermsFk
+ LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
+ JOIN volume v
+ JOIN intrastat i