Merge pull request '2387-zone_delete_fix' (#355) from 2387-zone_delete_fix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #355 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
519580161e
|
@ -601,11 +601,11 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||||
(12, 3, 19, NOW()),
|
(12, 3, 19, NOW()),
|
||||||
(13, 3, 19, NOW()),
|
(13, 3, 19, NOW()),
|
||||||
(14, 3, 19, NOW()),
|
(14, 3, 19, NOW()),
|
||||||
(15, 3, 19, NOW()),
|
(15, 2, 19, NOW()),
|
||||||
(16, 3, 19, NOW()),
|
(16, 3, 19, NOW()),
|
||||||
(17, 3, 19, NOW()),
|
(17, 2, 19, NOW()),
|
||||||
(18, 3, 19, NOW()),
|
(18, 2, 19, NOW()),
|
||||||
(19, 3, 19, NOW()),
|
(19, 2, 19, NOW()),
|
||||||
(20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
(20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||||
(21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
(21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||||
(22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
(22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('Ticket index payout path', () => {
|
||||||
await page.waitForState('ticket.index');
|
await page.waitForState('ticket.index');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check three tickets 2 of a clinet and 1 of another', async() => {
|
it('should check the second ticket from a client and 1 of another', async() => {
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox);
|
await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox);
|
||||||
await page.waitToClick(selectors.ticketsIndex.sixthTicketCheckbox);
|
await page.waitToClick(selectors.ticketsIndex.sixthTicketCheckbox);
|
||||||
|
|
|
@ -265,7 +265,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
|
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
|
||||||
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
|
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
|
||||||
|
|
||||||
if (args.problems != undefined && (!args.from || !args.to))
|
if (args.problems != undefined && (!args.from && !args.to))
|
||||||
throw new UserError('Choose a date range or days forward');
|
throw new UserError('Choose a date range or days forward');
|
||||||
|
|
||||||
let condition;
|
let condition;
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('ticket deleteStowaway()', () => {
|
||||||
await app.models.Stowaway.rawSql(
|
await app.models.Stowaway.rawSql(
|
||||||
`CALL ticketStateUpdate(?, ?)`, [shipId, 'OK']);
|
`CALL ticketStateUpdate(?, ?)`, [shipId, 'OK']);
|
||||||
await app.models.Stowaway.rawSql(
|
await app.models.Stowaway.rawSql(
|
||||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'OK']);
|
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'FREE']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create an stowaway', async() => {
|
it('should create an stowaway', async() => {
|
||||||
|
@ -97,6 +97,6 @@ describe('ticket deleteStowaway()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(shipState.name).toEqual('OK');
|
expect(shipState.name).toEqual('Libre');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,16 @@ describe('ticket filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on true', async() => {
|
it('should return the tickets matching the problems on true', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}};
|
const yesterday = new Date();
|
||||||
|
yesterday.setHours(0, 0, 0, 0);
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||||
|
problems: true,
|
||||||
|
from: yesterday,
|
||||||
|
to: today
|
||||||
|
}};
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await app.models.Ticket.filter(ctx, filter);
|
const result = await app.models.Ticket.filter(ctx, filter);
|
||||||
|
|
||||||
|
@ -19,11 +28,21 @@ describe('ticket filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on false', async() => {
|
it('should return the tickets matching the problems on false', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}};
|
const yesterday = new Date();
|
||||||
|
yesterday.setDate(yesterday.getDate() - 1);
|
||||||
|
yesterday.setHours(0, 0, 0, 0);
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||||
|
problems: false,
|
||||||
|
from: yesterday,
|
||||||
|
to: today
|
||||||
|
}};
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await app.models.Ticket.filter(ctx, filter);
|
const result = await app.models.Ticket.filter(ctx, filter);
|
||||||
|
|
||||||
expect(result.length).toEqual(20);
|
expect(result.length).toEqual(11);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on null', async() => {
|
it('should return the tickets matching the problems on null', async() => {
|
||||||
|
@ -52,10 +71,10 @@ describe('ticket filter()', () => {
|
||||||
const secondRow = result[1];
|
const secondRow = result[1];
|
||||||
const thirdRow = result[2];
|
const thirdRow = result[2];
|
||||||
|
|
||||||
expect(result.length).toEqual(3);
|
expect(result.length).toEqual(7);
|
||||||
expect(firstRow.state).toEqual('Arreglar');
|
expect(firstRow.state).toEqual('Libre');
|
||||||
expect(secondRow.state).toEqual('Arreglar');
|
expect(secondRow.state).toEqual('Libre');
|
||||||
expect(thirdRow.state).toEqual('Arreglar');
|
expect(thirdRow.state).toEqual('Libre');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets that are not pending', async() => {
|
it('should return the tickets that are not pending', async() => {
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
panel="vn-ticket-search-panel"
|
panel="vn-ticket-search-panel"
|
||||||
info="Search ticket by id or alias"
|
info="Search ticket by id or alias"
|
||||||
model="model"
|
model="model"
|
||||||
fetch-params="$ctrl.fetchParams($params)">
|
fetch-params="$ctrl.fetchParams($params)"
|
||||||
|
suggested-filter="$ctrl.defaultFilter">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-portal>
|
</vn-portal>
|
||||||
<vn-portal slot="menu">
|
<vn-portal slot="menu">
|
||||||
|
|
|
@ -2,6 +2,14 @@ import ngModule from '../module';
|
||||||
import ModuleMain from 'salix/components/module-main';
|
import ModuleMain from 'salix/components/module-main';
|
||||||
|
|
||||||
export default class Ticket extends ModuleMain {
|
export default class Ticket extends ModuleMain {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.defaultFilter = {
|
||||||
|
scopeDays: 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fetchParams($params) {
|
fetchParams($params) {
|
||||||
if (!Object.entries($params).length)
|
if (!Object.entries($params).length)
|
||||||
$params.scopeDays = 1;
|
$params.scopeDays = 1;
|
||||||
|
|
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
zoneFk: id
|
zoneFk: id,
|
||||||
|
shipped: {gte: today}
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
relation: 'ticketState',
|
relation: 'ticketState',
|
||||||
|
@ -46,10 +47,10 @@ module.exports = Self => {
|
||||||
where: {userFk: userId}
|
where: {userFk: userId}
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
ticketList.forEach(ticket => {
|
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], options);
|
||||||
promises.push(ticket.updateAttributes({zoneFk: null}, options));
|
|
||||||
|
|
||||||
if (ticket.ticketState().alertLevel == 0 && ticket.shipped >= today) {
|
ticketList.forEach(ticket => {
|
||||||
|
if (ticket.ticketState().alertLevel == 0) {
|
||||||
promises.push(models.TicketTracking.create({
|
promises.push(models.TicketTracking.create({
|
||||||
ticketFk: ticket.id,
|
ticketFk: ticket.id,
|
||||||
stateFk: fixingState.id,
|
stateFk: fixingState.id,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
This zone contains tickets: Esta zona contiene {{ticketsAmount}} tickets. ¿Seguro que quieres eliminar esta zona?
|
This zone contains tickets: Esta zona contiene {{ticketsAmount}} tickets por servir. ¿Seguro que quieres eliminar esta zona?
|
||||||
Do you want to clone this zone?: ¿Quieres clonar esta zona?
|
Do you want to clone this zone?: ¿Quieres clonar esta zona?
|
||||||
All it's properties will be copied: Todas sus propiedades serán copiadas
|
All it's properties will be copied: Todas sus propiedades serán copiadas
|
||||||
Zone deleted: Zona eliminada
|
Zone deleted: Zona eliminada
|
Loading…
Reference in New Issue