diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue
index 940b72ff0..58b4146bf 100644
--- a/src/components/CrudModel.vue
+++ b/src/components/CrudModel.vue
@@ -1,6 +1,6 @@
@@ -192,7 +203,7 @@ function exprBuilder(param, value) {
-
+
diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue
index 7685c55bc..10d5107e2 100644
--- a/src/pages/Customer/components/CustomerAddressEdit.vue
+++ b/src/pages/Customer/components/CustomerAddressEdit.vue
@@ -2,7 +2,7 @@
import { onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
-
+import { useQuasar } from 'quasar';
import axios from 'axios';
import VnLocation from 'src/components/common/VnLocation.vue';
import FetchData from 'components/FetchData.vue';
@@ -13,11 +13,12 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
+import VnConfirm from 'components/ui/VnConfirm.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
-
+const quasar = useQuasar();
const urlUpdate = ref('');
const agencyModes = ref([]);
const incoterms = ref([]);
@@ -83,8 +84,26 @@ const deleteNote = (id, index) => {
notes.value.splice(index, 1);
};
-const onDataSaved = async () => {
- let payload = {
+const updateAddress = async (data) => {
+ await axios.patch(urlUpdate.value, data);
+};
+
+const updateAddressTicket = async () => {
+ urlUpdate.value += '?updateObservations=true';
+};
+
+const updateObservations = async (payload) => {
+ await axios.post('AddressObservations/crud', payload);
+ notes.value = [];
+ deletes.value = [];
+ toCustomerAddress();
+};
+async function updateAll({ data, payload }) {
+ await updateObservations(payload);
+ await updateAddress(data);
+}
+function getPayload() {
+ return {
creates: notes.value.filter((note) => note.$isNew),
deletes: deletes.value,
updates: notes.value
@@ -101,14 +120,40 @@ const onDataSaved = async () => {
where: { id: note.id },
})),
};
+}
- await axios.post('AddressObservations/crud', payload);
- notes.value = [];
- deletes.value = [];
- toCustomerAddress();
-};
+async function handleDialog(data) {
+ const payload = getPayload();
+ const body = { data, payload };
+ if (payload.updates.length) {
+ quasar
+ .dialog({
+ component: VnConfirm,
+ componentProps: {
+ title: t(
+ 'confirmTicket'
+ ),
+ message: t('confirmDeletionMessage'),
+ },
+ })
+ .onOk(async () => {
+ await updateAddressTicket();
+ await updateAll(body);
+ toCustomerAddress();
+ })
+ .onCancel(async () => {
+ await updateAll(body);
+ toCustomerAddress();
+ });
+ } else {
+ updateAll(body);
+ toCustomerAddress();
+ }
+}
const toCustomerAddress = () => {
+ notes.value = [];
+ deletes.value = [];
router.push({
name: 'CustomerAddress',
params: {
@@ -143,7 +188,7 @@ function handleLocation(data, location) {
:observe-form-changes="false"
:url-update="urlUpdate"
:url="`Addresses/${route.params.addressId}`"
- @on-data-saved="onDataSaved()"
+ :save-fn="handleDialog"
auto-load
>
@@ -336,4 +381,9 @@ es:
Remove note: Eliminar nota
Longitude: Longitud
Latitude: Latitud
+ confirmTicket: ¿Desea modificar también los estados de todos los tickets que están a punto de ser servidos?
+ confirmDeletionMessage: Si le das a aceptar, se modificaran todas las notas de los ticket a futuro
+en:
+ confirmTicket: Do you also want to modify the states of all the tickets that are about to be served?
+ confirmDeletionMessage: If you click accept, all the notes of the future tickets will be modified
diff --git a/src/pages/Customer/composables/__tests__/getAddresses.spec.js b/src/pages/Customer/composables/__tests__/getAddresses.spec.js
new file mode 100644
index 000000000..9e04a83cc
--- /dev/null
+++ b/src/pages/Customer/composables/__tests__/getAddresses.spec.js
@@ -0,0 +1,33 @@
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import axios from 'axios';
+import { getAddresses } from 'src/pages/Customer/composables/getAddresses';
+
+vi.mock('axios');
+
+describe('getAddresses', () => {
+ afterEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('should fetch addresses with correct parameters for a valid clientId', async () => {
+ const clientId = '12345';
+
+ await getAddresses(clientId);
+
+ expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
+ params: {
+ filter: JSON.stringify({
+ fields: ['nickname', 'street', 'city', 'id'],
+ where: { isActive: true },
+ order: 'nickname ASC',
+ }),
+ },
+ });
+ });
+
+ it('should return undefined when clientId is not provided', async () => {
+ await getAddresses(undefined);
+
+ expect(axios.get).not.toHaveBeenCalled();
+ });
+});
\ No newline at end of file
diff --git a/src/pages/Customer/composables/__tests__/getClient.spec.js b/src/pages/Customer/composables/__tests__/getClient.spec.js
new file mode 100644
index 000000000..a83d3d89f
--- /dev/null
+++ b/src/pages/Customer/composables/__tests__/getClient.spec.js
@@ -0,0 +1,41 @@
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import axios from 'axios';
+import { getClient } from 'src/pages/Customer/composables/getClient';
+
+vi.mock('axios');
+
+describe('getClient', () => {
+ afterEach(() => {
+ vi.clearAllMocks();
+ });
+
+ const generateParams = (clientId) => ({
+ params: {
+ filter: JSON.stringify({
+ include: {
+ relation: 'defaultAddress',
+ scope: {
+ fields: ['id', 'agencyModeFk'],
+ },
+ },
+ where: { id: clientId },
+ }),
+ },
+ });
+
+ it('should fetch client data with correct parameters for a valid clientId', async () => {
+ const clientId = '12345';
+
+ await getClient(clientId);
+
+ expect(axios.get).toHaveBeenCalledWith('Clients', generateParams(clientId));
+ });
+
+ it('should return undefined when clientId is not provided', async () => {
+ const clientId = undefined;
+
+ await getClient(clientId);
+
+ expect(axios.get).toHaveBeenCalledWith('Clients', generateParams(clientId));
+ });
+});
diff --git a/src/pages/Customer/composables/getAddresses.js b/src/pages/Customer/composables/getAddresses.js
new file mode 100644
index 000000000..eecc0150b
--- /dev/null
+++ b/src/pages/Customer/composables/getAddresses.js
@@ -0,0 +1,14 @@
+import axios from 'axios';
+
+export async function getAddresses(clientId) {
+ if (!clientId) return;
+ const filter = {
+ fields: ['nickname', 'street', 'city', 'id'],
+ where: { isActive: true },
+ order: 'nickname ASC',
+ };
+ const params = { filter: JSON.stringify(filter) };
+ return await axios.get(`Clients/${clientId}/addresses`, {
+ params,
+ });
+};
\ No newline at end of file
diff --git a/src/pages/Customer/composables/getClient.js b/src/pages/Customer/composables/getClient.js
new file mode 100644
index 000000000..ecacc67c0
--- /dev/null
+++ b/src/pages/Customer/composables/getClient.js
@@ -0,0 +1,15 @@
+import axios from 'axios';
+
+export async function getClient(clientId) {
+ const filter = {
+ include: {
+ relation: 'defaultAddress',
+ scope: {
+ fields: ['id', 'agencyModeFk'],
+ },
+ },
+ where: { id: clientId },
+ };
+ const params = { filter: JSON.stringify(filter) };
+ return await axios.get('Clients', { params });
+};
\ No newline at end of file
diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue
index e88336fd4..5d521d1fc 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue
@@ -272,7 +272,6 @@ const createInvoiceInCorrection = async () => {
>
- {{ console.log('opt: ', opt) }}
{{ opt.id }} -
diff --git a/src/pages/Item/ItemRequest.vue b/src/pages/Item/ItemRequest.vue
index d96fbca2f..76e4b8083 100644
--- a/src/pages/Item/ItemRequest.vue
+++ b/src/pages/Item/ItemRequest.vue
@@ -272,11 +272,12 @@ const onDenyAccept = (_, responseData) => {
diff --git a/src/pages/Route/Agency/AgencyList.vue b/src/pages/Route/Agency/AgencyList.vue
index 9d456c1da..4322b9bc8 100644
--- a/src/pages/Route/Agency/AgencyList.vue
+++ b/src/pages/Route/Agency/AgencyList.vue
@@ -2,11 +2,12 @@
import { computed } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
-import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnTable from 'components/VnTable/VnTable.vue';
+import VnSection from 'src/components/common/VnSection.vue';
const { t } = useI18n();
const router = useRouter();
+const dataKey = 'AgencyList';
function navigate(id) {
router.push({ path: `/agency/${id}` });
}
@@ -67,26 +68,28 @@ const columns = computed(() => [
]);
-
-
+
+