fix: #8422 fixed ItemTag e2e test not working #1301
|
@ -500,7 +500,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
<QCard
|
<QCard
|
||||||
bordered
|
bordered
|
||||||
flat
|
flat
|
||||||
class="row no-wrap justify-between cursor-pointer"
|
class="row no-wrap justify-between cursor-pointer q-pa-sm"
|
||||||
@click="
|
@click="
|
||||||
(_, row) => {
|
(_, row) => {
|
||||||
$props.rowClick && $props.rowClick(row);
|
$props.rowClick && $props.rowClick(row);
|
||||||
|
@ -581,7 +581,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<QCardSection
|
<QCardSection
|
||||||
v-if="colsMap.tableActions"
|
v-if="colsMap.tableActions"
|
||||||
class="column flex-center w-10 no-margin q-pa-xs q-gutter-y-xs"
|
|
||||||
@click="stopEventPropagation($event)"
|
@click="stopEventPropagation($event)"
|
||||||
>
|
>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -807,12 +806,15 @@ es:
|
||||||
|
|
||||||
.grid-two {
|
.grid-two {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
grid-template-columns: 2fr 2fr;
|
||||||
max-width: 100%;
|
.vn-label-value {
|
||||||
margin: 0 auto;
|
flex-direction: column;
|
||||||
overflow: scroll;
|
white-space: nowrap;
|
||||||
white-space: wrap;
|
.fields {
|
||||||
width: 100%;
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.w-80 {
|
.w-80 {
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
|
import UserPanel from 'src/components/UserPanel.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
|
describe('UserPanel', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vm;
|
||||||
|
let state;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = createWrapper(UserPanel, {});
|
||||||
|
state = useState();
|
||||||
|
state.setUser({
|
||||||
|
id: 115,
|
||||||
|
name: 'itmanagement',
|
||||||
|
nickname: 'itManagementNick',
|
||||||
|
lang: 'en',
|
||||||
|
darkMode: false,
|
||||||
|
companyFk: 442,
|
||||||
|
warehouseFk: 1,
|
||||||
|
});
|
||||||
|
wrapper = wrapper.wrapper;
|
||||||
|
vm = wrapper.vm;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fetch warehouses data on mounted', async () => {
|
||||||
|
const fetchData = wrapper.findComponent({ name: 'FetchData' });
|
||||||
|
expect(fetchData.props('url')).toBe('Warehouses');
|
||||||
|
expect(fetchData.props('autoLoad')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should toggle dark mode correctly and update preferences', async () => {
|
||||||
|
await vm.saveDarkMode(true);
|
||||||
|
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
|
||||||
|
expect(vm.user.darkMode).toBe(true);
|
||||||
|
vm.updatePreferences();
|
||||||
|
expect(vm.darkMode).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change user language and update preferences', async () => {
|
||||||
|
const userLanguage = 'es';
|
||||||
|
await vm.saveLanguage(userLanguage);
|
||||||
|
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
|
||||||
|
expect(vm.user.lang).toBe(userLanguage);
|
||||||
|
vm.updatePreferences();
|
||||||
|
expect(vm.locale).toBe(userLanguage);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update user data', async () => {
|
||||||
|
const key = 'name';
|
||||||
|
const value = 'itboss';
|
||||||
|
await vm.saveUserData(key, value);
|
||||||
|
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
|
||||||
|
});
|
||||||
|
});
|
|
@ -123,7 +123,7 @@ watch(
|
||||||
() => props.data,
|
() => props.data,
|
||||||
() => {
|
() => {
|
||||||
store.data = props.data;
|
store.data = props.data;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -132,12 +132,12 @@ watch(
|
||||||
if (!mounted.value) return;
|
if (!mounted.value) return;
|
||||||
emit('onChange', data);
|
emit('onChange', data);
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.url, props.filter],
|
() => [props.url, props.filter],
|
||||||
([url, filter]) => mounted.value && fetch({ url, filter })
|
([url, filter]) => mounted.value && fetch({ url, filter }),
|
||||||
);
|
);
|
||||||
const addFilter = async (filter, params) => {
|
const addFilter = async (filter, params) => {
|
||||||
await arrayData.addFilter({ filter, params });
|
await arrayData.addFilter({ filter, params });
|
||||||
|
@ -198,7 +198,7 @@ function endPagination() {
|
||||||
async function onLoad(index, done) {
|
async function onLoad(index, done) {
|
||||||
if (!store.data || !mounted.value) return done();
|
if (!store.data || !mounted.value) return done();
|
||||||
|
|
||||||
if (store.data.length === 0 || !props.url) return done(false);
|
if (store.data.length === 0 || !arrayData.store.url) return done(false);
|
||||||
|
|
||||||
pagination.value.page = pagination.value.page + 1;
|
pagination.value.page = pagination.value.page + 1;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ login:
|
||||||
loginError: Invalid username or password
|
loginError: Invalid username or password
|
||||||
fieldRequired: This field is required
|
fieldRequired: This field is required
|
||||||
twoFactorRequired: Two-factor verification required
|
twoFactorRequired: Two-factor verification required
|
||||||
twoFactorRequired:
|
twoFactor:
|
||||||
validate: Validate
|
validate: Validate
|
||||||
insert: Enter the verification code
|
insert: Enter the verification code
|
||||||
explanation: >-
|
explanation: >-
|
||||||
|
@ -457,48 +457,6 @@ ticket:
|
||||||
consigneeStreet: Street
|
consigneeStreet: Street
|
||||||
create:
|
create:
|
||||||
address: Address
|
address: Address
|
||||||
invoiceOut:
|
|
||||||
card:
|
|
||||||
issued: Issued
|
|
||||||
customerCard: Customer card
|
|
||||||
ticketList: Ticket List
|
|
||||||
summary:
|
|
||||||
issued: Issued
|
|
||||||
dued: Due
|
|
||||||
booked: Booked
|
|
||||||
taxBreakdown: Tax breakdown
|
|
||||||
taxableBase: Taxable base
|
|
||||||
rate: Rate
|
|
||||||
fee: Fee
|
|
||||||
tickets: Tickets
|
|
||||||
totalWithVat: Amount
|
|
||||||
globalInvoices:
|
|
||||||
errors:
|
|
||||||
chooseValidClient: Choose a valid client
|
|
||||||
chooseValidCompany: Choose a valid company
|
|
||||||
chooseValidPrinter: Choose a valid printer
|
|
||||||
chooseValidSerialType: Choose a serial type
|
|
||||||
fillDates: Invoice date and the max date should be filled
|
|
||||||
invoiceDateLessThanMaxDate: Invoice date can not be less than max date
|
|
||||||
invoiceWithFutureDate: Exists an invoice with a future date
|
|
||||||
noTicketsToInvoice: There are not tickets to invoice
|
|
||||||
criticalInvoiceError: 'Critical invoicing error, process stopped'
|
|
||||||
invalidSerialTypeForAll: The serial type must be global when invoicing all clients
|
|
||||||
table:
|
|
||||||
addressId: Address id
|
|
||||||
streetAddress: Street
|
|
||||||
statusCard:
|
|
||||||
percentageText: '{getPercentage}% {getAddressNumber} of {getNAddresses}'
|
|
||||||
pdfsNumberText: '{nPdfs} of {totalPdfs} PDFs'
|
|
||||||
negativeBases:
|
|
||||||
clientId: Client Id
|
|
||||||
base: Base
|
|
||||||
active: Active
|
|
||||||
hasToInvoice: Has to Invoice
|
|
||||||
verifiedData: Verified Data
|
|
||||||
comercial: Comercial
|
|
||||||
errors:
|
|
||||||
downloadCsvFailed: CSV download failed
|
|
||||||
department:
|
department:
|
||||||
chat: Chat
|
chat: Chat
|
||||||
bossDepartment: Boss Department
|
bossDepartment: Boss Department
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export async function getAddresses(clientId) {
|
export async function getAddresses(clientId, _filter = {}) {
|
||||||
if (!clientId) return;
|
if (!clientId) return;
|
||||||
const filter = {
|
const filter = {
|
||||||
|
..._filter,
|
||||||
fields: ['nickname', 'street', 'city', 'id'],
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: 'nickname ASC',
|
order: 'nickname ASC',
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export async function getClient(clientId) {
|
export async function getClient(clientId, _filter = {}) {
|
||||||
const filter = {
|
const filter = {
|
||||||
|
..._filter,
|
||||||
include: {
|
include: {
|
||||||
relation: 'defaultAddress',
|
relation: 'defaultAddress',
|
||||||
scope: {
|
scope: {
|
||||||
|
|
|
@ -134,6 +134,7 @@ function downloadCSV(rows) {
|
||||||
@click="
|
@click="
|
||||||
openReport(`Entries/${entityId}/labelSupplier`)
|
openReport(`Entries/${entityId}/labelSupplier`)
|
||||||
"
|
"
|
||||||
|
data-cy="printLabelsBtn"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #body="props">
|
<template #body="props">
|
||||||
|
|
|
@ -177,7 +177,7 @@ const cols = computed(() => [
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('invoicein.list.supplierRef')"
|
:label="t('invoiceIn.list.supplierRef')"
|
||||||
v-model="data.supplierRef"
|
v-model="data.supplierRef"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
@ -190,7 +190,7 @@ const cols = computed(() => [
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('invoicein.summary.issued')"
|
:label="t('invoiceIn.summary.issued')"
|
||||||
v-model="data.issued"
|
v-model="data.issued"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -22,7 +22,6 @@ const catalogParams = {
|
||||||
};
|
};
|
||||||
const arrayData = useArrayData(dataKey, {
|
const arrayData = useArrayData(dataKey, {
|
||||||
url: 'Orders/CatalogFilter',
|
url: 'Orders/CatalogFilter',
|
||||||
limit: 50,
|
|
||||||
userParams: catalogParams,
|
userParams: catalogParams,
|
||||||
});
|
});
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
|
@ -66,7 +65,7 @@ function extractValueTags(items) {
|
||||||
.filter((k) => /^value\d+$/.test(k))
|
.filter((k) => /^value\d+$/.test(k))
|
||||||
.map((v) => x[v])
|
.map((v) => x[v])
|
||||||
.filter((v) => v)
|
.filter((v) => v)
|
||||||
.sort()
|
.sort(),
|
||||||
);
|
);
|
||||||
tagValue.value = resultValueTags;
|
tagValue.value = resultValueTags;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,7 @@ watch(
|
||||||
(val) => {
|
(val) => {
|
||||||
extractTags(val);
|
extractTags(val);
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,17 @@ import axios from 'axios';
|
||||||
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
|
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
|
||||||
|
|
||||||
vi.mock('axios');
|
vi.mock('axios');
|
||||||
|
const response = { data: [{ agencyModeFk: 'Agency1' }, { agencyModeFk: 'Agency2' }] };
|
||||||
|
axios.get.mockResolvedValue(response);
|
||||||
|
|
||||||
describe('getAgencies', () => {
|
describe('getAgencies', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
const generateParams = (formData) => ({
|
const generateParams = (formData, filter = {}) => ({
|
||||||
params: {
|
params: {
|
||||||
|
filter: JSON.stringify(filter),
|
||||||
warehouseFk: formData.warehouseId,
|
warehouseFk: formData.warehouseId,
|
||||||
addressFk: formData.addressId,
|
addressFk: formData.addressId,
|
||||||
landed: formData.landed,
|
landed: formData.landed,
|
||||||
|
@ -23,10 +26,15 @@ describe('getAgencies', () => {
|
||||||
addressId: '456',
|
addressId: '456',
|
||||||
landed: 'true',
|
landed: 'true',
|
||||||
};
|
};
|
||||||
|
const filter = {
|
||||||
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
|
where: { isActive: true },
|
||||||
|
order: 'nickname ASC',
|
||||||
|
};
|
||||||
|
|
||||||
await getAgencies(formData);
|
await getAgencies(formData, null, filter);
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData));
|
expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData, filter));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call API when formData is missing required landed field', async () => {
|
it('should not call API when formData is missing required landed field', async () => {
|
||||||
|
@ -52,4 +60,23 @@ describe('getAgencies', () => {
|
||||||
|
|
||||||
expect(axios.get).not.toHaveBeenCalled();
|
expect(axios.get).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return options and agency when default agency is found', async () => {
|
||||||
|
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
||||||
|
const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
|
||||||
|
|
||||||
|
const { options, agency } = await getAgencies(formData, client);
|
||||||
|
|
||||||
|
expect(options).toEqual(response.data);
|
||||||
|
expect(agency).toEqual(response.data[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return options and agency when client is not provided', async () => {
|
||||||
|
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
||||||
|
|
||||||
|
const { options, agency } = await getAgencies(formData);
|
||||||
|
|
||||||
|
expect(options).toEqual(response.data);
|
||||||
|
expect(agency).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,26 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import agency from 'src/router/modules/agency';
|
||||||
|
|
||||||
export async function getAgencies(formData) {
|
export async function getAgencies(formData, client, _filter = {}) {
|
||||||
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
|
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
|
||||||
|
|
||||||
|
const filter = {
|
||||||
|
..._filter
|
||||||
|
};
|
||||||
|
|
||||||
|
let defaultAgency = null;
|
||||||
let params = {
|
let params = {
|
||||||
|
filter: JSON.stringify(filter),
|
||||||
warehouseFk: formData.warehouseId,
|
warehouseFk: formData.warehouseId,
|
||||||
addressFk: formData.addressId,
|
addressFk: formData.addressId,
|
||||||
landed: formData.landed,
|
landed: formData.landed,
|
||||||
};
|
};
|
||||||
|
|
||||||
return await axios.get('Agencies/getAgenciesWithWarehouse', { params });
|
const { data } = await axios.get('Agencies/getAgenciesWithWarehouse', { params });
|
||||||
|
|
||||||
|
if(data && client) {
|
||||||
|
defaultAgency = data.find((agency) => agency.agencyModeFk === client.defaultAddress.agencyModeFk );
|
||||||
|
};
|
||||||
|
|
||||||
|
return {options: data, agency: defaultAgency}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,14 +69,16 @@ const onAddressSelected = (addressId) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchClient = async () => {
|
const fetchClient = async () => {
|
||||||
const { data } = await getClient(client.value)
|
const response = await getClient(client.value)
|
||||||
const [retrievedClient] = data;
|
if (!response) return;
|
||||||
|
const [retrievedClient] = response.data;
|
||||||
selectedClient.value = retrievedClient;
|
selectedClient.value = retrievedClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async () => {
|
const fetchAddresses = async () => {
|
||||||
const { data } = await getAddresses(client.value);
|
const response = await getAddresses(client.value);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
address.value = defaultAddress.id;
|
address.value = defaultAddress.id;
|
||||||
|
|
|
@ -38,35 +38,43 @@ onBeforeMount(async () => {
|
||||||
await onClientSelected(initialFormState);
|
await onClientSelected(initialFormState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function resetAgenciesSelector(formData) {
|
||||||
|
agenciesOptions.value = [];
|
||||||
|
formData.agencyModeId = null;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
const onClientSelected = async (formData) => {
|
||||||
|
resetAgenciesSelector(formData);
|
||||||
await fetchClient(formData);
|
await fetchClient(formData);
|
||||||
await fetchAddresses(formData);
|
await fetchAddresses(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
resetAgenciesSelector(formData);
|
||||||
agenciesOptions.value = data;
|
const response= await getAgencies(formData, selectedClient.value);
|
||||||
|
if (!response) return;
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
|
||||||
(agency) =>
|
const { options, agency } = response
|
||||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
if(options)
|
||||||
);
|
agenciesOptions.value = options;
|
||||||
|
if(agency)
|
||||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
formData.agencyModeId = agency;
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectToTicketList = (_, { id }) => {
|
const redirectToTicketList = (_, { id }) => {
|
||||||
|
|
|
@ -38,35 +38,43 @@ onBeforeMount(async () => {
|
||||||
await onClientSelected(initialFormState);
|
await onClientSelected(initialFormState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function resetAgenciesSelector(formData) {
|
||||||
|
agenciesOptions.value = [];
|
||||||
|
if(formData) formData.agencyModeId = null;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
const onClientSelected = async (formData) => {
|
||||||
|
resetAgenciesSelector(formData);
|
||||||
await fetchClient(formData);
|
await fetchClient(formData);
|
||||||
await fetchAddresses(formData);
|
await fetchAddresses(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
resetAgenciesSelector(formData);
|
||||||
agenciesOptions.value = data;
|
const response= await getAgencies(formData, selectedClient.value);
|
||||||
|
if (!response) return;
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
|
||||||
(agency) =>
|
const { options, agency } = response
|
||||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
if(options)
|
||||||
);
|
agenciesOptions.value = options;
|
||||||
|
if(agency)
|
||||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
formData.agencyModeId = agency;
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectToTicketList = (_, { id }) => {
|
const redirectToTicketList = (_, { id }) => {
|
||||||
|
|
|
@ -229,37 +229,46 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
function resetAgenciesSelector(formData) {
|
||||||
|
agenciesOptions.value = [];
|
||||||
|
if(formData) formData.agencyModeId = null;
|
||||||
|
}
|
||||||
|
|
||||||
function redirectToLines(id) {
|
function redirectToLines(id) {
|
||||||
const url = `#/ticket/${id}/sale`;
|
const url = `#/ticket/${id}/sale`;
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
const onClientSelected = async (formData) => {
|
||||||
|
resetAgenciesSelector(formData);
|
||||||
await fetchClient(formData);
|
await fetchClient(formData);
|
||||||
await fetchAddresses(formData);
|
await fetchAddresses(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
resetAgenciesSelector(formData);
|
||||||
agenciesOptions.value = data;
|
const response= await getAgencies(formData, selectedClient.value);
|
||||||
|
if (!response) return;
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
|
||||||
(agency) =>
|
const { options, agency } = response
|
||||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
if(options)
|
||||||
);
|
agenciesOptions.value = options;
|
||||||
|
if(agency)
|
||||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
formData.agencyModeId = agency;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
|
|
|
@ -8,12 +8,12 @@ describe('EntryMy when is supplier', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// https://redmine.verdnatura.es/issues/8418
|
|
||||||
it.skip('should open buyLabel when is supplier', () => {
|
it('should open buyLabel when is supplier', () => {
|
||||||
cy.get(
|
cy.get(
|
||||||
'[to="/null/3"] > .q-card > .column > .q-btn > .q-btn__content > .q-icon'
|
'[to="/null/3"] > .q-card > .column > .q-btn > .q-btn__content > .q-icon'
|
||||||
).click();
|
).click();
|
||||||
cy.get('.q-card__actions > .q-btn').click();
|
cy.dataCy('printLabelsBtn').click();
|
||||||
cy.window().its('open').should('be.called');
|
cy.window().its('open').should('be.called');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue