diff --git a/modules/route/back/methods/route/summary.js b/modules/route/back/methods/route/summary.js
new file mode 100644
index 000000000..0aad8f6bb
--- /dev/null
+++ b/modules/route/back/methods/route/summary.js
@@ -0,0 +1,97 @@
+module.exports = Self => {
+ Self.remoteMethod('summary', {
+ description: 'Updates the item taxes',
+ accessType: 'READ',
+ accepts: [{
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The item id',
+ http: {source: 'path'}
+ }],
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/:id/summary`,
+ verb: 'GET'
+ }
+ });
+
+ Self.summary = async id => {
+ let summary = {};
+
+ // Item basic data and taxes
+ let filter = {
+ where: {id: id},
+ include: [
+ {relation: 'ticket',
+ scope: {
+ fields: ['id', 'packages', 'warehouseFk', 'nickname', 'clientFk', 'priority'],
+ include: [
+ {
+ relation: 'client',
+ scope: {
+ fields: ['id', 'street'],
+ }
+ },
+ {
+ relation: 'state',
+ scope: {
+ fields: ['id', 'stateFk'],
+ include: [{relation: 'state'}]
+ }
+ },
+ {
+ relation: 'warehouse',
+ scope: {
+ fields: ['id', 'name']
+ }
+ }
+
+ ]
+ }
+ }, {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['id', 'name']
+ }
+ }, {
+ relation: 'worker',
+ scope: {
+ fields: ['id', 'userFk'],
+ include: [
+ {
+ relation: 'user',
+ scope: {
+ fields: ['id', 'nickname']
+ }
+ }
+ ]
+ }
+ }, {
+ relation: 'vehicle',
+ scope: {
+ fields: ['id', 'm3']
+ }
+ }
+ ],
+ };
+
+ summary.route = await Self.app.models.Route.findOne(filter);
+
+ for (let i = 0; i < summary.route.ticket().length; i++) {
+ let ticket = summary.route.ticket()[i];
+ let query = `
+ SELECT vn.ticketTotalVolume(?) AS m3`;
+
+ let options = [ticket.id];
+ let [volume] = await Self.rawSql(query, options);
+
+ ticket.volume = volume.m3;
+ }
+
+ return summary;
+ };
+};
diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js
new file mode 100644
index 000000000..a3871d07e
--- /dev/null
+++ b/modules/route/back/models/route.js
@@ -0,0 +1,3 @@
+module.exports = Self => {
+ require('../methods/route/summary')(Self);
+};
diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json
index 8c0ff6776..8930d314c 100644
--- a/modules/route/back/models/route.json
+++ b/modules/route/back/models/route.json
@@ -61,6 +61,11 @@
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agencyModeFk"
- }
+ },
+ "ticket": {
+ "type": "hasMany",
+ "model": "Ticket",
+ "foreignKey": "routeFk"
+ }
}
}
diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html
index 571650909..5d46af81d 100644
--- a/modules/route/front/index/index.html
+++ b/modules/route/front/index/index.html
@@ -26,7 +26,7 @@
Worker
Agency
Vehicle
- Created
+ Date
m³
Description
diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js
index 724dcf968..c516a2e8f 100644
--- a/modules/route/front/index/index.js
+++ b/modules/route/front/index/index.js
@@ -66,7 +66,7 @@ export default class Controller {
preview(event, route) {
this.routeSelected = route;
- this.$.dialogSummaryClaim.show();
+ this.$.summary.show();
event.preventDefault();
event.stopImmediatePropagation();
}
diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html
new file mode 100644
index 000000000..1680b6e52
--- /dev/null
+++ b/modules/route/front/summary/index.html
@@ -0,0 +1,98 @@
+
+ {{$ctrl.summary.route.id}} - {{$ctrl.summary.route.description}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ticket
+
+
+
+ Ticket id
+ Alias
+ Packages
+ Volume
+ Warehouse
+ Street
+ State
+
+
+
+
+
+
+ {{ticket.id | zeroFill:6}}
+
+
+
+
+ {{ticket.nickname}}
+
+
+ {{ticket.packages}}
+ {{ticket.volume}}
+ {{ticket.warehouse.name}}
+ {{ticket.client.street}}
+ {{ticket.state.state.name}}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/route/front/summary/index.js b/modules/route/front/summary/index.js
new file mode 100644
index 000000000..b83127080
--- /dev/null
+++ b/modules/route/front/summary/index.js
@@ -0,0 +1,58 @@
+import ngModule from '../module';
+import './style.scss';
+
+class Controller {
+ constructor($scope, $http) {
+ this.$http = $http;
+ this.$ = $scope;
+ }
+
+ set route(value) {
+ this._route = value;
+ if (value && value.id)
+ this.getSummary();
+ }
+
+ sumPackages() {
+ this.packagesTotal = 0;
+ this.summary.route.ticket.forEach(ticket => {
+ this.packagesTotal += ticket.packages;
+ });
+ }
+
+ showTicketDescriptor(event, ticketFk) {
+ this.$.ticketDescriptor.ticketFk = ticketFk;
+ this.$.ticketDescriptor.parent = event.target;
+ this.$.ticketDescriptor.show();
+ event.preventDefault();
+ }
+
+ showClientDescriptor(event, clientFk) {
+ this.$.clientDescriptor.clientFk = clientFk;
+ this.$.clientDescriptor.parent = event.target;
+ this.$.clientDescriptor.show();
+ event.preventDefault();
+ }
+
+ get route() {
+ return this._route;
+ }
+
+ getSummary() {
+ this.$http.get(`/api/Routes/${this.route.id}/summary`).then(response => {
+ this.summary = response.data;
+ if (response.data && response.data.route && response.data.route.ticket)
+ this.sumPackages();
+ });
+ }
+}
+
+Controller.$inject = ['$scope', '$http'];
+
+ngModule.component('vnRouteSummary', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ route: '<'
+ }
+});
diff --git a/modules/route/front/summary/index.spec.js b/modules/route/front/summary/index.spec.js
new file mode 100644
index 000000000..1da9a412d
--- /dev/null
+++ b/modules/route/front/summary/index.spec.js
@@ -0,0 +1,27 @@
+import './index.js';
+
+describe('Route', () => {
+ describe('Component summary', () => {
+ let controller;
+ let $httpBackend;
+
+ beforeEach(ngModule('route'));
+
+ beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
+ controller = $componentController('vnRouteSummary');
+ controller.route = {id: 1};
+ }));
+
+ describe('getSummary()', () => {
+ it('should perform a query to set summary', () => {
+ $httpBackend.when('GET', `/api/Routes/1/summary`).respond(200, 24);
+ $httpBackend.expect('GET', `/api/Routes/1/summary`);
+ controller.getSummary();
+ $httpBackend.flush();
+
+ expect(controller.summary).toEqual(24);
+ });
+ });
+ });
+});
diff --git a/modules/route/front/summary/locale/es.yml b/modules/route/front/summary/locale/es.yml
new file mode 100644
index 000000000..0853f047c
--- /dev/null
+++ b/modules/route/front/summary/locale/es.yml
@@ -0,0 +1,7 @@
+Driver: Conductor
+Vehicle: Vehículo
+Packages: Bultos
+Time: F. Inicio
+Finished: F. Fin
+Km Start: Km de inicio
+Km End: Km de fin
\ No newline at end of file
diff --git a/modules/route/front/summary/style.scss b/modules/route/front/summary/style.scss
new file mode 100644
index 000000000..7ff8b3056
--- /dev/null
+++ b/modules/route/front/summary/style.scss
@@ -0,0 +1,5 @@
+@import "./variables";
+
+vn-route-summary .summary {
+ max-width: $width-large;
+}
\ No newline at end of file