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-03-13 07:57:54 +01:00
commit 5fbd57a177
11 changed files with 215 additions and 168 deletions

View File

@ -28,6 +28,17 @@ defineProps({ row: { type: Object, required: true } });
{{ t('ticketSale.reserved') }} {{ t('ticketSale.reserved') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon
v-if="row?.isDeleted"
color="primary"
name="vn:deletedTicket"
size="xs"
data-cy="ticketDeletedIcon"
>
<QTooltip>
{{ t('Ticket deleted') }}
</QTooltip>
</QIcon>
<QIcon <QIcon
v-if="row?.hasRisk" v-if="row?.hasRisk"
name="vn:risk" name="vn:risk"

View File

@ -920,12 +920,24 @@ const rowCtrlClickFunction = computed(() => {
:row-index="index" :row-index="index"
> >
<VnColumn <VnColumn
:column="col" :column="{
...col,
disable:
col?.component ===
'checkbox'
? true
: false,
}"
:row="row" :row="row"
:is-editable="false" :is-editable="false"
v-model="row[col.name]" v-model="row[col.name]"
component-prop="columnField" component-prop="columnField"
:show-label="true" :show-label="
col?.component ===
'checkbox'
? false
: true
"
/> />
</slot> </slot>
</span> </span>

View File

@ -43,16 +43,22 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
label: t('isOwn'), label: t('agency.isOwn'),
name: 'isOwn', name: 'isOwn',
component: 'checkbox', component: 'checkbox',
columnFilter: {
inWhere: true,
},
cardVisible: true, cardVisible: true,
}, },
{ {
align: 'left', align: 'left',
label: t('isAnyVolumeAllowed'), label: t('agency.isAnyVolumeAllowed'),
name: 'isAnyVolumeAllowed', name: 'isAnyVolumeAllowed',
component: 'checkbox', component: 'checkbox',
columnFilter: {
inWhere: true,
},
cardVisible: true, cardVisible: true,
}, },
{ {
@ -61,7 +67,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('Client ticket list'), title: t('globals.pageTitles.summary'),
icon: 'preview', icon: 'preview',
action: (row) => viewSummary(row?.id, AgencySummary), action: (row) => viewSummary(row?.id, AgencySummary),
isPrimary: true, isPrimary: true,
@ -107,11 +113,3 @@ const columns = computed(() => [
justify-content: center; justify-content: center;
} }
</style> </style>
<i18n>
es:
isOwn: Tiene propietario
isAnyVolumeAllowed: Permite cualquier volumen
en:
isOwn: Has owner
isAnyVolumeAllowed: Allows any volume
</i18n>

View File

@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import VnTitle from 'src/components/common/VnTitle.vue'; import VnTitle from 'src/components/common/VnTitle.vue';
import VnCheckbox from 'components/common/VnCheckbox.vue';
const route = useRoute(); const route = useRoute();
const $props = defineProps({ id: { type: Number, default: 0 } }); const $props = defineProps({ id: { type: Number, default: 0 } });
@ -24,12 +25,12 @@ const entityId = computed(() => $props.id || route.params.id);
:text="t('globals.pageTitles.basicData')" :text="t('globals.pageTitles.basicData')"
/> />
<VnLv :label="t('globals.name')" :value="agency.name" /> <VnLv :label="t('globals.name')" :value="agency.name" />
<QCheckbox <VnCheckbox
:label="t('agency.isOwn')" :label="t('agency.isOwn')"
v-model="agency.isOwn" v-model="agency.isOwn"
:disable="true" :disable="true"
/> />
<QCheckbox <VnCheckbox
:label="t('agency.isAnyVolumeAllowed')" :label="t('agency.isAnyVolumeAllowed')"
v-model="agency.isAnyVolumeAllowed" v-model="agency.isAnyVolumeAllowed"
:disable="true" :disable="true"

View File

@ -1,11 +1,12 @@
agency: agency:
search: Search agency search: Search agency
searchInfo: You can search by name searchInfo: You can search by name and by id
isOwn: Own isOwn: Own
isAnyVolumeAllowed: Any volume allowed isAnyVolumeAllowed: Any volume allowed
removeItem: Agency removed successfully
notification: notification:
removeItemError: Error removing agency removeItemError: Error removing work center
removeItem: WorkCenter removed successfully removeItem: Work center removed successfully
pageTitles: pageTitles:
agency: Agency agency: Agency
searchBar: searchBar:

View File

@ -1,15 +1,14 @@
agency: agency:
search: Buscar agencia search: Buscar agencia
searchInfo: Puedes buscar por nombre searchInfo: Puedes buscar por nombre y por id
isOwn: Propio isOwn: Propio
isAnyVolumeAllowed: Cualquier volumen isAnyVolumeAllowed: Cualquier volumen
removeItem: Agencia eliminada correctamente removeItem: Agencia eliminada correctamente
notification: notification:
removeItemError: Error al eliminar la agencia removeItemError: Error al eliminar la el centro de trabajo
removeItem: Centro de trabajo eliminado correctamente removeItem: Centro de trabajo eliminado correctamente
pageTitles: pageTitles:
agency: Agencia agency: Agencia
searchBar: searchBar:
info: Puedes buscar por nombre o id info: Puedes buscar por nombre o id
label: Buscar agencia... label: Buscar agencia...

View File

@ -49,6 +49,12 @@ route:
shipped: Shipped shipped: Shipped
agencyAgreement: Agency agreement agencyAgreement: Agency agreement
agencyModeName: Agency route agencyModeName: Agency route
isOwn: Own
isAnyVolumeallowed: Any volume allowed
Worker: Worker
Agency: Agency
Vehicle: Vehicle
Description: Description
hourStarted: H.Start hourStarted: H.Start
hourFinished: H.End hourFinished: H.End
createRoute: Create route createRoute: Create route

View File

@ -50,6 +50,8 @@ route:
shipped: Fecha preparación shipped: Fecha preparación
agencyModeName: Agencia Ruta agencyModeName: Agencia Ruta
agencyAgreement: Agencia Acuerdo agencyAgreement: Agencia Acuerdo
isOwn: Propio
isAnyVolumeAllowed: Cualquier volumen
Worker: Trabajador Worker: Trabajador
Agency: Agencia Agency: Agencia
Vehicle: Vehículo Vehicle: Vehículo

View File

@ -110,7 +110,7 @@ function getInfo() {
</template> </template>
<template #icons="{ entity }"> <template #icons="{ entity }">
<QCardActions class="q-gutter-x-xs"> <QCardActions class="q-gutter-x-xs">
<TicketProblems :row="{ ...entity?.client, ...problems }" /> <TicketProblems :row="{ ...entity?.client, ...problems, ...entity }" />
</QCardActions> </QCardActions>
</template> </template>
<template #actions="{ entity }"> <template #actions="{ entity }">

View File

@ -174,22 +174,28 @@ const getSaleTotal = (sale) => {
return price - discount; return price - discount;
}; };
const getRowUpdateInputEvents = (sale) => ({ const getRowUpdateInputEvents = (sale) => {
'keyup.enter': () => { return {
changeQuantity(sale); 'keyup.enter': (evt) => {
}, console.error(evt);
blur: () => { changeQuantity(sale);
changeQuantity(sale); },
}, blur: (evt) => {
}); console.error(evt);
changeQuantity(sale);
},
};
};
const resetChanges = async () => { const resetChanges = async () => {
arrayData.fetch({ append: false }); arrayData.fetch({ append: false });
tableRef.value.reload(); tableRef.value.reload();
selectedRows.value = [];
}; };
const changeQuantity = async (sale) => { const changeQuantity = async (sale) => {
if (!sale.itemFk || sale.quantity == null || sale?.originalQuantity === sale.quantity) if (!sale.itemFk || sale.quantity == null || sale?.originalQuantity === sale.quantity)
return; return;
else sale.originalQuantity = sale.quantity;
if (!sale.id) return addSale(sale); if (!sale.id) return addSale(sale);
if (await isSalePrepared(sale)) { if (await isSalePrepared(sale)) {
@ -235,7 +241,7 @@ const addSale = async (sale) => {
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
sale.isNew = false; sale.isNew = false;
arrayData.fetch({}); resetChanges();
}; };
const changeConcept = async (sale) => { const changeConcept = async (sale) => {
if (await isSalePrepared(sale)) { if (await isSalePrepared(sale)) {
@ -310,7 +316,7 @@ const changeDiscount = async (sale) => {
} }
}; };
const updateDiscounts = async (sales, newDiscount = null) => { const updateDiscounts = async (sales, newDiscount) => {
const salesTracking = await fetchSalesTracking(); const salesTracking = await fetchSalesTracking();
const someSaleIsPrepared = salesTracking.some((sale) => const someSaleIsPrepared = salesTracking.some((sale) =>
@ -320,12 +326,11 @@ const updateDiscounts = async (sales, newDiscount = null) => {
else updateDiscount(sales, newDiscount); else updateDiscount(sales, newDiscount);
}; };
const updateDiscount = async (sales, newDiscount = null) => { const updateDiscount = async (sales, newDiscount = 0) => {
const saleIds = sales.map((sale) => sale.id); const salesIds = sales.map(({ id }) => id);
const _newDiscount = newDiscount || edit.value.discount;
const params = { const params = {
salesIds: saleIds, salesIds,
newDiscount: _newDiscount, newDiscount,
manaCode: manaCode.value, manaCode: manaCode.value,
}; };
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params); await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
@ -474,7 +479,7 @@ const endNewRow = (row) => {
}; };
async function confirmUpdate(cb) { async function confirmUpdate(cb) {
await quasar quasar
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
@ -664,6 +669,7 @@ watch(
selection: 'multiple', selection: 'multiple',
}" }"
:right-search="false" :right-search="false"
:search-url="false"
:column-search="false" :column-search="false"
:disable-option="{ card: true }" :disable-option="{ card: true }"
auto-load auto-load
@ -703,7 +709,7 @@ watch(
</template> </template>
<template #column-image="{ row }"> <template #column-image="{ row }">
<div class="image-wrapper"> <div class="image-wrapper">
<VnImg :id="parseInt(row?.item?.id)" class="rounded" /> <VnImg v-if="row.item" :id="parseInt(row?.item?.id)" class="rounded" />
</div> </div>
</template> </template>
<template #column-visible="{ row }"> <template #column-visible="{ row }">
@ -751,7 +757,7 @@ watch(
{{ row?.item?.subName.toUpperCase() }} {{ row?.item?.subName.toUpperCase() }}
</div> </div>
</div> </div>
<FetchedTags :item="row.item" :max-length="6" /> <FetchedTags v-if="row.item" :item="row.item" :max-length="6" />
<QPopupProxy v-if="row.id && isTicketEditable"> <QPopupProxy v-if="row.id && isTicketEditable">
<VnInput <VnInput
v-model="row.concept" v-model="row.concept"

View File

@ -1,139 +1,14 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
const firstRow = 'tbody > :nth-child(1)';
describe('TicketSale', () => { describe('TicketSale', () => {
describe.skip('Free ticket #31', () => { describe('Ticket #23', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale');
});
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('should send SMS', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
it('should recalculate price when "Recalculate price" is clicked', () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
it('should update discount when "Update discount" is clicked', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
it('adds claim', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.url().should('contain', 'claim/');
// Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Data deleted');
});
it('marks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="markAsReservedItem"]');
cy.dataCy('markAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('exist');
});
it('unmarks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="unmarkAsReservedItem"]');
cy.dataCy('unmarkAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('not.exist');
});
it('refunds row with warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('refunds row without warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithoutWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('transfer sale to a new ticket', () => {
cy.visit('/#/ticket/32/sale');
cy.get('.q-item > .q-item__label').should('have.text', ' #32');
selectFirstRow();
cy.dataCy('ticketSaleTransferBtn').click();
cy.dataCy('ticketTransferPopup').should('exist');
cy.dataCy('ticketTransferNewTicketBtn').click();
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
it('should redirect to ticket logs', () => {
cy.get(firstRow).find('.q-btn:last').click();
cy.url().should('match', /\/ticket\/31\/log/);
});
});
describe.skip('Ticket prepared #23', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.visit('/#/ticket/23/sale'); cy.visit('/#/ticket/23/sale');
}); });
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('update price', () => { it('update price', () => {
const price = Number((Math.random() * 99 + 1).toFixed(2)); const price = Number((Math.random() * 99 + 1).toFixed(2));
cy.waitForElement(firstRow); cy.waitForElement(firstRow);
@ -196,8 +71,144 @@ describe('TicketSale', () => {
.should('have.value', `${quantity}`); .should('have.value', `${quantity}`);
}); });
}); });
}); describe('Ticket to add claim #24', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/24/sale');
});
it('adds claim', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.url().should('contain', 'claim/');
// Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
});
});
describe('Free ticket #31', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale');
});
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('should send SMS', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
it('should recalculate price when "Recalculate price" is clicked', () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
});
it('should update discount when "Update discount" is clicked', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
});
it('adds claim', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Future ticket date not allowed');
});
it('marks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="markAsReservedItem"]');
cy.dataCy('markAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('exist');
});
it('unmarks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="unmarkAsReservedItem"]');
cy.dataCy('unmarkAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('not.exist');
});
it('refunds row with warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('refunds row without warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithoutWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('should redirect to ticket logs', () => {
cy.get(firstRow).find('.q-btn:last').click();
cy.url().should('match', /\/ticket\/31\/log/);
});
});
describe('Ticket to transfer #32', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/32/sale');
});
it('transfer sale to a new ticket', () => {
cy.get('.q-item > .q-item__label').should('have.text', ' #32');
selectFirstRow();
cy.dataCy('ticketSaleTransferBtn').click();
cy.dataCy('ticketTransferPopup').should('exist');
cy.dataCy('ticketTransferNewTicketBtn').click();
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
});
});
function selectFirstRow() {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
}
function handleVnConfirm() { function handleVnConfirm() {
cy.get('[data-cy="VnConfirm_confirm"]').click(); cy.get('[data-cy="VnConfirm_confirm"]').click();
cy.waitForElement('.q-notification__message'); cy.waitForElement('.q-notification__message');