0
0
Fork 0

fix(TicketSale): set old quantity when error

This commit is contained in:
Alex Moreno 2024-11-26 09:21:51 +01:00
parent 8fbf7fed43
commit 2076072eeb
2 changed files with 12 additions and 4 deletions

View File

@ -94,6 +94,7 @@ defineExpose({
saveChanges, saveChanges,
getChanges, getChanges,
formData, formData,
originalData,
vnPaginateRef, vnPaginateRef,
}); });

View File

@ -183,18 +183,25 @@ const resetChanges = async () => {
}; };
const updateQuantity = async (sale) => { const updateQuantity = async (sale) => {
const payload = { quantity: sale.quantity }; const params = { quantity: sale.quantity };
await axios.post(`Sales/${sale.id}/updateQuantity`, payload); try {
await axios.post(`Sales/${sale.id}/updateQuantity`, params);
} catch (e) {
sale.quantity = tableRef.value.CrudModelRef.originalData.find(
(s) => s.id === sale.id
).quantity;
throw e;
}
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
}; };
const addSale = async (sale) => { const addSale = async (sale) => {
const payload = { const params = {
barcode: sale.itemFk, barcode: sale.itemFk,
quantity: sale.quantity, quantity: sale.quantity,
}; };
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, payload); const { data } = await axios.post(`tickets/${route.params.id}/addSale`, params);
if (!data) return; if (!data) return;