feat: refs #8828 add warehouse filtering for tickets and travels #1678

Open
benjaminedc wants to merge 29 commits from 8828-filterVnSelectWarehouses into dev
19 changed files with 135 additions and 27 deletions

View File

@ -156,6 +156,11 @@ const selectTravel = ({ id }) => {
option-label="name"
option-value="id"
v-model="travelFilterParams.warehouseOutFk"
:where="{
isOrigin: {
neq: 0,
},
}"
/>
<VnSelect
:label="t('globals.warehouseIn')"
@ -164,6 +169,11 @@ const selectTravel = ({ id }) => {
option-label="name"
option-value="id"
v-model="travelFilterParams.warehouseInFk"
:where="{
isDestiny: {
neq: 0,
},
}"
/>
<VnInputDate
:label="t('globals.shipped')"

View File

@ -40,6 +40,11 @@ const onDataSaved = (data) => {
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
auto-load
:where="{
isInventory: {
neq: 0,
},
}"
/>
<FormModelPopup
url-create="Items/regularize"

View File

@ -162,6 +162,11 @@ const entryFilterPanel = ref();
v-model="params.warehouseOutFk"
@update:model-value="searchFn()"
url="Warehouses"
:where="{
isOrigin: {
neq: 0,
},
}"
:fields="['id', 'name']"
sort-by="name ASC"
hide-selected
@ -177,6 +182,11 @@ const entryFilterPanel = ref();
v-model="params.warehouseInFk"
@update:model-value="searchFn()"
url="Warehouses"
:where="{
isDestiny: {
neq: 0,
},
}"
:fields="['id', 'name']"
sort-by="name ASC"
hide-selected

View File

@ -239,6 +239,11 @@ async function getZone(options) {
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
auto-load
/>
<FetchData

View File

@ -46,7 +46,16 @@ const setUserParams = (params) => {
</script>
<template>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehouses = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
auto-load
/>
<FetchData
url="ItemCategories"
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"

View File

@ -51,6 +51,11 @@ onMounted(async () => await getItemPackingTypes());
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
auto-load
/>
<VnFilterPanel

View File

@ -67,14 +67,12 @@ const onClientSelected = async (formData) => {
const fetchAvailableAgencies = async (formData) => {
resetAgenciesSelector(formData);
const response= await getAgencies(formData, selectedClient.value);
const response = await getAgencies(formData, selectedClient.value);
if (!response) return;
const { options, agency } = response
if(options)
agenciesOptions.value = options;
if(agency)
formData.agencyModeId = agency;
const { options, agency } = response;
if (options) agenciesOptions.value = options;
if (agency) formData.agencyModeId = agency;
};
const redirectToTicketList = (_, { id }) => {
@ -92,6 +90,11 @@ const redirectToTicketList = (_, { id }) => {
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
order="name"
auto-load
/>

View File

@ -40,7 +40,7 @@ onBeforeMount(async () => {
function resetAgenciesSelector(formData) {
agenciesOptions.value = [];
if(formData) formData.agencyModeId = null;
if (formData) formData.agencyModeId = null;
}
const fetchClient = async (formData) => {
@ -67,14 +67,12 @@ const onClientSelected = async (formData) => {
const fetchAvailableAgencies = async (formData) => {
resetAgenciesSelector(formData);
const response= await getAgencies(formData, selectedClient.value);
const response = await getAgencies(formData, selectedClient.value);
if (!response) return;
const { options, agency } = response
if(options)
agenciesOptions.value = options;
if(agency)
formData.agencyModeId = agency;
const { options, agency } = response;
if (options) agenciesOptions.value = options;
if (agency) formData.agencyModeId = agency;
};
const redirectToTicketList = (_, { id }) => {
@ -86,6 +84,11 @@ const redirectToTicketList = (_, { id }) => {
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
order="name"
auto-load
/>

View File

@ -41,7 +41,16 @@ const groupedStates = ref([]);
@on-fetch="(data) => (agencies = data)"
auto-load
/>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehouses = data)"
auto-load
:where="{
isForTicket: {
neq: 0,
},
}"
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"

View File

@ -55,6 +55,11 @@ onMounted(async () => {
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
:where="{
isForTicket: {
neq: 0,
},
}"
auto-load
/>
<VnFilterPanel

View File

@ -202,6 +202,11 @@ const columns = computed(() => [
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
where: {
isForTicket: {
neq: 0,
},
},
},
format: (row) => row.warehouse,
columnField: {
@ -668,9 +673,13 @@ function setReference(data) {
:sort-by="['name']"
:label="t('globals.warehouse')"
v-model="data.warehouseId"
:options="warehousesOptions"
hide-selected
required
:where="{
isForTicket: {
neq: 0,
},
}"
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>

View File

@ -102,6 +102,9 @@ const columns = computed(() => [
attrs: {
url: 'Warehouses',
fields: ['id', 'name'],
where: {
isForTicket: { neq: 0 },
},
},
inWhere: true,
},

View File

@ -208,6 +208,7 @@ ticketList:
hour: Hour
rounding: Rounding
noVerifiedData: No verified data
warehouse: Warehouse
purchaseRequest: Purchase request
notVisible: Not visible
clientFrozen: Client frozen

View File

@ -28,13 +28,21 @@ const warehousesOptionsIn = ref([]);
url="Warehouses"
@on-fetch="(data) => (warehousesOptionsOut = data)"
auto-load
:filter="{ where: { isOrigin: TRUE } }"
:where="{
isOrigin: {
neq: 0,
},
}"
/>
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptionsIn = data)"
auto-load
:filter="{ where: { isDestiny: TRUE } }"
:where="{
isDestiny: {
neq: 0,
},
}"
/>
<FormModel :url-update="`Travels/${route.params.id}`" model="Travel">
<template #form="{ data }">

View File

@ -183,7 +183,9 @@ warehouses();
<VnSelect
:label="t('extraCommunity.filter.warehouseOutFk')"
v-model="params.warehouseOutFk"
:options="warehousesOptions"
:options="
warehousesOptions.filter((option) => option.isOrigin !== 0)
"
option-value="id"
option-label="name"
hide-selected
@ -197,7 +199,9 @@ warehouses();
<VnSelect
:label="t('extraCommunity.filter.warehouseInFk')"
v-model="params.warehouseInFk"
:options="warehousesOptions"
:options="
warehousesOptions.filter((option) => option.isDestiny !== 0)
"
option-value="id"
option-label="name"
hide-selected

View File

@ -81,6 +81,11 @@ const redirectToTravelBasicData = (_, { id }) => {
option-value="id"
option-label="name"
hide-selected
:where="{
isOrigin: {
neq: 0,
},
}"
/>
<VnSelect
:label="t('globals.warehouseIn')"
@ -89,6 +94,11 @@ const redirectToTravelBasicData = (_, { id }) => {
option-value="id"
option-label="name"
hide-selected
:where="{
isDestiny: {
neq: 0,
},
}"
/>
</VnRow>
</template>

View File

@ -64,6 +64,11 @@ defineExpose({ states });
option-filter="name"
dense
filled
:where="{
isDestiny: {
neq: 0,
},
}"
/>
<VnInputDate
:label="t('travel.shipped')"
@ -89,6 +94,11 @@ defineExpose({ states });
option-filter="name"
dense
filled
:where="{
isOrigin: {
neq: 0,
},
}"
/>
<VnInputDate
:label="t('travel.landed')"

View File

@ -99,6 +99,7 @@ const columns = computed(() => [
fields: ['id', 'name'],
optionLabel: 'name',
optionValue: 'id',
where: { isDestiny: { neq: 0 } },
},
format: (row) => row.warehouseInName,
columnField: {
@ -133,6 +134,7 @@ const columns = computed(() => [
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
where: { isOrigin: { neq: 0 } },
},
format: (row) => row.warehouseOutName,
columnField: {

View File

@ -76,16 +76,13 @@ describe('TicketList', () => {
});
}).as('ticket');
cy.get('[data-cy="Warehouse_select"]').type('Warehouse Five');
cy.get('.q-menu .q-item').contains('Warehouse Five').click();
cy.get('[data-cy="Warehouse_select"]').type('Warehouse One');
cy.get('.q-menu .q-item').contains('Warehouse One').click();
cy.wait('@ticket').then((interception) => {
const data = interception.response.body[1];
expect(data.hasComponentLack).to.equal(1);
expect(data.isTooLittle).to.equal(1);
expect(data.hasItemShortage).to.equal(1);
});
cy.get('.icon-components').should('exist');
cy.get('.icon-unavailable').should('exist');
cy.get('.icon-isTooLittle').should('exist');
});
});