fix: refs #8222 fix prDeleteZone #3269
|
@ -245,6 +245,6 @@
|
||||||
"Invalid or expired verification code": "Invalid or expired verification code",
|
"Invalid or expired verification code": "Invalid or expired verification code",
|
||||||
"Payment method is required": "Payment method is required",
|
"Payment method is required": "Payment method is required",
|
||||||
"The raid information is not correct": "The raid information is not correct",
|
"The raid information is not correct": "The raid information is not correct",
|
||||||
"Sales already moved": "Sales already moved"
|
"Sales already moved": "Sales already moved",
|
||||||
|
"There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first"
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,5 +388,6 @@
|
||||||
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
|
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
|
||||||
"The web user's email already exists": "El correo del usuario web ya existe",
|
"The web user's email already exists": "El correo del usuario web ya existe",
|
||||||
"Sales already moved": "Ya han sido transferidas",
|
"Sales already moved": "Ya han sido transferidas",
|
||||||
"The raid information is not correct": "La información de la redada no es correcta"
|
"The raid information is not correct": "La información de la redada no es correcta",
|
||||||
|
"There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero"
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticketList = await models.Ticket.find(filter, myOptions);
|
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||||
|
const hasRefFk = ticketList.some(ticket => ticket.refFk);
|
||||||
if (ticketList.length > 0)
|
if (hasRefFk)
|
||||||
throw new UserError('There are tickets for this area, delete them first');
|
throw new UserError('There are tickets to be invoiced');
|
||||||
|
|
||||||
await models.Zone.destroyById(id, myOptions);
|
await models.Zone.destroyById(id, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,14 @@ describe('zone deletezone()', () => {
|
||||||
__: value => value
|
__: value => value
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
const zoneId = 4;
|
|
||||||
const zoneId2 = 3;
|
|
||||||
let ticketIDs;
|
let ticketIDs;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const zoneId = 4;
|
||||||
const originalTickets = await models.Ticket.find({
|
const originalTickets = await models.Ticket.find({
|
||||||
where: {
|
where: {
|
||||||
zoneFk: zoneId
|
zoneFk: zoneId
|
||||||
|
@ -29,7 +29,7 @@ describe('zone deletezone()', () => {
|
||||||
|
|
||||||
it('should delete a zone and update their tickets', async() => {
|
it('should delete a zone and update their tickets', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
const zoneId = 4;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
await models.Zone.deleteZone(ctx, zoneId, options);
|
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||||
|
@ -47,17 +47,18 @@ describe('zone deletezone()', () => {
|
||||||
|
|
||||||
it('should not delete the zone if it has tickets', async() => {
|
it('should not delete the zone if it has tickets', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
const zoneId = 1;
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
await models.Zone.deleteZone(ctx, zoneId2, options);
|
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e.message;
|
error = e.message;
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toEqual('There are tickets for this area, delete them first');
|
expect(error).toEqual('There are tickets to be invoiced');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue