salix-front/src/pages/Supplier/Card/SupplierFiscalData.vue

169 lines
5.8 KiB
Vue

<script setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnLocation from 'src/components/common/VnLocation.vue';
const route = useRoute();
const { t } = useI18n();
const sageTaxTypesOptions = ref([]);
const sageWithholdingsOptions = ref([]);
const sageTransactionTypesOptions = ref([]);
const supplierActivitiesOptions = ref([]);
function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {};
data.postCode = code;
data.city = town;
data.provinceFk = provinceFk;
data.countryFk = countryFk;
}
</script>
<template>
<FetchData
url="SageTaxTypes"
auto-load
@on-fetch="(data) => (sageTaxTypesOptions = data)"
/>
<FetchData
url="SageWithholdings"
auto-load
@on-fetch="(data) => (sageWithholdingsOptions = data)"
/>
<FetchData
url="sageTransactionTypes"
auto-load
@on-fetch="(data) => (sageTransactionTypesOptions = data)"
/>
<FetchData
url="SupplierActivities"
auto-load
@on-fetch="(data) => (supplierActivitiesOptions = data)"
/>
<FormModel
:url="`Suppliers/${route.params.id}`"
:url-update="`Suppliers/${route.params.id}/updateFiscalData`"
model="supplier"
auto-load
:clear-store-on-unmount="false"
>
<template #form="{ data, validate }">
<VnRow>
<VnInput
v-model="data.name"
:label="t('supplier.fiscalData.name')"
clearable
/>
<VnInput
v-model="data.nif"
:label="t('supplier.fiscalData.nif')"
clearable
/>
</VnRow>
<VnRow>
<VnInput
v-model="data.account"
:label="t('supplier.fiscalData.account')"
clearable
/>
<VnSelect
:label="t('supplier.fiscalData.sageTaxTypeFk')"
v-model="data.sageTaxTypeFk"
:options="sageTaxTypesOptions"
option-value="id"
option-label="vat"
hide-selected
map-options
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('supplier.fiscalData.sageWithholdingFk')"
v-model="data.sageWithholdingFk"
:options="sageWithholdingsOptions"
option-value="id"
option-label="withholding"
hide-selected
map-options
/>
<VnSelect
:label="t('supplier.fiscalData.sageTransactionTypeFk')"
v-model="data.sageTransactionTypeFk"
:options="sageTransactionTypesOptions"
option-value="id"
option-label="transaction"
hide-selected
map-options
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('supplier.fiscalData.supplierActivityFk')"
v-model="data.supplierActivityFk"
:options="supplierActivitiesOptions"
option-value="code"
option-label="name"
hide-selected
map-options
/>
<VnInput
v-model="data.healthRegister"
:label="t('supplier.fiscalData.healthRegister')"
clearable
/>
</VnRow>
<VnRow>
<VnInput
v-model="data.street"
:label="t('supplier.fiscalData.street')"
clearable
/>
</VnRow>
<VnRow>
<VnLocation
:rules="validate('Worker.postcode')"
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
v-model="data.postCode"
@update:model-value="(location) => handleLocation(data, location)"
>
</VnLocation>
</VnRow>
<VnRow>
<div class="col flex justify-around">
<QCheckbox
v-model="data.isTrucker"
:label="t('supplier.fiscalData.isTrucker')"
/>
<div class="row items-center">
<QCheckbox
v-model="data.isVies"
:label="t('supplier.fiscalData.isVies')"
/>
<QIcon name="info" size="xs" class="cursor-pointer q-ml-sm">
<QTooltip>
{{
t(
'When activating it, do not enter the country code in the ID field.'
)
}}
</QTooltip>
</QIcon>
</div>
</div>
</VnRow>
</template>
</FormModel>
</template>
<i18n>
es:
When activating it, do not enter the country code in the ID field.: Al activarlo, no informar el código del país en el campo nif
</i18n>