From 6bb758b88ce42d932c888eff78d551ab0ddf2bce Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 18 Feb 2025 00:40:13 +0100 Subject: [PATCH] fix: reload table when apply discount --- src/pages/Ticket/Card/TicketSale.vue | 40 +++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index b849b3b35..fa3c146ce 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -57,7 +57,7 @@ const canProceed = ref(); watch( () => route.params.id, - () => tableRef.value.reload() + () => tableRef.value.reload(), ); const columns = computed(() => [ @@ -133,7 +133,7 @@ const columns = computed(() => [ align: 'left', label: t('globals.amount'), name: 'amount', - format: (row) => parseInt(row.amount * row.quantity), + format: (row) => toCurrency(getSaleTotal(row)), }, { align: 'left', @@ -200,7 +200,7 @@ const changeQuantity = async (sale) => { await updateQuantity(sale); } catch (e) { const { quantity } = tableRef.value.CrudModelRef.originalData.find( - (s) => s.id === sale.id + (s) => s.id === sale.id, ); sale.quantity = quantity; throw e; @@ -331,8 +331,7 @@ const updateDiscount = async (sales, newDiscount = null) => { }; await axios.post(`Tickets/${route.params.id}/updateDiscount`, params); notify('globals.dataSaved', 'positive'); - for (let sale of sales) sale.discount = _newDiscount; - edit.value = { ...DEFAULT_EDIT }; + tableRef.value.reload(); }; const getNewPrice = computed(() => { @@ -505,7 +504,7 @@ async function isSalePrepared(item) { componentProps: { title: t('Item prepared'), message: t( - 'This item is already prepared. Do you want to continue?' + 'This item is already prepared. Do you want to continue?', ), data: item, }, @@ -527,7 +526,7 @@ watch( if (newItemFk) { updateItem(newRow.value); } - } + }, ); @@ -597,7 +596,7 @@ watch( openConfirmationModal( t('Continue anyway?'), t('You are going to delete lines of the ticket'), - removeSales + removeSales, ) " > @@ -826,21 +825,24 @@ watch( :mana-code="manaCode" @save="changeDiscount(row)" > - -
- -
+ {{ toPercentage(row.discount / 100) }} -