Compare commits

...

7 Commits

Author SHA1 Message Date
Javier Segarra 04b7e8a426 Merge branch 'dev' into 6943_customerFD_alreadyExists
gitea/salix-front/pipeline/pr-dev Build started... Details
2025-03-14 11:27:52 +00:00
Javier Segarra 397df9fd78 feat: refs #6943 solve conflicts
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-03-01 20:12:39 +01:00
Javier Segarra a92f66fbcb feat: refs #6943 solve conflicts
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-03-01 20:07:39 +01:00
Javier Segarra 4551691922 Merge branch 'dev' into 6943_customerFD_alreadyExists 2025-03-01 18:52:38 +01:00
Javier Segarra 921f3b6985 Merge branch 'dev' into 6943_customerFD_alreadyExists
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-03-01 12:08:03 +01:00
Javier Segarra 67bdce8bf9 Merge branch 'dev' into 6943_customerFD_alreadyExists
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-02-12 09:49:43 +01:00
Javier Segarra 8dd74501ec feat: refs #6943 already exists
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-02-10 13:42:42 +01:00
2 changed files with 61 additions and 7 deletions

View File

@ -75,6 +75,10 @@ const $props = defineProps({
type: Boolean,
default: true,
},
hasConfirmModal: {
type: Boolean,
default: false,
},
saveFn: {
type: Function,
default: null,
@ -231,7 +235,7 @@ async function save() {
if ($props.saveFn) response = await $props.saveFn(body);
else response = await axios[method](url, body);
if ($props.hasConfirmModal) return;
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
updateAndEmit('onDataSaved', {

View File

@ -4,14 +4,14 @@ import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useQuasar } from 'quasar';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import FetchData from 'src/components/FetchData.vue';
import FormModel from 'src/components/FormModel.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnLocation from 'src/components/common/VnLocation.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
import { getDifferences, getUpdatedValues } from 'src/filters';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
@ -19,6 +19,7 @@ import VnConfirm from 'src/components/ui/VnConfirm.vue';
const quasar = useQuasar();
const { t } = useI18n();
const route = useRoute();
const { openConfirmationModal } = useVnConfirm();
const { notify } = useNotify();
const typesTaxes = ref([]);
@ -31,6 +32,44 @@ function handleLocation(data, location) {
data.provinceFk = provinceFk;
data.countryFk = countryFk;
}
const formModelRef = ref({});
const hasChangedTaxData = ref(false);
async function formCustomFn(body) {
const data = formModelRef.value.formData;
const { email, phone, mobile } = data;
const hasContactData = email || phone || mobile;
if (hasChangedTaxData.value && hasContactData) await checkExistingClient(body, data);
else await confirm(data);
}
async function checkExistingClient(body, { email, phone, mobile, id }) {
const findParams = Object.entries({ email, phone, mobile })
.filter(([, value]) => value)
.map(([key, value]) => ({ [key]: value }));
const filter = JSON.stringify({
where: {
and: [{ or: findParams }, { id: { neq: id } }],
},
});
const { data: exist } = await axios.get(`Clients/findOne`, { params: { filter } });
if (!exist) confirm(data);
else {
openConfirmationModal(
t('Found a client with this data'),
`${t('foundClient_before')} <a class="link" href="#!/client/${exist.id}/summary" target="_blank">${exist.id}</a> ${t('foundClient_after')}`,
() => confirm(body),
null,
);
}
}
async function confirm(data) {
await axios.patch(`Clients/${route.params.id}/updateFiscalData`, data);
}
function onBeforeSave(formData, originalData) {
return getUpdatedValues(
Object.keys(getDifferences(formData, originalData)),
@ -72,9 +111,12 @@ async function acceptPropagate({ isEqualizated }) {
url="SageTransactionTypes"
/>
<FormModel
:url-update="`Clients/${route.params.id}/updateFiscalData`"
:has-confirm-modal="true"
ref="formModelRef"
auto-load
model="Customer"
:save-fn="formCustomFn"
prevent-submit
:mapper="onBeforeSave"
observe-form-changes
@on-data-saved="checkEtChanges"
@ -101,7 +143,6 @@ async function acceptPropagate({ isEqualizated }) {
<VnRow>
<VnInput :label="t('Street')" clearable v-model="data.street" required />
</VnRow>
<VnRow>
<VnSelect
:label="t('Sage tax type')"
@ -112,6 +153,7 @@ async function acceptPropagate({ isEqualizated }) {
v-model="data.sageTaxTypeFk"
data-cy="sageTaxTypeFk"
:required="data.isTaxDataChecked"
@update:model-value="hasChangedTaxData = true"
/>
<VnSelect
:label="t('Sage transaction type')"
@ -122,6 +164,7 @@ async function acceptPropagate({ isEqualizated }) {
data-cy="sageTransactionTypeFk"
v-model="data.sageTransactionTypeFk"
:required="data.isTaxDataChecked"
@update:model-value="hasChangedTaxData = true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
@ -183,6 +226,7 @@ async function acceptPropagate({ isEqualizated }) {
/><QCheckbox
:label="t('Verified data')"
v-model="data.isTaxDataChecked"
@update:model-value="hasChangedTaxData = true"
/>
</VnRow>
</template>
@ -191,6 +235,9 @@ async function acceptPropagate({ isEqualizated }) {
<i18n>
es:
Found a client with this data: Se ha encontrado un cliente con estos datos
foundClient_before: El cliente con id
foundClient_after: ya tiene este teléfono o email. ¿Quieres continuar?
Social name: Razón social
Tax number: NIF / CIF
Street: Dirección fiscal
@ -217,6 +264,9 @@ es:
You changed the equalization tax: Has cambiado el recargo de equivalencia
Do you want to spread the change?: ¿Deseas propagar el cambio a sus consignatarios?
en:
Found a client with this data: A client with this data has been found
foundClient_before: The client with id
foundClient_after: already has this phone or email. ¿Do you want to continue?
onlyLetters: Only letters, numbers and spaces can be used
whenActivatingIt: When activating it, do not enter the country code in the ID field
inOrderToInvoice: In order to invoice, this field is not contulted, but the consignee's ET. When modifiying this field if the invoice by address option is not checked, the change will be automatically propagated to all addresses, otherwise the user will be asked if he wants to propagate it or not