From 42d16d02583ee7878f5f2a3faaf6528b9bb9e798 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 29 Oct 2020 11:09:58 +0100 Subject: [PATCH] ticket component refactor --- modules/ticket/back/models/ticket.json | 6 ++++ modules/ticket/front/card/index.js | 3 ++ modules/ticket/front/component/index.html | 30 ++++++++++++++++++-- modules/ticket/front/component/index.js | 10 ++++++- modules/ticket/front/component/index.spec.js | 5 +++- modules/ticket/front/component/locale/es.yml | 6 +++- 6 files changed, 54 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index ca4668b3a..2bb86312d 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -48,6 +48,12 @@ }, "zoneFk": { "type": "Number" + }, + "zonePrice": { + "type": "Number" + }, + "zoneBonus": { + "type": "Number" } }, "relations": { diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 44fc3e48b..6e38039e2 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -15,6 +15,9 @@ class Controller extends ModuleCard { relation: 'warehouse', scope: {fields: ['name']} }, + { + relation: 'zone', + }, { relation: 'invoiceOut', scope: {fields: ['id']} diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index fb8af3219..c9b506bc9 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -76,11 +76,35 @@
-
Theorical cost
-
Price {{$ctrl.theoricalCost | currency: 'EUR': 2}}
+
Zone breakdown
+
Zone price {{$ctrl.ticket.zonePrice | currency: 'EUR': 2}}
+
Zone bonus {{$ctrl.ticket.zoneBonus | currency: 'EUR': 2}}
+
Zone + + {{$ctrl.ticket.zone.name | dashIfEmpty}} + +
+
+ Volume {{$ctrl.ticketVolume}} +
+
+ Packages {{$ctrl.ticket.packages}} +
+
+
+
Theorical cost
+
Price total {{$ctrl.theoricalCost | currency: 'EUR': 2}}
- \ No newline at end of file + + + + + diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 7557bfba6..2a5988719 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -37,9 +37,10 @@ class Controller extends Section { this._ticket = value; if (!value) return; - this.getTheoricalCost(); this.getComponentsSum(); + if (this.ticket.zone.isVolumetric) + this.getTicketVolume(); } base() { @@ -76,6 +77,13 @@ class Controller extends Section { this.$http.get(`Tickets/${this.ticket.id}/getComponentsSum`) .then(res => this.componentsList = res.data); } + + getTicketVolume() { + if (!this.ticket) return; + + this.$http.get(`Tickets/${this.ticket.id}/getVolume`) + .then(res => this.ticketVolume = res.data[0].volume); + } } ngModule.vnComponent('vnTicketComponents', { diff --git a/modules/ticket/front/component/index.spec.js b/modules/ticket/front/component/index.spec.js index 053248c2c..acd757578 100644 --- a/modules/ticket/front/component/index.spec.js +++ b/modules/ticket/front/component/index.spec.js @@ -89,7 +89,10 @@ describe('ticket', () => { jest.spyOn(controller, 'getComponentsSum'); controller._ticket = undefined; controller.ticket = { - id: 7 + id: 7, + zone: { + isVolumetric: false + } }; expect(controller.ticket).toBeDefined(); diff --git a/modules/ticket/front/component/locale/es.yml b/modules/ticket/front/component/locale/es.yml index 57dcf64e0..af07811b8 100644 --- a/modules/ticket/front/component/locale/es.yml +++ b/modules/ticket/front/component/locale/es.yml @@ -1,2 +1,6 @@ Theorical cost: Porte teorico -Total without VAT: Total sin IVA \ No newline at end of file +Total without VAT: Total sin IVA +Zone bonus: Bonificación +Zone price: Precio de la zona +Price total: Precio total +Zone breakdown: Desglose zona \ No newline at end of file