Merge branch 'dev' into e2e_monitor

This commit is contained in:
Javier Segarra 2025-04-14 10:16:43 +02:00
commit d1440c1083
101 changed files with 890 additions and 1027 deletions

View File

@ -332,6 +332,7 @@ watch(formUrl, async () => {
:disable="!selected?.length" :disable="!selected?.length"
:title="t('globals.remove')" :title="t('globals.remove')"
v-if="$props.defaultRemove" v-if="$props.defaultRemove"
data-cy="crudModelDefaultRemoveBtn"
/> />
<QBtn <QBtn
:label="tMobile('globals.reset')" :label="tMobile('globals.reset')"

View File

@ -1,12 +1,22 @@
<script setup> <script setup>
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import { getValueFromPath } from 'src/composables/getValueFromPath';
defineProps({ row: { type: Object, required: true } }); const { row, visibleProblems = null } = defineProps({
row: { type: Object, required: true },
visibleProblems: { type: Array },
});
function showProblem(problem) {
const val = getValueFromPath(row, problem);
if (!visibleProblems) return val;
return !!(visibleProblems?.includes(problem) && val);
}
</script> </script>
<template> <template>
<span class="q-gutter-x-xs"> <span class="q-gutter-x-xs">
<router-link <router-link
v-if="row.claim?.claimFk" v-if="showProblem('claim.claimFk')"
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }" :to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
class="link" class="link"
> >
@ -18,7 +28,7 @@ defineProps({ row: { type: Object, required: true } });
</QIcon> </QIcon>
</router-link> </router-link>
<QIcon <QIcon
v-if="row?.isDeleted" v-if="showProblem('isDeleted')"
color="primary" color="primary"
name="vn:deletedTicket" name="vn:deletedTicket"
size="xs" size="xs"
@ -29,7 +39,7 @@ defineProps({ row: { type: Object, required: true } });
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="row?.hasRisk" v-if="showProblem('hasRisk')"
name="vn:risk" name="vn:risk"
:color="row.hasHighRisk ? 'negative' : 'primary'" :color="row.hasHighRisk ? 'negative' : 'primary'"
size="xs" size="xs"
@ -40,51 +50,76 @@ defineProps({ row: { type: Object, required: true } });
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="row?.hasComponentLack" v-if="showProblem('hasComponentLack')"
name="vn:components" name="vn:components"
color="primary" color="primary"
size="xs" size="xs"
> >
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.hasItemDelay" color="primary" size="xs" name="vn:hasItemDelay"> <QIcon
v-if="showProblem('hasItemDelay')"
color="primary"
size="xs"
name="vn:hasItemDelay"
>
<QTooltip> <QTooltip>
{{ $t('ticket.summary.hasItemDelay') }} {{ $t('ticket.summary.hasItemDelay') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.hasItemLost" color="primary" size="xs" name="vn:hasItemLost"> <QIcon
v-if="showProblem('hasItemLost')"
color="primary"
size="xs"
name="vn:hasItemLost"
>
<QTooltip> <QTooltip>
{{ $t('salesTicketsTable.hasItemLost') }} {{ $t('salesTicketsTable.hasItemLost') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="row?.hasItemShortage" v-if="showProblem('hasItemShortage')"
name="vn:unavailable" name="vn:unavailable"
color="primary" color="primary"
size="xs" size="xs"
> >
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.hasRounding" color="primary" name="sync_problem" size="xs"> <QIcon
v-if="showProblem('hasRounding')"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip> <QTooltip>
{{ $t('ticketList.rounding') }} {{ $t('ticketList.rounding') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="row?.hasTicketRequest" v-if="showProblem('hasTicketRequest')"
name="vn:buyrequest" name="vn:buyrequest"
color="primary" color="primary"
size="xs" size="xs"
> >
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.isTaxDataChecked" name="vn:no036" color="primary" size="xs"> <QIcon
v-if="showProblem('isTaxDataChecked')"
name="vn:no036"
color="primary"
size="xs"
>
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs"> <QIcon v-if="showProblem('isFreezed')" name="vn:frozen" color="primary" size="xs">
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row?.isTooLittle" name="vn:isTooLittle" color="primary" size="xs"> <QIcon
v-if="showProblem('isTooLittle')"
name="vn:isTooLittle"
color="primary"
size="xs"
>
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
</QIcon> </QIcon>
</span> </span>

View File

@ -229,6 +229,7 @@ watch(
defineExpose({ defineExpose({
create: createForm, create: createForm,
showForm,
reload, reload,
redirect: redirectFn, redirect: redirectFn,
selected, selected,

View File

@ -1,57 +0,0 @@
import { createWrapper } from 'app/test/vitest/helper';
import { default as axios } from 'axios';
import EditForm from 'components/EditTableCellValueForm.vue';
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
const fieldA = 'fieldA';
const fieldB = 'fieldB';
describe('EditForm', () => {
let vm;
const mockRows = [
{ id: 1, itemFk: 101 },
{ id: 2, itemFk: 102 },
];
const mockFieldsOptions = [
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
];
const editUrl = '/api/edit';
beforeAll(() => {
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
vm = createWrapper(EditForm, {
props: {
rows: mockRows,
fieldsOptions: mockFieldsOptions,
editUrl,
},
}).vm;
});
afterEach(() => {
vi.clearAllMocks();
});
describe('onSubmit()', () => {
it('should call axios.post with the correct parameters in the payload', async () => {
const selectedField = { field: fieldA, component: 'input', attrs: {} };
const newValue = 'Test Value';
vm.selectedField = selectedField;
vm.newValue = newValue;
await vm.onSubmit();
const payload = axios.post.mock.calls[0][1];
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
expect(payload.field).toEqual(fieldA);
expect(payload.newValue).toEqual(newValue);
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
expect(vm.isLoading).toEqual(false);
});
});
});

View File

@ -1,13 +1,9 @@
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest'; import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper'; import { createWrapper } from 'app/test/vitest/helper';
import UserPanel from 'src/components/UserPanel.vue'; import UserPanel from 'src/components/UserPanel.vue';
import axios from 'axios'; import axios from 'axios';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
vi.mock('src/utils/quasarLang', () => ({
default: vi.fn(),
}));
describe('UserPanel', () => { describe('UserPanel', () => {
let wrapper; let wrapper;
let vm; let vm;
@ -43,7 +39,7 @@ describe('UserPanel', () => {
await vm.saveDarkMode(true); await vm.saveDarkMode(true);
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true }); expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
expect(vm.user.darkMode).toBe(true); expect(vm.user.darkMode).toBe(true);
await vm.updatePreferences(); vm.updatePreferences();
expect(vm.darkMode).toBe(true); expect(vm.darkMode).toBe(true);
}); });
@ -52,7 +48,7 @@ describe('UserPanel', () => {
await vm.saveLanguage(userLanguage); await vm.saveLanguage(userLanguage);
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage }); expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
expect(vm.user.lang).toBe(userLanguage); expect(vm.user.lang).toBe(userLanguage);
await vm.updatePreferences(); vm.updatePreferences();
expect(vm.locale).toBe(userLanguage); expect(vm.locale).toBe(userLanguage);
}); });
@ -60,6 +56,8 @@ describe('UserPanel', () => {
const key = 'name'; const key = 'name';
const value = 'itboss'; const value = 'itboss';
await vm.saveUserData(key, value); await vm.saveUserData(key, value);
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value }); expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', {
[key]: value,
});
}); });
}); });

View File

@ -1,4 +1,6 @@
<script setup> <script setup>
import { computed } from 'vue';
const $props = defineProps({ const $props = defineProps({
colors: { colors: {
type: String, type: String,
@ -6,9 +8,9 @@ const $props = defineProps({
}, },
}); });
const colorArray = JSON.parse($props.colors)?.value; const colorArray = computed(() => JSON.parse($props.colors)?.value);
const maxHeight = 30; const maxHeight = 30;
const colorHeight = maxHeight / colorArray?.length; const colorHeight = maxHeight / colorArray.value?.length;
</script> </script>
<template> <template>
<div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }"> <div v-if="colors" class="color-div" :style="{ height: `${maxHeight}px` }">

View File

@ -0,0 +1,44 @@
<script setup>
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const model = defineModel({ type: [Number, String] });
const emit = defineEmits(['updateBic']);
const getIbanCountry = (bank) => {
return bank.substr(0, 2);
};
const autofillBic = async (iban) => {
if (!iban) return;
const bankEntityId = parseInt(iban.substr(4, 4));
const ibanCountry = getIbanCountry(iban);
if (ibanCountry != 'ES') return;
const filter = { where: { id: bankEntityId } };
const params = { filter: JSON.stringify(filter) };
const { data } = await axios.get(`BankEntities`, { params });
emit('updateBic', data[0]?.id);
};
</script>
<template>
<VnInput
:label="t('IBAN')"
clearable
v-model="model"
@update:model-value="autofillBic($event)"
>
<template #append>
<QIcon name="info" class="cursor-info">
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip>
</QIcon>
</template>
</VnInput>
</template>

View File

@ -68,7 +68,6 @@ const filter = {
}, },
}, },
], ],
where: { and: [{ originFk: route.params.id }] },
}; };
const paginate = ref(); const paginate = ref();
@ -267,13 +266,6 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
stateStore.rightDrawer = false; stateStore.rightDrawer = false;
}); });
watch(
() => router.currentRoute.value.params.id,
() => {
applyFilter();
},
);
</script> </script>
<template> <template>
<VnPaginate <VnPaginate
@ -281,6 +273,7 @@ watch(
:data-key :data-key
:url="dataKey + 's'" :url="dataKey + 's'"
:user-filter="filter" :user-filter="filter"
:filter="{ where: { and: [{ originFk: route.params.id }] } }"
:skeleton="false" :skeleton="false"
auto-load auto-load
@on-fetch="setLogTree" @on-fetch="setLogTree"

View File

@ -39,7 +39,7 @@ const checkboxOptions = ref([
{ name: 'select', label: 'Accesses', selected: false }, { name: 'select', label: 'Accesses', selected: false },
]); ]);
const columns = computed(() => [ const columns = computed(() => [
{ name: 'changedModelValue' }, { name: 'changedModelValue', orderBy: 'id' },
{ name: 'changedModel' }, { name: 'changedModel' },
{ name: 'userType', orderBy: false }, { name: 'userType', orderBy: false },
{ name: 'userFk' }, { name: 'userFk' },

View File

@ -6,6 +6,7 @@ import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useClipboard } from 'src/composables/useClipboard'; import { useClipboard } from 'src/composables/useClipboard';
import VnMoreOptions from './VnMoreOptions.vue'; import VnMoreOptions from './VnMoreOptions.vue';
import { getValueFromPath } from 'src/composables/getValueFromPath';
const entity = defineModel({ type: Object, default: null }); const entity = defineModel({ type: Object, default: null });
const $props = defineProps({ const $props = defineProps({
@ -56,18 +57,6 @@ const routeName = computed(() => {
return `${routeName}Summary`; return `${routeName}Summary`;
}); });
function getValueFromPath(path) {
if (!path) return;
const keys = path.toString().split('.');
let current = entity.value;
for (const key of keys) {
if (current[key] === undefined) return undefined;
else current = current[key];
}
return current;
}
function copyIdText(id) { function copyIdText(id) {
copyText(id, { copyText(id, {
component: { component: {
@ -170,10 +159,10 @@ const toModule = computed(() => {
<div class="title"> <div class="title">
<span <span
v-if="title" v-if="title"
:title="getValueFromPath(title)" :title="getValueFromPath(entity, title)"
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`" :data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
> >
{{ getValueFromPath(title) ?? title }} {{ getValueFromPath(entity, title) ?? title }}
</span> </span>
<slot v-else name="description" :entity="entity"> <slot v-else name="description" :entity="entity">
<span <span
@ -189,7 +178,7 @@ const toModule = computed(() => {
class="subtitle" class="subtitle"
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`" :data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
> >
#{{ getValueFromPath(subtitle) ?? entity.id }} #{{ getValueFromPath(entity, subtitle) ?? entity.id }}
</QItemLabel> </QItemLabel>
<QBtn <QBtn
round round

View File

@ -6,6 +6,7 @@ import { computed } from 'vue';
const $props = defineProps({ const $props = defineProps({
label: { type: String, default: null }, label: { type: String, default: null },
tooltip: { type: String, default: null },
value: { value: {
type: [String, Boolean, Number], type: [String, Boolean, Number],
default: null, default: null,
@ -40,7 +41,10 @@ const val = computed(() => $props.value);
<template v-else> <template v-else>
<div v-if="label || $slots.label" class="label"> <div v-if="label || $slots.label" class="label">
<slot name="label"> <slot name="label">
<span style="color: var(--vn-label-color)">{{ label }}</span> <QTooltip v-if="tooltip">{{ tooltip }}</QTooltip>
<span style="color: var(--vn-label-color)">
{{ label }}
</span>
</slot> </slot>
</div> </div>
<div class="value" v-if="value || $slots.value"> <div class="value" v-if="value || $slots.value">

View File

@ -1,60 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const props = defineProps({
usesMana: {
type: Boolean,
required: true,
},
manaCode: {
type: String,
required: true,
},
manaVal: {
type: String,
default: 'mana',
},
manaLabel: {
type: String,
default: 'Promotion mana',
},
manaClaimVal: {
type: String,
default: 'manaClaim',
},
claimLabel: {
type: String,
default: 'Claim mana',
},
});
const manaCode = ref(props.manaCode);
</script>
<template>
<div class="column q-gutter-y-sm q-mt-sm">
<QRadio
v-model="manaCode"
dense
:val="manaVal"
:label="t(manaLabel)"
:dark="true"
class="q-mb-sm"
/>
<QRadio
v-model="manaCode"
dense
:val="manaClaimVal"
:label="t(claimLabel)"
:dark="true"
class="q-mb-sm"
/>
</div>
</template>
<i18n>
es:
Promotion mana: Maná promoción
Claim mana: Maná reclamación
</i18n>

View File

@ -0,0 +1,11 @@
export function getValueFromPath(root, path) {
if (!root || !path) return;
const keys = path.toString().split('.');
let current = root;
for (const key of keys) {
if (current[key] === undefined) return undefined;
else current = current[key];
}
return current;
}

View File

@ -0,0 +1,51 @@
import axios from 'axios';
export async function beforeSave(data, getChanges, modelOrigin) {
try {
const changes = data.updates;
if (!changes) return data;
const patchPromises = [];
for (const change of changes) {
let patchData = {};
if ('hasMinPrice' in change.data) {
patchData.hasMinPrice = change.data?.hasMinPrice;
delete change.data.hasMinPrice;
}
if ('minPrice' in change.data) {
patchData.minPrice = change.data?.minPrice;
delete change.data.minPrice;
}
if (Object.keys(patchData).length > 0) {
const promise = axios
.get(`${modelOrigin}/findOne`, {
params: {
filter: {
fields: ['itemFk'],
where: { id: change.where.id },
},
},
})
.then((row) => {
return axios.patch(`Items/${row.data.itemFk}`, patchData);
})
.catch((error) => {
console.error('Error processing change: ', change, error);
});
patchPromises.push(promise);
}
}
await Promise.all(patchPromises);
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
return data;
} catch (error) {
console.error('Error in beforeSave:', error);
throw error;
}
}

View File

@ -18,6 +18,7 @@ $positive: #c8e484;
$negative: #fb5252; $negative: #fb5252;
$info: #84d0e2; $info: #84d0e2;
$warning: #f4b974; $warning: #f4b974;
$neutral: #b0b0b0;
// Pendiente de cuadrar con la base de datos // Pendiente de cuadrar con la base de datos
$success: $positive; $success: $positive;
$alert: $negative; $alert: $negative;
@ -51,3 +52,6 @@ $width-xl: 1600px;
.bg-alert { .bg-alert {
background-color: $negative; background-color: $negative;
} }
.bg-neutral {
background-color: $neutral;
}

View File

@ -877,6 +877,11 @@ components:
active: Is active active: Is active
floramondo: Is floramondo floramondo: Is floramondo
showBadDates: Show future items showBadDates: Show future items
name: Nombre
rate2: Grouping price
rate3: Packing price
minPrice: Min. Price
itemFk: Item id
userPanel: userPanel:
copyToken: Token copied to clipboard copyToken: Token copied to clipboard
settings: Settings settings: Settings

View File

@ -961,6 +961,11 @@ components:
to: Hasta to: Hasta
floramondo: Floramondo floramondo: Floramondo
showBadDates: Ver items a futuro showBadDates: Ver items a futuro
name: Nombre
rate2: Precio grouping
rate3: Precio packing
minPrice: Precio mínimo
itemFk: Id item
userPanel: userPanel:
copyToken: Token copiado al portapapeles copyToken: Token copiado al portapapeles
settings: Configuración settings: Configuración

View File

@ -28,14 +28,8 @@ const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const STATE_COLOR = { function stateColor(entity) {
pending: 'warning', return entity?.claimState?.classColor;
incomplete: 'info',
resolved: 'positive',
canceled: 'negative',
};
function stateColor(code) {
return STATE_COLOR[code];
} }
onMounted(async () => { onMounted(async () => {
@ -57,9 +51,8 @@ onMounted(async () => {
<VnLv v-if="entity.claimState" :label="t('claim.state')"> <VnLv v-if="entity.claimState" :label="t('claim.state')">
<template #value> <template #value>
<QBadge <QBadge
:color="stateColor(entity.claimState.code)" :color="stateColor(entity)"
text-color="black" style="color: var(--vn-black-text-color)"
dense
> >
{{ entity.claimState.description }} {{ entity.claimState.description }}
</QBadge> </QBadge>

View File

@ -123,8 +123,8 @@ async function fetchMana() {
async function updateDiscount({ saleFk, discount, canceller }) { async function updateDiscount({ saleFk, discount, canceller }) {
const body = { salesIds: [saleFk], newDiscount: discount }; const body = { salesIds: [saleFk], newDiscount: discount };
const claimId = claim.value.ticketFk; const ticketFk = claim.value.ticketFk;
const query = `Tickets/${claimId}/updateDiscount`; const query = `Tickets/${ticketFk}/updateDiscount`;
await axios.post(query, body, { await axios.post(query, body, {
signal: canceller.signal, signal: canceller.signal,

View File

@ -108,15 +108,9 @@ const markerLabels = [
{ value: 5, label: t('claim.person') }, { value: 5, label: t('claim.person') },
]; ];
const STATE_COLOR = {
pending: 'warning',
incomplete: 'info',
resolved: 'positive',
canceled: 'negative',
};
function stateColor(code) { function stateColor(code) {
return STATE_COLOR[code]; const claimState = claimStates.value.find((state) => state.code === code);
return claimState?.classColor;
} }
const developmentColumns = ref([ const developmentColumns = ref([
@ -188,7 +182,7 @@ function claimUrl(section) {
<template> <template>
<FetchData <FetchData
url="ClaimStates" url="ClaimStates"
:filter="{ fields: ['id', 'description'] }" :filter="{ fields: ['id', 'description', 'code', 'classColor'] }"
@on-fetch="(data) => (claimStates = data)" @on-fetch="(data) => (claimStates = data)"
auto-load auto-load
/> />
@ -346,17 +340,18 @@ function claimUrl(section) {
<template #body="props"> <template #body="props">
<QTr :props="props"> <QTr :props="props">
<QTd v-for="col in props.cols" :key="col.name" :props="props"> <QTd v-for="col in props.cols" :key="col.name" :props="props">
<span v-if="col.name != 'description'">{{ <template v-if="col.name === 'description'">
t(col.value) <span class="link">{{
}}</span> dashIfEmpty(col.field(props.row))
<span class="link" v-if="col.name === 'description'">{{
t(col.value)
}}</span> }}</span>
<ItemDescriptorProxy <ItemDescriptorProxy
v-if="col.name == 'description'"
:id="props.row.sale.itemFk" :id="props.row.sale.itemFk"
:sale-fk="props.row.saleFk" :sale-fk="props.row.saleFk"
></ItemDescriptorProxy> />
</template>
<template v-else>
{{ dashIfEmpty(col.field(props.row)) }}
</template>
</QTd> </QTd>
</QTr> </QTr>
</template> </template>

View File

@ -101,7 +101,10 @@ const columns = computed(() => [
name: 'stateCode', name: 'stateCode',
chip: { chip: {
condition: () => true, condition: () => true,
color: ({ stateCode }) => STATE_COLOR[stateCode] ?? 'bg-grey', color: ({ stateCode }) => {
const state = states.value?.find(({ code }) => code === stateCode);
return `bg-${state.classColor}`;
},
}, },
columnFilter: { columnFilter: {
name: 'claimStateFk', name: 'claimStateFk',
@ -131,12 +134,6 @@ const columns = computed(() => [
], ],
}, },
]); ]);
const STATE_COLOR = {
pending: 'bg-warning',
loses: 'bg-negative',
resolved: 'bg-positive',
};
</script> </script>
<template> <template>

View File

@ -131,6 +131,7 @@ const columns = computed(() => [
name: 'isConciliate', name: 'isConciliate',
label: t('Conciliated'), label: t('Conciliated'),
cardVisible: true, cardVisible: true,
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',

View File

@ -9,6 +9,7 @@ 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 VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue'; import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
import VnInputBic from 'src/components/common/VnInputBic.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -17,7 +18,7 @@ const bankEntitiesRef = ref(null);
const filter = { const filter = {
fields: ['id', 'bic', 'name'], fields: ['id', 'bic', 'name'],
order: 'bic ASC' order: 'bic ASC',
}; };
const getBankEntities = (data, formData) => { const getBankEntities = (data, formData) => {
@ -43,13 +44,11 @@ const getBankEntities = (data, formData) => {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput :label="t('IBAN')" clearable v-model="data.iban"> <VnInputBic
<template #append> :label="t('IBAN')"
<QIcon name="info" class="cursor-info"> v-model="data.iban"
<QTooltip>{{ t('components.iban_tooltip') }}</QTooltip> @update-bic="(bankEntityFk) => (data.bankEntityFk = bankEntityFk)"
</QIcon> />
</template>
</VnInput>
<VnSelectDialog <VnSelectDialog
:label="t('Swift / BIC')" :label="t('Swift / BIC')"
ref="bankEntitiesRef" ref="bankEntitiesRef"

View File

@ -18,7 +18,7 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
const arrayData = useArrayData('Client'); const arrayData = useArrayData('Customer');
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const campaignList = ref(); const campaignList = ref();
@ -260,7 +260,7 @@ const updateDateParams = (value, params) => {
:label="t('globals.campaign')" :label="t('globals.campaign')"
:filled="true" :filled="true"
class="q-px-sm q-pt-none fit" class="q-px-sm q-pt-none fit"
:option-label="(opt) => t(opt.code)" :option-label="(opt) => t(opt.code ?? '')"
:fields="['id', 'code', 'dated', 'scopeDays']" :fields="['id', 'code', 'dated', 'scopeDays']"
@update:model-value="(data) => updateDateParams(data, params)" @update:model-value="(data) => updateDateParams(data, params)"
dense dense

View File

@ -34,7 +34,7 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
format: (row) => row.type.description, format: (row) => row?.type?.description,
label: t('Description'), label: t('Description'),
name: 'description', name: 'description',
}, },

View File

@ -185,7 +185,7 @@ const sumRisk = ({ clientRisks }) => {
/> />
<VnLv <VnLv
:label="t('customer.summary.payMethod')" :label="t('customer.summary.payMethod')"
:value="entity.payMethod.name" :value="entity.payMethod?.name"
/> />
<VnLv :label="t('customer.summary.bankAccount')" :value="entity.iban" /> <VnLv :label="t('customer.summary.bankAccount')" :value="entity.iban" />
<VnLv :label="t('customer.summary.dueDay')" :value="entity.dueDay" /> <VnLv :label="t('customer.summary.dueDay')" :value="entity.dueDay" />
@ -208,7 +208,8 @@ const sumRisk = ({ clientRisks }) => {
:text="t('customer.summary.consignee')" :text="t('customer.summary.consignee')"
/> />
<VnLv <VnLv
:label="t('customer.summary.addressName')" :tooltip="t('customer.summary.addressName')"
:label="t('customer.summary.addressNameAbbr')"
:value="entity.defaultAddress.nickname" :value="entity.defaultAddress.nickname"
/> />
<VnLv <VnLv
@ -252,7 +253,8 @@ const sumRisk = ({ clientRisks }) => {
/> />
<VnLv <VnLv
v-if="entity.claimsRatio" v-if="entity.claimsRatio"
:label="t('customer.summary.priceIncreasingRate')" :tooltip="t('customer.summary.priceIncreasingRate')"
:label="t('customer.summary.priceIncreasingRateAbbr')"
:value="toPercentage(priceIncreasingRate)" :value="toPercentage(priceIncreasingRate)"
/> />
<VnLv <VnLv
@ -261,7 +263,8 @@ const sumRisk = ({ clientRisks }) => {
/> />
<VnLv <VnLv
v-if="entity.claimsRatio" v-if="entity.claimsRatio"
:label="t('customer.summary.claimRate')" :label="t('customer.summary.claimRateAbbr')"
:tooltip="t('customer.summary.claimRate')"
:value="toPercentage(claimRate)" :value="toPercentage(claimRate)"
/> />
</QCard> </QCard>
@ -289,7 +292,7 @@ const sumRisk = ({ clientRisks }) => {
<VnLv <VnLv
v-if="entity.creditInsurance" v-if="entity.creditInsurance"
:label="t('customer.summary.securedCredit')" :label="t('customer.summary.securedCredit')"
:value="toCurrency(entity.creditInsurance)" :value="`${toCurrency(entity.creditInsurance)} (${entity.classifications[0]?.insurances[0]?.grade || ''})`"
:info="t('customer.summary.securedCreditInfo')" :info="t('customer.summary.securedCreditInfo')"
/> />
@ -318,8 +321,9 @@ const sumRisk = ({ clientRisks }) => {
/> />
<VnLv <VnLv
:label="t('customer.summary.recommendCredit')" :label="t('customer.summary.recommendCreditAbbr')"
:value="entity.recommendedCredit" :tooltip="t('customer.summary.recommendCredit')"
:value="toCurrency(entity.recommendedCredit)"
/> />
</QCard> </QCard>
<QCard class="vn-max"> <QCard class="vn-max">

View File

@ -111,8 +111,6 @@ const columns = computed(() => [
component: 'number', component: 'number',
}, },
columnField: { columnField: {
component: null,
after: {
component: markRaw(VnLinkPhone), component: markRaw(VnLinkPhone),
attrs: ({ model }) => { attrs: ({ model }) => {
return { return {
@ -121,7 +119,6 @@ const columns = computed(() => [
}, },
}, },
}, },
},
{ {
align: 'left', align: 'left',
name: 'mobile', name: 'mobile',

View File

@ -42,14 +42,17 @@ customer:
hasCoreVnl: Has core VNL hasCoreVnl: Has core VNL
hasB2BVnl: Has B2B VNL hasB2BVnl: Has B2B VNL
addressName: Address name addressName: Address name
addressNameAbbr: A. Name
addressCity: City addressCity: City
username: Username username: Username
webAccess: Web access webAccess: Web access
totalGreuge: Total greuge totalGreuge: Total greuge
mana: Mana mana: Mana
priceIncreasingRate: Price increasing rate priceIncreasingRate: Price increasing rate
priceIncreasingRateAbbr: Price inc. rate
averageInvoiced: Average invoiced averageInvoiced: Average invoiced
claimRate: Claming rate claimRate: Claming rate
claimRateAbbr: Claim. rate
payMethodFk: Billing data payMethodFk: Billing data
risk: Risk risk: Risk
maximumRisk: Solunion's maximum risk maximumRisk: Solunion's maximum risk
@ -68,6 +71,7 @@ customer:
descriptorInfo: Invoices minus payments plus orders not yet descriptorInfo: Invoices minus payments plus orders not yet
rating: Rating rating: Rating
recommendCredit: Recommended credit recommendCredit: Recommended credit
recommendCreditAbbr: Rec. credit
goToLines: Go to lines goToLines: Go to lines
basicData: basicData:
socialName: Fiscal name socialName: Fiscal name

View File

@ -42,14 +42,17 @@ customer:
hasCoreVnl: Recibido core VNL hasCoreVnl: Recibido core VNL
hasB2BVnl: Recibido B2B VNL hasB2BVnl: Recibido B2B VNL
addressName: Nombre de la dirección addressName: Nombre de la dirección
addressNameAbbr: N. Dirección
addressCity: Ciudad addressCity: Ciudad
username: Usuario username: Usuario
webAccess: Acceso web webAccess: Acceso web
totalGreuge: Greuge total totalGreuge: Greuge total
mana: Maná mana: Maná
priceIncreasingRate: Ratio de incremento de precio priceIncreasingRate: Ratio de incremento de precio
priceIncreasingRateAbbr: R. Inc. Precio
averageInvoiced: Facturación media averageInvoiced: Facturación media
claimRate: Ratio de reclamaciones claimRate: Ratio de reclamaciones
claimRateAbbr: R. Reclamaciones
maximumRisk: Riesgo máximo asumido por Solunion maximumRisk: Riesgo máximo asumido por Solunion
payMethodFk: Forma de pago payMethodFk: Forma de pago
risk: Riesgo risk: Riesgo
@ -68,6 +71,7 @@ customer:
descriptorInfo: Facturas menos recibos mas pedidos sin facturar descriptorInfo: Facturas menos recibos mas pedidos sin facturar
rating: Clasificación rating: Clasificación
recommendCredit: Crédito recomendado recommendCredit: Crédito recomendado
recommendCreditAbbr: Cr. Recomendado
goToLines: Ir a líneas goToLines: Ir a líneas
basicData: basicData:
socialName: Nombre fiscal socialName: Nombre fiscal

View File

@ -19,6 +19,7 @@ import { checkEntryLock } from 'src/composables/checkEntryLock';
import VnRow from 'src/components/ui/VnRow.vue'; import VnRow from 'src/components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import { beforeSave } from 'src/composables/updateMinPriceBeforeSave';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -415,56 +416,6 @@ function getAmountStyle(row) {
return { color: 'var(--vn-label-color)' }; return { color: 'var(--vn-label-color)' };
} }
async function beforeSave(data, getChanges) {
try {
const changes = data.updates;
if (!changes) return data;
const patchPromises = [];
for (const change of changes) {
let patchData = {};
if ('hasMinPrice' in change.data) {
patchData.hasMinPrice = change.data?.hasMinPrice;
delete change.data.hasMinPrice;
}
if ('minPrice' in change.data) {
patchData.minPrice = change.data?.minPrice;
delete change.data.minPrice;
}
if (Object.keys(patchData).length > 0) {
const promise = axios
.get('Buys/findOne', {
params: {
filter: {
fields: ['itemFk'],
where: { id: change.where.id },
},
},
})
.then((buy) => {
return axios.patch(`Items/${buy.data.itemFk}`, patchData);
})
.catch((error) => {
console.error('Error processing change: ', change, error);
});
patchPromises.push(promise);
}
}
await Promise.all(patchPromises);
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
return data;
} catch (error) {
console.error('Error in beforeSave:', error);
throw error;
}
}
function invertQuantitySign(rows, sign) { function invertQuantitySign(rows, sign) {
for (const row of rows) { for (const row of rows) {
if (sign > 0) row.quantity = Math.abs(row.quantity); if (sign > 0) row.quantity = Math.abs(row.quantity);
@ -697,7 +648,7 @@ onMounted(() => {
:right-search="false" :right-search="false"
:row-click="false" :row-click="false"
:columns="columns" :columns="columns"
:beforeSaveFn="beforeSave" :beforeSaveFn="(data, getChanges) => beforeSave(data, getChanges, 'Buys')"
class="buyList" class="buyList"
:table-height="$props.tableHeight ?? '84vh'" :table-height="$props.tableHeight ?? '84vh'"
auto-load auto-load

View File

@ -1,574 +1,386 @@
<script setup> <script setup>
import { onMounted, ref, onUnmounted, nextTick, computed } from 'vue'; import { onMounted, ref, onUnmounted, computed, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
import { useQuasar } from 'quasar';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import { tMobile } from 'src/composables/tMobile';
import VnConfirm from 'components/ui/VnConfirm.vue';
import FetchData from 'src/components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import { beforeSave } from 'src/composables/updateMinPriceBeforeSave';
import { isLower, isBigger } from 'src/filters/date.js';
import FetchedTags from 'components/ui/FetchedTags.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import EditFixedPriceForm from 'src/pages/Item/components/EditFixedPriceForm.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import { QCheckbox } from 'quasar'; import VnColor from 'src/components/common/VnColor.vue';
import { toDate } from 'src/filters';
import { isLower, isBigger } from 'src/filters/date.js';
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import { toCurrency } from 'src/filters';
const quasar = useQuasar();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
const state = useState();
const { notify } = useNotify();
const tableRef = ref(); const tableRef = ref();
const editTableCellDialogRef = ref(null); const editFixedPriceForm = ref(null);
const user = state.getUser(); const selectedRows = ref([]);
const fixedPrices = ref([]); const hasSelectedRows = computed(() => selectedRows.value.length > 0);
const warehousesOptions = ref([]); const isToClone = ref(false);
const hasSelectedRows = computed(() => rowsSelected.value.length > 0); const dateColor = 'var(--vn-label-text-color)';
const rowsSelected = ref([]); const state = useState();
const itemFixedPriceFilterRef = ref(); const user = state.getUser().fn();
const warehouse = computed(() => user.warehouseFk);
onMounted(async () => { onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
}); });
onUnmounted(() => (stateStore.rightDrawer = false)); onUnmounted(() => (stateStore.rightDrawer = false));
const defaultColumnAttrs = {
align: 'left',
sortable: true,
};
const columns = computed(() => [ const columns = computed(() => [
{ {
label: t('item.fixedPrice.itemFk'),
name: 'itemFk', name: 'itemFk',
...defaultColumnAttrs, label: t('item.fixedPrice.itemFk'),
isId: true, labelAbbreviation: 'Id',
columnField: { toolTip: t('item.fixedPrice.itemFk'),
component: 'input', component: 'input',
type: 'number',
},
columnClass: 'shrink',
},
{
label: t('globals.name'),
name: 'name',
...defaultColumnAttrs,
create: true,
columnFilter: { columnFilter: {
component: 'select',
attrs: { attrs: {
component: 'select',
url: 'Items', url: 'Items',
fields: ['id', 'name', 'subName'], fields: ['id', 'name', 'subName'],
optionLabel: 'name', optionLabel: 'name',
optionValue: 'name', optionValue: 'id',
uppercase: false, uppercase: false,
}, },
inWhere: true,
}, },
width: '55px',
isEditable: false,
},
{
labelAbbreviation: '',
name: 'hex',
columnSearch: false,
isEditable: false,
width: '9px',
component: 'select',
attrs: {
url: 'Inks',
fields: ['id', 'name'],
},
},
{
align: 'left',
label: t('globals.name'),
name: 'name',
create: true,
component: 'input',
isEditable: false,
}, },
{ {
label: t('item.fixedPrice.groupingPrice'), label: t('item.fixedPrice.groupingPrice'),
labelAbbreviation: 'P. Group',
toolTip: t('item.fixedPrice.groupingPrice'),
name: 'rate2', name: 'rate2',
...defaultColumnAttrs, component: 'number',
component: 'input', create: true,
type: 'number', createOrder: 3,
createAttrs: {
required: true,
},
width: '50px',
format: (row) => toCurrency(row.rate2),
}, },
{ {
label: t('item.fixedPrice.packingPrice'), label: t('item.fixedPrice.packingPrice'),
labelAbbreviation: 'P. Pack',
toolTip: t('item.fixedPrice.packingPrice'),
name: 'rate3', name: 'rate3',
...defaultColumnAttrs, component: 'number',
component: 'input', create: true,
type: 'number', createOrder: 4,
createAttrs: {
required: true,
},
width: '50px',
format: (row) => toCurrency(row.rate3),
},
{
name: 'hasMinPrice',
label: t('item.fixedPrice.hasMinPrice'),
labelAbbreviation: t('item.fixedPrice.MP'),
toolTip: t('item.fixedPrice.hasMinPrice'),
label: t('item.fixedPrice.hasMinPrice'),
component: 'checkbox',
attrs: {
toggleIndeterminate: false,
},
width: '50px',
}, },
{ {
label: t('item.fixedPrice.minPrice'), label: t('item.fixedPrice.minPrice'),
labelAbbreviation: 'Min.P',
toolTip: t('item.fixedPrice.minPrice'),
name: 'minPrice', name: 'minPrice',
...defaultColumnAttrs, component: 'number',
component: 'input', width: '50px',
type: 'number', style: (row) => {
if (!row?.hasMinPrice) return { color: 'var(--vn-label-color)' };
},
format: (row) => toCurrency(row.minPrice),
}, },
{ {
label: t('item.fixedPrice.started'), label: t('item.fixedPrice.started'),
field: 'started',
name: 'started', name: 'started',
format: ({ started }) => toDate(started),
...defaultColumnAttrs,
columnField: {
component: 'date', component: 'date',
class: 'shrink',
},
columnFilter: { columnFilter: {
component: 'date', component: 'date',
}, },
columnClass: 'expand', createAttrs: {
required: true,
},
create: true,
createOrder: 5,
width: '65px',
}, },
{ {
label: t('item.fixedPrice.ended'), label: t('item.fixedPrice.ended'),
name: 'ended', name: 'ended',
...defaultColumnAttrs,
columnField: {
component: 'date', component: 'date',
class: 'shrink',
},
columnFilter: { columnFilter: {
component: 'date', component: 'date',
}, },
columnClass: 'expand', createAttrs: {
format: (row) => toDate(row.ended), required: true,
},
create: true,
createOrder: 6,
width: '65px',
}, },
{ {
align: 'center',
label: t('globals.warehouse'), label: t('globals.warehouse'),
name: 'warehouseFk', name: 'warehouseFk',
...defaultColumnAttrs,
columnClass: 'shrink',
component: 'select',
options: warehousesOptions,
columnFilter: {
name: 'warehouseFk',
inWhere: true,
component: 'select', component: 'select',
attrs: { attrs: {
options: warehousesOptions, url: 'Warehouses',
'option-label': 'name', fields: ['id', 'name'],
'option-value': 'id', optionLabel: 'name',
}, optionValue: 'id',
}, },
create: true,
format: (row, dashIfEmpty) => dashIfEmpty(row.warehouseName),
width: '80px',
}, },
{ {
align: 'right', align: 'right',
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('delete'), title: t('globals.clone'),
icon: 'delete', icon: 'vn:clone',
action: (row) => confirmRemove(row), action: (row) => openCloneFixedPriceForm(row),
isPrimary: true, isPrimary: true,
}, },
], ],
}, },
]); ]);
const editTableFieldsOptions = [ const openEditFixedPriceForm = () => {
{ editFixedPriceForm.value.show();
field: 'rate2',
label: t('item.fixedPrice.groupingPrice'),
component: 'input',
attrs: {
type: 'number',
},
},
{
field: 'rate3',
label: t('item.fixedPrice.packingPrice'),
component: 'input',
attrs: {
type: 'number',
},
},
{
field: 'minPrice',
label: t('item.fixedPrice.minPrice'),
component: 'input',
attrs: {
type: 'number',
},
},
{
field: 'started',
label: t('item.fixedPrice.started'),
component: 'date',
},
{
field: 'ended',
label: t('item.fixedPrice.ended'),
component: 'date',
},
{
field: 'warehouseFk',
label: t('globals.warehouse'),
component: 'select',
attrs: {
options: [],
'option-label': 'name',
'option-value': 'id',
},
},
];
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
return inputType === 'text'
? {
'keyup.enter': () => upsertPrice(props, resetMinPrice),
blur: () => upsertPrice(props, resetMinPrice),
}
: { 'update:modelValue': () => upsertPrice(props, resetMinPrice) };
}; };
const updateMinPrice = async (value, props) => { const openCloneFixedPriceForm = (row) => {
props.row.hasMinPrice = value; tableRef.value.showForm = true;
await upsertPrice({ isToClone.value = true;
row: props.row, tableRef.value.create.title = t('Clone fixed price');
col: { field: 'hasMinPrice' }, tableRef.value.create.formInitialData = (({
rowIndex: props.rowIndex, itemFk,
}); rate2,
rate3,
started,
ended,
warehouseFk,
}) => ({
itemFk,
rate2,
rate3,
started,
ended,
warehouseFk,
}))(JSON.parse(JSON.stringify(row)));
}; };
const validations = ({ row }) => {
const requiredFields = [
'itemFk',
'started',
'ended',
'rate2',
'rate3',
'warehouseFk',
];
const isValid = requiredFields.every(
(field) => row[field] !== null && row[field] !== undefined
);
return isValid;
};
const upsertPrice = async (props, resetMinPrice = false) => {
const isValid = validations({ ...props });
if (!isValid) {
return;
}
const { row } = props;
const changes = tableRef.value.CrudModelRef.getChanges();
if (changes?.updates?.length > 0) {
if (resetMinPrice) row.hasMinPrice = 0;
}
if (!changes.updates && !changes.creates) return;
const data = await upsertFixedPrice(row);
Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data);
notify(t('globals.dataSaved'), 'positive');
tableRef.value.reload();
};
async function upsertFixedPrice(row) {
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
data.hasMinPrice = data.hasMinPrice ? 1 : 0;
return data;
}
function checkLastVisibleRow() {
let lastVisibleRow = null;
getTableRows().forEach((row, index) => {
const rect = row.getBoundingClientRect();
if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
lastVisibleRow = index;
}
});
return lastVisibleRow;
}
const addRow = (original = null) => {
let copy = null;
const today = Date.vnNew();
const millisecsInDay = 86400000;
const daysInWeek = 7;
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
copy = {
id: 0,
started: today,
ended: nextWeek,
hasMinPrice: 0,
$index: 0,
};
return { original, copy };
};
const getTableRows = () =>
document.getElementsByClassName('q-table')[0].querySelectorAll('tr.cursor-pointer');
function highlightNewRow({ $index: index }) {
const row = getTableRows()[index];
if (row) {
row.classList.add('highlight');
setTimeout(() => {
row.classList.remove('highlight');
}, 3000);
}
}
const openEditTableCellDialog = () => {
editTableCellDialogRef.value.show();
};
const onEditCellDataSaved = async () => {
rowsSelected.value = [];
tableRef.value.reload();
};
const removeFuturePrice = async () => {
rowsSelected.value.forEach(({ id }) => {
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
removePrice(id, rowIndex);
});
};
function confirmRemove(item, isFuture) {
const promise = async () =>
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
quasar.dialog({
component: VnConfirm,
componentProps: {
title: t('globals.rowWillBeRemoved'),
message: t('globals.confirmDeletion'),
promise,
},
});
}
const removePrice = async (id) => {
await axios.delete(`FixedPrices/${id}`);
notify(t('globals.dataSaved'), 'positive');
tableRef.value.reload({});
};
const dateStyle = (date) => const dateStyle = (date) =>
date date
? { ? {
'bg-color': 'warning', color: 'var(--vn-black-text-color)',
'is-outlined': true,
} }
: {}; : { color: dateColor, 'background-color': 'transparent' };
function handleOnDataSave({ CrudModelRef }) { const onDataSaved = () => {
const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]); tableRef.value.CrudModelRef.saveChanges();
if (original) { selectedRows.value = [];
CrudModelRef.formData.splice(original?.$index ?? 0, 0, copy); };
} else {
CrudModelRef.insert(copy); onMounted(() => {
if (tableRef.value) {
tableRef.value.showForm = false;
} }
nextTick(() => {
highlightNewRow(original ?? { $index: 0 });
}); });
watch(
() => tableRef.value?.showForm,
(newVal) => {
if (!newVal) {
tableRef.value.create.title = '';
tableRef.value.create.formInitialData = { warehouseFk: warehouse };
if (tableRef.value) {
isToClone.value = false;
tableRef.value.create.title = t('Create fixed price');
} }
}
},
);
</script> </script>
<template> <template>
<FetchData
@on-fetch="(data) => (warehousesOptions = data)"
auto-load
url="Warehouses"
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
/>
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<ItemFixedPriceFilter <ItemFixedPriceFilter data-key="ItemFixedPrices" />
data-key="ItemFixedPrices"
ref="itemFixedPriceFilterRef"
/>
</template> </template>
</RightMenu> </RightMenu>
<VnSubToolbar> <VnSubToolbar />
<template #st-actions> <Teleport to="#st-data" v-if="stateStore?.isSubToolbarShown()">
<QBtnGroup push style="column-gap: 10px">
<QBtn <QBtn
:disable="!hasSelectedRows" :disable="!hasSelectedRows"
@click="openEditTableCellDialog()" @click="openEditFixedPriceForm()"
color="primary" color="primary"
icon="edit" icon="edit"
flat
:label="t('globals.edit')"
data-cy="FixedPriceToolbarEditBtn"
> >
<QTooltip> <QTooltip>
{{ t('Edit fixed price(s)') }} {{ t('Edit fixed price(s)') }}
</QTooltip> </QTooltip>
</QBtn> </QBtn>
<QBtn </QBtnGroup>
:disable="!hasSelectedRows" </Teleport>
:label="tMobile('globals.remove')"
color="primary"
icon="delete"
flat
@click="(row) => confirmRemove(row, true)"
:title="t('globals.remove')"
/>
</template>
</VnSubToolbar>
<VnTable <VnTable
:default-remove="false" ref="tableRef"
:default-reset="false"
:default-save="false"
data-key="ItemFixedPrices" data-key="ItemFixedPrices"
url="FixedPrices/filter" url="FixedPrices/filter"
:order="['name DESC', 'itemFk DESC']" :order="'name DESC'"
save-url="FixedPrices/crud" save-url="FixedPrices/crud"
ref="tableRef"
dense
:filter="{
where: {
warehouseFk: user.warehouseFk,
},
}"
:columns="columns" :columns="columns"
default-mode="table"
auto-load
:is-editable="true" :is-editable="true"
:right-search="false" :right-search="false"
:table="{ :table="{
'row-key': 'id', 'row-key': 'id',
selection: 'multiple', selection: 'multiple',
}" }"
v-model:selected="rowsSelected" v-model:selected="selectedRows"
:create-as-dialog="false"
:create="{ :create="{
onDataSaved: handleOnDataSave, urlCreate: 'FixedPrices',
title: t('Create fixed price'),
formInitialData: { warehouseFk: warehouse },
onDataSaved: () => tableRef.reload(),
showSaveAndContinueBtn: true,
}" }"
:disable-option="{ card: true }" :disable-option="{ card: true }"
:has-sub-toolbar="false" auto-load
:beforeSaveFn="(data, getChanges) => beforeSave(data, getChanges, 'FixedPrices')"
> >
<template #header-selection="scope"> <template #column-hex="{ row }">
<QCheckbox v-model="scope.selected" /> <VnColor :colors="row?.hexJson" style="height: 100%; min-width: 2000px" />
</template> </template>
<template #body-selection="scope"> <template #column-name="{ row }">
{{ scope }} <span class="link">
<QCheckbox flat v-model="scope.selected" /> {{ row.name }}
<ItemDescriptorProxy :id="row.itemFk" />
</span>
<span class="subName">{{ row.subName }}</span>
<FetchedTags :item="row" :columns="6" />
</template> </template>
<template #column-started="{ row }">
<template #column-itemFk="props"> <div class="editable-text q-pb-xxs">
<QBadge class="badge" :style="dateStyle(isLower(row?.ended))">
{{ toDate(row?.started) }}
</QBadge>
</div>
</template>
<template #column-ended="{ row }">
<div class="editable-text q-pb-xxs">
<QBadge class="badge" :style="dateStyle(isBigger(row?.ended))">
{{ toDate(row?.ended) }}
</QBadge>
</div>
</template>
<template #column-create-name="{ data }">
<VnSelect <VnSelect
style="max-width: 100px" url="Items/search"
url="Items/withName" v-model="data.itemFk"
hide-selected :label="t('item.fixedPrice.itemName')"
option-label="id" :fields="['id', 'name']"
:filter-options="['id', 'name']"
option-label="name"
option-value="id" option-value="id"
v-model="props.row.itemFk" :required="true"
v-on="getRowUpdateInputEvents(props, true, 'select')" sort-by="name ASC"
data-cy="FixedPriceCreateNameSelect"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
<QItemSection> <QItemSection>
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel> <QItemLabel>
<QItemLabel caption>{{ scope.opt?.name }}</QItemLabel> {{ scope.opt.name }}
</QItemLabel>
<QItemLabel caption> #{{ scope.opt.id }} </QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>
</VnSelect> </VnSelect>
</template> </template>
<template #column-name="{ row }"> <template #column-create-warehouseFk="{ data }">
<span class="link">
{{ row.name }}
</span>
<span class="subName">{{ row.subName }}</span>
<ItemDescriptorProxy :id="row.itemFk" />
<FetchedTags :item="row" :columns="3" />
</template>
<template #column-rate2="props">
<QTd class="col">
<VnInput
type="currency"
style="width: 75px"
v-model.number="props.row.rate2"
v-on="getRowUpdateInputEvents(props)"
>
<template #append></template>
</VnInput>
</QTd>
</template>
<template #column-rate3="props">
<QTd class="col">
<VnInput
style="width: 75px"
type="currency"
v-model.number="props.row.rate3"
v-on="getRowUpdateInputEvents(props)"
>
<template #append></template>
</VnInput>
</QTd>
</template>
<template #column-minPrice="props">
<QTd class="col">
<div class="row" style="align-items: center">
<QCheckbox
:model-value="props.row.hasMinPrice"
@update:model-value="updateMinPrice($event, props)"
:false-value="0"
:true-value="1"
:toggle-indeterminate="false"
/>
<VnInput
class="col"
type="currency"
mask="###.##"
:disable="props.row.hasMinPrice === 0"
v-model.number="props.row.minPrice"
v-on="getRowUpdateInputEvents(props)"
>
<template #append></template>
</VnInput>
</div>
</QTd>
</template>
<template #column-started="props">
<VnInputDate
class="vnInputDate"
:show-event="true"
v-model="props.row.started"
v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind="dateStyle(isBigger(props.row.started))"
/>
</template>
<template #column-ended="props">
<VnInputDate
class="vnInputDate"
:show-event="true"
v-model="props.row.ended"
v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind="dateStyle(isLower(props.row.ended))"
/>
</template>
<template #column-warehouseFk="props">
<QTd class="col">
<VnSelect <VnSelect
style="max-width: 150px" :label="t('globals.warehouse')"
:options="warehousesOptions" url="Warehouses"
hide-selected v-model="data.warehouseFk"
:fields="['id', 'name']"
option-label="name" option-label="name"
option-value="id" option-value="id"
v-model="props.row.warehouseFk" hide-selected
v-on="getRowUpdateInputEvents(props, false, 'select')" :required="true"
/> sort-by="name ASC"
</QTd> data-cy="FixedPriceCreateWarehouseSelect"
</template>
<template #column-deleteAction="{ row, rowIndex }">
<QIcon
name="delete"
size="sm"
class="cursor-pointer fill-icon-on-hover"
color="primary"
@click.stop="
openConfirmationModal(
t('globals.rowWillBeRemoved'),
t('Do you want to clone this item?'),
() => removePrice(row.id, rowIndex)
)
"
> >
<QTooltip class="text-no-wrap"> <template #option="scope">
{{ t('globals.delete') }} <QItem v-bind="scope.itemProps">
</QTooltip> <QItemSection>
</QIcon> <QItemLabel>
{{ scope.opt.name }}
</QItemLabel>
<QItemLabel caption> #{{ scope.opt.id }} </QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</template> </template>
</VnTable> </VnTable>
<QDialog ref="editFixedPriceForm">
<QDialog ref="editTableCellDialogRef"> <EditFixedPriceForm
<EditTableCellValueForm
edit-url="FixedPrices/editFixedPrice" edit-url="FixedPrices/editFixedPrice"
:rows="rowsSelected" :rows="selectedRows"
:fields-options="editTableFieldsOptions" :fields-options="
@on-data-saved="onEditCellDataSaved()" columns.filter(
({ isEditable, component, name }) =>
isEditable !== false && component && name !== 'itemFk',
)
"
:beforeSave="beforeSave"
@on-data-saved="onDataSaved"
/> />
</QDialog> </QDialog>
</template> </template>
@ -623,8 +435,17 @@ tbody tr.highlight .q-td {
color: var(--vn-label-color); color: var(--vn-label-color);
} }
</style> </style>
<style lang="scss" scoped>
.badge {
background-color: $warning;
}
</style>
<i18n> <i18n>
es: es:
Add fixed price: Añadir precio fijado Add fixed price: Añadir precio fijado
Edit fixed price(s): Editar precio(s) fijado(s) Edit fixed price(s): Editar precio(s) fijado(s)
Create fixed price: Crear precio fijado
Clone fixed price: Clonar precio fijado
</i18n> </i18n>

View File

@ -29,6 +29,7 @@ const props = defineProps({
dense dense
filled filled
use-input use-input
:use-like="false"
@update:model-value="searchFn()" @update:model-value="searchFn()"
sort-by="nickname ASC" sort-by="nickname ASC"
/> />
@ -50,21 +51,19 @@ const props = defineProps({
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem class="q-my-md"> <QItem>
<QItemSection> <QItemSection>
<VnInputDate <VnInputDate
:label="t('params.started')"
v-model="params.started" v-model="params.started"
:label="t('params.started')"
filled filled
@update:model-value="searchFn()" @update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
</QItem>
<QItem class="q-my-md">
<QItemSection> <QItemSection>
<VnInputDate <VnInputDate
:label="t('params.ended')"
v-model="params.ended" v-model="params.ended"
:label="t('params.ended')"
filled filled
@update:model-value="searchFn()" @update:model-value="searchFn()"
/> />

View File

@ -8,11 +8,6 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import { QCheckbox } from 'quasar'; import { QCheckbox } from 'quasar';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
const emit = defineEmits(['onDataSaved']);
const $props = defineProps({ const $props = defineProps({
rows: { rows: {
type: Array, type: Array,
@ -26,10 +21,14 @@ const $props = defineProps({
type: String, type: String,
default: '', default: '',
}, },
beforeSave: {
type: Function,
default: () => {},
},
}); });
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useNotify(); const emit = defineEmits(['onDataSaved']);
const inputs = { const inputs = {
input: markRaw(VnInput), input: markRaw(VnInput),
@ -44,24 +43,13 @@ const selectedField = ref(null);
const closeButton = ref(null); const closeButton = ref(null);
const isLoading = ref(false); const isLoading = ref(false);
const onDataSaved = () => {
notify('globals.dataSaved', 'positive');
emit('onDataSaved');
closeForm();
};
const onSubmit = async () => { const onSubmit = async () => {
isLoading.value = true; isLoading.value = true;
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); $props.rows.forEach((row) => {
const payload = { row[selectedField.value.name] = newValue.value;
field: selectedField.value.field, });
newValue: newValue.value, emit('onDataSaved', $props.rows);
lines: rowsToEdit, closeForm();
};
await axios.post($props.editUrl, payload);
onDataSaved();
isLoading.value = false;
}; };
const closeForm = () => { const closeForm = () => {
@ -78,21 +66,24 @@ const closeForm = () => {
<span class="title">{{ t('Edit') }}</span> <span class="title">{{ t('Edit') }}</span>
<span class="countLines">{{ ` ${rows.length} ` }}</span> <span class="countLines">{{ ` ${rows.length} ` }}</span>
<span class="title">{{ t('buy(s)') }}</span> <span class="title">{{ t('buy(s)') }}</span>
<VnRow> <VnRow class="q-mt-md">
<VnSelect <VnSelect
class="editOption"
:label="t('Field to edit')" :label="t('Field to edit')"
:options="fieldsOptions" :options="fieldsOptions"
hide-selected hide-selected
option-label="label" option-label="label"
v-model="selectedField" v-model="selectedField"
data-cy="field-to-edit" data-cy="EditFixedPriceSelectOption"
@update:model-value="newValue = null"
:class="{ 'is-select': selectedField?.component === 'select' }"
/> />
<component <component
:is="inputs[selectedField?.component || 'input']" :is="inputs[selectedField?.component || 'input']"
v-bind="selectedField?.attrs || {}" v-bind="selectedField?.attrs || {}"
v-model="newValue" v-model="newValue"
:label="t('Value')" :label="t('Value')"
data-cy="value-to-edit" data-cy="EditFixedPriceValueOption"
style="width: 200px" style="width: 200px"
/> />
</VnRow> </VnRow>
@ -140,6 +131,15 @@ const closeForm = () => {
} }
</style> </style>
<style lang="scss">
.editOption .q-field__inner .q-field__control {
padding: 0 !important;
}
.editOption.is-select .q-field__inner .q-field__control {
padding: 0 !important;
}
</style>
<i18n> <i18n>
es: es:
Edit: Editar Edit: Editar

View File

@ -0,0 +1,46 @@
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import EditFixedPriceForm from 'src/pages/Item/components/EditFixedPriceForm.vue';
describe('EditFixedPriceForm.vue', () => {
let wrapper;
let vm;
const mockRows = [
{ id: 1, itemFk: 101 },
{ id: 2, itemFk: 102 },
];
const mockFieldsOptions = [
{
name: 'price',
label: 'Price',
component: 'input',
attrs: { type: 'number' },
},
];
beforeEach(() => {
wrapper = createWrapper(EditFixedPriceForm, {
props: {
rows: JSON.parse(JSON.stringify(mockRows)),
fieldsOptions: mockFieldsOptions,
},
});
wrapper = wrapper.wrapper;
vm = wrapper.vm;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should emit "onDataSaved" with updated rows on submit', async () => {
vm.selectedField = mockFieldsOptions[0];
vm.newValue = 199.99;
await vm.onSubmit();
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
});
});

View File

@ -167,6 +167,8 @@ item:
started: Started started: Started
ended: Ended ended: Ended
warehouse: Warehouse warehouse: Warehouse
MP: MP
itemName: Item
create: create:
name: Name name: Name
tag: Tag tag: Tag

View File

@ -173,6 +173,8 @@ item:
started: Inicio started: Inicio
ended: Fin ended: Fin
warehouse: Almacén warehouse: Almacén
MP: PM
itemName: Nombre
create: create:
name: Nombre name: Nombre
tag: Etiqueta tag: Etiqueta

View File

@ -295,13 +295,11 @@ watch(
:user-filter="lineFilter" :user-filter="lineFilter"
> >
<template #column-image="{ row }"> <template #column-image="{ row }">
<div class="image-wrapper">
<VnImg <VnImg
:id="parseInt(row?.item?.image)" :id="parseInt(row?.item?.image)"
class="rounded" class="rounded"
zoom-resolution="1600x900" zoom-resolution="1600x900"
/> />
</div>
</template> </template>
<template #column-id="{ row }"> <template #column-id="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
@ -361,12 +359,6 @@ watch(
} }
} }
.image-wrapper {
height: 50px;
width: 50px;
margin-left: 30%;
}
.header { .header {
color: $primary; color: $primary;
font-weight: bold; font-weight: bold;

View File

@ -141,7 +141,7 @@ const setOrderedPriority = async () => {
}; };
const sortRoutes = async () => { const sortRoutes = async () => {
await axios.patch(`Routes/${route.params?.id}/guessPriority/`); await axios.patch(`Routes/${route.params?.id}/optimizePriority`);
refreshKey.value++; refreshKey.value++;
}; };

View File

@ -46,7 +46,7 @@ async function getClaims() {
originalTicket.value = data[0]?.originalTicketFk; originalTicket.value = data[0]?.originalTicketFk;
} }
async function getProblems() { async function getProblems() {
const { data } = await axios.get(`Tickets/${entityId.value}/getTicketProblems`); const { data } = await axios.get(`Tickets/getTicketProblems`, {params: { ids: [entityId.value] }});
if (!data) return; if (!data) return;
problems.value = data[0]; problems.value = data[0];
} }

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import VnUsesMana from 'components/ui/VnUsesMana.vue';
const $props = defineProps({ const $props = defineProps({
newPrice: { newPrice: {
@ -15,23 +14,36 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
componentId: {
type: Number,
default: null,
},
}); });
const emit = defineEmits(['save', 'cancel', 'update:componentId']);
const route = useRoute(); const route = useRoute();
const mana = ref(null); const mana = ref(null);
const usesMana = ref(false); const usesMana = ref([]);
const emit = defineEmits(['save', 'cancel']);
const { t } = useI18n(); const { t } = useI18n();
const QPopupProxyRef = ref(null); const QPopupProxyRef = ref(null);
const manaCode = ref($props.manaCode);
const componentId = computed({
get: () => $props.componentId,
set: (val) => emit('update:componentId', val),
});
const save = (sale = $props.sale) => { const save = (sale = $props.sale) => {
emit('save', sale); emit('save', sale);
QPopupProxyRef.value.hide(); QPopupProxyRef.value.hide();
}; };
const cancel = () => {
emit('cancel');
QPopupProxyRef.value.hide();
};
const getMana = async () => { const getMana = async () => {
const { data } = await axios.get(`Tickets/${route.params.id}/getDepartmentMana`); const { data } = await axios.get(`Tickets/${route.params.id}/getDepartmentMana`);
mana.value = data; mana.value = data;
@ -39,15 +51,12 @@ const getMana = async () => {
}; };
const getUsesMana = async () => { const getUsesMana = async () => {
const { data } = await axios.get('Sales/usesMana'); const { data } = await axios.get('Sales/getComponents');
usesMana.value = data; usesMana.value = data;
}; };
const cancel = () => {
emit('cancel');
QPopupProxyRef.value.hide();
};
const hasMana = computed(() => typeof mana.value === 'number'); const hasMana = computed(() => typeof mana.value === 'number');
defineExpose({ save }); defineExpose({ save });
</script> </script>
@ -59,17 +68,29 @@ defineExpose({ save });
> >
<div class="container"> <div class="container">
<div class="header">Mana: {{ toCurrency(mana) }}</div> <div class="header">Mana: {{ toCurrency(mana) }}</div>
<QSpinner v-if="!hasMana" color="primary" size="md" />
<QSpinner v-if="!usesMana.length" color="primary" />
<div class="q-pa-md" v-else> <div class="q-pa-md" v-else>
<slot :popup="QPopupProxyRef" /> <slot :popup="QPopupProxyRef" />
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<VnUsesMana :mana-code="manaCode" /> <div v-if="usesMana.length" class="column q-gutter-y-sm q-mt-sm">
<QRadio
v-for="(item, index) in usesMana"
:key="index"
v-model="componentId"
:val="item.id"
:label="item.name"
dense
:dark="true"
class="q-mb-sm"
:data-cy="`componentOption-${item.id}`"
/>
</div> </div>
<div v-if="newPrice" class="column items-center q-mt-lg"> <div v-if="newPrice" class="column items-center q-mt-lg">
<span class="text-primary">{{ t('New price') }}</span> <span class="text-primary">{{ t('New price') }}</span>
<span class="text-subtitle1"> <span class="text-subtitle1">{{ toCurrency(newPrice) }}</span>
{{ toCurrency($props.newPrice) }}
</span>
</div> </div>
</div> </div>
@ -77,7 +98,6 @@ defineExpose({ save });
<QBtn <QBtn
color="primary" color="primary"
class="no-border-radius" class="no-border-radius"
dense
style="width: 50%" style="width: 50%"
@click="cancel()" @click="cancel()"
> >
@ -86,7 +106,6 @@ defineExpose({ save });
<QBtn <QBtn
color="primary" color="primary"
class="no-border-radius" class="no-border-radius"
dense
style="width: 50%" style="width: 50%"
@click="save()" @click="save()"
data-cy="saveManaBtn" data-cy="saveManaBtn"
@ -116,8 +135,3 @@ defineExpose({ save });
min-width: 230px; min-width: 230px;
} }
</style> </style>
<i18n>
es:
New price: Nuevo precio
</i18n>

View File

@ -38,7 +38,9 @@ function handleDelete(row) {
ticketNotesCrudRef.value.remove([row]); ticketNotesCrudRef.value.remove([row]);
} }
async function handleSave() { async function handleSave(e) {
if (e.shiftKey && e.key === 'Enter') return;
e.preventDefault();
if (!isSaving.value) { if (!isSaving.value) {
isSaving.value = true; isSaving.value = true;
await ticketNotesCrudRef.value?.saveChanges(); await ticketNotesCrudRef.value?.saveChanges();
@ -70,7 +72,7 @@ async function handleSave() {
<div <div
v-for="(row, index) in rows" v-for="(row, index) in rows"
:key="index" :key="index"
class="q-mb-md row items-center q-gutter-x-md" class="q-mb-md row q-gutter-x-md"
> >
<VnSelect <VnSelect
:label="t('ticketNotes.observationType')" :label="t('ticketNotes.observationType')"
@ -86,7 +88,8 @@ async function handleSave() {
:label="t('basicData.description')" :label="t('basicData.description')"
v-model="row.description" v-model="row.description"
class="col" class="col"
@keyup.enter="handleSave" @keydown.enter.stop="handleSave"
autogrow
data-cy="ticketNotesDescription" data-cy="ticketNotesDescription"
/> />
<QIcon <QIcon

View File

@ -45,7 +45,7 @@ const isTicketEditable = ref(false);
const sales = ref([]); const sales = ref([]);
const editableStatesOptions = ref([]); const editableStatesOptions = ref([]);
const selectedSales = ref([]); const selectedSales = ref([]);
const manaCode = ref('mana'); const componentId = ref(null);
const ticketState = computed(() => store.data?.ticketState?.state?.code); const ticketState = computed(() => store.data?.ticketState?.state?.code);
const transfer = ref({ const transfer = ref({
lastActiveTickets: [], lastActiveTickets: [],
@ -187,7 +187,7 @@ const getRowUpdateInputEvents = (sale) => {
}; };
const resetChanges = async () => { const resetChanges = async () => {
arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
tableRef.value.CrudModelRef.hasChanges = false; tableRef.value.CrudModelRef.hasChanges = false;
await tableRef.value.reload(); await tableRef.value.reload();
@ -308,14 +308,15 @@ const changePrice = async (sale) => {
if (newPrice != null && newPrice != sale.price) { if (newPrice != null && newPrice != sale.price) {
if (await isSalePrepared(sale)) { if (await isSalePrepared(sale)) {
await confirmUpdate(() => updatePrice(sale, newPrice)); await confirmUpdate(() => updatePrice(sale, newPrice));
} else updatePrice(sale, newPrice); } else await updatePrice(sale, newPrice);
} }
}; };
const updatePrice = async (sale, newPrice) => { const updatePrice = async (sale, newPrice) => {
try { try {
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice }); await axios.post(`Sales/${sale.id}/updatePrice`, {
sale.price = newPrice; newPrice: newPrice,
edit.value = { ...DEFAULT_EDIT }; componentId: componentId.value,
});
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
resetChanges(); resetChanges();
} catch (e) { } catch (e) {
@ -327,28 +328,31 @@ const changeDiscount = async (sale) => {
const newDiscount = edit.value.discount; const newDiscount = edit.value.discount;
if (newDiscount != null && newDiscount != sale.discount) { if (newDiscount != null && newDiscount != sale.discount) {
if (await isSalePrepared(sale)) if (await isSalePrepared(sale))
await confirmUpdate(() => updateDiscount([sale], newDiscount)); await confirmUpdate(() =>
else await updateDiscount([sale], newDiscount); updateDiscount([sale], newDiscount, componentId.value),
);
else await updateDiscount([sale], newDiscount, componentId.value);
} }
}; };
const updateDiscounts = async (sales, newDiscount) => { const updateDiscounts = async (sales, newDiscount, componentId) => {
const salesTracking = await fetchSalesTracking(); const salesTracking = await fetchSalesTracking();
const someSaleIsPrepared = salesTracking.some((sale) => const someSaleIsPrepared = salesTracking.some((sale) =>
matchSale(salesTracking, sale), matchSale(salesTracking, sale),
); );
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount)); if (someSaleIsPrepared)
else updateDiscount(sales, newDiscount); await confirmUpdate(() => updateDiscount(sales, newDiscount, componentId));
else updateDiscount(sales, newDiscount, componentId);
}; };
const updateDiscount = async (sales, newDiscount = 0) => { const updateDiscount = async (sales, newDiscount, componentId) => {
try { try {
const salesIds = sales.map(({ id }) => id); const salesIds = sales.map(({ id }) => id);
const params = { const params = {
salesIds, salesIds,
newDiscount, newDiscount: newDiscount ?? 0,
manaCode: manaCode.value, componentId,
}; };
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params); await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
@ -821,10 +825,11 @@ watch(
ref="editPriceProxyRef" ref="editPriceProxyRef"
:sale="row" :sale="row"
:new-price="getNewPrice" :new-price="getNewPrice"
v-model:component-id="componentId"
@save="changePrice" @save="changePrice"
> >
<VnInput <VnInput
@keyup.enter.stop="() => editManaProxyRef.save(row)" @keyup.enter.stop="() => editPriceProxyRef.save(row)"
v-model.number="edit.price" v-model.number="edit.price"
:label="t('basicData.price')" :label="t('basicData.price')"
type="number" type="number"
@ -843,7 +848,7 @@ watch(
ref="editManaProxyRef" ref="editManaProxyRef"
:sale="row" :sale="row"
:new-price="getNewPrice" :new-price="getNewPrice"
:mana-code="manaCode" v-model:component-id="componentId"
@save="changeDiscount" @save="changeDiscount"
> >
<VnInput <VnInput

View File

@ -47,6 +47,7 @@ const { notify } = useNotify();
const acl = useAcl(); const acl = useAcl();
const btnDropdownRef = ref(null); const btnDropdownRef = ref(null);
const editManaProxyRef = ref(null); const editManaProxyRef = ref(null);
const componentId = ref(null);
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const newDiscount = ref(null); const newDiscount = ref(null);
@ -112,7 +113,7 @@ const changeMultipleDiscount = () => {
}); });
if (newDiscount.value != null && hasChanges) if (newDiscount.value != null && hasChanges)
emit('updateDiscounts', props.sales, newDiscount.value); emit('updateDiscounts', props.sales, newDiscount.value, componentId.value);
btnDropdownRef.value.hide(); btnDropdownRef.value.hide();
}; };
@ -206,6 +207,7 @@ const createRefund = async (withWarehouse) => {
ref="editManaProxyRef" ref="editManaProxyRef"
:sale="row" :sale="row"
@save="changeMultipleDiscount" @save="changeMultipleDiscount"
v-model:component-id="componentId"
> >
<VnInput <VnInput
autofocus autofocus

View File

@ -241,6 +241,7 @@ onMounted(async () => {
:value="`${entity.address?.nickname} #${entity.address?.id}`" :value="`${entity.address?.nickname} #${entity.address?.id}`"
/> />
<VnLv <VnLv
class="white-space-normal"
:label="t('ticket.summary.consigneeStreet')" :label="t('ticket.summary.consigneeStreet')"
:value="formattedAddress" :value="formattedAddress"
/> />
@ -524,4 +525,7 @@ onMounted(async () => {
.grafana { .grafana {
color: $primary-light; color: $primary-light;
} }
.white-space-normal :deep(.value span) {
white-space: normal;
}
</style> </style>

View File

@ -14,6 +14,8 @@ import { useState } from 'src/composables/useState';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import { QTable } from 'quasar';
import TicketProblems from 'src/components/TicketProblems.vue';
const state = useState(); const state = useState();
const { t } = useI18n(); const { t } = useI18n();
@ -27,6 +29,16 @@ const selectedTickets = ref([]);
const vnTableRef = ref({}); const vnTableRef = ref({});
const originElRef = ref(null); const originElRef = ref(null);
const destinationElRef = ref(null); const destinationElRef = ref(null);
const actions = {
advance: {
title: t('advanceTickets.advanceTickets'),
cb: moveTicketsAdvance,
},
advanceWithoutNegative: {
title: t('advanceTickets.advanceTicketsWithoutNegatives'),
cb: splitTickets,
},
};
let today = Date.vnNew().toISOString(); let today = Date.vnNew().toISOString();
const tomorrow = new Date(today); const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
@ -78,6 +90,15 @@ const ticketColumns = computed(() => [
headerClass: 'horizontal-separator', headerClass: 'horizontal-separator',
hidden: true, hidden: true,
}, },
{
label: t('globals.agency'),
name: 'agency',
field: 'agency',
align: 'left',
sortable: true,
headerClass: 'horizontal-separator',
columnFilter: false,
},
{ {
label: t('advanceTickets.preparation'), label: t('advanceTickets.preparation'),
name: 'preparation', name: 'preparation',
@ -85,7 +106,6 @@ const ticketColumns = computed(() => [
align: 'left', align: 'left',
sortable: true, sortable: true,
headerClass: 'horizontal-separator', headerClass: 'horizontal-separator',
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
@ -110,10 +130,17 @@ const ticketColumns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
label: t('advanceTickets.futureId'), label: '',
name: 'futureId', name: 'problems',
headerClass: 'vertical-separator horizontal-separator', headerClass: 'vertical-separator horizontal-separator',
columnClass: 'vertical-separator', columnClass: 'vertical-separator',
hidden: true,
},
{
align: 'left',
label: t('advanceTickets.futureId'),
name: 'futureId',
headerClass: 'horizontal-separator',
}, },
{ {
align: 'left', align: 'left',
@ -242,7 +269,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
return { query, params }; return { query, params };
}; };
const moveTicketsAdvance = async () => { async function moveTicketsAdvance() {
let ticketsToMove = []; let ticketsToMove = [];
for (const ticket of selectedTickets.value) { for (const ticket of selectedTickets.value) {
if (!ticket.id) { if (!ticket.id) {
@ -267,7 +294,7 @@ const moveTicketsAdvance = async () => {
vnTableRef.value.reload(); vnTableRef.value.reload();
selectedTickets.value = []; selectedTickets.value = [];
if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive'); if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive');
}; }
const progressLength = ref(0); const progressLength = ref(0);
const progressPercentage = computed(() => { const progressPercentage = computed(() => {
@ -290,7 +317,7 @@ const progressAdd = () => {
} }
}; };
const splitTickets = async () => { async function splitTickets() {
try { try {
showProgressDialog.value = true; showProgressDialog.value = true;
for (const ticket of selectedTickets.value) { for (const ticket of selectedTickets.value) {
@ -310,7 +337,7 @@ const splitTickets = async () => {
} finally { } finally {
vnTableRef.value.reload(); vnTableRef.value.reload();
} }
}; }
const resetProgressData = () => { const resetProgressData = () => {
if (cancelProgress.value) cancelProgress.value = false; if (cancelProgress.value) cancelProgress.value = false;
@ -326,6 +353,32 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
const confirmAction = (action) => {
openConfirmationModal(actions[action].title, false, actions[action].cb, null, {
component: QTable,
props: {
columns: [
{
align: 'left',
label: t('advanceTickets.destination'),
name: 'id',
field: (row) => row.id,
},
{
align: 'left',
label: t('advanceTickets.origin'),
name: 'futureId',
field: (row) => row.futureId,
},
],
rows: selectedTickets.value,
class: 'full-width',
dense: true,
flat: true,
},
});
};
watch( watch(
() => vnTableRef.value.tableRef?.$el, () => vnTableRef.value.tableRef?.$el,
($el) => { ($el) => {
@ -399,15 +452,7 @@ watch(
color="primary" color="primary"
class="q-mr-sm" class="q-mr-sm"
:disable="!selectedTickets.length" :disable="!selectedTickets.length"
@click.stop=" @click.stop="confirmAction('advance')"
openConfirmationModal(
t('advanceTickets.advanceTicketTitle'),
t(`advanceTickets.advanceTitleSubtitle`, {
selectedTickets: selectedTickets.length,
}),
moveTicketsAdvance,
)
"
> >
<QTooltip> <QTooltip>
{{ t('advanceTickets.advanceTickets') }} {{ t('advanceTickets.advanceTickets') }}
@ -417,15 +462,7 @@ watch(
icon="alt_route" icon="alt_route"
color="primary" color="primary"
:disable="!selectedTickets.length" :disable="!selectedTickets.length"
@click.stop=" @click.stop="confirmAction('advanceWithoutNegative')"
openConfirmationModal(
t('advanceTickets.advanceWithoutNegativeTitle'),
t(`advanceTickets.advanceWithoutNegativeSubtitle`, {
selectedTickets: selectedTickets.length,
}),
splitTickets,
)
"
> >
<QTooltip> <QTooltip>
{{ t('advanceTickets.advanceTicketsWithoutNegatives') }} {{ t('advanceTickets.advanceTicketsWithoutNegatives') }}
@ -454,7 +491,7 @@ watch(
}" }"
v-model:selected="selectedTickets" v-model:selected="selectedTickets"
:pagination="{ rowsPerPage: 0 }" :pagination="{ rowsPerPage: 0 }"
:no-data-label="t('globals.noResults')" :no-data-label="$t('globals.noResults')"
:right-search="false" :right-search="false"
:order="['futureTotalWithVat ASC']" :order="['futureTotalWithVat ASC']"
auto-load auto-load
@ -522,6 +559,9 @@ watch(
{{ toCurrency(row.totalWithVat || 0) }} {{ toCurrency(row.totalWithVat || 0) }}
</QBadge> </QBadge>
</template> </template>
<template #column-problems="{ row }">
<TicketProblems :row="row.problems" :visible-problems="['hasRisk']" />
</template>
<template #column-futureId="{ row }"> <template #column-futureId="{ row }">
<QBtn flat class="link" dense> <QBtn flat class="link" dense>
{{ row.futureId }} {{ row.futureId }}

View File

@ -10,7 +10,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
import axios from 'axios'; import axios from 'axios';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
const { t, te } = useI18n(); const { t, te } = useI18n();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
@ -122,18 +122,20 @@ onMounted(async () => await getItemPackingTypes());
<QItemSection> <QItemSection>
<VnInputNumber <VnInputNumber
v-model="params.scopeDays" v-model="params.scopeDays"
:label="t('Days onward')" :label="t('globals.daysOnward')"
filled filled
:step="0"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<QCheckbox <VnCheckbox
:label="t('params.isFullMovable')" :label="t('params.isFullMovable')"
v-model="params.isFullMovable" v-model="params.isFullMovable"
toggle-indeterminate toggle-indeterminate
@update:model-value="searchFn()" @update:model-value="searchFn()"
dense
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -166,11 +168,12 @@ onMounted(async () => await getItemPackingTypes());
</QItem> </QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<QCheckbox <VnCheckbox
toggle-indeterminate toggle-indeterminate
label="only with destination" :label="t('params.onlyWithDestination')"
v-model="params.onlyWithDestination" v-model="params.onlyWithDestination"
@update:model-value="searchFn()" @update:model-value="searchFn()"
dense
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -194,8 +197,8 @@ es:
Vertical: Vertical Vertical: Vertical
iptInfo: Encajado iptInfo: Encajado
params: params:
dateFuture: fecha origen dateFuture: F. origen
dateToAdvance: Fecha destino dateToAdvance: F. destino
futureIpt: IPT Origen futureIpt: IPT Origen
ipt: IPT destino ipt: IPT destino
isFullMovable: 100% movible isFullMovable: 100% movible

View File

@ -273,6 +273,7 @@ en:
orderFk: Order orderFk: Order
from: From from: From
shipped: Shipped shipped: Shipped
shippedDate: Shipped date
to: To to: To
stateFk: State stateFk: State
groupedStates: Grouped State groupedStates: Grouped State
@ -300,6 +301,7 @@ es:
orderFk: Pedido orderFk: Pedido
from: Desde from: Desde
shipped: F. envío shipped: F. envío
shippedDate: F. envío
to: Hasta to: Hasta
stateFk: Estado stateFk: Estado
groupedStates: Estado agrupado groupedStates: Estado agrupado

View File

@ -113,13 +113,13 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
name: 'shippedDate', name: 'shipped',
cardVisible: true, cardVisible: true,
label: t('ticketList.shipped'), label: t('ticketList.shipped'),
columnFilter: { columnFilter: {
component: 'date', component: 'date',
}, },
format: ({ shippedDate }) => toDate(shippedDate), format: ({ shipped }) => toDate(shipped),
}, },
{ {
align: 'left', align: 'left',
@ -477,7 +477,7 @@ function setReference(data) {
prefix="card" prefix="card"
:array-data-props="{ :array-data-props="{
url: 'Tickets/filter', url: 'Tickets/filter',
order: ['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id'], order: ['shipped DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id'],
exprBuilder, exprBuilder,
}" }"
> >
@ -515,10 +515,10 @@ function setReference(data) {
<DepartmentDescriptorProxy :id="row.departmentFk" /> <DepartmentDescriptorProxy :id="row.departmentFk" />
</span> </span>
</template> </template>
<template #column-shippedDate="{ row }"> <template #column-shipped="{ row }">
<span v-if="getDateColor(row.shipped)"> <span v-if="getDateColor(row.shipped)">
<QChip :class="getDateColor(row.shipped)" dense square> <QChip :class="getDateColor(row.shipped)" dense square>
{{ toDate(row.shippedDate) }} {{ toDate(row.shipped) }}
</QChip> </QChip>
</span> </span>
</template> </template>

View File

@ -18,6 +18,8 @@ import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
import VnSection from 'src/components/common/VnSection.vue'; import VnSection from 'src/components/common/VnSection.vue';
import VnInputBic from 'src/components/common/VnInputBic.vue';
const { t } = useI18n(); const { t } = useI18n();
const tableRef = ref(); const tableRef = ref();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
@ -161,16 +163,6 @@ function generateCodeUser(worker) {
if (!worker.companyFk) worker.companyFk = user.companyFk; if (!worker.companyFk) worker.companyFk = user.companyFk;
} }
async function autofillBic(worker) {
if (!worker || !worker.iban) return;
let bankEntityId = parseInt(worker.iban.substr(4, 4));
let filter = { where: { id: bankEntityId } };
const { data } = await axios.get(`BankEntities`, { params: { filter } });
worker.bankEntityFk = data?.[0]?.id ?? undefined;
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -331,20 +323,14 @@ async function autofillBic(worker) {
(val) => !val && delete data.payMethodFk (val) => !val && delete data.payMethodFk
" "
/> />
<VnInput <VnInputBic
:label="t('IBAN')"
v-model="data.iban" v-model="data.iban"
:label="t('worker.create.iban')"
:disable="data.isFreelance" :disable="data.isFreelance"
@update:model-value="autofillBic(data)" @update-bic="
> (bankEntityFk) => (data.bankEntityFk = bankEntityFk)
<template #append> "
<QIcon name="info" class="cursor-info"> />
<QTooltip>{{
t('components.iban_tooltip')
}}</QTooltip>
</QIcon>
</template>
</VnInput>
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelectDialog <VnSelectDialog
@ -362,7 +348,6 @@ async function autofillBic(worker) {
}, },
]" ]"
:disable="data.isFreelance" :disable="data.isFreelance"
@update:model-value="autofillBic(data)"
:filter-options="['bic', 'name']" :filter-options="['bic', 'name']"
> >
<template #form> <template #form>

View File

@ -113,7 +113,7 @@ const ticketCard = {
name: 'TicketExpedition', name: 'TicketExpedition',
meta: { meta: {
title: 'expedition', title: 'expedition',
icon: 'vn:package', icon: 'view_in_ar',
}, },
component: () => import('src/pages/Ticket/Card/TicketExpedition.vue'), component: () => import('src/pages/Ticket/Card/TicketExpedition.vue'),
}, },
@ -168,7 +168,7 @@ const ticketCard = {
name: 'TicketBoxing', name: 'TicketBoxing',
meta: { meta: {
title: 'boxing', title: 'boxing',
icon: 'view_in_ar', icon: 'videocam',
}, },
component: () => import('src/pages/Ticket/Card/TicketBoxing.vue'), component: () => import('src/pages/Ticket/Card/TicketBoxing.vue'),
}, },

View File

@ -6,7 +6,6 @@ describe.skip('ClaimAction', () => {
const destinationRow = '.q-item__section > .q-field'; const destinationRow = '.q-item__section > .q-field';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/claim/${claimId}/action`); cy.visit(`/#/claim/${claimId}/action`);
}); });

View File

@ -7,7 +7,6 @@ describe.skip('ClaimDevelopment', () => {
const newReason = 'Calor'; const newReason = 'Calor';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/claim/${claimId}/development`); cy.visit(`/#/claim/${claimId}/development`);
cy.waitForElement('tbody'); cy.waitForElement('tbody');

View File

@ -2,7 +2,6 @@ import '../commands.js';
describe('EntryBasicData', () => { describe('EntryBasicData', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -1,7 +1,6 @@
import '../commands.js'; import '../commands.js';
describe('EntryDescriptor', () => { describe('EntryDescriptor', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -1,7 +1,6 @@
import '../commands.js'; import '../commands.js';
describe('EntryDms', () => { describe('EntryDms', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -1,7 +1,6 @@
import '../commands.js'; import '../commands.js';
describe('EntryLock', () => { describe('EntryLock', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -2,7 +2,6 @@ import '../commands.js';
describe('EntryNotes', () => { describe('EntryNotes', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -2,7 +2,6 @@ import './commands';
describe('EntryList', () => { describe('EntryList', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/list`); cy.visit(`/#/entry/list`);
}); });

View File

@ -1,6 +1,5 @@
describe('EntryStockBought', () => { describe('EntryStockBought', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyer'); cy.login('buyer');
cy.visit(`/#/entry/stock-Bought`); cy.visit(`/#/entry/stock-Bought`);
}); });

View File

@ -1,6 +1,5 @@
describe('EntrySupplier when is supplier', () => { describe('EntrySupplier when is supplier', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('supplier'); cy.login('supplier');
cy.visit(`/#/entry/my`, { cy.visit(`/#/entry/my`, {
onBeforeLoad(win) { onBeforeLoad(win) {

View File

@ -1,7 +1,6 @@
import './commands'; import './commands';
describe('EntryDms', () => { describe('EntryDms', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('buyerBoss'); cy.login('buyerBoss');
cy.visit(`/#/entry/waste-recalc`); cy.visit(`/#/entry/waste-recalc`);
}); });

View File

@ -3,7 +3,7 @@
describe('InvoiceInList', () => { describe('InvoiceInList', () => {
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)'; const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
const firstId = `${firstRow} > td:nth-child(2) span`; const firstId = `${firstRow} > td:nth-child(2) span`;
const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`; const invoiceId = '6';
const summaryHeaders = (opt) => `.summaryBody > .${opt} > .q-pb-lg > .header-link`; const summaryHeaders = (opt) => `.summaryBody > .${opt} > .q-pb-lg > .header-link`;
const mockInvoiceRef = `createMockInvoice${Math.floor(Math.random() * 100)}`; const mockInvoiceRef = `createMockInvoice${Math.floor(Math.random() * 100)}`;
const mock = { const mock = {
@ -31,7 +31,13 @@ describe('InvoiceInList', () => {
}); });
it('should open the details', () => { it('should open the details', () => {
cy.get(firstDetailBtn).click(); cy.get('[data-col-field="id"]').then(($cells) => {
const exactMatch = [...$cells].find(
(cell) => cell.textContent.trim() === invoiceId,
);
expect(exactMatch).to.exist;
cy.wrap(exactMatch).closest('tr').find('.q-btn:nth-child(1)').click();
});
cy.get(summaryHeaders('max-width')).contains('Basic data'); cy.get(summaryHeaders('max-width')).contains('Basic data');
cy.get(summaryHeaders('vat')).contains('Vat'); cy.get(summaryHeaders('vat')).contains('Vat');
}); });

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe.skip('InvoiceOut manual invoice', () => { describe.skip('InvoiceOut manual invoice', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/ticket/list`); cy.visit(`/#/ticket/list`);
cy.get('#searchbar input').type('{enter}'); cy.get('#searchbar input').type('{enter}');

View File

@ -4,7 +4,6 @@ describe('InvoiceOut negative bases', () => {
`:nth-child(1) > [data-col-field="${opt}"] > .no-padding > .link`; `:nth-child(1) > [data-col-field="${opt}"] > .no-padding > .link`;
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/invoice-out/negative-bases`); cy.visit(`/#/invoice-out/negative-bases`);
}); });

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('InvoiceOut global invoicing', () => { describe('InvoiceOut global invoicing', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('administrative'); cy.login('administrative');
cy.visit(`/#/invoice-out/global-invoicing`); cy.visit(`/#/invoice-out/global-invoicing`);
}); });
@ -17,7 +16,7 @@ describe('InvoiceOut global invoicing', () => {
cy.dataCy('InvoiceOutGlobalPrinterSelect').type('printer1'); cy.dataCy('InvoiceOutGlobalPrinterSelect').type('printer1');
cy.get('.q-menu .q-item').contains('printer1').click(); cy.get('.q-menu .q-item').contains('printer1').click();
cy.get( cy.get(
'[label="Invoice date"] > .q-field > .q-field__inner > .q-field__control' '[label="Invoice date"] > .q-field > .q-field__inner > .q-field__control',
).click(); ).click();
cy.get(':nth-child(5) > div > .q-btn > .q-btn__content > .block').click(); cy.get(':nth-child(5) > div > .q-btn > .q-btn__content > .block').click();
cy.get('.q-date__years-content > :nth-child(2) > .q-btn').click(); cy.get('.q-date__years-content > :nth-child(2) > .q-btn').click();

View File

@ -1,9 +1,14 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
function goTo(n = 1) {
return `.q-virtual-scroll__content > :nth-child(${n})`;
}
const firstRow = goTo();
describe('Handle Items FixedPrice', () => { describe('Handle Items FixedPrice', () => {
const grouping = 'Grouping price';
const saveEditBtn = '.q-mt-lg > .q-btn--standard';
const createForm = {
'Grouping price': { val: '5' },
'Packing price': { val: '5' },
Started: { val: '01-01-2001', type: 'date' },
Ended: { val: '15-01-2001', type: 'date' },
};
beforeEach(() => { beforeEach(() => {
cy.viewport(1280, 720); cy.viewport(1280, 720);
cy.login('developer'); cy.login('developer');
@ -13,50 +18,57 @@ describe('Handle Items FixedPrice', () => {
'.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon', '.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon',
).click(); ).click();
}); });
it.skip('filter', function () {
it('filter by category', () => {
cy.get('.category-filter > :nth-child(1) > .q-btn__content > .q-icon').click(); cy.get('.category-filter > :nth-child(1) > .q-btn__content > .q-icon').click();
cy.selectOption('.list > :nth-child(2)', 'Alstroemeria'); cy.get('.q-table__middle').should('be.visible').should('have.length', 1);
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
cy.addBtnClick();
cy.selectOption(`${firstRow} > :nth-child(2)`, '#13');
cy.get(`${firstRow} > :nth-child(4)`).find('input').type(1);
cy.get(`${firstRow} > :nth-child(5)`).find('input').type('2');
cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
cy.get('.q-notification__message').should('have.text', 'Data saved');
/* ==== End Cypress Studio ==== */
});
it.skip('Create and delete ', function () {
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
cy.addBtnClick();
cy.selectOption(`${firstRow} > :nth-child(2)`, '#11');
cy.get(`${firstRow} > :nth-child(4)`).type('1');
cy.get(`${firstRow} > :nth-child(5)`).type('2');
cy.selectOption(`${firstRow} > :nth-child(9)`, 'Warehouse One');
cy.get('.q-notification__message').should('have.text', 'Data saved');
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
cy.get(`${firstRow} > .text-right > .q-btn > .q-btn__content > .q-icon`).click();
cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block',
).click();
cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
it.skip('Massive edit', function () { it('should create a new fixed price, then delete it', () => {
cy.dataCy('vnTableCreateBtn').click();
cy.dataCy('FixedPriceCreateNameSelect').type('Melee weapon combat fist 15cm');
cy.get('.q-menu .q-item').contains('Melee weapon combat fist 15cm').click();
cy.dataCy('FixedPriceCreateWarehouseSelect').type('Warehouse One');
cy.get('.q-menu .q-item').contains('Warehouse One').click();
cy.get('.q-menu').then(($menu) => {
if ($menu.is(':visible')) {
cy.dataCy('FixedPriceCreateWarehouseSelect').as('focusedElement').focus();
cy.dataCy('FixedPriceCreateWarehouseSelect').blur();
}
});
cy.fillInForm(createForm);
cy.dataCy('FormModelPopup_save').click();
cy.checkNotification('Data created');
cy.get('[data-col-field="name"]').each(($el) => {
cy.wrap($el)
.invoke('text')
.then((text) => {
if (text.includes('Melee weapon combat fist 15cm')) {
cy.wrap($el).parent().find('.q-checkbox').click();
cy.get('[data-cy="crudModelDefaultRemoveBtn"]').click();
cy.dataCy('VnConfirm_confirm').click().click();
cy.checkNotification('Data saved');
}
});
});
});
it('should edit all items', () => {
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click(); cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
cy.get('#subToolbar > .q-btn--standard').click(); cy.dataCy('FixedPriceToolbarEditBtn').should('not.be.disabled');
cy.selectOption("[data-cy='field-to-edit']", 'Min price'); cy.dataCy('FixedPriceToolbarEditBtn').click();
cy.dataCy('value-to-edit').find('input').type('1'); cy.dataCy('EditFixedPriceSelectOption').type(grouping);
cy.get('.countLines').should('have.text', ' 1 '); cy.get('.q-menu .q-item').contains(grouping).click();
cy.get('.q-mt-lg > .q-btn--standard').click(); cy.dataCy('EditFixedPriceValueOption').type('5');
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get(saveEditBtn).click();
cy.checkNotification('Data saved');
}); });
it.skip('Massive remove', function () {
it('should remove all items', () => {
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click(); cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
cy.get('#subToolbar > .q-btn--flat').click(); cy.dataCy('crudModelDefaultRemoveBtn').should('not.be.disabled');
cy.get( cy.dataCy('crudModelDefaultRemoveBtn').click();
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block', cy.dataCy('VnConfirm_confirm').click();
).click(); cy.checkNotification('Data saved');
cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
}); });

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('ItemBarcodes', () => { describe('ItemBarcodes', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/barcode`); cy.visit(`/#/item/1/barcode`);
}); });

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('Item botanical', () => { describe('Item botanical', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/botanical`); cy.visit(`/#/item/1/botanical`);
}); });

View File

@ -2,7 +2,6 @@
describe.skip('Item list', () => { describe.skip('Item list', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/list`); cy.visit(`/#/item/list`);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('Item summary', () => { describe('Item summary', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/summary`); cy.visit(`/#/item/1/summary`);
}); });

View File

@ -1,6 +1,5 @@
describe('Item tag', () => { describe('Item tag', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/tags`); cy.visit(`/#/item/1/tags`);
cy.get('.q-page').should('be.visible'); cy.get('.q-page').should('be.visible');

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('Item tax', () => { describe('Item tax', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/tax`); cy.visit(`/#/item/1/tax`);
}); });

View File

@ -6,7 +6,6 @@ describe('Item type', () => {
const type = 'Flower'; const type = 'Flower';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/item-type`); cy.visit(`/#/item/item-type`);
}); });

View File

@ -6,7 +6,6 @@ describe('OrderList', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/order/list'); cy.visit('/#/order/list');
}); });

View File

@ -2,7 +2,6 @@ describe('Agency modes', () => {
const name = 'inhouse pickup'; const name = 'inhouse pickup';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/agency/1/modes`); cy.visit(`/#/route/agency/1/modes`);
}); });

View File

@ -13,7 +13,6 @@ describe('AgencyWorkCenter', () => {
}; };
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/agency/11/workCenter`); cy.visit(`/#/route/agency/11/workCenter`);
}); });

View File

@ -24,7 +24,6 @@ describe('Cmr list', () => {
}; };
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit('/#/route/cmr'); cy.visit('/#/route/cmr');
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -27,7 +27,6 @@ describe('RoadMap', () => {
const summaryUrl = '/summary'; const summaryUrl = '/summary';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/roadmap`); cy.visit(`/#/route/roadmap`);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -32,7 +32,6 @@ describe.skip('RouteAutonomous', () => {
const dataSaved = 'Data saved'; const dataSaved = 'Data saved';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/agency-term`); cy.visit(`/#/route/agency-term`);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -1,4 +1,4 @@
describe('Route extended list', () => { describe.skip('Route extended list', () => {
const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`; const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`;
const selectors = { const selectors = {
@ -75,7 +75,6 @@ describe('Route extended list', () => {
} }
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(url); cy.visit(url);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -26,8 +26,8 @@ describe('Route', () => {
const summaryUrl = '/summary'; const summaryUrl = '/summary';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit(`/#/route/list`); cy.visit(`/#/route/list`);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');
}); });

View File

@ -1,6 +1,5 @@
describe('Vehicle', () => { describe('Vehicle', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('deliveryAssistant'); cy.login('deliveryAssistant');
cy.visit(`/#/route/vehicle/7/summary`); cy.visit(`/#/route/vehicle/7/summary`);
}); });

View File

@ -21,7 +21,6 @@ describe('Vehicle list', () => {
const summaryUrl = '/summary'; const summaryUrl = '/summary';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/vehicle/list`); cy.visit(`/#/route/vehicle/list`);
cy.typeSearchbar('{enter}'); cy.typeSearchbar('{enter}');

View File

@ -10,7 +10,6 @@ describe('Vehicle Notes', () => {
const newNoteText = 'probando'; const newNoteText = 'probando';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/vehicle/1/notes`); cy.visit(`/#/route/vehicle/1/notes`);
}); });

View File

@ -5,7 +5,6 @@ describe('ParkingList', () => {
const summaryHeader = '.header-link'; const summaryHeader = '.header-link';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/shelving/parking/list`); cy.visit(`/#/shelving/parking/list`);
}); });

View File

@ -3,7 +3,6 @@ describe('ShelvingList', () => {
const parking = const parking =
'.q-card > :nth-child(1) > .q-select > .q-field__inner > .q-field__control > .q-field__control-container'; '.q-card > :nth-child(1) > .q-select > .q-field__inner > .q-field__control > .q-field__control-container';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/shelving/1/basic-data`); cy.visit(`/#/shelving/1/basic-data`);
}); });

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('ShelvingList', () => { describe('ShelvingList', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/shelving/list`); cy.visit(`/#/shelving/list`);
}); });

View File

@ -1,6 +1,5 @@
describe('Supplier Balance', () => { describe('Supplier Balance', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/supplier/1/balance`); cy.visit(`/#/supplier/1/balance`);
}); });

View File

@ -9,7 +9,6 @@ describe('Ticket descriptor', () => {
const weightValue = '[data-cy="vnLvWeight"]'; const weightValue = '[data-cy="vnLvWeight"]';
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
}); });
it('should clone the ticket without warehouse', () => { it('should clone the ticket without warehouse', () => {

View File

@ -5,7 +5,6 @@ describe('Ticket expedtion', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
}); });
it('should change the state', () => { it('should change the state', () => {

View File

@ -2,7 +2,6 @@
describe('TicketFilter', () => { describe('TicketFilter', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/list'); cy.visit('/#/ticket/list');
}); });

View File

@ -2,7 +2,6 @@
describe('TicketList', () => { describe('TicketList', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/list', false); cy.visit('/#/ticket/list', false);
}); });

View File

@ -2,7 +2,6 @@
describe('TicketNotes', () => { describe('TicketNotes', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/observation'); cy.visit('/#/ticket/31/observation');
}); });

View File

@ -2,7 +2,6 @@
describe('TicketRequest', () => { describe('TicketRequest', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/request'); cy.visit('/#/ticket/31/request');
}); });

View File

@ -4,7 +4,7 @@ const firstRow = 'tbody > :nth-child(1)';
describe('TicketSale', () => { describe('TicketSale', () => {
describe('#23', () => { describe('#23', () => {
beforeEach(() => { beforeEach(() => {
cy.login('salesBoss'); cy.login('claimManager');
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.visit('/#/ticket/23/sale'); cy.visit('/#/ticket/23/sale');
}); });
@ -15,6 +15,8 @@ describe('TicketSale', () => {
cy.get('[data-col-field="price"]').find('.q-btn').click(); cy.get('[data-col-field="price"]').find('.q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]'); cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist'); cy.dataCy('ticketEditManaProxy').should('exist');
cy.get('[data-cy="componentOption-37"]').click();
cy.waitForElement('[data-cy="Price_input"]'); cy.waitForElement('[data-cy="Price_input"]');
cy.dataCy('Price_input').clear().type(price); cy.dataCy('Price_input').clear().type(price);
cy.intercept('POST', /\/api\/Sales\/\d+\/updatePrice/).as('updatePrice'); cy.intercept('POST', /\/api\/Sales\/\d+\/updatePrice/).as('updatePrice');
@ -33,6 +35,7 @@ describe('TicketSale', () => {
cy.get('[data-col-field="discount"]').find('.q-btn').click(); cy.get('[data-col-field="discount"]').find('.q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]'); cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist'); cy.dataCy('ticketEditManaProxy').should('exist');
cy.get('[data-cy="componentOption-37"]').click();
cy.waitForElement('[data-cy="Disc_input"]'); cy.waitForElement('[data-cy="Disc_input"]');
cy.dataCy('Disc_input').clear().type(discount); cy.dataCy('Disc_input').clear().type(discount);
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as( cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
@ -83,8 +86,7 @@ describe('TicketSale', () => {
}); });
describe('#24 add claim', () => { describe('#24 add claim', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('salesPerson');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/24/sale'); cy.visit('/#/ticket/24/sale');
}); });
@ -102,8 +104,7 @@ describe('TicketSale', () => {
}); });
describe('#31 free ticket', () => { describe('#31 free ticket', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('claimManager');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale'); cy.visit('/#/ticket/31/sale');
}); });
@ -139,14 +140,15 @@ describe('TicketSale', () => {
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled'); cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
}); });
it.only('should update discount when "Update discount" is clicked', () => { it('should update discount when "Update discount" is clicked', () => {
const discount = Number((Math.random() * 99 + 1).toFixed(2)); const discount = Number((Math.random() * 99 + 1).toFixed(2));
selectFirstRow(); selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]'); cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click(); cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="componentOption-37"]');
cy.get('[data-cy="componentOption-37"]').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]'); cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus(); cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as( cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
@ -191,8 +193,7 @@ describe('TicketSale', () => {
}); });
describe('#32 transfer', () => { describe('#32 transfer', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('salesPerson');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/32/sale'); cy.visit('/#/ticket/32/sale');
}); });
it('transfer sale to a new ticket', () => { it('transfer sale to a new ticket', () => {

View File

@ -2,7 +2,6 @@
describe('VnBreadcrumbs', () => { describe('VnBreadcrumbs', () => {
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el'; const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit('/'); cy.visit('/');
}); });

View File

@ -1,6 +1,5 @@
describe('WagonTypeCreate', () => { describe('WagonTypeCreate', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit('/#/wagon/type/list'); cy.visit('/#/wagon/type/list');
cy.waitForElement('.q-page', 6000); cy.waitForElement('.q-page', 6000);

View File

@ -2,7 +2,6 @@ describe('WagonTypeEdit', () => {
const trayColorRow = const trayColorRow =
'.q-select > .q-field__inner > .q-field__control > .q-field__control-container'; '.q-select > .q-field__inner > .q-field__control > .q-field__control-container';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit('/#/wagon/type/1/edit'); cy.visit('/#/wagon/type/1/edit');
}); });

View File

@ -4,7 +4,6 @@ describe('WorkerPit', () => {
const savePIT = '#st-actions > .q-btn-group > .q-btn--standard'; const savePIT = '#st-actions > .q-btn-group > .q-btn--standard';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/worker/1107/pit`); cy.visit(`/#/worker/1107/pit`);
}); });

View File

@ -4,7 +4,6 @@ describe('ZoneDeliveryDays', () => {
const submitForm = '.q-form > .q-btn > .q-btn__content'; const submitForm = '.q-form > .q-btn > .q-btn__content';
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080);
cy.visit(`/#/zone/delivery-days`); cy.visit(`/#/zone/delivery-days`);
}); });

Some files were not shown because too many files have changed in this diff Show More