fixes #5149 ticket.descriptor-menu Eliminar ticket, debe comprobar que no existe un abono #1348
|
@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- (Trabajador -> PDA) Nueva sección
|
- (Trabajador -> PDA) Nueva sección
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
- (Ticket -> Borrar ticket) Restringido el borrado de tickets con abono
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
-
|
-
|
||||||
|
|
|
@ -2787,6 +2787,10 @@ INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, NULL, 1);
|
(1, NULL, 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 12);
|
||||||
|
|
||||||
INSERT INTO `vn`.`deviceProductionModels` (`code`)
|
INSERT INTO `vn`.`deviceProductionModels` (`code`)
|
||||||
VALUES
|
VALUES
|
||||||
('BLACKVIEW'),
|
('BLACKVIEW'),
|
||||||
|
|
|
@ -22,6 +22,7 @@ export default {
|
||||||
userConfigSecondAutocomplete: '#localBank',
|
userConfigSecondAutocomplete: '#localBank',
|
||||||
userConfigThirdAutocomplete: '#localCompany',
|
userConfigThirdAutocomplete: '#localCompany',
|
||||||
acceptButton: '.vn-confirm.shown button[response=accept]',
|
acceptButton: '.vn-confirm.shown button[response=accept]',
|
||||||
|
cancelButton: '.vn-confirm.shown input[response=cancel]',
|
||||||
searchButton: 'vn-searchbar vn-icon[icon="search"]'
|
searchButton: 'vn-searchbar vn-icon[icon="search"]'
|
||||||
},
|
},
|
||||||
moduleIndex: {
|
moduleIndex: {
|
||||||
|
|
|
@ -227,9 +227,21 @@ describe('Ticket Edit sale path', () => {
|
||||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||||
await page.waitToClick(selectors.ticketSales.moreMenuRefund);
|
await page.waitToClick(selectors.ticketSales.moreMenuRefund);
|
||||||
|
await page.waitForSnackbar();
|
||||||
await page.waitForState('ticket.card.sale');
|
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() => {
|
it('should select the third sale and create a claim of it', async() => {
|
||||||
await page.accessToSearchResult('16');
|
await page.accessToSearchResult('16');
|
||||||
await page.accessToSection('ticket.card.sale');
|
await page.accessToSection('ticket.card.sale');
|
||||||
|
|
|
@ -147,8 +147,8 @@
|
||||||
"Receipt's bank was not found": "Receipt's bank was not found",
|
"Receipt's bank was not found": "Receipt's bank was not found",
|
||||||
"This receipt was not compensated": "This receipt was not compensated",
|
"This receipt was not compensated": "This receipt was not compensated",
|
||||||
"Client's email was not found": "Client's email was not found",
|
"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 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 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",
|
"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"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,6 +264,7 @@
|
||||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
"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.",
|
"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",
|
"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}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,14 @@ module.exports = Self => {
|
||||||
if (!isEditable)
|
if (!isEditable)
|
||||||
throw new UserError(`The sales of this ticket can't be modified`);
|
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
|
// Check if has sales with shelving
|
||||||
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
||||||
const sales = await models.Sale.find({
|
const sales = await models.Sale.find({
|
||||||
|
|
|
@ -101,4 +101,32 @@ describe('ticket setDeleted()', () => {
|
||||||
throw e;
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue