#6264 - renewToken #1824
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`ticketTracking` CHANGE `workerFk` `userFk` int(10) unsigned DEFAULT NULL NULL;
|
|
@ -0,0 +1,4 @@
|
||||||
|
RENAME TABLE `vn`.`clientCreditLimit` TO `vn`.`roleCreditLimit`;
|
||||||
|
ALTER TABLE `vn`.`clientCreditLimit` DROP FOREIGN KEY `clientCreditLimit_FK`;
|
||||||
|
ALTER TABLE `vn`.`roleCreditLimit` ADD CONSTRAINT `roleCreditLimit_FK` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
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`());
|
|
@ -493,7 +493,7 @@ INSERT INTO `vn`.`clientCredit`(`clientFk`, `workerFk`, `amount`, `created`)
|
||||||
(1104, 9, 90 , util.VN_CURDATE()),
|
(1104, 9, 90 , util.VN_CURDATE()),
|
||||||
(1105, 9, 90 , util.VN_CURDATE());
|
(1105, 9, 90 , util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 9999999, 20),
|
(1, 9999999, 20),
|
||||||
(2, 10000, 21),
|
(2, 10000, 21),
|
||||||
|
@ -771,7 +771,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
||||||
-- FIX for state hours on local, inter_afterInsert
|
-- FIX for state hours on local, inter_afterInsert
|
||||||
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
|
-- 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
|
VALUES
|
||||||
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
||||||
(2, 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
|
VALUES
|
||||||
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
|
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Diff', 'diff'),
|
(1, 'Diff', 'diff'),
|
||||||
|
|
|
@ -123,7 +123,7 @@ module.exports = Self => {
|
||||||
await models.TicketTracking.create({
|
await models.TicketTracking.create({
|
||||||
ticketFk: newRefundTicket.id,
|
ticketFk: newRefundTicket.id,
|
||||||
stateFk: state.id,
|
stateFk: state.id,
|
||||||
workerFk: worker.id
|
userFk: worker.id
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);
|
const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"ClientCredit": {
|
"ClientCredit": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ClientCreditLimit": {
|
"RoleCreditLimit": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ClientConsumptionQueue": {
|
"ClientConsumptionQueue": {
|
||||||
|
|
|
@ -463,7 +463,7 @@ module.exports = Self => {
|
||||||
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
|
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const creditLimits = await models.ClientCreditLimit.find({
|
const creditLimits = await models.RoleCreditLimit.find({
|
||||||
fields: ['roleFk'],
|
fields: ['roleFk'],
|
||||||
where: {
|
where: {
|
||||||
maxAmount: {gte: changes.credit}
|
maxAmount: {gte: changes.credit}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClientCreditLimit",
|
"name": "RoleCreditLimit",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientCreditLimit"
|
"table": "roleCreditLimit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
|
@ -94,10 +94,10 @@ describe('ticket state()', () => {
|
||||||
|
|
||||||
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
expect(ticketTracking.__data.ticketFk).toBe(params.ticketFk);
|
expect(ticketTracking.ticketFk).toBe(params.ticketFk);
|
||||||
expect(ticketTracking.__data.stateFk).toBe(params.stateFk);
|
expect(ticketTracking.stateFk).toBe(params.stateFk);
|
||||||
expect(ticketTracking.__data.workerFk).toBe(49);
|
expect(ticketTracking.userFk).toBe(49);
|
||||||
expect(ticketTracking.__data.id).toBeDefined();
|
expect(ticketTracking.id).toBeDefined();
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -116,14 +116,14 @@ describe('ticket state()', () => {
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
const ctx = {req: {accessToken: {userId: 18}}};
|
const ctx = {req: {accessToken: {userId: 18}}};
|
||||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
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);
|
const res = await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
expect(res.__data.ticketFk).toBe(params.ticketFk);
|
expect(res.ticketFk).toBe(params.ticketFk);
|
||||||
expect(res.__data.stateFk).toBe(params.stateFk);
|
expect(res.stateFk).toBe(params.stateFk);
|
||||||
expect(res.__data.workerFk).toBe(params.workerFk);
|
expect(res.userFk).toBe(params.userFk);
|
||||||
expect(res.__data.workerFk).toBe(1);
|
expect(res.userFk).toBe(1);
|
||||||
expect(res.__data.id).toBeDefined();
|
expect(res.id).toBeDefined();
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -51,12 +51,12 @@ module.exports = Self => {
|
||||||
params.stateFk = state.id;
|
params.stateFk = state.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.workerFk) {
|
if (!params.userFk) {
|
||||||
const worker = await models.Worker.findOne({
|
const worker = await models.Worker.findOne({
|
||||||
where: {id: userId}
|
where: {id: userId}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
params.workerFk = worker.id;
|
params.userFk = worker.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ticketState = await models.TicketState.findById(params.ticketFk, {
|
const ticketState = await models.TicketState.findById(params.ticketFk, {
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
"model": "State",
|
"model": "State",
|
||||||
"foreignKey": "stateFk"
|
"foreignKey": "stateFk"
|
||||||
},
|
},
|
||||||
"worker": {
|
"user": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Worker",
|
"model": "VnUser",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket-tracking/setDelivered')(Self);
|
require('../methods/ticket-tracking/setDelivered')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
|
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": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"id": true,
|
"id": true,
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"forceId": false
|
"forceId": false
|
||||||
},
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
},
|
},
|
||||||
"ticketFk": {
|
"ticketFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"stateFk": {
|
"stateFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"workerFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
"model": "State",
|
"model": "State",
|
||||||
"foreignKey": "stateFk"
|
"foreignKey": "stateFk"
|
||||||
},
|
},
|
||||||
"worker": {
|
"user": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Worker",
|
"model": "VnUser",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,9 @@ class Controller extends Section {
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'worker',
|
relation: 'user',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id'],
|
fields: ['name']
|
||||||
include: {
|
|
||||||
relation: 'user',
|
|
||||||
scope: {
|
|
||||||
fields: ['name']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
relation: 'state',
|
relation: 'state',
|
||||||
|
|
|
@ -64,7 +64,7 @@ module.exports = Self => {
|
||||||
promises.push(models.TicketTracking.create({
|
promises.push(models.TicketTracking.create({
|
||||||
ticketFk: ticket.id,
|
ticketFk: ticket.id,
|
||||||
stateFk: fixingState.id,
|
stateFk: fixingState.id,
|
||||||
workerFk: worker.id
|
userFk: worker.id
|
||||||
}, myOptions));
|
}, myOptions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue