refs #5669 refactor: simplificado front
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-08-25 10:45:01 +02:00
parent f388415ba3
commit 87311261ca
4 changed files with 16 additions and 36 deletions

View File

@ -9,41 +9,27 @@ module.exports = Self => {
description: 'ticket id', description: 'ticket id',
http: {source: 'path'} http: {source: 'path'}
}], }],
returns: [{ returns: {
arg: 'saleVolume', type: 'object',
type: ['object'] root: true
}, },
{
arg: 'packingTypeVolume',
type: ['object']
}],
http: { http: {
path: `/:id/getVolume`, path: `/:id/getVolume`,
verb: 'GET' verb: 'GET'
} }
}); });
Self.getVolume = async(ticketFk, options) => { Self.getVolume = async ticketFk => {
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);
const packingTypeVolume = await Self.rawSql(` const packingTypeVolume = await Self.rawSql(`
SELECT s.itemPackingTypeFk code, SELECT s.itemPackingTypeFk code,
i.description, i.description,
SUM(s.volume) volume SUM(s.volume) volume
FROM vn.saleVolume s FROM vn.saleVolume s
LEFT JOIN vn.itemPackingType i LEFT JOIN vn.itemPackingType i
ON i.code = s.itemPackingTypeFk ON i.code = s.itemPackingTypeFk
WHERE s.ticketFk = ? WHERE s.ticketFk = ?
GROUP BY s.itemPackingTypeFk`, [ticketFk], myOptions); GROUP BY s.itemPackingTypeFk`, [ticketFk]);
return [saleVolume, packingTypeVolume]; return packingTypeVolume;
}; };
}; };

View File

@ -42,9 +42,11 @@ module.exports = Self => {
i.value7, i.value7,
i.value8, i.value8,
i.value9, i.value9,
i.value10 i.value10,
sv.volume
FROM vn.sale s FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk JOIN vn.item i ON i.id = s.itemFk
JOIN vn.saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = ?` WHERE s.ticketFk = ?`
, [id] , [id]
); );

View File

@ -53,7 +53,7 @@
</vn-td> </vn-td>
<vn-td number>{{::sale.item.itemPackingTypeFk}}</vn-td> <vn-td number>{{::sale.item.itemPackingTypeFk}}</vn-td>
<vn-td number>{{::sale.quantity}}</vn-td> <vn-td number>{{::sale.quantity}}</vn-td>
<vn-td number>{{::sale.saleVolume.volume | number:3}}</vn-td> <vn-td number>{{::sale.volume | number:3}}</vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>
</vn-table> </vn-table>

View File

@ -19,18 +19,10 @@ class Controller extends Section {
} }
applyVolumes() { applyVolumes() {
this.$http.get(`Tickets/${this.$params.id}/getVolume`).then(res => { this.$http.get(`Tickets/${this.$params.id}/getVolume`)
const saleVolume = res.data.saleVolume; .then(res => {
this.packingTypeVolume = res.data;
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;
});
} }
} }