diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 0de5d3aa2..19e990862 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -94,6 +94,7 @@ defineExpose({ saveChanges, getChanges, formData, + originalData, vnPaginateRef, }); diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index 14f6fe7f0..08cdcb9df 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -183,18 +183,25 @@ const resetChanges = async () => { }; const updateQuantity = async (sale) => { - const payload = { quantity: sale.quantity }; - await axios.post(`Sales/${sale.id}/updateQuantity`, payload); + const params = { quantity: sale.quantity }; + 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'); }; const addSale = async (sale) => { - const payload = { + const params = { barcode: sale.itemFk, 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;