getVolume route should return only data #324 CR: Juan

This commit is contained in:
Joan Sanchez 2018-05-28 08:52:18 +02:00
parent 8231a935d6
commit 74410d4045
3 changed files with 4 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
};
};

View File

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