feat: refs #6942 use correct currency in InvoiceIn components
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
e8fed46dd1
commit
4a6d09ae2c
|
@ -370,7 +370,10 @@ const createInvoiceInCorrection = async () => {
|
||||||
<template #body="{ entity }">
|
<template #body="{ entity }">
|
||||||
<VnLv :label="t('invoiceIn.card.issued')" :value="toDate(entity.issued)" />
|
<VnLv :label="t('invoiceIn.card.issued')" :value="toDate(entity.issued)" />
|
||||||
<VnLv :label="t('invoiceIn.summary.booked')" :value="toDate(entity.booked)" />
|
<VnLv :label="t('invoiceIn.summary.booked')" :value="toDate(entity.booked)" />
|
||||||
<VnLv :label="t('invoiceIn.card.amount')" :value="toCurrency(totalAmount)" />
|
<VnLv
|
||||||
|
:label="t('invoiceIn.card.amount')"
|
||||||
|
:value="toCurrency(totalAmount, entity.currency?.code)"
|
||||||
|
/>
|
||||||
<VnLv :label="t('invoiceIn.summary.supplier')">
|
<VnLv :label="t('invoiceIn.summary.supplier')">
|
||||||
<template #value>
|
<template #value>
|
||||||
<span class="link">
|
<span class="link">
|
||||||
|
|
|
@ -23,11 +23,7 @@ const invoiceId = route.params.id;
|
||||||
|
|
||||||
const placeholder = 'yyyy/mm/dd';
|
const placeholder = 'yyyy/mm/dd';
|
||||||
|
|
||||||
const filter = {
|
const filter = { where: { invoiceInFk: invoiceId } };
|
||||||
where: {
|
|
||||||
invoiceInFk: invoiceId,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
@ -192,8 +188,9 @@ const getTotalAmount = (rows) => rows.reduce((acc, { amount }) => acc + +amount,
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd>
|
<QTd>
|
||||||
{{ getTotalAmount(rows) }} ||
|
{{
|
||||||
{{ toCurrency(getTotalAmount(rows)) }}
|
toCurrency(getTotalAmount(rows), invoiceIn.currency.code)
|
||||||
|
}}
|
||||||
</QTd>
|
</QTd>
|
||||||
<QTd />
|
<QTd />
|
||||||
</QTr>
|
</QTr>
|
||||||
|
|
|
@ -6,26 +6,18 @@ import { toCurrency } from 'src/filters';
|
||||||
import CrudModel from 'src/components/CrudModel.vue';
|
import CrudModel from 'src/components/CrudModel.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
|
const currency = computed(() => useArrayData('invoiceIn').store.data?.currency?.code);
|
||||||
const invoceInIntrastat = ref([]);
|
const invoceInIntrastat = ref([]);
|
||||||
const amountTotal = computed(() => getTotal('amount'));
|
|
||||||
const netTotal = computed(() => getTotal('net'));
|
|
||||||
const stemsTotal = computed(() => getTotal('stems'));
|
|
||||||
const rowsSelected = ref([]);
|
const rowsSelected = ref([]);
|
||||||
const countries = ref([]);
|
const countries = ref([]);
|
||||||
const intrastats = ref([]);
|
const intrastats = ref([]);
|
||||||
const invoiceInFormRef = ref();
|
const invoiceInFormRef = ref();
|
||||||
|
const invoiceInId = computed(() => +useRoute().params.id);
|
||||||
const filter = {
|
const filter = { where: { invoiceInFk: invoiceInId.value } };
|
||||||
where: {
|
|
||||||
invoiceInFk: route.params.id,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'code',
|
name: 'code',
|
||||||
|
@ -77,13 +69,8 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function getTotal(type) {
|
const getTotal = (data, key) =>
|
||||||
if (!invoceInIntrastat.value.length) return 0.0;
|
data.reduce((acc, cur) => acc + +String(cur[key]).replace(',', '.'), 0);
|
||||||
return invoceInIntrastat.value.reduce(
|
|
||||||
(total, intrastat) => total + intrastat[type],
|
|
||||||
0.0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -99,30 +86,12 @@ function getTotal(type) {
|
||||||
@on-fetch="(data) => (intrastats = data)"
|
@on-fetch="(data) => (intrastats = data)"
|
||||||
/>
|
/>
|
||||||
<div class="invoiceIn-intrastat">
|
<div class="invoiceIn-intrastat">
|
||||||
<QCard v-if="invoceInIntrastat.length" class="full-width q-mb-md q-pa-sm">
|
|
||||||
<QItem class="justify-end">
|
|
||||||
<div>
|
|
||||||
<QItemLabel>
|
|
||||||
<VnLv
|
|
||||||
:label="t('Total amount')"
|
|
||||||
:value="toCurrency(amountTotal)"
|
|
||||||
/>
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
<VnLv :label="t('Total net')" :value="netTotal" />
|
|
||||||
</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
<VnLv :label="t('Total stems')" :value="stemsTotal" />
|
|
||||||
</QItemLabel>
|
|
||||||
</div>
|
|
||||||
</QItem>
|
|
||||||
</QCard>
|
|
||||||
<CrudModel
|
<CrudModel
|
||||||
ref="invoiceInFormRef"
|
ref="invoiceInFormRef"
|
||||||
data-key="InvoiceInIntrastats"
|
data-key="InvoiceInIntrastats"
|
||||||
url="InvoiceInIntrastats"
|
url="InvoiceInIntrastats"
|
||||||
auto-load
|
:auto-load="!currency"
|
||||||
:data-required="{ invoiceInFk: route.params.id }"
|
:data-required="{ invoiceInFk: invoiceInId }"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
v-model:selected="rowsSelected"
|
v-model:selected="rowsSelected"
|
||||||
@on-fetch="(data) => (invoceInIntrastat = data)"
|
@on-fetch="(data) => (invoceInIntrastat = data)"
|
||||||
|
@ -172,6 +141,22 @@ function getTotal(type) {
|
||||||
/>
|
/>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
<template #bottom-row>
|
||||||
|
<QTr class="bg">
|
||||||
|
<QTd />
|
||||||
|
<QTd />
|
||||||
|
<QTd>
|
||||||
|
{{ toCurrency(getTotal(rows, 'amount'), currency) }}
|
||||||
|
</QTd>
|
||||||
|
<QTd>
|
||||||
|
{{ getTotal(rows, 'net') }}
|
||||||
|
</QTd>
|
||||||
|
<QTd>
|
||||||
|
{{ getTotal(rows, 'stems') }}
|
||||||
|
</QTd>
|
||||||
|
<QTd />
|
||||||
|
</QTr>
|
||||||
|
</template>
|
||||||
<template #item="props">
|
<template #item="props">
|
||||||
<div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition">
|
<div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition">
|
||||||
<QCard>
|
<QCard>
|
||||||
|
|
|
@ -16,7 +16,7 @@ const { t } = useI18n();
|
||||||
|
|
||||||
const entityId = computed(() => props.id || useRoute().params.id);
|
const entityId = computed(() => props.id || useRoute().params.id);
|
||||||
const invoiceIn = computed(() => useArrayData('InvoiceIn').store.data);
|
const invoiceIn = computed(() => useArrayData('InvoiceIn').store.data);
|
||||||
|
const currency = computed(() => invoiceIn.value?.currency?.code);
|
||||||
const invoiceInUrl = ref();
|
const invoiceInUrl = ref();
|
||||||
const amountsNotMatch = ref(null);
|
const amountsNotMatch = ref(null);
|
||||||
const intrastatTotals = ref({ amount: 0, net: 0, stems: 0 });
|
const intrastatTotals = ref({ amount: 0, net: 0, stems: 0 });
|
||||||
|
@ -33,7 +33,7 @@ const vatColumns = ref([
|
||||||
name: 'landed',
|
name: 'landed',
|
||||||
label: 'invoiceIn.summary.taxableBase',
|
label: 'invoiceIn.summary.taxableBase',
|
||||||
field: (row) => row.taxableBase,
|
field: (row) => row.taxableBase,
|
||||||
format: (value) => toCurrency(value),
|
format: (value) => toCurrency(value, currency.value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ const vatColumns = ref([
|
||||||
name: 'rate',
|
name: 'rate',
|
||||||
label: 'invoiceIn.summary.rate',
|
label: 'invoiceIn.summary.rate',
|
||||||
field: (row) => taxRate(row.taxableBase, row.taxTypeSage?.rate),
|
field: (row) => taxRate(row.taxableBase, row.taxTypeSage?.rate),
|
||||||
format: (value) => toCurrency(value),
|
format: (value) => toCurrency(value, currency.value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
@ -95,7 +95,7 @@ const dueDayColumns = ref([
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
label: 'invoiceIn.summary.amount',
|
label: 'invoiceIn.summary.amount',
|
||||||
field: (row) => row.amount,
|
field: (row) => row.amount,
|
||||||
format: (value) => toCurrency(value),
|
format: (value) => toCurrency(value, currency.value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
@ -122,7 +122,7 @@ const intrastatColumns = ref([
|
||||||
{
|
{
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
label: 'invoiceIn.summary.amount',
|
label: 'invoiceIn.summary.amount',
|
||||||
field: (row) => toCurrency(row.amount),
|
field: (row) => toCurrency(row.amount, currency.value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
@ -278,7 +278,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
/>
|
/>
|
||||||
<VnLv
|
<VnLv
|
||||||
:label="t('invoiceIn.summary.booked')"
|
:label="t('invoiceIn.summary.booked')"
|
||||||
:value="invoiceIn.isBooked"
|
:value="invoiceIn?.isBooked"
|
||||||
/>
|
/>
|
||||||
</QCard>
|
</QCard>
|
||||||
<QCard class="vn-one">
|
<QCard class="vn-one">
|
||||||
|
@ -291,9 +291,12 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
<QCardSection class="q-pa-none">
|
<QCardSection class="q-pa-none">
|
||||||
<VnLv
|
<VnLv
|
||||||
:label="t('invoiceIn.summary.taxableBase')"
|
:label="t('invoiceIn.summary.taxableBase')"
|
||||||
:value="toCurrency(entity.totals.totalTaxableBase)"
|
:value="toCurrency(entity.totals.totalTaxableBase, currency)"
|
||||||
|
/>
|
||||||
|
<VnLv
|
||||||
|
label="Total"
|
||||||
|
:value="toCurrency(entity.totals.totalVat, currency)"
|
||||||
/>
|
/>
|
||||||
<VnLv label="Total" :value="toCurrency(entity.totals.totalVat)" />
|
|
||||||
<VnLv :label="t('invoiceIn.summary.dueTotal')">
|
<VnLv :label="t('invoiceIn.summary.dueTotal')">
|
||||||
<template #value>
|
<template #value>
|
||||||
<QChip
|
<QChip
|
||||||
|
@ -306,7 +309,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
: t('invoiceIn.summary.dueTotal')
|
: t('invoiceIn.summary.dueTotal')
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ toCurrency(entity.totals.totalDueDay) }}
|
{{ toCurrency(entity.totals.totalDueDay, currency) }}
|
||||||
</QChip>
|
</QChip>
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
|
@ -335,10 +338,14 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
<template #bottom-row>
|
<template #bottom-row>
|
||||||
<QTr class="bg">
|
<QTr class="bg">
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd>{{ toCurrency(entity.totals.totalTaxableBase) }}</QTd>
|
<QTd>{{
|
||||||
|
toCurrency(entity.totals.totalTaxableBase, currency)
|
||||||
|
}}</QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd>{{ toCurrency(getTotalTax(entity.invoiceInTax)) }}</QTd>
|
<QTd>{{
|
||||||
|
toCurrency(getTotalTax(entity.invoiceInTax, currency))
|
||||||
|
}}</QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
@ -368,7 +375,9 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
<QTr class="bg">
|
<QTr class="bg">
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd>{{ toCurrency(entity.totals.totalDueDay) }}</QTd>
|
<QTd>{{
|
||||||
|
toCurrency(entity.totals.totalDueDay, currency)
|
||||||
|
}}</QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
@ -399,7 +408,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||||
<template #bottom-row>
|
<template #bottom-row>
|
||||||
<QTr class="bg">
|
<QTr class="bg">
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
<QTd>{{ toCurrency(intrastatTotals.amount) }}</QTd>
|
<QTd>{{ toCurrency(intrastatTotals.amount, currency) }}</QTd>
|
||||||
<QTd>{{ intrastatTotals.net }}</QTd>
|
<QTd>{{ intrastatTotals.net }}</QTd>
|
||||||
<QTd>{{ intrastatTotals.stems }}</QTd>
|
<QTd>{{ intrastatTotals.stems }}</QTd>
|
||||||
<QTd></QTd>
|
<QTd></QTd>
|
||||||
|
|
|
@ -17,8 +17,8 @@ const quasar = useQuasar();
|
||||||
|
|
||||||
const arrayData = useArrayData('InvoiceIn');
|
const arrayData = useArrayData('InvoiceIn');
|
||||||
const invoiceIn = computed(() => arrayData.store.data);
|
const invoiceIn = computed(() => arrayData.store.data);
|
||||||
const invoiceId = currentRoute.value.params.id;
|
const invoiceId = +currentRoute.value.params.id;
|
||||||
|
const currency = computed(() => invoiceIn.value?.currency?.code);
|
||||||
const expenses = ref([]);
|
const expenses = ref([]);
|
||||||
const sageTaxTypes = ref([]);
|
const sageTaxTypes = ref([]);
|
||||||
const sageTransactionTypes = ref([]);
|
const sageTransactionTypes = ref([]);
|
||||||
|
@ -56,7 +56,7 @@ const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'taxablebase',
|
name: 'taxablebase',
|
||||||
label: t('Taxable base'),
|
label: t('Taxable base'),
|
||||||
field: (row) => toCurrency(row.taxableBase),
|
field: (row) => toCurrency(row.taxableBase, currency.value),
|
||||||
model: 'taxableBase',
|
model: 'taxableBase',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
tabIndex: 2,
|
tabIndex: 2,
|
||||||
|
@ -91,7 +91,7 @@ const columns = computed(() => [
|
||||||
label: t('Rate'),
|
label: t('Rate'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
tabIndex: 5,
|
tabIndex: 5,
|
||||||
field: (row) => toCurrency(taxRate(row, row.taxTypeSageFk)),
|
field: (row) => toCurrency(taxRate(row, row.taxTypeSageFk), currency.value),
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -162,8 +162,9 @@ async function addExpense() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const getTotalTaxableBase = (rows) => rows.reduce((acc, cur) => acc + cur.taxableBase, 0);
|
const getTotalTaxableBase = (rows) =>
|
||||||
const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + taxRate(cur), 0);
|
rows.reduce((acc, { taxableBase }) => acc + +taxableBase, 0);
|
||||||
|
const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + +taxRate(cur), 0);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -195,7 +196,7 @@ const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + taxRate(cur), 0);
|
||||||
selection="multiple"
|
selection="multiple"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
row-key="$index"
|
row-key="$index"
|
||||||
:grid="$q.screen.lt.sm"
|
:grid="$q.screen.lt.sm"
|
||||||
>
|
>
|
||||||
<template #body-cell-expense="{ row, col }">
|
<template #body-cell-expense="{ row, col }">
|
||||||
|
@ -312,11 +313,11 @@ const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + taxRate(cur), 0);
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd>
|
<QTd>
|
||||||
{{ toCurrency(getTotalTaxableBase(rows)) }}
|
{{ toCurrency(getTotalTaxableBase(rows), currency) }}
|
||||||
</QTd>
|
</QTd>
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd> {{ toCurrency(getTotalRate(rows)) }}</QTd>
|
<QTd> {{ toCurrency(getTotalRate(rows), currency) }}</QTd>
|
||||||
<QTd />
|
<QTd />
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
@ -408,7 +409,7 @@ const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + taxRate(cur), 0);
|
||||||
</VnSelect>
|
</VnSelect>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
{{ toCurrency(taxRate(props.row)) }}
|
{{ toCurrency(taxRate(props.row), currency) }}
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
<QInput
|
<QInput
|
||||||
|
|
Loading…
Reference in New Issue