diff --git a/loopback/locale/en.json b/loopback/locale/en.json index b0e33a42f9..dc02f89eb6 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,5 @@ "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", - "There are tickets to be invoiced for this area, please delete them first": "There are tickets to be invoiced for this area, please delete them first" + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a1d25f77b2..20d04d69e3 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -383,5 +383,5 @@ "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", - "There are tickets to be invoiced for this area, please delete them first": "Hay tickets para esta sección, borralos primero" + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" } diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 62d88509c8..85303e46f6 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -51,9 +51,9 @@ module.exports = Self => { }; const ticketList = await models.Ticket.find(filter, myOptions); - const hasRefFkFilled = ticketList.some(ticket => ticket.refFk !== null && ticket.refFk !== undefined); - if (hasRefFkFilled) - throw new UserError('There are tickets to be invoiced for this area, please delete them first'); + const hasRefFk = ticketList.some(ticket => ticket.refFk !== null && ticket.refFk !== undefined); + if (hasRefFk) + throw new UserError('There are tickets to be invoiced'); await models.Zone.destroyById(id, myOptions); diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 4b67944f34..938b99f96c 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -8,8 +8,6 @@ describe('zone deletezone()', () => { __: value => value }; const ctx = {req: activeCtx}; - const zoneId = 4; - const zoneId1 = 1; let ticketIDs; beforeAll(async() => { @@ -18,7 +16,7 @@ describe('zone deletezone()', () => { }); const originalTickets = await models.Ticket.find({ where: { - zoneFk: zoneId + zoneFk: 4 } }); ticketIDs = originalTickets.map(ticket => ticket.id); @@ -32,9 +30,9 @@ describe('zone deletezone()', () => { try { const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId, options); + await models.Zone.deleteZone(ctx, 4, options); - const updatedZone = await models.Zone.findById(zoneId, null, options); + const updatedZone = await models.Zone.findById(4, null, options); expect(updatedZone).toBeNull(); @@ -51,7 +49,7 @@ describe('zone deletezone()', () => { let error; try { const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId1, options); + await models.Zone.deleteZone(ctx, 1, options); await tx.rollback(); } catch (e) { error = e.message;