From 5551781bac2a50c2c20611d84b0b7847c3976cf3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 5 Mar 2024 16:26:56 +0100 Subject: [PATCH] feat: refs #6942 to unbook --- .../InvoiceIn/Card/InvoiceInDescriptor.vue | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index ec528ef76..d6ce0e41d 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -20,11 +20,7 @@ import { useCapitalize } from 'src/composables/useCapitalize'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; const $props = defineProps({ - id: { - type: Number, - required: false, - default: null, - }, + id: { type: Number, default: null }, }); const route = useRoute(); @@ -51,6 +47,10 @@ const actions = { cb: checkToBook, action: toBook, }, + unbook: { + title: 'Are you sure you want to unbook this invoice?', + action: toUnbook, + }, delete: { title: 'Are you sure you want to delete this invoice?', action: deleteInvoice, @@ -235,6 +235,19 @@ async function toBook() { setTimeout(() => location.reload(), 500); } +async function toUnbook() { + const { data } = await axios.post(`InvoiceIns/${entityId.value}/toUnbook`); + const { isLinked, bookEntry, accountingEntries } = data; + + const type = isLinked ? 'warning' : 'positive'; + const message = isLinked + ? t('isLinked', { bookEntry, accountingEntries }) + : t('isNotLinked', { bookEntry }); + + quasar.notify({ type, message }); + if (isLinked) await cardDescriptorRef.value.getData(); +} + async function deleteInvoice() { await axios.delete(`InvoiceIns/${entityId.value}`); quasar.notify({ @@ -253,8 +266,6 @@ async function cloneInvoice() { router.push({ path: `/invoice-in/${data.id}/summary` }); } -const requiredFieldRule = (val) => val || t('globals.requiredField'); - const isAdministrative = () => hasAny(['administrative']); const isAgricultural = () => @@ -346,6 +357,16 @@ const createInvoiceInCorrection = async () => { > {{ t('To book') }} + + + {{ t('To unbook') }} + + { :options="siiTypeInvoiceOuts" option-value="id" option-label="code" - :rules="[requiredFieldRule]" + :required="true" /> @@ -501,7 +522,7 @@ const createInvoiceInCorrection = async () => { :options="cplusRectificationTypes" option-value="id" option-label="description" - :rules="[requiredFieldRule]" + :required="true" /> { :options="invoiceCorrectionTypes" option-value="id" option-label="description" - :rules="[requiredFieldRule]" + :required="true" /> @@ -549,9 +570,14 @@ const createInvoiceInCorrection = async () => { } +en: + isNotLinked: The entry {bookEntry} has been deleted with {accountingEntries} entries + isLinked: The entry {bookEntry} has been linked to Sage. Please contact administration for further information es: To book: Contabilizar + To unbook: Descontabilizar Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? + Are you sure you want to unbook this invoice?: Estas seguro de querer desasentar esta factura? Delete invoice: Eliminar factura Are you sure you want to delete this invoice?: Estas seguro de querer eliminar esta factura? Invoice deleted: Factura eliminada @@ -565,4 +591,6 @@ es: Rectificative invoice: Factura rectificativa Original invoice: Factura origen Entry: entrada + isNotLinked: Se ha eliminado el asiento nº {bookEntry} con {accountingEntries} apuntes + isLinked: El asiento {bookEntry} fue enlazado a Sage, por favor contacta con administración