#7936 improve InvoiceIn #1004
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -249,6 +249,7 @@ function deleteFile(dmsFk) {
|
|||
:options="currencies"
|
||||
option-value="id"
|
||||
option-label="code"
|
||||
sort-by="id"
|
||||
/>
|
||||
|
||||
<VnSelect
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue