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(); }); });