Merge branch 'test' into warmfix_style_vnTable_card
gitea/salix-front/pipeline/pr-test This commit looks good
Details
gitea/salix-front/pipeline/pr-test This commit looks good
Details
This commit is contained in:
commit
22bedf2fc4
|
@ -97,7 +97,7 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||||
).value;
|
).value;
|
||||||
const componentIsRendered = ref(false);
|
const componentIsRendered = ref(false);
|
||||||
const arrayData = useArrayData(modelValue);
|
const arrayData = useArrayData(modelValue);
|
||||||
|
@ -136,7 +136,8 @@ onMounted(async () => {
|
||||||
|
|
||||||
if (!$props.formInitialData) {
|
if (!$props.formInitialData) {
|
||||||
if ($props.autoLoad && $props.url) await fetch();
|
if ($props.autoLoad && $props.url) await fetch();
|
||||||
else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data);
|
else if (arrayData.store.data)
|
||||||
|
updateAndEmit('onFetch', { val: arrayData.store.data });
|
||||||
}
|
}
|
||||||
if ($props.observeFormChanges) {
|
if ($props.observeFormChanges) {
|
||||||
watch(
|
watch(
|
||||||
|
@ -148,7 +149,7 @@ onMounted(async () => {
|
||||||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
||||||
isResetting.value = false;
|
isResetting.value = false;
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -156,7 +157,7 @@ onMounted(async () => {
|
||||||
if (!$props.url)
|
if (!$props.url)
|
||||||
watch(
|
watch(
|
||||||
() => arrayData.store.data,
|
() => arrayData.store.data,
|
||||||
(val) => updateAndEmit('onFetch', val)
|
(val) => updateAndEmit('onFetch', { val }),
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -165,7 +166,7 @@ watch(
|
||||||
originalData.value = null;
|
originalData.value = null;
|
||||||
reset();
|
reset();
|
||||||
await fetch();
|
await fetch();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
onBeforeRouteLeave((to, from, next) => {
|
||||||
|
@ -194,7 +195,7 @@ async function fetch() {
|
||||||
});
|
});
|
||||||
if (Array.isArray(data)) data = data[0] ?? {};
|
if (Array.isArray(data)) data = data[0] ?? {};
|
||||||
|
|
||||||
updateAndEmit('onFetch', data);
|
updateAndEmit('onFetch', { val: data });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state.set(modelValue, {});
|
state.set(modelValue, {});
|
||||||
originalData.value = {};
|
originalData.value = {};
|
||||||
|
@ -222,7 +223,11 @@ async function save() {
|
||||||
|
|
||||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||||
|
|
||||||
updateAndEmit('onDataSaved', formData.value, response?.data);
|
updateAndEmit('onDataSaved', {
|
||||||
|
val: formData.value,
|
||||||
|
res: response?.data,
|
||||||
|
old: originalData.value,
|
||||||
|
});
|
||||||
if ($props.reload) await arrayData.fetch({});
|
if ($props.reload) await arrayData.fetch({});
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -236,7 +241,7 @@ async function saveAndGo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
updateAndEmit('onFetch', originalData.value);
|
updateAndEmit('onFetch', { val: originalData.value });
|
||||||
if ($props.observeFormChanges) {
|
if ($props.observeFormChanges) {
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
isResetting.value = true;
|
isResetting.value = true;
|
||||||
|
@ -254,16 +259,16 @@ function filter(value, update, filterOptions) {
|
||||||
(ref) => {
|
(ref) => {
|
||||||
ref.setOptionIndex(-1);
|
ref.setOptionIndex(-1);
|
||||||
ref.moveOptionSelection(1, true);
|
ref.moveOptionSelection(1, true);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAndEmit(evt, val, res) {
|
function updateAndEmit(evt, { val, res, old } = { val: null, res: null, old: null }) {
|
||||||
state.set(modelValue, val);
|
state.set(modelValue, val);
|
||||||
originalData.value = val && JSON.parse(JSON.stringify(val));
|
originalData.value = val && JSON.parse(JSON.stringify(val));
|
||||||
if (!$props.url) arrayData.store.data = val;
|
if (!$props.url) arrayData.store.data = val;
|
||||||
|
|
||||||
emit(evt, state.get(modelValue), res);
|
emit(evt, state.get(modelValue), res, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimData(data) {
|
function trimData(data) {
|
||||||
|
|
|
@ -49,12 +49,22 @@ onBeforeMount(async () => {
|
||||||
|
|
||||||
if (props.baseUrl) {
|
if (props.baseUrl) {
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
|
if (hasRouteParam(to.params)) {
|
||||||
|
const { matched } = router.currentRoute.value;
|
||||||
|
const { name } = matched.at(-3);
|
||||||
|
if (name) {
|
||||||
|
router.push({ name, params: to.params });
|
||||||
|
}
|
||||||
|
}
|
||||||
if (to.params.id !== from.params.id) {
|
if (to.params.id !== from.params.id) {
|
||||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function hasRouteParam(params, valueToCheck = ':addressId') {
|
||||||
|
return Object.values(params).includes(valueToCheck);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
||||||
|
|
|
@ -85,6 +85,7 @@ const handleModelValue = (data) => {
|
||||||
:tooltip="t('Create new location')"
|
:tooltip="t('Create new location')"
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewPostcode
|
<CreateNewPostcode
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
import { useRequired } from '../useRequired';
|
||||||
|
|
||||||
|
vi.mock('../useValidator', () => ({
|
||||||
|
useValidator: () => ({
|
||||||
|
validations: () => ({
|
||||||
|
required: vi.fn((isRequired, val) => {
|
||||||
|
if (!isRequired) return true;
|
||||||
|
return val !== null && val !== undefined && val !== '';
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('useRequired', () => {
|
||||||
|
it('should detect required when attr is boolean true', () => {
|
||||||
|
const attrs = { required: true };
|
||||||
|
const { isRequired } = useRequired(attrs);
|
||||||
|
expect(isRequired).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect required when attr is boolean false', () => {
|
||||||
|
const attrs = { required: false };
|
||||||
|
const { isRequired } = useRequired(attrs);
|
||||||
|
expect(isRequired).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect required when attr exists without value', () => {
|
||||||
|
const attrs = { required: '' };
|
||||||
|
const { isRequired } = useRequired(attrs);
|
||||||
|
expect(isRequired).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false when required attr does not exist', () => {
|
||||||
|
const attrs = { someOtherAttr: 'value' };
|
||||||
|
const { isRequired } = useRequired(attrs);
|
||||||
|
expect(isRequired).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('requiredFieldRule', () => {
|
||||||
|
it('should validate required field with value', () => {
|
||||||
|
const attrs = { required: true };
|
||||||
|
const { requiredFieldRule } = useRequired(attrs);
|
||||||
|
expect(requiredFieldRule('some value')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate required field with empty value', () => {
|
||||||
|
const attrs = { required: true };
|
||||||
|
const { requiredFieldRule } = useRequired(attrs);
|
||||||
|
expect(requiredFieldRule('')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation when field is not required', () => {
|
||||||
|
const attrs = { required: false };
|
||||||
|
const { requiredFieldRule } = useRequired(attrs);
|
||||||
|
expect(requiredFieldRule('')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle null and undefined values', () => {
|
||||||
|
const attrs = { required: true };
|
||||||
|
const { requiredFieldRule } = useRequired(attrs);
|
||||||
|
expect(requiredFieldRule(null)).toBe(false);
|
||||||
|
expect(requiredFieldRule(undefined)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -2,14 +2,10 @@ import { useValidator } from 'src/composables/useValidator';
|
||||||
|
|
||||||
export function useRequired($attrs) {
|
export function useRequired($attrs) {
|
||||||
const { validations } = useValidator();
|
const { validations } = useValidator();
|
||||||
const hasRequired = Object.keys($attrs).includes('required');
|
const isRequired =
|
||||||
let isRequired = false;
|
typeof $attrs['required'] === 'boolean'
|
||||||
if (hasRequired) {
|
? $attrs['required']
|
||||||
const required = $attrs['required'];
|
: Object.keys($attrs).includes('required');
|
||||||
if (typeof required === 'boolean') {
|
|
||||||
isRequired = required;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
const requiredFieldRule = (val) => validations().required(isRequired, val);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
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 FetchData from 'components/FetchData.vue';
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
@ -10,9 +13,12 @@ import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnLocation from 'src/components/common/VnLocation.vue';
|
import VnLocation from 'src/components/common/VnLocation.vue';
|
||||||
import { getDifferences, getUpdatedValues } from 'src/filters';
|
import { getDifferences, getUpdatedValues } from 'src/filters';
|
||||||
|
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||||
|
|
||||||
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const typesTaxes = ref([]);
|
const typesTaxes = ref([]);
|
||||||
const typesTransactions = ref([]);
|
const typesTransactions = ref([]);
|
||||||
|
@ -30,6 +36,31 @@ function onBeforeSave(formData, originalData) {
|
||||||
formData,
|
formData,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkEtChanges(data, _, originalData) {
|
||||||
|
const equalizatedHasChanged = originalData.isEqualizated != data.isEqualizated;
|
||||||
|
const hasToInvoiceByAddress =
|
||||||
|
originalData.hasToInvoiceByAddress || data.hasToInvoiceByAddress;
|
||||||
|
if (equalizatedHasChanged && hasToInvoiceByAddress) {
|
||||||
|
quasar.dialog({
|
||||||
|
component: VnConfirm,
|
||||||
|
componentProps: {
|
||||||
|
title: t('You changed the equalization tax'),
|
||||||
|
message: t('Do you want to spread the change?'),
|
||||||
|
promise: () => acceptPropagate(data),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if (equalizatedHasChanged) {
|
||||||
|
await acceptPropagate(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function acceptPropagate({ isEqualizated }) {
|
||||||
|
await axios.patch(`Clients/${route.params.id}/addressesPropagateRe`, {
|
||||||
|
isEqualizated,
|
||||||
|
});
|
||||||
|
notify(t('Equivalent tax spreaded'), 'warning');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -44,6 +75,8 @@ function onBeforeSave(formData, originalData) {
|
||||||
auto-load
|
auto-load
|
||||||
model="customer"
|
model="customer"
|
||||||
:mapper="onBeforeSave"
|
:mapper="onBeforeSave"
|
||||||
|
observe-form-changes
|
||||||
|
@on-data-saved="checkEtChanges"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
@ -188,6 +221,9 @@ es:
|
||||||
whenActivatingIt: Al activarlo, no informar el código del país en el campo nif
|
whenActivatingIt: Al activarlo, no informar el código del país en el campo nif
|
||||||
inOrderToInvoice: Para facturar no se consulta este campo, sino el RE de consignatario. Al modificar este campo si no esta marcada la casilla Facturar por consignatario, se propagará automaticamente el cambio a todos lo consignatarios, en caso contrario preguntará al usuario si quiere o no propagar
|
inOrderToInvoice: Para facturar no se consulta este campo, sino el RE de consignatario. Al modificar este campo si no esta marcada la casilla Facturar por consignatario, se propagará automaticamente el cambio a todos lo consignatarios, en caso contrario preguntará al usuario si quiere o no propagar
|
||||||
Daily invoice: Facturación diaria
|
Daily invoice: Facturación diaria
|
||||||
|
Equivalent tax spreaded: Recargo de equivalencia propagado
|
||||||
|
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:
|
en:
|
||||||
onlyLetters: Only letters, numbers and spaces can be used
|
onlyLetters: Only letters, numbers and spaces can be used
|
||||||
whenActivatingIt: When activating it, do not enter the country code in the ID field
|
whenActivatingIt: When activating it, do not enter the country code in the ID field
|
||||||
|
|
|
@ -98,7 +98,6 @@ function onAgentCreated({ id, fiscalName }, data) {
|
||||||
:rules="validate('Worker.postcode')"
|
:rules="validate('Worker.postcode')"
|
||||||
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
:acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]"
|
||||||
v-model="data.location"
|
v-model="data.location"
|
||||||
:required="true"
|
|
||||||
@update:model-value="(location) => handleLocation(data, location)"
|
@update:model-value="(location) => handleLocation(data, location)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ const getData = async (observations) => {
|
||||||
notes.value = originalNotes
|
notes.value = originalNotes
|
||||||
.map((observation) => {
|
.map((observation) => {
|
||||||
const type = observationTypes.value.find(
|
const type = observationTypes.value.find(
|
||||||
(type) => type.id === observation.observationTypeFk
|
(type) => type.id === observation.observationTypeFk,
|
||||||
);
|
);
|
||||||
return type
|
return type
|
||||||
? {
|
? {
|
||||||
|
@ -96,11 +96,11 @@ const updateObservations = async (payload) => {
|
||||||
await axios.post('AddressObservations/crud', payload);
|
await axios.post('AddressObservations/crud', payload);
|
||||||
notes.value = [];
|
notes.value = [];
|
||||||
deletes.value = [];
|
deletes.value = [];
|
||||||
toCustomerAddress();
|
|
||||||
};
|
};
|
||||||
async function updateAll({ data, payload }) {
|
async function updateAll({ data, payload }) {
|
||||||
await updateObservations(payload);
|
await updateObservations(payload);
|
||||||
await updateAddress(data);
|
await updateAddress(data);
|
||||||
|
toCustomerAddress();
|
||||||
}
|
}
|
||||||
function getPayload() {
|
function getPayload() {
|
||||||
return {
|
return {
|
||||||
|
@ -112,8 +112,8 @@ function getPayload() {
|
||||||
(oNote) =>
|
(oNote) =>
|
||||||
oNote.id === note.id &&
|
oNote.id === note.id &&
|
||||||
(note.description !== oNote.description ||
|
(note.description !== oNote.description ||
|
||||||
note.observationTypeFk !== oNote.observationTypeFk)
|
note.observationTypeFk !== oNote.observationTypeFk),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.map((note) => ({
|
.map((note) => ({
|
||||||
data: note,
|
data: note,
|
||||||
|
@ -130,24 +130,19 @@ async function handleDialog(data) {
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
title: t(
|
title: t('confirmTicket'),
|
||||||
'confirmTicket'
|
|
||||||
),
|
|
||||||
message: t('confirmDeletionMessage'),
|
message: t('confirmDeletionMessage'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
await updateAddressTicket();
|
await updateAddressTicket();
|
||||||
await updateAll(body);
|
await updateAll(body);
|
||||||
toCustomerAddress();
|
|
||||||
})
|
})
|
||||||
.onCancel(async () => {
|
.onCancel(async () => {
|
||||||
await updateAll(body);
|
await updateAll(body);
|
||||||
toCustomerAddress();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateAll(body);
|
await updateAll(body);
|
||||||
toCustomerAddress();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
import FormModel from 'src/components/FormModel.vue';
|
import FormModel from 'src/components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
@ -7,10 +9,23 @@ import VnInputTime from 'src/components/common/VnInputTime.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const validAddresses = ref([]);
|
||||||
|
const addresses = ref([]);
|
||||||
|
|
||||||
|
const setFilteredAddresses = (data) => {
|
||||||
|
const validIds = new Set(validAddresses.value.map((item) => item.addressFk));
|
||||||
|
addresses.value = data.filter((address) => validIds.has(address.id));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FormModel :url="`Zones/${$route.params.id}`" auto-load model="zone">
|
<FetchData
|
||||||
|
url="RoadmapAddresses"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (validAddresses = data)"
|
||||||
|
/>
|
||||||
|
<FetchData url="Addresses" auto-load @on-fetch="setFilteredAddresses" />
|
||||||
|
<FormModel auto-load model="zone">
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -20,13 +35,12 @@ const { t } = useI18n();
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
v-model="data.agencyModeFk"
|
v-model="data.agencyModeFk"
|
||||||
:rules="validate('zone.agencyModeFk')"
|
:rules="validate('zone.agencyModeFk')"
|
||||||
url="AgencyModes/isActive"
|
url="AgencyModes/isActive"
|
||||||
:fields="['id', 'name']"
|
:fields="['id', 'name']"
|
||||||
:label="t('Agency')"
|
:label="t('Agency')"
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
|
@ -103,7 +117,7 @@ const { t } = useI18n();
|
||||||
v-model="data.addressFk"
|
v-model="data.addressFk"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="nickname"
|
option-label="nickname"
|
||||||
url="Addresses"
|
:options="addresses"
|
||||||
:fields="['id', 'nickname']"
|
:fields="['id', 'nickname']"
|
||||||
sort-by="id"
|
sort-by="id"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
|
|
@ -22,15 +22,50 @@ const exprBuilder = (param, value) => {
|
||||||
return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } };
|
return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tableFilter = {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'agencyMode',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'address',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'nickname', 'provinceFk', 'postalCode'],
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'province',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'postcode',
|
||||||
|
scope: {
|
||||||
|
fields: ['code', 'townFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'town',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSearchbar
|
<VnSearchbar
|
||||||
data-key="ZonesList"
|
data-key="ZonesList"
|
||||||
url="Zones"
|
url="Zones"
|
||||||
:filter="{
|
:filter="tableFilter"
|
||||||
include: { relation: 'agencyMode', scope: { fields: ['name'] } },
|
|
||||||
}"
|
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
:label="t('list.searchZone')"
|
:label="t('list.searchZone')"
|
||||||
:info="t('list.searchInfo')"
|
:info="t('list.searchInfo')"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useRouter } from 'vue-router';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { toCurrency } from 'src/filters';
|
import { dashIfEmpty, toCurrency } from 'src/filters';
|
||||||
import { toTimeFormat } from 'src/filters/date';
|
import { toTimeFormat } from 'src/filters/date';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
@ -17,7 +17,6 @@ import VnInputTime from 'src/components/common/VnInputTime.vue';
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
import ZoneFilterPanel from './ZoneFilterPanel.vue';
|
import ZoneFilterPanel from './ZoneFilterPanel.vue';
|
||||||
import ZoneSearchbar from './Card/ZoneSearchbar.vue';
|
import ZoneSearchbar from './Card/ZoneSearchbar.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -26,7 +25,6 @@ const { viewSummary } = useSummaryDialog();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const warehouseOptions = ref([]);
|
const warehouseOptions = ref([]);
|
||||||
const validAddresses = ref([]);
|
|
||||||
|
|
||||||
const tableFilter = {
|
const tableFilter = {
|
||||||
include: [
|
include: [
|
||||||
|
@ -161,30 +159,18 @@ const handleClone = (id) => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('list.confirmCloneTitle'),
|
t('list.confirmCloneTitle'),
|
||||||
t('list.confirmCloneSubtitle'),
|
t('list.confirmCloneSubtitle'),
|
||||||
() => clone(id)
|
() => clone(id),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function showValidAddresses(row) {
|
function formatRow(row) {
|
||||||
if (row.addressFk) {
|
if (!row?.address) return '-';
|
||||||
const isValid = validAddresses.value.some(
|
return dashIfEmpty(`${row?.address?.nickname},
|
||||||
(address) => address.addressFk === row.addressFk
|
${row?.address?.postcode?.town?.name} (${row?.address?.province?.name})`);
|
||||||
);
|
|
||||||
if (isValid)
|
|
||||||
return `${row.address?.nickname},
|
|
||||||
${row.address?.postcode?.town?.name} (${row.address?.province?.name})`;
|
|
||||||
else return '-';
|
|
||||||
}
|
|
||||||
return '-';
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
|
||||||
url="RoadmapAddresses"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (validAddresses = data)"
|
|
||||||
/>
|
|
||||||
<ZoneSearchbar />
|
<ZoneSearchbar />
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel>
|
<template #right-panel>
|
||||||
|
@ -207,7 +193,7 @@ function showValidAddresses(row) {
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
>
|
>
|
||||||
<template #column-addressFk="{ row }">
|
<template #column-addressFk="{ row }">
|
||||||
{{ showValidAddresses(row) }}
|
{{ dashIfEmpty(formatRow(row)) }}
|
||||||
</template>
|
</template>
|
||||||
<template #more-create-dialog="{ data }">
|
<template #more-create-dialog="{ data }">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
|
|
@ -3,11 +3,46 @@ describe('Client consignee', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1110/address', {
|
cy.visit('#/customer/1107/address');
|
||||||
timeout: 5000,
|
cy.domContentLoad();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
it('Should load layout', () => {
|
it('Should load layout', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('check as equalizated', function () {
|
||||||
|
cy.get('.q-card__section > .address-card').then(($el) => {
|
||||||
|
let addressCards_before = $el.length;
|
||||||
|
|
||||||
|
cy.get('.q-page-sticky > div > .q-btn').click();
|
||||||
|
const addressName = 'test';
|
||||||
|
cy.dataCy('Consignee_input').type(addressName);
|
||||||
|
cy.dataCy('Location_select').click();
|
||||||
|
cy.get('[role="listbox"] .q-item:nth-child(1)').click();
|
||||||
|
cy.dataCy('Street address_input').type('TEST ADDRESS');
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard').click();
|
||||||
|
cy.location('href').should('contain', '#/customer/1107/address');
|
||||||
|
cy.get('.q-card__section > .address-card').should(
|
||||||
|
'have.length',
|
||||||
|
addressCards_before + 1,
|
||||||
|
);
|
||||||
|
cy.get('.q-card__section > .address-card')
|
||||||
|
.eq(addressCards_before)
|
||||||
|
.should('be.visible')
|
||||||
|
.get('.text-weight-bold')
|
||||||
|
.eq(addressCards_before - 1)
|
||||||
|
.should('contain', addressName)
|
||||||
|
.click();
|
||||||
|
});
|
||||||
|
cy.get(
|
||||||
|
'.q-card > :nth-child(1) > :nth-child(2) > .q-checkbox > .q-checkbox__inner',
|
||||||
|
)
|
||||||
|
.should('have.class', 'q-checkbox__inner--falsy')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click();
|
||||||
|
cy.get(
|
||||||
|
':nth-child(2) > :nth-child(2) > .flex > .q-mr-lg > .q-checkbox__inner',
|
||||||
|
).should('have.class', 'q-checkbox__inner--truthy');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,9 +3,8 @@ describe('Client fiscal data', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit('#/customer/1107/fiscal-data', {
|
cy.visit('#/customer/1107/fiscal-data');
|
||||||
timeout: 5000,
|
cy.domContentLoad();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
it('Should change required value when change customer', () => {
|
it('Should change required value when change customer', () => {
|
||||||
cy.get('.q-card').should('be.visible');
|
cy.get('.q-card').should('be.visible');
|
||||||
|
@ -15,4 +14,25 @@ describe('Client fiscal data', () => {
|
||||||
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
|
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
|
||||||
cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
|
cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('check as equalizated', () => {
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg',
|
||||||
|
).click();
|
||||||
|
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click();
|
||||||
|
|
||||||
|
cy.get('.q-card > :nth-child(1) > span').should(
|
||||||
|
'contain',
|
||||||
|
'You changed the equalization tax',
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.get('.q-card > :nth-child(2) > span').should(
|
||||||
|
'have.text',
|
||||||
|
'Do you want to spread the change?',
|
||||||
|
);
|
||||||
|
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
|
||||||
|
cy.get(
|
||||||
|
'.bg-warning > .q-notification__wrapper > .q-notification__content > .q-notification__message',
|
||||||
|
).should('have.text', 'Equivalent tax spreaded');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue