fix: refs #8388 update invoice total calculation and improve UI feedback for discrepancies
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jorge Penadés 2025-03-17 14:12:18 +01:00
parent 01d1ca83ea
commit 5a49d72986
1 changed files with 25 additions and 6 deletions

View File

@ -25,7 +25,7 @@ const invoiceInFormRef = ref();
const invoiceId = +route.params.id;
const filter = { where: { invoiceInFk: invoiceId } };
const areRows = ref(false);
const totals = ref();
const totalTaxableBase = ref();
const columns = computed(() => [
{
name: 'duedate',
@ -74,9 +74,12 @@ async function insert() {
notify(t('globals.dataSaved'), 'positive');
}
onBeforeMount(async () => {
totals.value = (await axios.get(`InvoiceIns/${invoiceId}/getTotals`)).data;
});
const getTaxableBase = async () => {
const { data } = await axios.get(`InvoiceIns/${invoiceId}/getTotals`);
return data.totalTaxableBase;
};
onBeforeMount(async () => (totalTaxableBase.value = await getTaxableBase()));
</script>
<template>
<CrudModel
@ -89,6 +92,7 @@ onBeforeMount(async () => {
:data-required="{ invoiceInFk: invoiceId }"
v-model:selected="rowsSelected"
@on-fetch="(data) => (areRows = !!data.length)"
@save-changes="() => {}"
>
<template #body="{ rows }">
<QTable
@ -151,7 +155,18 @@ onBeforeMount(async () => {
<QTd />
<QTd />
<QTd>
{{ toCurrency(totalAmount) }}
<QChip
dense
:color="
totalAmount != totalTaxableBase
? 'negative'
: 'transparent'
"
class="q-pa-xs"
:title="t('invoiceIn.summary.noMatch')"
>
{{ toCurrency(totalAmount) }}
</QChip>
</QTd>
<QTd>
<template v-if="isNotEuro(invoiceIn.currency.code)">
@ -237,7 +252,7 @@ onBeforeMount(async () => {
if (!areRows) insert();
else
invoiceInFormRef.insert({
amount: (totals.totalTaxableBase - totalAmount).toFixed(2),
amount: (totalTaxableBase - totalAmount).toFixed(2),
invoiceInFk: invoiceId,
});
}
@ -249,6 +264,10 @@ onBeforeMount(async () => {
.bg {
background-color: var(--vn-light-gray);
}
.q-chip {
color: var(--vn-text-color);
}
</style>
<i18n>
es: