diff --git a/src/pages/InvoiceIn/InvoiceInToBook.vue b/src/pages/InvoiceIn/InvoiceInToBook.vue index 95ce8155a..fbebddd94 100644 --- a/src/pages/InvoiceIn/InvoiceInToBook.vue +++ b/src/pages/InvoiceIn/InvoiceInToBook.vue @@ -4,6 +4,7 @@ import { useQuasar } from 'quasar'; import { useI18n } from 'vue-i18n'; import VnConfirm from 'src/components/ui/VnConfirm.vue'; import { useArrayData } from 'src/composables/useArrayData'; +import qs from 'qs'; const { notify, dialog } = useQuasar(); const { t } = useI18n(); @@ -12,29 +13,41 @@ defineExpose({ checkToBook }); const { store } = useArrayData(); async function checkToBook(id) { - let directBooking = true; + let messages = []; const { data: totals } = await axios.get(`InvoiceIns/${id}/getTotals`); const taxableBaseNotEqualDueDay = totals.totalDueDay != totals.totalTaxableBase; const vatNotEqualDueDay = totals.totalDueDay != totals.totalVat; - if (taxableBaseNotEqualDueDay && vatNotEqualDueDay) directBooking = false; + if (taxableBaseNotEqualDueDay && vatNotEqualDueDay) + messages.push(t('The sum of the taxable bases does not match the due dates')); - const { data: dueDaysCount } = await axios.get('InvoiceInDueDays/count', { - where: { - invoiceInFk: id, - dueDated: { gte: Date.vnNew() }, - }, - }); + const dueDaysCount = ( + await axios.get('InvoiceInDueDays/count', { + params: { + where: JSON.stringify({ + invoiceInFk: id, + dueDated: { gte: Date.vnNew() }, + }), + }, + }) + ).data?.count; - if (dueDaysCount) directBooking = false; + if (dueDaysCount) messages.push(t('Some due dates are less than or equal to today')); - if (directBooking) return toBook(id); + if (!messages.length) toBook(id); + else + dialog({ + component: VnConfirm, + componentProps: { + title: t('Are you sure you want to book this invoice?'), + message: messages.reduce((acc, msg) => `${acc}

${msg}

`, ''), + }, + }).onOk(async () => { + await toBook(id); - dialog({ - component: VnConfirm, - componentProps: { title: t('Are you sure you want to book this invoice?') }, - }).onOk(async () => await toBook(id)); + axios.get(); + }); } async function toBook(id) { @@ -59,4 +72,6 @@ async function toBook(id) { es: Are you sure you want to book this invoice?: ¿Estás seguro de querer asentar esta factura? It was not able to book the invoice: No se pudo contabilizar la factura + Some due dates are less than or equal to today: Algún vencimiento tiene una fecha menor o igual que hoy + The sum of the taxable bases does not match the due dates: La suma de las bases imponibles no coincide con la de los vencimientos