<script setup>
import VnCard from 'components/common/VnCard.vue';
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
import InvoiceInFilter from '../InvoiceInFilter.vue';
import InvoiceInSearchbar from '../InvoiceInSearchbar.vue';
import { onBeforeRouteUpdate } from 'vue-router';
import { setRectificative } from '../composables/setRectificative';

const filter = {
    include: [
        {
            relation: 'supplier',
            scope: {
                include: {
                    relation: 'contacts',
                    scope: { where: { email: { neq: null } } },
                },
            },
        },
        { relation: 'invoiceInDueDay' },
        { relation: 'company' },
        { relation: 'currency' },
    ],
};

onBeforeRouteUpdate(async (to) => await setRectificative(to));
</script>
<template>
    <VnCard
        data-key="InvoiceIn"
        base-url="InvoiceIns"
        :filter="filter"
        :descriptor="InvoiceInDescriptor"
        :filter-panel="InvoiceInFilter"
        search-data-key="InvoiceInList"
    >
        <template #searchbar>
            <InvoiceInSearchbar />
        </template>
    </VnCard>
</template>
