feat: revert changes and fix test
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Javier Segarra 2025-03-05 22:47:17 +01:00
parent 2c33205cdc
commit 0237a2364d
4 changed files with 11 additions and 4 deletions

View File

@ -22,6 +22,12 @@ describe('getAddresses', () => {
relation: 'client', relation: 'client',
scope: { scope: {
fields: ['defaultAddressFk'], 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 () => { it('should return options and agency when default agency is found', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' }; const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const client = { agencyModeFk: 'Agency1' }; const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
const { options, agency } = await getAgencies(formData, client); const { options, agency } = await getAgencies(formData, client);

View File

@ -21,7 +21,9 @@ export async function getAgencies(formData, client, _filter = {}) {
}); });
if (options && client) { if (options && client) {
agency = options.find(({ agencyModeFk }) => agencyModeFk === client.agencyModeFk); agency = options.find(
({ agencyModeFk }) => agencyModeFk === client.defaultAddress.agencyModeFk,
);
} }
return { options, agency }; 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 InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import TicketProblems from 'src/components/TicketProblems.vue'; import TicketProblems from 'src/components/TicketProblems.vue';
import VnSection from 'src/components/common/VnSection.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 { getAddresses } from 'src/pages/Customer/composables/getAddresses';
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies'; import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
@ -272,7 +271,7 @@ const fetchAddresses = async (formData) => {
formInitialData.value = { clientId: formData.clientId }; formInitialData.value = { clientId: formData.clientId };
if (!data) return; if (!data) return;
addressesOptions.value = data; addressesOptions.value = data;
selectedClient.value = { ...data[0].client, agencyModeFk: data[0].agencyModeFk }; selectedClient.value = data[0].client;
formData.addressId = selectedClient.value.defaultAddressFk; formData.addressId = selectedClient.value.defaultAddressFk;
formInitialData.value.addressId = formData.addressId; formInitialData.value.addressId = formData.addressId;
}; };