Suppliers corrections

This commit is contained in:
William Buezas 2024-01-24 10:47:48 -03:00
parent 41605db454
commit 899633171d
8 changed files with 259 additions and 32 deletions

View File

@ -48,6 +48,13 @@ const workersOptions = ref([]);
map-options
:rules="validate('supplier.workerFk')"
>
<template #append>
<QIcon name="info" class="cursor-pointer">
<QTooltip>{{
t('Responsible for approving invoices')
}}</QTooltip>
</QIcon>
</template>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
@ -95,3 +102,8 @@ const workersOptions = ref([]);
</template>
</FormModel>
</template>
<i18n>
es:
Responsible for approving invoices: Responsable de aprobar las facturas
</i18n>

View File

@ -13,6 +13,13 @@ const { t } = useI18n();
const paymethodsOptions = ref([]);
const payDemsOptions = ref([]);
const formatPayDems = (data) => {
payDemsOptions.value = data.map(({ id, payDem }) => ({
id: id,
payDem: payDem || '0',
}));
};
</script>
<template>
<FetchData
@ -20,7 +27,7 @@ const payDemsOptions = ref([]);
@on-fetch="(data) => (paymethodsOptions = data)"
auto-load
/>
<FetchData url="PayDems" @on-fetch="(data) => (payDemsOptions = data)" auto-load />
<FetchData url="PayDems" @on-fetch="(data) => formatPayDems(data)" auto-load />
<FormModel
:url="`Suppliers/${route.params.id}`"
:url-update="`Suppliers/${route.params.id}`"
@ -37,7 +44,6 @@ const payDemsOptions = ref([]);
option-value="id"
option-label="name"
hide-selected
map-options
:rules="validate('supplier.payMethodFk')"
/>
</div>
@ -49,7 +55,6 @@ const payDemsOptions = ref([]);
option-value="id"
option-label="payDem"
hide-selected
map-options
:rules="validate('supplier.payDemFk')"
/>
</div>

View File

@ -8,7 +8,7 @@ import FetchedTags from 'components/ui/FetchedTags.vue';
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import SupplierConsumptionFilter from './SupplierConsumptionFilter.vue';
import { toDate, toDateString } from 'src/filters';
import { toDate } from 'src/filters';
import { dashIfEmpty } from 'src/filters';
import { usePrintService } from 'composables/usePrintService';
import useNotify from 'src/composables/useNotify.js';
@ -31,23 +31,26 @@ const arrayData = useArrayData('SupplierConsumption', {
const store = arrayData.store;
const userParams = computed(() => {
const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
minDate.setMonth(minDate.getMonth() - 2);
const maxDate = Date.vnNew();
maxDate.setHours(23, 59, 59, 59);
return {
from: toDateString(minDate),
to: toDateString(maxDate),
const dateRanges = computed(() => {
const ranges = {
from: null,
to: null,
};
if (route.query && route.query.params) {
const params = JSON.parse(route.query.params);
if (params.from && params.to) {
ranges.from = params.from;
ranges.to = params.to;
}
}
return ranges;
});
const reportParams = computed(() => ({
recipientId: Number(route.params.id),
...userParams.value,
...dateRanges.value,
}));
async function getSupplierConsumptionData() {
@ -113,10 +116,10 @@ onMounted(async () => {
</script>
<template>
<QToolbar class="bg-vn-dark justify-end">
<QToolbar v-if="rows && rows.length > 0" class="bg-vn-dark justify-end">
<div id="st-data">
<QBtn
v-if="userParams.from && userParams.to"
:disabled="!dateRanges.from && !dateRanges.to"
color="primary"
icon-right="picture_as_pdf"
no-caps
@ -128,7 +131,7 @@ onMounted(async () => {
</QTooltip>
</QBtn>
<QBtn
v-if="userParams.from && userParams.to"
:disabled="!dateRanges.from && !dateRanges.to"
color="primary"
icon-right="email"
no-caps

View File

@ -50,18 +50,14 @@ const itemCategoriesOptions = ref([]);
@on-fetch="(data) => (itemCategoriesOptions = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
:unremovable-params="['supplierFk']"
>
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params }">
<template #body="{ params, searchFn }">
<QItem>
<QItemSection>
<VnInput
@ -85,6 +81,7 @@ const itemCategoriesOptions = ref([]);
<VnSelectFilter
:label="t('params.buyerId')"
v-model="params.buyerId"
@update:model-value="searchFn()"
:options="buyersOptions"
option-value="id"
option-label="nickname"
@ -100,6 +97,7 @@ const itemCategoriesOptions = ref([]);
<VnSelectFilter
:label="t('params.typeId')"
v-model="params.typeId"
@update:model-value="searchFn()"
:options="itemTypesOptions"
option-value="id"
option-label="name"
@ -126,6 +124,7 @@ const itemCategoriesOptions = ref([]);
<VnSelectFilter
:label="t('params.categoryId')"
v-model="params.categoryId"
@update:model-value="searchFn()"
:options="itemCategoriesOptions"
option-value="id"
option-label="name"
@ -140,8 +139,9 @@ const itemCategoriesOptions = ref([]);
<QItemSection>
<VnInputDate
:label="t('params.from')"
is-outlined
v-model="params.from"
@update:model-value="searchFn()"
is-outlined
/>
</QItemSection>
</QItem>
@ -149,8 +149,9 @@ const itemCategoriesOptions = ref([]);
<QItemSection>
<VnInputDate
:label="t('params.to')"
is-outlined
v-model="params.to"
@update:model-value="searchFn()"
is-outlined
/>
</QItemSection>
</QItem>

View File

@ -1,10 +1,14 @@
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { toDateString } from 'src/filters';
import useCardDescription from 'src/composables/useCardDescription';
import { getUrl } from 'src/composables/getUrl';
const $props = defineProps({
id: {
@ -16,6 +20,7 @@ const $props = defineProps({
const route = useRoute();
const { t } = useI18n();
const url = ref();
const filter = {
fields: [
@ -53,6 +58,10 @@ const filter = {
],
};
onMounted(async () => {
url.value = await getUrl('');
});
const entityId = computed(() => {
return $props.id || route.params.id;
});
@ -61,6 +70,27 @@ const data = ref(useCardDescription());
const setData = (entity) => {
data.value = useCardDescription(entity.ref, entity.id);
};
const getEntryQueryParams = (supplier) => {
if (!supplier) return null;
const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const from = new Date(date.getTime());
from.setDate(from.getDate() - 10);
const to = new Date(date.getTime());
to.setDate(to.getDate() + 10);
const params = {
supplierFk: supplier.id,
from: toDateString(from),
to: toDateString(to),
};
return params;
};
</script>
<template>
@ -87,8 +117,46 @@ const setData = (entity) => {
<VnLv :label="t('supplier.summary.payDay')" :value="entity.payDay" />
<VnLv :label="t('supplier.summary.account')" :value="entity.account" />
</template>
<template #actions="{ entity }">
<QCardActions>
<QBtn
:to="{
name: 'EntryList',
query: { params: JSON.stringify(getEntryQueryParams(entity)) },
}"
size="md"
icon="vn:entry"
color="primary"
>
<QTooltip>{{ t('All entries with current supplier') }}</QTooltip>
</QBtn>
<QBtn
:to="{
name: 'CustomerCard',
params: { id: entity.client?.id },
}"
size="md"
icon="vn:Person"
color="primary"
>
<QTooltip>{{ t('Go to client') }}</QTooltip>
</QBtn>
<QBtn
:href="`${url}invoice-in/create`"
size="md"
icon="vn:invoice-in-create"
color="primary"
>
<QTooltip>{{ t('Create invoiceIn') }}</QTooltip>
</QBtn>
</QCardActions>
</template>
</CardDescriptor>
</template>
<i18n>
<i18n>
es:
All entries with current supplier: Todas las entradas con proveedor actual
Go to client: Ir a cliente
Create invoiceIn: Crear factura recibida
</i18n>

View File

@ -1,6 +1,8 @@
<script setup>
import { reactive } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
@ -9,12 +11,17 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useStateStore } from 'stores/useStateStore';
const router = useRouter();
const { t } = useI18n();
const stateStore = useStateStore();
const newSupplierForm = reactive({
name: null,
});
const redirectToSupplierFiscalData = (_, responseData) => {
router.push({ name: 'SupplierFiscalData', params: { id: responseData.id } });
};
</script>
<template>
@ -34,6 +41,7 @@ const newSupplierForm = reactive({
url-create="Suppliers/newSupplier"
model="supplier"
:form-initial-data="newSupplierForm"
@on-data-saved="redirectToSupplierFiscalData"
>
<template #form="{ data }">
<VnRow class="row q-gutter-md q-mb-md">

View File

@ -1,13 +1,16 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore';
import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import CardList from 'src/components/ui/CardList.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { useQuasar } from 'quasar';
import SupplierSummaryDialog from './Card/SupplierSummaryDialog.vue';
import SupplierListFilter from './SupplierListFilter.vue';
import { useStateStore } from 'stores/useStateStore';
const stateStore = useStateStore();
const router = useRouter();
@ -44,6 +47,11 @@ const viewSummary = (id) => {
</template>
<QPage class="column items-center q-pa-md">
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8">
<SupplierListFilter data-key="SuppliersList" />
</QScrollArea>
</QDrawer>
<div class="vn-card-list">
<VnPaginate data-key="SuppliersList" url="Suppliers/filter" auto-load>
<template #body="{ rows }">
@ -56,7 +64,7 @@ const viewSummary = (id) => {
>
<template #list-items>
<VnLv label="NIF/CIF" :value="row.nif" />
<VnLv label="Alias" :value="row.nickname" />
<VnLv label="Alias" :value="row.alias" />
<VnLv
:label="t('supplier.list.payMethod')"
:value="row.payMethod"

View File

@ -0,0 +1,122 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue';
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const { t } = useI18n();
const provincesOptions = ref([]);
const countriesOptions = ref([]);
</script>
<template>
<FetchData
url="Provinces"
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
@on-fetch="(data) => (provincesOptions = data)"
auto-load
/>
<FetchData
url="countries"
:filter="{ fields: ['id', 'country'], order: 'country ASC', limit: 30 }"
@on-fetch="(data) => (countriesOptions = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
:unremovable-params="['supplierFk']"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params, searchFn }">
<QItem>
<QItemSection>
<VnInput
v-model="params.search"
:label="t('params.search')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput
v-model="params.nickname"
:label="t('params.nickname')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput v-model="params.nif" :label="t('params.nif')" is-outlined />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelectFilter
:label="t('params.provinceFk')"
v-model="params.provinceFk"
@update:model-value="searchFn()"
:options="provincesOptions"
option-value="id"
option-label="name"
hide-selected
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelectFilter
:label="t('params.countryFk')"
v-model="params.countryFk"
@update:model-value="searchFn()"
:options="countriesOptions"
option-value="id"
option-label="country"
hide-selected
dense
outlined
rounded
/>
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>
<i18n>
en:
params:
search: General search
nickname: Alias
nif: Tax number
provinceFk: Province
countryFk: Country
es:
params:
search: Búsqueda general
nickname: Alias
nif: NIF/CIF
provinceFk: Provincia
countryFk: País
</i18n>