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 |
|
@ -20,7 +20,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const [,, {collectionFk}] = await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
const [, , [{collectionFk}]] =
|
||||||
|
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||||
[userId], myOptions);
|
[userId], myOptions);
|
||||||
|
|
||||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||||
|
|
|
@ -122,7 +122,7 @@ describe('machineWorker updateInTime()', () => {
|
||||||
|
|
||||||
expect(isNotParked.outTime).toBeNull();
|
expect(isNotParked.outTime).toBeNull();
|
||||||
expect(isParked.outTime).toBeDefined();
|
expect(isParked.outTime).toBeDefined();
|
||||||
expect(totalAfter.length).toEqual(totalBefore.length + 1);
|
expect(totalAfter.length).toEqual(totalBefore.length);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
|
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
|
||||||
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
|
const hoursDifference = (Date.vnNow() - machineWorker?.inTimed?.getTime() ?? 0) / (60 * 60 * 1000);
|
||||||
|
|
||||||
if (machineWorker) {
|
if (machineWorker) {
|
||||||
const isHimself = userId == machineWorker.workerFk;
|
const isHimself = userId == machineWorker.workerFk;
|
||||||
|
|
|
@ -40,6 +40,11 @@ module.exports = Self => {
|
||||||
fields,
|
fields,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Self.findOne(filter);
|
const result = await Self.findOne(filter);
|
||||||
|
return {
|
||||||
|
isVersionCritical: result?.isVersionBetaCritical ?? result?.isVersionCritical,
|
||||||
|
version: result?.versionBeta ?? result?.version,
|
||||||
|
url: result?.urlBeta ?? result?.urlProduction
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,8 @@ const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('mobileAppVersionControl getVersion()', () => {
|
describe('mobileAppVersionControl getVersion()', () => {
|
||||||
const appName = 'delivery';
|
const appName = 'delivery';
|
||||||
|
const appNameVersion = '9.2';
|
||||||
|
const appNameVersionBeta = '9.7';
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
ctx = {
|
ctx = {
|
||||||
req: {
|
req: {
|
||||||
|
@ -13,17 +15,15 @@ describe('mobileAppVersionControl getVersion()', () => {
|
||||||
|
|
||||||
it('should get the version app', async() => {
|
it('should get the version app', async() => {
|
||||||
ctx.req.accessToken.userId = 9;
|
ctx.req.accessToken.userId = 9;
|
||||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||||
|
|
||||||
expect(version).toEqual('9.2');
|
expect(version).toEqual(appNameVersion);
|
||||||
expect(versionBeta).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get the beta version app', async() => {
|
it('should get the beta version app', async() => {
|
||||||
ctx.req.accessToken.userId = 66;
|
ctx.req.accessToken.userId = 66;
|
||||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||||
|
|
||||||
expect(versionBeta).toBeDefined();
|
expect(version).toEqual(appNameVersionBeta);
|
||||||
expect(version).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
VALUES
|
VALUES
|
||||||
('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||||
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'production'),
|
|
||||||
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
|
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
|
||||||
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
|
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
|
||||||
('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
|
('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
|
||||||
|
@ -9,4 +8,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
|
||||||
('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
|
('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
|
||||||
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
|
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||||
('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
|
('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||||
('ItemBarcode', 'delete', 'WRITE', '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);
|
const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions);
|
||||||
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
|
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
|
||||||
} catch (e) {
|
} 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;
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw new UserError('The line could not be marked');
|
throw new UserError('The line could not be marked');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue