Compare commits
9 Commits
f63b26b71f
...
9bcd0a3c98
Author | SHA1 | Date |
---|---|---|
David Domenech | 9bcd0a3c98 | |
David Domenech | fb74ea3b2c | |
David Domenech | d4fa1e9aca | |
David Domenech | 2f61b648f7 | |
David Domenech | ee6ad55e66 | |
Pablo Natek | 303b6f5240 | |
Pablo Natek | bec1ff71ef | |
David Domenech | eb0766bafd | |
David Domenech | 8ab981907d |
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`ticketTracking` CHANGE `workerFk` `userFk` int(10) unsigned DEFAULT NULL NULL;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,52 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`ticketState`
|
||||
AS SELECT `tt`.`created` AS `updated`,
|
||||
`tt`.`stateFk` AS `stateFk`,
|
||||
`tt`.`userFk` AS `userFk`,
|
||||
`tls`.`ticketFk` AS `ticketFk`,
|
||||
`s`.`id` AS `state`,
|
||||
`s`.`order` AS `productionOrder`,
|
||||
`s`.`alertLevel` AS `alertLevel`,
|
||||
`s`.`code` AS `code`,
|
||||
`tls`.`ticketFk` AS `ticket`,
|
||||
`tt`.`userFk` AS `worker`,
|
||||
`s`.`isPreviousPreparable` AS `isPreviousPreparable`,
|
||||
`s`.`isPicked` AS `isPicked`
|
||||
FROM (
|
||||
(
|
||||
`vn`.`ticketLastState` `tls`
|
||||
JOIN `vn`.`ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
|
||||
)
|
||||
JOIN `vn`.`state` `s` ON(`s`.`id` = `tt`.`stateFk`)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`v_inter`
|
||||
AS SELECT `tt`.`id` AS `inter_id`,
|
||||
`tt`.`stateFk` AS `state_id`,
|
||||
`tt`.`notes` AS `nota`,
|
||||
`tt`.`created` AS `odbc_date`,
|
||||
`tt`.`ticketFk` AS `Id_Ticket`,
|
||||
`tt`.`userFk` AS `Id_Trabajador`,
|
||||
`tt`.`supervisorFk` AS `Id_supervisor`
|
||||
FROM `vn`.`ticketTracking` `tt`;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `ticketStateToday` AS
|
||||
SELECT
|
||||
`ts`.`ticket` AS `ticket`,
|
||||
`ts`.`state` AS `state`,
|
||||
`ts`.`productionOrder` AS `productionOrder`,
|
||||
`ts`.`alertLevel` AS `alertLevel`,
|
||||
`ts`.`userFk` AS `userFk`,
|
||||
`ts`.`code` AS `code`,
|
||||
`ts`.`updated` AS `updated`,
|
||||
`ts`.`isPicked` AS `isPicked`
|
||||
FROM
|
||||
(`ticketState` `ts`
|
||||
JOIN `ticket` `t` ON
|
||||
(`t`.`id` = `ts`.`ticket`))
|
||||
WHERE
|
||||
`t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`());
|
|
@ -771,7 +771,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
|||
-- FIX for state hours on local, inter_afterInsert
|
||||
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
|
||||
|
||||
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
|
||||
VALUES
|
||||
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
||||
(2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
||||
|
@ -815,6 +815,7 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
|
|||
VALUES
|
||||
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
|
||||
|
||||
|
||||
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
||||
VALUES
|
||||
(1, 'Diff', 'diff'),
|
||||
|
|
|
@ -123,7 +123,7 @@ module.exports = Self => {
|
|||
await models.TicketTracking.create({
|
||||
ticketFk: newRefundTicket.id,
|
||||
stateFk: state.id,
|
||||
workerFk: worker.id
|
||||
userFk: worker.id
|
||||
}, myOptions);
|
||||
|
||||
const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);
|
||||
|
|
|
@ -94,10 +94,10 @@ describe('ticket state()', () => {
|
|||
|
||||
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
||||
|
||||
expect(ticketTracking.__data.ticketFk).toBe(params.ticketFk);
|
||||
expect(ticketTracking.__data.stateFk).toBe(params.stateFk);
|
||||
expect(ticketTracking.__data.workerFk).toBe(49);
|
||||
expect(ticketTracking.__data.id).toBeDefined();
|
||||
expect(ticketTracking.ticketFk).toBe(params.ticketFk);
|
||||
expect(ticketTracking.stateFk).toBe(params.stateFk);
|
||||
expect(ticketTracking.userFk).toBe(49);
|
||||
expect(ticketTracking.id).toBeDefined();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -116,14 +116,14 @@ describe('ticket state()', () => {
|
|||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
const ctx = {req: {accessToken: {userId: 18}}};
|
||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||
const params = {ticketFk: ticket.id, stateFk: assignedState.id, workerFk: 1};
|
||||
const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
||||
const res = await models.Ticket.state(ctx, params, options);
|
||||
|
||||
expect(res.__data.ticketFk).toBe(params.ticketFk);
|
||||
expect(res.__data.stateFk).toBe(params.stateFk);
|
||||
expect(res.__data.workerFk).toBe(params.workerFk);
|
||||
expect(res.__data.workerFk).toBe(1);
|
||||
expect(res.__data.id).toBeDefined();
|
||||
expect(res.ticketFk).toBe(params.ticketFk);
|
||||
expect(res.stateFk).toBe(params.stateFk);
|
||||
expect(res.userFk).toBe(params.userFk);
|
||||
expect(res.userFk).toBe(1);
|
||||
expect(res.id).toBeDefined();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -51,12 +51,12 @@ module.exports = Self => {
|
|||
params.stateFk = state.id;
|
||||
}
|
||||
|
||||
if (!params.workerFk) {
|
||||
if (!params.userFk) {
|
||||
const worker = await models.Worker.findOne({
|
||||
where: {id: userId}
|
||||
}, myOptions);
|
||||
|
||||
params.workerFk = worker.id;
|
||||
params.userFk = worker.id;
|
||||
}
|
||||
|
||||
const ticketState = await models.TicketState.findById(params.ticketFk, {
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
"model": "State",
|
||||
"foreignKey": "stateFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ module.exports = function(Self) {
|
|||
require('../methods/ticket-tracking/setDelivered')(Self);
|
||||
|
||||
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
|
||||
Self.validatesPresenceOf('workerFk', {message: 'Worker cannot be blank'});
|
||||
Self.validatesPresenceOf('userFk', {message: 'Worker cannot be blank'});
|
||||
};
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
"type": "date"
|
||||
},
|
||||
"ticketFk": {
|
||||
"type": "number"
|
||||
"type": "number"
|
||||
},
|
||||
"stateFk": {
|
||||
"type": "number"
|
||||
"type": "number"
|
||||
},
|
||||
"workerFk": {
|
||||
"type": "number"
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -36,10 +36,10 @@
|
|||
"model": "State",
|
||||
"foreignKey": "stateFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,9 @@ class Controller extends Section {
|
|||
this.filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'worker',
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
fields: ['name']
|
||||
}
|
||||
}, {
|
||||
relation: 'state',
|
||||
|
|
|
@ -64,7 +64,7 @@ module.exports = Self => {
|
|||
promises.push(models.TicketTracking.create({
|
||||
ticketFk: ticket.id,
|
||||
stateFk: fixingState.id,
|
||||
workerFk: worker.id
|
||||
userFk: worker.id
|
||||
}, myOptions));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue