From 1e36b460a130c05798f9b162c450a44cab8fd73b Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 1 Mar 2021 11:25:37 +0100 Subject: [PATCH] Added invoice incoterms report --- print/common/css/misc.css | 4 + print/core/component.js | 7 +- print/core/mixins/db-helper.js | 6 +- .../invoice-incoterms/assets/css/import.js | 9 ++ .../invoice-incoterms/assets/css/style.css | 29 ++++ .../invoice-incoterms/invoice-incoterms.html | 124 ++++++++++++++++++ .../invoice-incoterms/invoice-incoterms.js | 40 ++++++ .../reports/invoice-incoterms/locale/es.yml | 16 +++ .../reports/invoice-incoterms/sql/client.sql | 12 ++ .../invoice-incoterms/sql/incoterms.sql | 71 ++++++++++ .../reports/invoice-incoterms/sql/invoice.sql | 17 +++ print/templates/reports/invoice/invoice.html | 8 +- print/templates/reports/invoice/invoice.js | 8 +- .../reports/invoice/sql/hasIncoterms.sql | 8 ++ 14 files changed, 351 insertions(+), 8 deletions(-) create mode 100644 print/templates/reports/invoice-incoterms/assets/css/import.js create mode 100644 print/templates/reports/invoice-incoterms/assets/css/style.css create mode 100644 print/templates/reports/invoice-incoterms/invoice-incoterms.html create mode 100755 print/templates/reports/invoice-incoterms/invoice-incoterms.js create mode 100644 print/templates/reports/invoice-incoterms/locale/es.yml create mode 100644 print/templates/reports/invoice-incoterms/sql/client.sql create mode 100644 print/templates/reports/invoice-incoterms/sql/incoterms.sql create mode 100644 print/templates/reports/invoice-incoterms/sql/invoice.sql create mode 100644 print/templates/reports/invoice/sql/hasIncoterms.sql diff --git a/print/common/css/misc.css b/print/common/css/misc.css index 09d7706b3..df8bf571a 100644 --- a/print/common/css/misc.css +++ b/print/common/css/misc.css @@ -45,4 +45,8 @@ .no-page-break { page-break-inside: avoid; break-inside: avoid +} + +.page-break-after { + page-break-after: always; } \ No newline at end of file diff --git a/print/core/component.js b/print/core/component.js index 4985cd061..12474566e 100644 --- a/print/core/component.js +++ b/print/core/component.js @@ -83,6 +83,11 @@ class Component { component.template = juice.inlineContent(this.template, this.stylesheet, { inlinePseudoElements: true }); + const tplPath = this.path; + if (!component.computed) component.computed = {}; + component.computed.path = function() { + return tplPath; + }; return component; } @@ -93,7 +98,7 @@ class Component { const component = this.build(); const i18n = new VueI18n(config.i18n); - const props = {tplPath: this.path, ...this.args}; + const props = {...this.args}; this._component = new Vue({ i18n: i18n, render: h => h(component, { diff --git a/print/core/mixins/db-helper.js b/print/core/mixins/db-helper.js index ee45d65d4..a953a6ef1 100644 --- a/print/core/mixins/db-helper.js +++ b/print/core/mixins/db-helper.js @@ -24,7 +24,7 @@ const dbHelper = { * @return {Object} - Result promise */ rawSqlFromDef(queryName, params, connection) { - const absolutePath = path.join(__dirname, '../', this.tplPath, 'sql', queryName); + const absolutePath = path.join(__dirname, '../', this.path, 'sql', queryName); return db.rawSqlFromDef(absolutePath, params, connection); }, @@ -78,11 +78,11 @@ const dbHelper = { * @return {Object} - SQL */ getSqlFromDef(queryName) { - const absolutePath = path.join(__dirname, '../', this.tplPath, 'sql', queryName); + const absolutePath = path.join(__dirname, '../', this.path, 'sql', queryName); return db.getSqlFromDef(absolutePath); }, }, - props: ['tplPath'] + props: ['tplPath', 'name'] }; Vue.mixin(dbHelper); diff --git a/print/templates/reports/invoice-incoterms/assets/css/import.js b/print/templates/reports/invoice-incoterms/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/invoice-incoterms/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/invoice-incoterms/assets/css/style.css b/print/templates/reports/invoice-incoterms/assets/css/style.css new file mode 100644 index 000000000..d754d050f --- /dev/null +++ b/print/templates/reports/invoice-incoterms/assets/css/style.css @@ -0,0 +1,29 @@ +h2 { + font-weight: 100; + color: #555 +} + +.table-title { + margin-bottom: 15px; + font-size: 0.8rem +} + +.table-title h2 { + margin: 0 15px 0 0 +} + +.ticket-info { + font-size: 22px +} + +#incoterms table { + font-size: 1.2rem +} + +#incoterms table th { + width: 10% +} + +#incoterms p { + font-size: 1.2rem +} \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.html b/print/templates/reports/invoice-incoterms/invoice-incoterms.html new file mode 100644 index 000000000..2cceccc93 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.html @@ -0,0 +1,124 @@ + + + + + + + + + +
+ + + + +
+
+
+
+
+

{{$t('title')}}

+ + + + + + + + + + + + + + + +
{{$t('clientId')}}{{client.id}}
{{$t('invoice')}}{{invoice.ref}}
{{$t('date')}}{{invoice.issued | date('%d-%m-%Y')}}
+
+
+
+
+
{{$t('invoiceData')}}
+
+

{{client.socialName}}

+
+ {{client.postalAddress}} +
+
+ {{client.postcodeCity}} +
+
+ {{$t('fiscalId')}}: {{client.fi}} +
+
+
+
+
+ +
+
{{$t('incotermsTitle')}}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {{$t('incoterms')}} +
asd
+
{{incoterms.incotermsFk}} - {{incoterms.incotermsName}}
+ {{$t('productDescription')}} + {{incoterms.intrastat}}
{{$t('expeditionDescription')}}
{{$t('packageNumber')}}{{incoterms.packages}}
{{$t('packageGrossWeight')}}{{incoterms.weight}} KG
{{$t('packageCubing')}}{{incoterms.volume}} m3
+ +

+

+ {{$t('customsInfo')}} + {{incoterms.customsAgentName}} +
+
+ ( + {{incoterms.customsAgentNif}} + {{incoterms.customsAgentStreet}} + + ☎ {{incoterms.customsAgentPhone}} + + + ✉ {{incoterms.customsAgentEmail}} + + ) +
+

+

+ {{$t('productDisclaimer')}} +

+
+
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js new file mode 100755 index 000000000..cdf08bed0 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -0,0 +1,40 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); +const db = require(`${appPath}/core/database`); + +module.exports = { + name: 'invoice-incoterms', + async serverPrefetch() { + this.invoice = await this.fetchInvoice(this.invoiceId); + this.client = await this.fetchClient(this.invoiceId); + this.incoterms = await this.fetchIncoterms(this.invoiceId); + + if (!this.invoice) + throw new Error('Something went wrong'); + }, + computed: { + + }, + methods: { + fetchInvoice(invoiceId) { + return this.findOneFromDef('invoice', [invoiceId]); + }, + fetchClient(invoiceId) { + return this.findOneFromDef('client', [invoiceId]); + }, + fetchIncoterms(invoiceId) { + return this.findOneFromDef('incoterms', {invoiceId}); + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + invoiceId: { + type: String, + required: true + } + } +}; diff --git a/print/templates/reports/invoice-incoterms/locale/es.yml b/print/templates/reports/invoice-incoterms/locale/es.yml new file mode 100644 index 000000000..9828564d7 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/locale/es.yml @@ -0,0 +1,16 @@ +title: Factura +invoice: Factura +clientId: Cliente +date: Fecha +invoiceData: Datos de facturación +fiscalId: CIF / NIF +invoiceRef: Factura {0} +incotermsTitle: Información para la exportación +incoterms: Incoterms +productDescription: Descripción de la mercancia +expeditionDescription: INFORMACIÓN DE LA EXPEDICIÓN +packageNumber: Número de bultos +packageGrossWeight: Peso bruto +packageCubing: Cubicaje +customsInfo: A despachar por la agencia de aduanas +productDisclaimer: Mercancía destinada a la exportación, EXENTA de IVA (Ley 37/1992 - Art. 21) \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/sql/client.sql b/print/templates/reports/invoice-incoterms/sql/client.sql new file mode 100644 index 000000000..dd6035222 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/sql/client.sql @@ -0,0 +1,12 @@ +SELECT + c.id, + c.socialName, + c.street AS postalAddress, + IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi, + CONCAT(c.postcode, ' - ', c.city) postcodeCity +FROM vn.invoiceOut io + JOIN vn.client c ON c.id = io.clientFk + JOIN vn.country cty ON cty.id = c.countryFk + LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial + AND ios.taxAreaFk = 'CEE' +WHERE io.id = ? \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql new file mode 100644 index 000000000..e3d3f19c1 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -0,0 +1,71 @@ +SELECT io.issued, + c.socialName, + c.street postalAddress, + IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi, + io.clientFk, + c.postcode, + c.city, + io.companyFk, + io.ref, + tc.code, + s.concept, + s.quantity, + s.price, + s.discount, + s.ticketFk, + t.shipped, + t.refFk, + a.nickname, + s.itemFk, + s.id saleFk, + pm.name AS pmname, + sa.iban, + c.phone, + MAX(t.packages) packages, + a.incotermsFk, + ic.name incotermsName , + sub.description weight, + t.observations, + ca.fiscalName customsAgentName, + ca.street customsAgentStreet, + ca.nif customsAgentNif, + ca.phone customsAgentPhone, + ca.email customsAgentEmail, + CAST(sub2.volume AS DECIMAL (10,2)) volume, + sub3.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 + LEFT JOIN (SELECT tob.ticketFk,tob.description + FROM vn.ticketObservation tob + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk + WHERE ot.description = "Peso Aduana" + )sub ON sub.ticketFk = t.id + JOIN vn.address a ON a.id = t.addressFk + LEFT 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 + FROM vn.invoiceOut io + JOIN vn.ticket t ON t.refFk = io.ref + JOIN vn.saleVolume sv ON sv.ticketFk = t.id + WHERE io.id = :invoiceId + )sub2 ON TRUE + JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk + JOIN vn.taxClass tc ON tc.id = itc.taxClassFk + LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE' + 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 + LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) as 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 io.id = :invoiceId + )sub3 ON TRUE + WHERE io.id = :invoiceId diff --git a/print/templates/reports/invoice-incoterms/sql/invoice.sql b/print/templates/reports/invoice-incoterms/sql/invoice.sql new file mode 100644 index 000000000..b9a929183 --- /dev/null +++ b/print/templates/reports/invoice-incoterms/sql/invoice.sql @@ -0,0 +1,17 @@ +SELECT + io.id, + io.issued, + io.clientFk, + io.companyFk, + io.ref, + pm.code AS payMethodCode, + cny.code companyCode, + sa.iban, + ios.footNotes +FROM invoiceOut io + JOIN client c ON c.id = io.clientFk + JOIN payMethod pm ON pm.id = c.payMethodFk + JOIN company cny ON cny.id = io.companyFk + JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk + LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial +WHERE io.id = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index fa888dafc..671bb8c7f 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -6,9 +6,11 @@ - - - + + +