From 74410d404506fff71eb7e113e7993d395b99d717 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 28 May 2018 08:52:18 +0200 Subject: [PATCH] getVolume route should return only data #324 CR: Juan --- client/ticket/src/volume/index.js | 2 +- services/loopback/common/methods/ticket/getVolume.js | 3 ++- .../loopback/common/methods/ticket/specs/get-volume.spec.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/ticket/src/volume/index.js b/client/ticket/src/volume/index.js index 2b473cd45..1783f32ab 100644 --- a/client/ticket/src/volume/index.js +++ b/client/ticket/src/volume/index.js @@ -19,7 +19,7 @@ class Controller extends FilterTicketList { .then(response => { if (response.data) { this.$scope.index.model.instances.forEach(sale => { - response.data.volumes[0].forEach(volume => { + response.data.volumes.forEach(volume => { if (sale.id === volume.saleFk) { sale.volume = volume; } diff --git a/services/loopback/common/methods/ticket/getVolume.js b/services/loopback/common/methods/ticket/getVolume.js index f49456f65..0bfb6b9ea 100644 --- a/services/loopback/common/methods/ticket/getVolume.js +++ b/services/loopback/common/methods/ticket/getVolume.js @@ -19,6 +19,7 @@ module.exports = Self => { }); Self.getVolume = async ticketFk => { - return await Self.rawSql(`CALL vn.ticketListVolume(?);`, [ticketFk]); + let [volume] = await Self.rawSql(`CALL vn.ticketListVolume(?)`, [ticketFk]); + return volume; }; }; diff --git a/services/loopback/common/methods/ticket/specs/get-volume.spec.js b/services/loopback/common/methods/ticket/specs/get-volume.spec.js index dbe97684d..691d008f7 100644 --- a/services/loopback/common/methods/ticket/specs/get-volume.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-volume.spec.js @@ -5,7 +5,7 @@ describe('ticket getVolume()', () => { let ticketFk = 1; app.models.Ticket.getVolume(ticketFk) .then(response => { - expect(response[0][0].m3_total).toEqual(0.008); + expect(response[0].m3_total).toEqual(0.008); done(); }); });