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