Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2025-04-01 07:28:11 +02:00
commit 40d59846fa
19 changed files with 69 additions and 134 deletions

View File

@ -17,17 +17,6 @@ defineProps({ row: { type: Object, required: true } });
</QTooltip>
</QIcon>
</router-link>
<QIcon
v-if="row?.reserved"
color="primary"
name="vn:reserva"
size="xs"
data-cy="ticketSaleReservedIcon"
>
<QTooltip>
{{ t('ticketSale.reserved') }}
</QTooltip>
</QIcon>
<QIcon
v-if="row?.isDeleted"
color="primary"

View File

@ -1,35 +1,14 @@
<script setup>
import { nextTick, ref } from 'vue';
import VnInput from './VnInput.vue';
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
const $props = defineProps({
insertable: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['update:modelValue', 'accountShortToStandard']);
const model = defineModel({ prop: 'modelValue' });
const inputRef = ref(false);
function setCursorPosition(pos) {
const input = inputRef.value.vnInputRef.$el.querySelector('input');
input.focus();
input.setSelectionRange(pos, pos);
}
async function handleUpdateModel(val) {
model.value = val?.at(-1) === '.' ? useAccountShortToStandard(val) : val;
await nextTick(() => setCursorPosition(0));
}
</script>
<template>
<VnInput
v-model="model"
ref="inputRef"
:insertable
@update:model-value="handleUpdateModel"
@keydown.tab="model = useAccountShortToStandard($event.target.value) ?? model"
@input="model = $event.target.value.replace(/[^\d.]/g, '')"
/>
</template>

View File

@ -23,18 +23,19 @@ describe('useRole', () => {
name: `T'Challa`,
nickname: 'Black Panther',
lang: 'en',
worker: { department: { departmentFk: 155 } },
};
const expectedUser = {
id: 999,
name: `T'Challa`,
nickname: 'Black Panther',
lang: 'en',
departmentFk: 155,
};
const expectedRoles = ['salesPerson', 'admin'];
vi.spyOn(axios, 'get')
.mockResolvedValueOnce({
vi.spyOn(axios, 'get').mockResolvedValueOnce({
data: { roles: rolesData, user: fetchedUser },
})
});
vi.spyOn(role.state, 'setUser');
vi.spyOn(role.state, 'setRoles');

View File

@ -75,6 +75,7 @@ describe('session', () => {
userConfig: {
darkMode: false,
},
worker: { department: { departmentFk: 155 } },
};
const rolesData = [
{
@ -143,7 +144,7 @@ describe('session', () => {
await session.destroy(); // this clears token and user for any other test
});
},
{}
{},
);
describe('RenewToken', () => {
@ -175,7 +176,7 @@ describe('session', () => {
await session.checkValidity();
expect(sessionStorage.getItem('token')).toEqual(expectedToken);
expect(sessionStorage.getItem('tokenMultimedia')).toEqual(
expectedTokenMultimedia
expectedTokenMultimedia,
);
});
it('Should renewToken', async () => {
@ -204,7 +205,7 @@ describe('session', () => {
await session.checkValidity();
expect(sessionStorage.getItem('token')).not.toEqual(expectedToken);
expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual(
expectedTokenMultimedia
expectedTokenMultimedia,
);
});
});

View File

@ -13,6 +13,7 @@ export function useRole() {
name: data.user.name,
nickname: data.user.nickname,
lang: data.user.lang || 'es',
departmentFk: data.user.worker.department.departmentFk,
};
state.setUser(userData);
state.setRoles(roles);

View File

@ -115,6 +115,7 @@ const props = defineProps({
<i18n>
en:
params:
departmentFk: Department
search: Contains
clientFk: Customer
clientName: Customer
@ -127,6 +128,7 @@ en:
zoneFk: Zone
es:
params:
departmentFk: Departamento
search: Contiene
clientFk: Cliente
clientName: Cliente

View File

@ -156,6 +156,7 @@ en:
email: Email
isToBeMailed: Mailed
isEqualizated: Equailized
departmentFk: Department
businessTypeFk: Business type
sageTaxTypeFk: Sage Tax Type
sageTransactionTypeFk: Sage Tax Type
@ -166,6 +167,7 @@ en:
postcode: Postcode
es:
params:
departmentFk: Departamento
search: Contiene
fi: NIF
isActive: Activo

View File

@ -192,8 +192,10 @@ en:
date: L. O. Date
credit: Credit I.
defaulterSinced: From
departmentFk: Department
es:
params:
departmentFk: Departamento
clientFk: Cliente
countryFk: País
paymentMethod: F. Pago

View File

@ -9,12 +9,14 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import { dateRange } from 'src/filters';
import useOpenURL from 'src/composables/useOpenURL';
import { useState } from 'src/composables/useState';
const { t } = useI18n();
const dates = dateRange(Date.vnNew());
const from = ref(dates[0]);
const to = ref(dates[1]);
const state = useState();
const filter = computed(() => {
const obj = {};
const formatFrom = setHours(from.value, 'from');
@ -24,16 +26,18 @@ const filter = computed(() => {
if (!formatFrom && formatTo) stamp = { lte: formatTo };
else if (formatFrom && !formatTo) stamp = { gte: formatFrom };
else if (formatFrom && formatTo) stamp = { between: [formatFrom, formatTo] };
return Object.assign(obj, { where: { 'v.stamp': stamp } });
return Object.assign(obj, {
where: {
'v.stamp': stamp,
'c.departmentFk': state.getUser().value.departmentFk,
},
});
});
function exprBuilder(param, value) {
switch (param) {
case 'clientFk':
return { [`c.id`]: value };
case 'departmentFk':
return { [`c.${param}`]: value };
}
}
@ -66,9 +70,13 @@ const columns = computed(() => [
align: 'left',
name: 'departmentFk',
label: t('customer.summary.team'),
component: 'select',
attrs: {
url: 'Departments',
columnFilter: {
component: 'select',
attrs: {
url: 'Departments',
},
alias: 'c',
inWhere: true,
},
columnField: {
component: null,

View File

@ -130,8 +130,10 @@ en:
myTeam: My Team
isConfirmed: Order Confirmed
showEmpty: Show Empty
departmentFk: Department
es:
params:
departmentFk: Departamento
search: Búsqueda
clientFk: Cliente
agencyModeFk: Agencia

View File

@ -187,7 +187,9 @@ const getRowUpdateInputEvents = (sale) => {
const resetChanges = async () => {
arrayData.fetch({ append: false });
tableRef.value.reload();
tableRef.value.CrudModelRef.hasChanges = false;
await tableRef.value.reload();
selectedRows.value = [];
};
const changeQuantity = async (sale) => {
@ -392,7 +394,7 @@ const changeTicketState = async (val) => {
const params = { ticketFk: route.params.id, code: val };
await axios.post('Tickets/state', params);
notify('globals.dataSaved', 'positive');
await resetChanges();
resetChanges();
};
const removeSelectedSales = () => {

View File

@ -62,6 +62,7 @@ const isClaimable = computed(() => {
}
return false;
});
const sendSms = async (params) => {
await axios.post(`Tickets/${ticket.value.id}/sendSms`, params);
notify(t('SMS sent'), 'positive');
@ -230,18 +231,6 @@ const createRefund = async (withWarehouse) => {
<QItemLabel>{{ t('Add claim') }}</QItemLabel>
</QItemSection>
</QItem>
<QItem
v-if="isTicketEditable"
clickable
v-close-popup
v-ripple
@click="setReserved(true)"
data-cy="markAsReservedItem"
>
<QItemSection>
<QItemLabel>{{ t('Mark as reserved') }}</QItemLabel>
</QItemSection>
</QItem>
<QItem clickable v-ripple data-cy="ticketSaleRefundItem">
<QItemSection>
<QItemLabel>{{ t('Refund') }}</QItemLabel>
@ -287,8 +276,6 @@ es:
Recalculate price: Recalcular precio
Update discount: Actualizar descuento
Add claim: Crear reclamación
Mark as reserved: Marcar como reservado
Unmark as reserved: Desmarcar como reservado
Refund: Abono
with warehouse: con almacén
without warehouse: sin almacén

View File

@ -22,16 +22,6 @@ const states = ref([]);
const agencies = ref([]);
const warehouses = ref([]);
const groupedStates = ref([]);
const getGroupedStates = (data) => {
for (const state of data) {
groupedStates.value.push({
id: state.id,
name: t(`${state.code}`),
code: state.code,
});
}
};
</script>
<template>
@ -39,12 +29,11 @@ const getGroupedStates = (data) => {
<FetchData url="States" @on-fetch="(data) => (states = data)" auto-load />
<FetchData
url="AlertLevels"
@on-fetch="
(data) => {
getGroupedStates(data);
}
"
auto-load
@on-fetch="
(data) =>
(groupedStates = data.map((x) => Object.assign(x, { code: t(x.code) })))
"
/>
<FetchData
url="AgencyModes"
@ -126,12 +115,11 @@ const getGroupedStates = (data) => {
</QItemSection>
<QItemSection v-if="groupedStates">
<VnSelect
:label="t('Grouped state')"
:label="t('params.groupedStates')"
v-model="params.groupedStates"
@update:model-value="searchFn()"
:options="groupedStates"
option-value="id"
option-label="name"
option-label="code"
emit-value
map-options
use-input
@ -304,7 +292,7 @@ en:
ON_PREPARATION: On preparation
PACKED: Packed
DELIVERED: Delivered
ON_PREVIOUS: ON_PREVIOUS
ON_PREVIOUS: On previous
es:
params:
search: Contiene
@ -349,7 +337,7 @@ es:
ON_PREPARATION: En preparación
PACKED: Encajado
DELIVERED: Servido
ON_PREVIOUS: ON_PREVIOUS
ON_PREVIOUS: En previa
Collection: Colección
Nickname: Nombre mostrado
</i18n>

View File

@ -8,6 +8,6 @@ import filter from './TravelFilter.js';
data-key="Travel"
url="Travels"
:descriptor="TravelDescriptor"
:filter="filter"
:filter="{ ...filter, where: { id: $route.params.id } }"
/>
</template>

View File

@ -410,18 +410,18 @@ onMounted(async () => {
</template>
</QTable>
</QCard>
<QCard class="full-width" v-if="thermographs.length > 0">
<RouterLink
class="header header-link"
:to="{
name: 'TravelThermographsIndex',
params: { id: travel.id },
}"
>
{{ t('travel.summary.thermographs') }}
<QIcon name="open_in_new" />
</RouterLink>
<FetchData
url="Warehouses"
:filter="{ fields: ['id', 'name'] }"
order="name"
@on-fetch="(data) => (warehouses = data)"
auto-load
/>
<VnTitle
:url="getLink('thermographs')"
:text="t('travel.summary.thermographs')"
/>
<QTable
:rows="thermographs"
:columns="thermographsTableColumns"

View File

@ -102,8 +102,11 @@ en:
lastName: Last name
userName: User
extension: Extension
departmentFk: Department
es:
params:
departmentFk: Departamento
search: Contiene
firstName: Nombre
lastName: Apellidos

View File

@ -1,4 +1,4 @@
describe('ClaimNotes', () => {
describe('Account descriptor', () => {
const descriptorOptions = '[data-cy="descriptor-more-opts-menu"] > .q-list';
const url = '/#/account/1/summary';
@ -7,6 +7,9 @@ describe('ClaimNotes', () => {
cy.visit(url);
cy.dataCy('descriptor-more-opts').click();
cy.get(descriptorOptions)
.should('exist')
.should('be.visible')
.find('.q-item')
.its('length')
.then((count) => {

View File

@ -30,9 +30,11 @@ describe('OrderList', () => {
cy.url().should('include', `/order`);
});
it.skip('filter list and create order', () => {
it('filter list and create order', () => {
cy.dataCy('Customer ID_input').type('1101{enter}');
cy.intercept('GET', /\/api\/Clients/).as('clientFilter');
cy.dataCy('vnTableCreateBtn').click();
cy.wait('@clientFilter');
cy.dataCy('landedDate').find('input').type('06/01/2001');
cy.selectOption(agencyCreateSelect, 1);

View File

@ -1,37 +0,0 @@
describe('VnAccountNumber', () => {
const accountInput = 'input[data-cy="supplierFiscalDataAccount_input"]';
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/supplier/1/fiscal-data');
});
describe('VnInput handleInsertMode()', () => {
it('should replace character at cursor position in insert mode', () => {
cy.get(accountInput).type('{selectall}4100000001');
cy.get(accountInput).type('{movetostart}');
cy.get(accountInput).type('999');
cy.get(accountInput).should('have.value', '9990000001');
});
it('should replace character at cursor position in insert mode', () => {
cy.get(accountInput).clear();
cy.get(accountInput).type('4100000001');
cy.get(accountInput).type('{movetostart}');
cy.get(accountInput).type('999');
cy.get(accountInput).should('have.value', '9990000001');
});
it('should respect maxlength prop', () => {
cy.get(accountInput).clear();
cy.get(accountInput).type('123456789012345');
cy.get(accountInput).should('have.value', '1234567890');
});
});
it('should convert short account number to standard format', () => {
cy.get(accountInput).clear();
cy.get(accountInput).type('123.');
cy.get(accountInput).should('have.value', '1230000000');
});
});