fix: add agencyModeFk to selectedClient #1560

Merged
jsegarra merged 8 commits from hotfix_fixGetAgenciesTicketList into master 2025-03-06 00:30:22 +00:00
4 changed files with 11 additions and 4 deletions
Showing only changes of commit 0237a2364d - Show all commits

View File

@ -22,6 +22,12 @@ describe('getAddresses', () => {
relation: 'client',
scope: {
fields: ['defaultAddressFk'],
include: {
relation: 'defaultAddress',
scope: {
fields: ['id', 'agencyModeFk'],
},
},
},
},
],

View File

@ -66,7 +66,7 @@ describe('getAgencies', () => {
it('should return options and agency when default agency is found', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const client = { agencyModeFk: 'Agency1' };
const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
const { options, agency } = await getAgencies(formData, client);

View File

@ -21,7 +21,9 @@ export async function getAgencies(formData, client, _filter = {}) {
});
if (options && client) {
agency = options.find(({ agencyModeFk }) => agencyModeFk === client.agencyModeFk);
agency = options.find(
({ agencyModeFk }) => agencyModeFk === client.defaultAddress.agencyModeFk,
);
}
return { options, agency };

View File

@ -22,7 +22,6 @@ import { toTimeFormat } from 'src/filters/date';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import TicketProblems from 'src/components/TicketProblems.vue';
import VnSection from 'src/components/common/VnSection.vue';
import { getClient } from 'src/pages/Customer/composables/getClient';
import { getAddresses } from 'src/pages/Customer/composables/getAddresses';
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
@ -272,7 +271,7 @@ const fetchAddresses = async (formData) => {
formInitialData.value = { clientId: formData.clientId };
if (!data) return;
addressesOptions.value = data;
selectedClient.value = { ...data[0].client, agencyModeFk: data[0].agencyModeFk };
selectedClient.value = data[0].client;
formData.addressId = selectedClient.value.defaultAddressFk;
formInitialData.value.addressId = formData.addressId;
};