fixes #5149 ticket.descriptor-menu Eliminar ticket, debe comprobar que no existe un abono #1348

Merged
joan merged 8 commits from 5149-check-ticket.refund into dev 2023-03-02 06:30:18 +00:00
8 changed files with 60 additions and 6 deletions

View File

@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (Trabajador -> PDA) Nueva sección
### Changed
-
- (Ticket -> Borrar ticket) Restringido el borrado de tickets con abono
### Fixed
-

View File

@ -2787,6 +2787,10 @@ INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
VALUES
(1, NULL, 1);
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
VALUES
(1, 12);
INSERT INTO `vn`.`deviceProductionModels` (`code`)
VALUES
('BLACKVIEW'),

View File

@ -22,6 +22,7 @@ export default {
userConfigSecondAutocomplete: '#localBank',
userConfigThirdAutocomplete: '#localCompany',
acceptButton: '.vn-confirm.shown button[response=accept]',
cancelButton: '.vn-confirm.shown input[response=cancel]',
searchButton: 'vn-searchbar vn-icon[icon="search"]'
},
moduleIndex: {

View File

@ -227,9 +227,21 @@ describe('Ticket Edit sale path', () => {
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuRefund);
await page.waitForSnackbar();
await page.waitForState('ticket.card.sale');
});
it('should show error trying to delete a ticket with a refund', async() => {
await page.accessToSearchResult('16');
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Tickets with associated refunds can\'t be deleted');
await page.waitToClick(selectors.globalItems.cancelButton);
});
it('should select the third sale and create a claim of it', async() => {
await page.accessToSearchResult('16');
await page.accessToSection('ticket.card.sale');

View File

@ -147,8 +147,8 @@
"Receipt's bank was not found": "Receipt's bank was not found",
"This receipt was not compensated": "This receipt was not compensated",
"Client's email was not found": "Client's email was not found",
"Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}",
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3"
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales"
}

View File

@ -264,6 +264,7 @@
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
"There is no assigned email for this client": "No hay correo asignado para este cliente",
"This locker has already been assigned": "Esta taquilla ya ha sido asignada"
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
"Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº {{id}}"
}

View File

@ -42,6 +42,14 @@ module.exports = Self => {
if (!isEditable)
throw new UserError(`The sales of this ticket can't be modified`);
// Check if ticket has refunds
const ticketRefunds = await models.TicketRefund.find({
where: {originalTicketFk: id},
fields: ['id']}
, myOptions);
if (ticketRefunds.length > 0)
throw new UserError($t('Tickets with associated refunds', {id: ticketRefunds[0].id}));
// Check if has sales with shelving
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
const sales = await models.Sale.find({

View File

@ -101,4 +101,32 @@ describe('ticket setDeleted()', () => {
throw e;
}
});
it('should show error trying to delete a ticket with a refund', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost:5000'},
}
};
ctx.req.__ = value => {
return value;
};
const ticketId = 12;
await models.Ticket.setDeleted(ctx, ticketId, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toContain('Tickets with associated refunds');
});
});