#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()),
|
||||
(1105, 9, 90 , util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||
INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||
VALUES
|
||||
(1, 9999999, 20),
|
||||
(2, 10000, 21),
|
||||
|
@ -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);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"ClientCredit": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ClientCreditLimit": {
|
||||
"RoleCreditLimit": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ClientConsumptionQueue": {
|
||||
|
|
|
@ -463,7 +463,7 @@ module.exports = Self => {
|
|||
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'],
|
||||
where: {
|
||||
maxAmount: {gte: changes.credit}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "ClientCreditLimit",
|
||||
"name": "RoleCreditLimit",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "clientCreditLimit"
|
||||
"table": "roleCreditLimit"
|
||||
}
|
||||
},
|
||||
"properties": {
|
|
@ -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": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
"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'});
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"stateFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"workerFk": {
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
|
@ -36,10 +36,10 @@
|
|||
"model": "State",
|
||||
"foreignKey": "stateFk"
|
||||
},
|
||||
"worker": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,10 @@ class Controller extends Section {
|
|||
this.filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'state',
|
||||
scope: {
|
||||
|
|
|
@ -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