feat: refs #8388 enhance invoice booking validation and user confirmation messages
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
c2042276ae
commit
f18da15262
|
@ -4,6 +4,7 @@ import { useQuasar } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
import qs from 'qs';
|
||||||
const { notify, dialog } = useQuasar();
|
const { notify, dialog } = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
@ -12,29 +13,41 @@ defineExpose({ checkToBook });
|
||||||
const { store } = useArrayData();
|
const { store } = useArrayData();
|
||||||
|
|
||||||
async function checkToBook(id) {
|
async function checkToBook(id) {
|
||||||
let directBooking = true;
|
let messages = [];
|
||||||
|
|
||||||
const { data: totals } = await axios.get(`InvoiceIns/${id}/getTotals`);
|
const { data: totals } = await axios.get(`InvoiceIns/${id}/getTotals`);
|
||||||
const taxableBaseNotEqualDueDay = totals.totalDueDay != totals.totalTaxableBase;
|
const taxableBaseNotEqualDueDay = totals.totalDueDay != totals.totalTaxableBase;
|
||||||
const vatNotEqualDueDay = totals.totalDueDay != totals.totalVat;
|
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', {
|
const dueDaysCount = (
|
||||||
where: {
|
await axios.get('InvoiceInDueDays/count', {
|
||||||
invoiceInFk: id,
|
params: {
|
||||||
dueDated: { gte: Date.vnNew() },
|
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}<p>${msg}</p>`, ''),
|
||||||
|
},
|
||||||
|
}).onOk(async () => {
|
||||||
|
await toBook(id);
|
||||||
|
|
||||||
dialog({
|
axios.get();
|
||||||
component: VnConfirm,
|
});
|
||||||
componentProps: { title: t('Are you sure you want to book this invoice?') },
|
|
||||||
}).onOk(async () => await toBook(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toBook(id) {
|
async function toBook(id) {
|
||||||
|
@ -59,4 +72,6 @@ async function toBook(id) {
|
||||||
es:
|
es:
|
||||||
Are you sure you want to book this invoice?: ¿Estás seguro de querer asentar esta factura?
|
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
|
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
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue