feat: refs #7936 calculate exchange & update taxable base
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-11-28 14:52:39 +01:00
parent 44cbabfc7e
commit 8e3d9b2bf3
3 changed files with 32 additions and 4 deletions

View File

@ -0,0 +1,16 @@
import axios from 'axios';
export async function getExchange(amount, currencyFk, dated, decimalPlaces = 2) {
try {
const { data } = await axios.get('ReferenceRates/findOne', {
params: {
filter: {
fields: ['value'],
where: { currencyFk, dated },
},
},
});
return (amount / data.value).toFixed(decimalPlaces);
} catch (e) {
return null;
}
}

View File

@ -249,6 +249,7 @@ function deleteFile(dmsFk) {
:options="currencies"
option-value="id"
option-label="code"
sort-by="id"
/>
<VnSelect

View File

@ -11,12 +11,13 @@ import CrudModel from 'src/components/CrudModel.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CreateNewExpenseForm from 'src/components/CreateNewExpenseForm.vue';
import { getExchange } from 'src/composables/getExchange';
const { t } = useI18n();
const arrayData = useArrayData();
const route = useRoute();
const invoiceIn = computed(() => arrayData.store.data);
const invoiceId = +useRoute().params.id;
const currency = computed(() => invoiceIn.value?.currency?.code);
const expenses = ref([]);
const sageTaxTypes = ref([]);
@ -106,7 +107,7 @@ const filter = {
'transactionTypeSageFk',
],
where: {
invoiceInFk: invoiceId,
invoiceInFk: route.params.id,
},
};
@ -148,10 +149,10 @@ const formatOpt = (row, { model, options }, prop) => {
data-key="InvoiceInTaxes"
url="InvoiceInTaxes"
:filter="filter"
:data-required="{ invoiceInFk: invoiceId }"
:data-required="{ invoiceInFk: $route.params.id }"
auto-load
v-model:selected="rowsSelected"
:go-to="`/invoice-in/${invoiceId}/due-day`"
:go-to="`/invoice-in/${$route.params.id}/due-day`"
>
<template #body="{ rows }">
<QTable
@ -253,6 +254,16 @@ const formatOpt = (row, { model, options }, prop) => {
}"
:disable="!isNotEuro(currency)"
v-model="row.foreignValue"
@update:model-value="
async (val) => {
const exchange = await getExchange(
val,
row.currencyFk,
invoiceIn.issued
);
row.taxableBase = exchange;
}
"
/>
</QTd>
</template>