7525-devToTest #419
|
@ -11,29 +11,15 @@ import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorP
|
|||
import InvoiceIntoBook from '../InvoiceInToBook.vue';
|
||||
import VnTitle from 'src/components/common/VnTitle.vue';
|
||||
|
||||
onMounted(async () => {
|
||||
salixUrl.value = await getUrl('');
|
||||
invoiceInUrl.value = salixUrl.value + `invoiceIn/${entityId.value}/`;
|
||||
});
|
||||
|
||||
const { params } = useRoute();
|
||||
const props = defineProps({ id: { type: Number, default: 0 } });
|
||||
const { t } = useI18n();
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
const entityId = computed(() => props.id || useRoute().params.id);
|
||||
const invoiceIn = computed(() => useArrayData('InvoiceIn').store.data);
|
||||
|
||||
const entityId = computed(() => $props.id || params.id);
|
||||
const arrayData = useArrayData('InvoiceIn');
|
||||
const invoiceIn = computed(() => arrayData.store.data);
|
||||
|
||||
const salixUrl = ref();
|
||||
const invoiceInUrl = ref();
|
||||
const amountsNotMatch = ref(null);
|
||||
const intrastatTotals = ref({});
|
||||
const intrastatTotals = ref({ amount: 0, net: 0, stems: 0 });
|
||||
const isBooked = ref();
|
||||
|
||||
const vatColumns = ref([
|
||||
|
@ -166,6 +152,10 @@ const intrastatColumns = ref([
|
|||
},
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
invoiceInUrl.value = `${await getUrl('')}invoiceIn/${entityId.value}/`;
|
||||
});
|
||||
|
||||
function getAmountNotMatch(totals) {
|
||||
return (
|
||||
totals.totalDueDay != totals.totalTaxableBase &&
|
||||
|
@ -173,16 +163,6 @@ function getAmountNotMatch(totals) {
|
|||
);
|
||||
}
|
||||
|
||||
function getIntrastatTotals(intrastat) {
|
||||
const totals = {
|
||||
amount: intrastat.reduce((acc, cur) => acc + cur.amount, 0),
|
||||
net: intrastat.reduce((acc, cur) => acc + cur.net, 0),
|
||||
stems: intrastat.reduce((acc, cur) => acc + cur.stems, 0),
|
||||
};
|
||||
|
||||
return totals;
|
||||
}
|
||||
|
||||
function getTaxTotal(tax) {
|
||||
return tax.reduce(
|
||||
(acc, cur) => acc + taxRate(cur.taxableBase, cur.taxTypeSage?.rate),
|
||||
|
@ -190,35 +170,36 @@ function getTaxTotal(tax) {
|
|||
);
|
||||
}
|
||||
|
||||
function setData(entity) {
|
||||
if (!entity) return false;
|
||||
const init = (data) => {
|
||||
if (!data) return;
|
||||
|
||||
isBooked.value = entity.isBooked;
|
||||
amountsNotMatch.value = getAmountNotMatch(entity.totals);
|
||||
isBooked.value = data.isBooked;
|
||||
amountsNotMatch.value = getAmountNotMatch(data.totals);
|
||||
|
||||
if (entity.invoiceInIntrastat.length)
|
||||
intrastatTotals.value = { ...getIntrastatTotals(entity.invoiceInIntrastat) };
|
||||
}
|
||||
if (data.invoiceInIntrastat.length) {
|
||||
data.invoiceInIntrastat.forEach((val) => {
|
||||
intrastatTotals.value.amount += val.amount;
|
||||
intrastatTotals.value.net += val.net;
|
||||
intrastatTotals.value.stems += val.stems;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function taxRate(taxableBase = 0, rate = 0) {
|
||||
return (rate / 100) * taxableBase;
|
||||
}
|
||||
const taxRate = (taxableBase = 0, rate = 0) => (rate / 100) * taxableBase;
|
||||
|
||||
function getLink(param) {
|
||||
return `#/invoice-in/${entityId.value}/${param}`;
|
||||
}
|
||||
const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardSummary
|
||||
data-key="InvoiceInSummary"
|
||||
:url="`InvoiceIns/${entityId}/summary`"
|
||||
@on-fetch="(data) => setData(data)"
|
||||
@on-fetch="(data) => init(data)"
|
||||
>
|
||||
<template #header="{ entity }">
|
||||
<div>{{ entity.id }} - {{ entity.supplier?.name }}</div>
|
||||
</template>
|
||||
<template #header-right v-if="!invoiceIn?.isBooked">
|
||||
<template #header-right v-if="!isBooked">
|
||||
<InvoiceIntoBook>
|
||||
<template #content="{ book }">
|
||||
<QBtn
|
||||
|
@ -346,7 +327,7 @@ function getLink(param) {
|
|||
</QCardSection>
|
||||
</QCard>
|
||||
<!--Vat-->
|
||||
<QCard v-if="invoiceIn.invoiceInTax.length">
|
||||
<QCard v-if="entity.invoiceInTax.length">
|
||||
<VnTitle :url="getLink('vat')" :text="t('invoiceIn.card.vat')" />
|
||||
<QTable
|
||||
:columns="vatColumns"
|
||||
|
@ -374,7 +355,7 @@ function getLink(param) {
|
|||
</QTable>
|
||||
</QCard>
|
||||
<!--Due Day-->
|
||||
<QCard v-if="invoiceIn.invoiceInDueDay.length">
|
||||
<QCard v-if="entity.invoiceInDueDay.length">
|
||||
<VnTitle :url="getLink('due-day')" :text="t('invoiceIn.card.dueDay')" />
|
||||
<QTable
|
||||
class="full-width"
|
||||
|
@ -400,7 +381,7 @@ function getLink(param) {
|
|||
</QTable>
|
||||
</QCard>
|
||||
<!--Intrastat-->
|
||||
<QCard v-if="invoiceIn.invoiceInIntrastat.length">
|
||||
<QCard v-if="entity.invoiceInIntrastat.length">
|
||||
<VnTitle
|
||||
:url="getLink('intrastat')"
|
||||
:text="t('invoiceIn.card.intrastat')"
|
||||
|
|
Loading…
Reference in New Issue