From 9f1c90387b822da6afbb9ae6e3b56054eedbde8a Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 20 Sep 2022 08:18:44 +0200 Subject: [PATCH 1/3] feat: add new report vehicleExpired --- .../assets/css/import.js | 9 ++++ .../assets/css/style.css | 19 ++++++++ .../campaign-metrics.html | 47 +++++++++++++++++++ .../vehicle-event-expired/campaign-metrics.js | 38 +++++++++++++++ .../vehicle-event-expired/locale/es.yml | 12 +++++ .../vehicle-event-expired/sql/client.sql | 13 +++++ .../vehicle-event-expired/sql/sales.sql | 20 ++++++++ 7 files changed, 158 insertions(+) create mode 100644 print/templates/reports/vehicle-event-expired/assets/css/import.js create mode 100644 print/templates/reports/vehicle-event-expired/assets/css/style.css create mode 100644 print/templates/reports/vehicle-event-expired/campaign-metrics.html create mode 100755 print/templates/reports/vehicle-event-expired/campaign-metrics.js create mode 100644 print/templates/reports/vehicle-event-expired/locale/es.yml create mode 100644 print/templates/reports/vehicle-event-expired/sql/client.sql create mode 100644 print/templates/reports/vehicle-event-expired/sql/sales.sql diff --git a/print/templates/reports/vehicle-event-expired/assets/css/import.js b/print/templates/reports/vehicle-event-expired/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/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/vehicle-event-expired/assets/css/style.css b/print/templates/reports/vehicle-event-expired/assets/css/style.css new file mode 100644 index 000000000..1b6428d3c --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/assets/css/style.css @@ -0,0 +1,19 @@ +.column-oriented { + margin-top: 50px !important; +} + +.bottom-line > tr { + border-bottom: 1px solid #ccc; +} + +.bottom-line tr:nth-last-child() { + border-bottom: none; +} + +.report-info { + font-size: 20px +} + +.description strong { + text-transform: uppercase; +} \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/campaign-metrics.html b/print/templates/reports/vehicle-event-expired/campaign-metrics.html new file mode 100644 index 000000000..60b8dd717 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/campaign-metrics.html @@ -0,0 +1,47 @@ + + + + + + + + + +
+ + + +
+
+
+
+

{{$t('title')}}

+
+
+ + + + + + + + + + + + + + + +
{{$t('Plate')}}{{$t('Concept')}}{{$t('expirationDate')}}
{{sale.itemFk | zerofill('000000')}}{{Math.trunc(sale.subtotal)}}{{sale.concept}}
+
+
+ + + +
+ + \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/campaign-metrics.js b/print/templates/reports/vehicle-event-expired/campaign-metrics.js new file mode 100755 index 000000000..6669ce067 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/campaign-metrics.js @@ -0,0 +1,38 @@ +const Component = require(`${appPath}/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); + + if (!this.client) + throw new Error('Something went wrong'); + }, + methods: { + fetchClient(clientId) { + return this.findOneFromDef('client', [clientId]); + }, + fetchSales(clientId, from, to) { + return this.rawSqlFromDef('sales', [clientId, from, to]); + }, + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + recipientId: { + type: [Number, String], + required: true + }, + from: { + required: true + }, + to: { + required: true + } + } +}; diff --git a/print/templates/reports/vehicle-event-expired/locale/es.yml b/print/templates/reports/vehicle-event-expired/locale/es.yml new file mode 100644 index 000000000..e73c8ef98 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/locale/es.yml @@ -0,0 +1,12 @@ +reportName: consumo-cliente +title: Expiración Tarjetas Vehículos +Client: Cliente +clientData: Datos del cliente +dated: Fecha +From: Desde +To: Hasta +client: Cliente {0} +Stems: Tallos +Plate: Matrícula +Concept: Concepto +expirationDate: Fecha caducidad \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/client.sql b/print/templates/reports/vehicle-event-expired/sql/client.sql new file mode 100644 index 000000000..9f392c97e --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/sql/client.sql @@ -0,0 +1,13 @@ +SELECT + c.street, + c.socialName, + c.city, + c.postcode, + c.id, + c.name AS clientName, + p.name AS province, + co.country +FROM client c + JOIN province p ON c.provinceFk = p.id + JOIN country co ON c.countryFk = co.id +WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/sales.sql b/print/templates/reports/vehicle-event-expired/sql/sales.sql new file mode 100644 index 000000000..2daa72aaa --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/sql/sales.sql @@ -0,0 +1,20 @@ +SELECT + SUM(s.quantity) AS subtotal, + s.itemFk, + s.concept, + i.subName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 +FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk +WHERE + t.clientFk = ? AND it.isPackaging = FALSE + AND DATE(t.shipped) BETWEEN ? AND ? +GROUP BY s.itemFk +ORDER BY i.typeFk , i.name \ No newline at end of file From c17e0fd38b44f05388901e45e53c6d46bed9a63b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 21 Sep 2022 08:11:04 +0200 Subject: [PATCH 2/3] feat: add new report --- .../vehicle-event-expired/campaign-metrics.js | 38 ------------------- .../vehicle-event-expired/locale/es.yml | 8 ---- .../vehicle-event-expired/sql/client.sql | 13 ------- .../vehicle-event-expired/sql/sales.sql | 20 ---------- .../sql/vehicleEvents.sql | 7 ++++ ...etrics.html => vehicle-event-expired.html} | 20 +++------- .../vehicle-event-expired.js | 28 ++++++++++++++ 7 files changed, 41 insertions(+), 93 deletions(-) delete mode 100755 print/templates/reports/vehicle-event-expired/campaign-metrics.js delete mode 100644 print/templates/reports/vehicle-event-expired/sql/client.sql delete mode 100644 print/templates/reports/vehicle-event-expired/sql/sales.sql create mode 100644 print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql rename print/templates/reports/vehicle-event-expired/{campaign-metrics.html => vehicle-event-expired.html} (58%) create mode 100755 print/templates/reports/vehicle-event-expired/vehicle-event-expired.js diff --git a/print/templates/reports/vehicle-event-expired/campaign-metrics.js b/print/templates/reports/vehicle-event-expired/campaign-metrics.js deleted file mode 100755 index 6669ce067..000000000 --- a/print/templates/reports/vehicle-event-expired/campaign-metrics.js +++ /dev/null @@ -1,38 +0,0 @@ -const Component = require(`${appPath}/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); - - if (!this.client) - throw new Error('Something went wrong'); - }, - methods: { - fetchClient(clientId) { - return this.findOneFromDef('client', [clientId]); - }, - fetchSales(clientId, from, to) { - return this.rawSqlFromDef('sales', [clientId, from, to]); - }, - }, - components: { - 'report-header': reportHeader.build(), - 'report-footer': reportFooter.build() - }, - props: { - recipientId: { - type: [Number, String], - required: true - }, - from: { - required: true - }, - to: { - required: true - } - } -}; diff --git a/print/templates/reports/vehicle-event-expired/locale/es.yml b/print/templates/reports/vehicle-event-expired/locale/es.yml index e73c8ef98..ba7685047 100644 --- a/print/templates/reports/vehicle-event-expired/locale/es.yml +++ b/print/templates/reports/vehicle-event-expired/locale/es.yml @@ -1,12 +1,4 @@ -reportName: consumo-cliente title: Expiración Tarjetas Vehículos -Client: Cliente -clientData: Datos del cliente -dated: Fecha -From: Desde -To: Hasta -client: Cliente {0} -Stems: Tallos Plate: Matrícula Concept: Concepto expirationDate: Fecha caducidad \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/client.sql b/print/templates/reports/vehicle-event-expired/sql/client.sql deleted file mode 100644 index 9f392c97e..000000000 --- a/print/templates/reports/vehicle-event-expired/sql/client.sql +++ /dev/null @@ -1,13 +0,0 @@ -SELECT - c.street, - c.socialName, - c.city, - c.postcode, - c.id, - c.name AS clientName, - p.name AS province, - co.country -FROM client c - JOIN province p ON c.provinceFk = p.id - JOIN country co ON c.countryFk = co.id -WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/sales.sql b/print/templates/reports/vehicle-event-expired/sql/sales.sql deleted file mode 100644 index 2daa72aaa..000000000 --- a/print/templates/reports/vehicle-event-expired/sql/sales.sql +++ /dev/null @@ -1,20 +0,0 @@ -SELECT - SUM(s.quantity) AS subtotal, - s.itemFk, - s.concept, - i.subName, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7 -FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk -WHERE - t.clientFk = ? AND it.isPackaging = FALSE - AND DATE(t.shipped) BETWEEN ? AND ? -GROUP BY s.itemFk -ORDER BY i.typeFk , i.name \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql b/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql new file mode 100644 index 000000000..09f9e5853 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql @@ -0,0 +1,7 @@ +SELECT + v.numberPlate, + ve.description, + ve.finished +FROM vehicleEvent ve + JOIN vehicle v ON v.id = ve.vehicleFk +WHERE ve.id IN (?) \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/campaign-metrics.html b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.html similarity index 58% rename from print/templates/reports/vehicle-event-expired/campaign-metrics.html rename to print/templates/reports/vehicle-event-expired/vehicle-event-expired.html index 60b8dd717..2045f2adb 100644 --- a/print/templates/reports/vehicle-event-expired/campaign-metrics.html +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.html @@ -10,11 +10,9 @@
-
-
-

{{$t('title')}}

+
+

{{$t('title')}}

-
@@ -23,22 +21,16 @@ - + - - - + + +
{{$t('expirationDate')}}
{{sale.itemFk | zerofill('000000')}}{{Math.trunc(sale.subtotal)}}{{sale.concept}}{{vehicleEvent.numberPlate}}{{vehicleEvent.description}}{{vehicleEvent.finished | date('%d-%m-%Y')}}
- - - diff --git a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js new file mode 100755 index 000000000..3e987d513 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js @@ -0,0 +1,28 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'vehicle-event-expired', + async serverPrefetch() { + this.vehicleEvents = await this.fetchVehicleEvent(this.eventIds); + + if (!this.vehicleEvents) + throw new Error('Something went wrong'); + }, + methods: { + fetchVehicleEvent(vehicleEventIds) { + return this.rawSqlFromDef('vehicleEvents', [vehicleEventIds]); + }, + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + eventIds: { + type: [Array], + required: false + } + } +}; From 888f70abcc77d83c135615d2a8dd63d970da1be5 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 21 Sep 2022 08:12:08 +0200 Subject: [PATCH 3/3] fix: required is true --- .../reports/vehicle-event-expired/vehicle-event-expired.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js index 3e987d513..33e60eab7 100755 --- a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js @@ -22,7 +22,7 @@ module.exports = { props: { eventIds: { type: [Array], - required: false + required: true } } };