diff --git a/modules/route/back/methods/route/getDeliveryPoint.js b/modules/route/back/methods/route/getDeliveryPoint.js index 59b22904f..e5a50805a 100644 --- a/modules/route/back/methods/route/getDeliveryPoint.js +++ b/modules/route/back/methods/route/getDeliveryPoint.js @@ -1,12 +1,12 @@ module.exports = Self => { Self.remoteMethod('getDeliveryPoint', { - description: 'get the deliveryPoint address ', + description: 'get the deliveryPoint address', accessType: 'WRITE', accepts: { arg: 'vehicleId', type: 'number', - required: true, description: 'vehicle id asigned in the route', + required: true, http: {source: 'path'} }, returns: { @@ -21,8 +21,9 @@ module.exports = Self => { Self.getDeliveryPoint = async vehicleId => { let vehicle = await Self.app.models.Vehicle.findById(vehicleId); - let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk); + if (!vehicle.deliveryPointFk) return; + let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk); return deliveryPoint.ubication; }; diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 92a112747..306e4d94a 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -5,9 +5,12 @@ data="$ctrl.tickets" auto-load="true"> - -
- + + + - + @@ -31,14 +34,14 @@ model="model"> - Order - Ticket + Order + Street + City + PC Client Packages - Warehouse - PC - Street + Ticket @@ -50,21 +53,18 @@ ng-model="ticket.checked"> - + + class="dense" + display-controls=true> - - - {{ticket.id}} - - + {{ticket.address.street}} + {{ticket.address.city}} + {{ticket.address.postalCode}} {{ticket.packages}} {{::ticket.volume | number:1}} - {{ticket.warehouse.name}} - {{ticket.address.postalCode}} - {{ticket.address.street}} + + + {{ticket.id}} + + { - deliveryPointAddress = response.data; - }).then(() => { - addresses = deliveryPointAddress; + if (!response.data) + throw new UserError(`The route's vehicle doesn't have a departing warehouse`); + + return response.data; + }).then(address => { + let addresses; + if (address) addresses = address; let lines = this.getSelectedItems(this.tickets); let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml index 042f5227b..6fa29e5ca 100644 --- a/modules/route/front/tickets/locale/es.yml +++ b/modules/route/front/tickets/locale/es.yml @@ -8,4 +8,6 @@ Add ticket: Añadir ticket Tickets to add: Tickets a añadir Ticket not found: No se ha encontrado el ticket The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta -PC: CP \ No newline at end of file +PC: CP +The route's vehicle doesn't have a departing warehouse: El vehículo de la ruta no tiene un almacén de salida +The route doesn't have a vehicle: La ruta no tiene un vehículo \ No newline at end of file