From 1984e1d0d81cc21578b86cd279fe0fab7f9fabe3 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 23 Aug 2024 10:25:05 +0200 Subject: [PATCH] feat: refs #7710 uses cloneAll --- src/pages/Ticket/Card/TicketExpedition.vue | 1 - .../Ticket/Card/TicketSaleMoreActions.vue | 22 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pages/Ticket/Card/TicketExpedition.vue b/src/pages/Ticket/Card/TicketExpedition.vue index a7eb9e27e..f344e4276 100644 --- a/src/pages/Ticket/Card/TicketExpedition.vue +++ b/src/pages/Ticket/Card/TicketExpedition.vue @@ -268,7 +268,6 @@ onMounted(async () => { stateStore.rightDrawer = true; const filteredColumns = columns.value.filter((col) => col.name !== 'history'); allColumnNames.value = filteredColumns.map((col) => col.name); - // await expeditionsArrayData.fetch({ append: false }); }); onUnmounted(() => (stateStore.rightDrawer = false)); diff --git a/src/pages/Ticket/Card/TicketSaleMoreActions.vue b/src/pages/Ticket/Card/TicketSaleMoreActions.vue index 9ec6b303a..ba827d062 100644 --- a/src/pages/Ticket/Card/TicketSaleMoreActions.vue +++ b/src/pages/Ticket/Card/TicketSaleMoreActions.vue @@ -153,14 +153,22 @@ const setReserved = async (reserved) => { }; const createRefund = async (withWarehouse) => { - if (!props.sales) return; + if (!props.ticket) return; - const salesIds = props.sales.map((sale) => sale.id); - const params = { salesIds: salesIds, withWarehouse: withWarehouse, negative: true }; - const { data } = await axios.post('Sales/clone', params); - const [refundTicket] = data; - notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive'); - router.push({ name: 'TicketSale', params: { id: refundTicket.id } }); + const params = { + ticketsIds: [props.ticket.id], + withWarehouse: withWarehouse, + negative: true, + }; + + try { + const { data } = await axios.post('Tickets/cloneAll', params); + const [refundTicket] = data; + notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive'); + router.push({ name: 'TicketSale', params: { id: refundTicket.id } }); + } catch (error) { + console.error(error); + } };