diff --git a/modules/ticket/back/methods/ticket/getVolume.js b/modules/ticket/back/methods/ticket/getVolume.js
index 6029020ba..5b710e07f 100644
--- a/modules/ticket/back/methods/ticket/getVolume.js
+++ b/modules/ticket/back/methods/ticket/getVolume.js
@@ -9,41 +9,27 @@ module.exports = Self => {
description: 'ticket id',
http: {source: 'path'}
}],
- returns: [{
- arg: 'saleVolume',
- type: ['object']
+ returns: {
+ type: 'object',
+ root: true
},
- {
- arg: 'packingTypeVolume',
- type: ['object']
- }],
http: {
path: `/:id/getVolume`,
verb: 'GET'
}
});
- Self.getVolume = async(ticketFk, options) => {
- const myOptions = {};
-
- if (typeof options == 'object')
- Object.assign(myOptions, options);
-
- const saleVolume = await Self.rawSql(`
- SELECT saleFk, volume
- FROM vn.saleVolume
- WHERE ticketFk = ?`, [ticketFk], myOptions);
-
+ Self.getVolume = async ticketFk => {
const packingTypeVolume = await Self.rawSql(`
SELECT s.itemPackingTypeFk code,
- i.description,
+ i.description,
SUM(s.volume) volume
FROM vn.saleVolume s
- LEFT JOIN vn.itemPackingType i
+ LEFT JOIN vn.itemPackingType i
ON i.code = s.itemPackingTypeFk
WHERE s.ticketFk = ?
- GROUP BY s.itemPackingTypeFk`, [ticketFk], myOptions);
+ GROUP BY s.itemPackingTypeFk`, [ticketFk]);
- return [saleVolume, packingTypeVolume];
+ return packingTypeVolume;
};
};
diff --git a/modules/ticket/back/methods/ticket/volume.js b/modules/ticket/back/methods/ticket/volume.js
index 0881edbee..3cc606c4b 100644
--- a/modules/ticket/back/methods/ticket/volume.js
+++ b/modules/ticket/back/methods/ticket/volume.js
@@ -42,9 +42,11 @@ module.exports = Self => {
i.value7,
i.value8,
i.value9,
- i.value10
+ i.value10,
+ sv.volume
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = ?`
, [id]
);
diff --git a/modules/ticket/front/volume/index.html b/modules/ticket/front/volume/index.html
index e7d43ae3e..3d133fc35 100644
--- a/modules/ticket/front/volume/index.html
+++ b/modules/ticket/front/volume/index.html
@@ -53,7 +53,7 @@
{{::sale.item.itemPackingTypeFk}}
{{::sale.quantity}}
- {{::sale.saleVolume.volume | number:3}}
+ {{::sale.volume | number:3}}
diff --git a/modules/ticket/front/volume/index.js b/modules/ticket/front/volume/index.js
index 48e374224..1b7c3d45b 100644
--- a/modules/ticket/front/volume/index.js
+++ b/modules/ticket/front/volume/index.js
@@ -19,18 +19,10 @@ class Controller extends Section {
}
applyVolumes() {
- this.$http.get(`Tickets/${this.$params.id}/getVolume`).then(res => {
- const saleVolume = res.data.saleVolume;
-
- const volumes = new Map();
- for (const volume of saleVolume)
- volumes.set(volume.saleFk, volume);
-
- for (const sale of this.sales)
- sale.saleVolume = volumes.get(sale.id);
-
- this.packingTypeVolume = res.data.packingTypeVolume;
- });
+ this.$http.get(`Tickets/${this.$params.id}/getVolume`)
+ .then(res => {
+ this.packingTypeVolume = res.data;
+ });
}
}