Merge branch 'dev' into 8304-workerChangesAndFixes
gitea/salix-front/pipeline/pr-dev Build queued...
Details
gitea/salix-front/pipeline/pr-dev Build queued...
Details
This commit is contained in:
commit
eabe29ed5c
|
@ -500,7 +500,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
<QCard
|
||||
bordered
|
||||
flat
|
||||
class="row no-wrap justify-between cursor-pointer"
|
||||
class="row no-wrap justify-between cursor-pointer q-pa-sm"
|
||||
@click="
|
||||
(_, row) => {
|
||||
$props.rowClick && $props.rowClick(row);
|
||||
|
@ -581,7 +581,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
<!-- Actions -->
|
||||
<QCardSection
|
||||
v-if="colsMap.tableActions"
|
||||
class="column flex-center w-10 no-margin q-pa-xs q-gutter-y-xs"
|
||||
@click="stopEventPropagation($event)"
|
||||
>
|
||||
<QBtn
|
||||
|
@ -807,12 +806,15 @@ es:
|
|||
|
||||
.grid-two {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
overflow: scroll;
|
||||
white-space: wrap;
|
||||
width: 100%;
|
||||
grid-template-columns: 2fr 2fr;
|
||||
.vn-label-value {
|
||||
flex-direction: column;
|
||||
white-space: nowrap;
|
||||
.fields {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.w-80 {
|
||||
|
|
|
@ -378,7 +378,7 @@ login:
|
|||
loginError: Invalid username or password
|
||||
fieldRequired: This field is required
|
||||
twoFactorRequired: Two-factor verification required
|
||||
twoFactorRequired:
|
||||
twoFactor:
|
||||
validate: Validate
|
||||
insert: Enter the verification code
|
||||
explanation: >-
|
||||
|
@ -457,48 +457,6 @@ ticket:
|
|||
consigneeStreet: Street
|
||||
create:
|
||||
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:
|
||||
chat: Chat
|
||||
bossDepartment: Boss Department
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export async function getAddresses(clientId) {
|
||||
export async function getAddresses(clientId, _filter = {}) {
|
||||
if (!clientId) return;
|
||||
const filter = {
|
||||
..._filter,
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export async function getClient(clientId) {
|
||||
export async function getClient(clientId, _filter = {}) {
|
||||
const filter = {
|
||||
..._filter,
|
||||
include: {
|
||||
relation: 'defaultAddress',
|
||||
scope: {
|
||||
|
|
|
@ -3,14 +3,17 @@ import axios from 'axios';
|
|||
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
|
||||
|
||||
vi.mock('axios');
|
||||
const response = { data: [{ agencyModeFk: 'Agency1' }, { agencyModeFk: 'Agency2' }] };
|
||||
axios.get.mockResolvedValue(response);
|
||||
|
||||
describe('getAgencies', () => {
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
const generateParams = (formData) => ({
|
||||
const generateParams = (formData, filter = {}) => ({
|
||||
params: {
|
||||
filter: JSON.stringify(filter),
|
||||
warehouseFk: formData.warehouseId,
|
||||
addressFk: formData.addressId,
|
||||
landed: formData.landed,
|
||||
|
@ -23,10 +26,15 @@ describe('getAgencies', () => {
|
|||
addressId: '456',
|
||||
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 () => {
|
||||
|
@ -52,4 +60,23 @@ describe('getAgencies', () => {
|
|||
|
||||
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 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;
|
||||
|
||||
const filter = {
|
||||
..._filter
|
||||
};
|
||||
|
||||
let defaultAgency = null;
|
||||
let params = {
|
||||
filter: JSON.stringify(filter),
|
||||
warehouseFk: formData.warehouseId,
|
||||
addressFk: formData.addressId,
|
||||
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 { data } = await getClient(client.value)
|
||||
const [retrievedClient] = data;
|
||||
const response = await getClient(client.value)
|
||||
if (!response) return;
|
||||
const [retrievedClient] = response.data;
|
||||
selectedClient.value = retrievedClient;
|
||||
};
|
||||
|
||||
const fetchAddresses = async () => {
|
||||
const { data } = await getAddresses(client.value);
|
||||
addressesOptions.value = data;
|
||||
const response = await getAddresses(client.value);
|
||||
if (!response) return;
|
||||
addressesOptions.value = response.data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
address.value = defaultAddress.id;
|
||||
|
|
|
@ -38,35 +38,43 @@ onBeforeMount(async () => {
|
|||
await onClientSelected(initialFormState);
|
||||
});
|
||||
|
||||
function resetAgenciesSelector(formData) {
|
||||
agenciesOptions.value = [];
|
||||
formData.agencyModeId = null;
|
||||
}
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
const { data } = await getClient(formData.clientId);
|
||||
const [client] = data;
|
||||
const response = await getClient(formData.clientId);
|
||||
if (!response) return;
|
||||
const [client] = response.data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
const { data } = await getAddresses(formData.clientId);
|
||||
addressesOptions.value = data;
|
||||
const response = await getAddresses(formData.clientId);
|
||||
if (!response) return;
|
||||
addressesOptions.value = response.data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
};
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
resetAgenciesSelector(formData);
|
||||
await fetchClient(formData);
|
||||
await fetchAddresses(formData);
|
||||
};
|
||||
|
||||
const fetchAvailableAgencies = async (formData) => {
|
||||
const { data } = await getAgencies(formData);
|
||||
agenciesOptions.value = data;
|
||||
|
||||
const defaultAgency = agenciesOptions.value.find(
|
||||
(agency) =>
|
||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
||||
);
|
||||
|
||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
||||
resetAgenciesSelector(formData);
|
||||
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 redirectToTicketList = (_, { id }) => {
|
||||
|
|
|
@ -38,35 +38,43 @@ onBeforeMount(async () => {
|
|||
await onClientSelected(initialFormState);
|
||||
});
|
||||
|
||||
function resetAgenciesSelector(formData) {
|
||||
agenciesOptions.value = [];
|
||||
if(formData) formData.agencyModeId = null;
|
||||
}
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
const { data } = await getClient(formData.clientId);
|
||||
const [client] = data;
|
||||
const response = await getClient(formData.clientId);
|
||||
if (!response) return;
|
||||
const [client] = response.data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
const { data } = await getAddresses(formData.clientId);
|
||||
addressesOptions.value = data;
|
||||
const response = await getAddresses(formData.clientId);
|
||||
if (!response) return;
|
||||
addressesOptions.value = response.data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
};
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
resetAgenciesSelector(formData);
|
||||
await fetchClient(formData);
|
||||
await fetchAddresses(formData);
|
||||
};
|
||||
|
||||
const fetchAvailableAgencies = async (formData) => {
|
||||
const { data } = await getAgencies(formData);
|
||||
agenciesOptions.value = data;
|
||||
|
||||
const defaultAgency = agenciesOptions.value.find(
|
||||
(agency) =>
|
||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
||||
);
|
||||
|
||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
||||
resetAgenciesSelector(formData);
|
||||
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 redirectToTicketList = (_, { id }) => {
|
||||
|
|
|
@ -229,37 +229,46 @@ const columns = computed(() => [
|
|||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function resetAgenciesSelector(formData) {
|
||||
agenciesOptions.value = [];
|
||||
if(formData) formData.agencyModeId = null;
|
||||
}
|
||||
|
||||
function redirectToLines(id) {
|
||||
const url = `#/ticket/${id}/sale`;
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
const onClientSelected = async (formData) => {
|
||||
resetAgenciesSelector(formData);
|
||||
await fetchClient(formData);
|
||||
await fetchAddresses(formData);
|
||||
};
|
||||
|
||||
const fetchAvailableAgencies = async (formData) => {
|
||||
const { data } = await getAgencies(formData);
|
||||
agenciesOptions.value = data;
|
||||
|
||||
const defaultAgency = agenciesOptions.value.find(
|
||||
(agency) =>
|
||||
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
||||
);
|
||||
|
||||
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
||||
resetAgenciesSelector(formData);
|
||||
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 fetchClient = async (formData) => {
|
||||
const { data } = await getClient(formData.clientId);
|
||||
const [client] = data;
|
||||
const response = await getClient(formData.clientId);
|
||||
if (!response) return;
|
||||
const [client] = response.data;
|
||||
selectedClient.value = client;
|
||||
};
|
||||
|
||||
const fetchAddresses = async (formData) => {
|
||||
const { data } = await getAddresses(formData.clientId);
|
||||
addressesOptions.value = data;
|
||||
const response = await getAddresses(formData.clientId);
|
||||
if (!response) return;
|
||||
addressesOptions.value = response.data;
|
||||
|
||||
const { defaultAddress } = selectedClient.value;
|
||||
formData.addressId = defaultAddress.id;
|
||||
|
|
Loading…
Reference in New Issue