Compare commits
5 Commits
dev
...
6276_newWa
Author | SHA1 | Date |
---|---|---|
Sergio De la torre | a61b1c0eef | |
Sergio De la torre | 650c31e4ae | |
Sergio De la torre | b84351e060 | |
Sergio De la torre | 99689917f5 | |
Jorge Penadés | d2b237bf24 |
|
@ -1,31 +1,32 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('assign', {
|
||||
description: 'Assign a collection',
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/assign`,
|
||||
verb: 'POST'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
});
|
||||
|
||||
Self.assign = async(ctx, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [,, {collectionFk}] = await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
[userId], myOptions);
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
||||
return collectionFk;
|
||||
};
|
||||
};
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('assign', {
|
||||
description: 'Assign a collection',
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/assign`,
|
||||
verb: 'POST'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
});
|
||||
|
||||
Self.assign = async(ctx, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [, , [{collectionFk}]] =
|
||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
[userId], myOptions);
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
||||
return collectionFk;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,132 +1,132 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('machineWorker updateInTime()', () => {
|
||||
const itBoss = 104;
|
||||
const davidCharles = 1106;
|
||||
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should throw an error if the plate does not exist', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const plate = 'RE-123';
|
||||
ctx.req.accessToken.userId = 1106;
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toContain('the plate does not exist');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should grab a machine where is not in use', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const plate = 'RE-003';
|
||||
ctx.req.accessToken.userId = 1107;
|
||||
try {
|
||||
const totalBefore = await models.MachineWorker.find(null, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const totalAfter = await models.MachineWorker.find(null, options);
|
||||
|
||||
expect(totalAfter.length).toEqual(totalBefore.length + 1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
describe('less than 12h', () => {
|
||||
const plate = 'RE-001';
|
||||
it('should trow an error if it is not himself', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = davidCharles;
|
||||
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toContain('This machine is already in use');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if it is himself with a different machine', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = itBoss;
|
||||
const plate = 'RE-003';
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toEqual('You are already using a machine');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should set the out time if it is himself', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = itBoss;
|
||||
|
||||
try {
|
||||
const isNotParked = await models.MachineWorker.findOne({
|
||||
where: {workerFk: itBoss}
|
||||
}, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const isParked = await models.MachineWorker.findOne({
|
||||
where: {workerFk: itBoss}
|
||||
}, options);
|
||||
|
||||
expect(isNotParked.outTime).toBeNull();
|
||||
expect(isParked.outTime).toBeDefined();
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('equal or more than 12h', () => {
|
||||
const plate = 'RE-002';
|
||||
it('should set the out time and grab the machine', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = davidCharles;
|
||||
const filter = {
|
||||
where: {workerFk: davidCharles, machineFk: 2}
|
||||
};
|
||||
try {
|
||||
const isNotParked = await models.MachineWorker.findOne(filter, options);
|
||||
const totalBefore = await models.MachineWorker.find(null, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const isParked = await models.MachineWorker.findOne(filter, options);
|
||||
const totalAfter = await models.MachineWorker.find(null, options);
|
||||
|
||||
expect(isNotParked.outTime).toBeNull();
|
||||
expect(isParked.outTime).toBeDefined();
|
||||
expect(totalAfter.length).toEqual(totalBefore.length + 1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('machineWorker updateInTime()', () => {
|
||||
const itBoss = 104;
|
||||
const davidCharles = 1106;
|
||||
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should throw an error if the plate does not exist', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const plate = 'RE-123';
|
||||
ctx.req.accessToken.userId = 1106;
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toContain('the plate does not exist');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should grab a machine where is not in use', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const plate = 'RE-003';
|
||||
ctx.req.accessToken.userId = 1107;
|
||||
try {
|
||||
const totalBefore = await models.MachineWorker.find(null, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const totalAfter = await models.MachineWorker.find(null, options);
|
||||
|
||||
expect(totalAfter.length).toEqual(totalBefore.length + 1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
describe('less than 12h', () => {
|
||||
const plate = 'RE-001';
|
||||
it('should trow an error if it is not himself', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = davidCharles;
|
||||
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toContain('This machine is already in use');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if it is himself with a different machine', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = itBoss;
|
||||
const plate = 'RE-003';
|
||||
try {
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toEqual('You are already using a machine');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should set the out time if it is himself', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = itBoss;
|
||||
|
||||
try {
|
||||
const isNotParked = await models.MachineWorker.findOne({
|
||||
where: {workerFk: itBoss}
|
||||
}, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const isParked = await models.MachineWorker.findOne({
|
||||
where: {workerFk: itBoss}
|
||||
}, options);
|
||||
|
||||
expect(isNotParked.outTime).toBeNull();
|
||||
expect(isParked.outTime).toBeDefined();
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('equal or more than 12h', () => {
|
||||
const plate = 'RE-002';
|
||||
it('should set the out time and grab the machine', async() => {
|
||||
const tx = await models.MachineWorker.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = davidCharles;
|
||||
const filter = {
|
||||
where: {workerFk: davidCharles, machineFk: 2}
|
||||
};
|
||||
try {
|
||||
const isNotParked = await models.MachineWorker.findOne(filter, options);
|
||||
const totalBefore = await models.MachineWorker.find(null, options);
|
||||
await models.MachineWorker.updateInTime(ctx, plate, options);
|
||||
const isParked = await models.MachineWorker.findOne(filter, options);
|
||||
const totalAfter = await models.MachineWorker.find(null, options);
|
||||
|
||||
expect(isNotParked.outTime).toBeNull();
|
||||
expect(isParked.outTime).toBeDefined();
|
||||
expect(totalAfter.length).toEqual(totalBefore.length);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateInTime', {
|
||||
description: 'Updates the corresponding registry if the worker has been registered in the last few hours',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'plate',
|
||||
type: 'string',
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/updateInTime`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateInTime = async(ctx, plate, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const machine = await models.Machine.findOne({
|
||||
fields: ['id', 'plate'],
|
||||
where: {plate}
|
||||
}, myOptions);
|
||||
|
||||
if (!machine)
|
||||
throw new Error($t('the plate does not exist', {plate}));
|
||||
|
||||
const machineWorker = await Self.findOne({
|
||||
where: {
|
||||
or: [{machineFk: machine.id}, {workerFk: userId}],
|
||||
outTime: null,
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
|
||||
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
|
||||
|
||||
if (machineWorker) {
|
||||
const isHimself = userId == machineWorker.workerFk;
|
||||
const isSameMachine = machine.id == machineWorker.machineFk;
|
||||
|
||||
if (hoursDifference < maxHours && !isHimself)
|
||||
throw new UserError($t('This machine is already in use.'));
|
||||
|
||||
if (hoursDifference < maxHours && isHimself && !isSameMachine)
|
||||
throw new UserError($t('You are already using a machine'));
|
||||
|
||||
await machineWorker.updateAttributes({
|
||||
outTime: Date.vnNew()
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
if (!machineWorker || hoursDifference >= maxHours)
|
||||
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateInTime', {
|
||||
description: 'Updates the corresponding registry if the worker has been registered in the last few hours',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'plate',
|
||||
type: 'string',
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/updateInTime`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateInTime = async(ctx, plate, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__;
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const machine = await models.Machine.findOne({
|
||||
fields: ['id', 'plate'],
|
||||
where: {plate}
|
||||
}, myOptions);
|
||||
|
||||
if (!machine)
|
||||
throw new Error($t('the plate does not exist', {plate}));
|
||||
|
||||
const machineWorker = await Self.findOne({
|
||||
where: {
|
||||
or: [{machineFk: machine.id}, {workerFk: userId}],
|
||||
outTime: null,
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
|
||||
const hoursDifference = (Date.vnNow() - machineWorker?.inTimed?.getTime() ?? 0) / (60 * 60 * 1000);
|
||||
|
||||
if (machineWorker) {
|
||||
const isHimself = userId == machineWorker.workerFk;
|
||||
const isSameMachine = machine.id == machineWorker.machineFk;
|
||||
|
||||
if (hoursDifference < maxHours && !isHimself)
|
||||
throw new UserError($t('This machine is already in use.'));
|
||||
|
||||
if (hoursDifference < maxHours && isHimself && !isSameMachine)
|
||||
throw new UserError($t('You are already using a machine'));
|
||||
|
||||
await machineWorker.updateAttributes({
|
||||
outTime: Date.vnNew()
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
if (!machineWorker || hoursDifference >= maxHours)
|
||||
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,45 +1,50 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getVersion', {
|
||||
description: 'gets app version data',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'app',
|
||||
type: 'string',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getVersion`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getVersion = async(ctx, app) => {
|
||||
const {models} = Self.app;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const workerFk = await models.WorkerAppTester.findOne({
|
||||
where: {
|
||||
workerFk: userId
|
||||
}
|
||||
});
|
||||
let fields = ['id', 'appName'];
|
||||
|
||||
if (workerFk)
|
||||
fields = fields.concat(['isVersionBetaCritical', 'versionBeta', 'urlBeta']);
|
||||
else
|
||||
fields = fields.concat(['isVersionCritical', 'version', 'urlProduction']);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
appName: app
|
||||
},
|
||||
fields,
|
||||
};
|
||||
|
||||
return Self.findOne(filter);
|
||||
};
|
||||
};
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getVersion', {
|
||||
description: 'gets app version data',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'app',
|
||||
type: 'string',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getVersion`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getVersion = async(ctx, app) => {
|
||||
const {models} = Self.app;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const workerFk = await models.WorkerAppTester.findOne({
|
||||
where: {
|
||||
workerFk: userId
|
||||
}
|
||||
});
|
||||
let fields = ['id', 'appName'];
|
||||
|
||||
if (workerFk)
|
||||
fields = fields.concat(['isVersionBetaCritical', 'versionBeta', 'urlBeta']);
|
||||
else
|
||||
fields = fields.concat(['isVersionCritical', 'version', 'urlProduction']);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
appName: app
|
||||
},
|
||||
fields,
|
||||
};
|
||||
|
||||
const result = await Self.findOne(filter);
|
||||
return {
|
||||
isVersionCritical: result?.isVersionBetaCritical ?? result?.isVersionCritical,
|
||||
version: result?.versionBeta ?? result?.version,
|
||||
url: result?.urlBeta ?? result?.urlProduction
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('mobileAppVersionControl getVersion()', () => {
|
||||
const appName = 'delivery';
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {},
|
||||
headers: {origin: 'http://localhost'},
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should get the version app', async() => {
|
||||
ctx.req.accessToken.userId = 9;
|
||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(version).toEqual('9.2');
|
||||
expect(versionBeta).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should get the beta version app', async() => {
|
||||
ctx.req.accessToken.userId = 66;
|
||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(versionBeta).toBeDefined();
|
||||
expect(version).toBeUndefined();
|
||||
});
|
||||
});
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('mobileAppVersionControl getVersion()', () => {
|
||||
const appName = 'delivery';
|
||||
const appNameVersion = '9.2';
|
||||
const appNameVersionBeta = '9.7';
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {},
|
||||
headers: {origin: 'http://localhost'},
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should get the version app', async() => {
|
||||
ctx.req.accessToken.userId = 9;
|
||||
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(version).toEqual(appNameVersion);
|
||||
});
|
||||
|
||||
it('should get the beta version app', async() => {
|
||||
ctx.req.accessToken.userId = 66;
|
||||
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(version).toEqual(appNameVersionBeta);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
|
||||
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
|
||||
('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
|
||||
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'),
|
||||
('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
|
||||
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('ItemBarcode', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
|
||||
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
|
||||
('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
|
||||
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'),
|
||||
('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
|
||||
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('ItemBarcode', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||
('Ticket', 'addSaleByCode', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
|
@ -89,16 +89,9 @@ module.exports = Self => {
|
|||
const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions);
|
||||
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
|
||||
} catch (e) {
|
||||
throw new UserError('The sale cannot be tracked');
|
||||
if (tx) await tx.commit();
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (e.message == 'The sale cannot be tracked') {
|
||||
if (tx) tx.commit();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (tx) await tx.rollback();
|
||||
throw new UserError('The line could not be marked');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue