Compare commits

...

42 Commits

Author SHA1 Message Date
Jorge Penadés 3c0627e077 Merge branch 'dev' into 5919-locker 2024-05-13 13:02:17 +00:00
Jorge Penadés b902a1a7f7 Merge branch 'dev' into 5919-locker
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-05-13 12:02:17 +00:00
Jorge Penadés 1f39330041 fix: refs #5919 drop focus 2024-05-13 14:00:19 +02:00
Jorge Penadés 5d5f1ef7c5 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-13 13:20:32 +02:00
Jorge Penadés e16e5e3db3 feat: refs #5919 back test 2024-05-13 13:19:28 +02:00
Jorge Penadés 29e3f934af Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-13 09:35:08 +02:00
Jorge Penadés 562aefecdd Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-13 08:56:54 +02:00
Jorge Penadés cbb7cb18eb fix: refs #5919 delete locker field 2024-05-10 16:02:50 +02:00
Jorge Penadés 8943bc7115 fix: refs #5919 back tests 2024-05-10 14:04:34 +02:00
Jorge Penadés 1996a00af1 feat: refs #5919 drop version 2024-05-10 13:31:21 +02:00
Jorge Penadés 8876a7ea8f Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-10 13:05:22 +02:00
Jorge Penadés af11bb8663 feat: refs #5919 hook 2024-05-10 13:04:12 +02:00
Jorge Penadés 4e7d0e6469 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-10 08:28:06 +02:00
Jorge Penadés 7f4965879c fix: refs #5919 get locker by relation 2024-05-09 15:54:34 +02:00
Jorge Penadés 035782414f Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-09 12:47:25 +02:00
Jorge Penadés 1450a680ea Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-09 12:45:33 +02:00
Jorge Penadés 2c826ed838 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-09 12:14:43 +02:00
Jorge Penadés dc45527e1d Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-09 08:45:17 +02:00
Jorge Penadés 26ff5e8fa9 feat; refs #5919 WIP acls 2024-05-08 11:03:18 +02:00
Jorge Penadés d0c9e83504 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-08 10:35:07 +02:00
Jorge Penadés 63655a4dd1 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-05-02 08:58:51 +02:00
Jorge Penadés 9802f0066c fix: refs #5919 unique key & unassigned locker 2024-04-29 16:05:36 +02:00
Jorge Penadés be69b5e2c4 fix: refs #5919 rollback 2024-04-29 12:04:31 +02:00
Jorge Penadés f6e89c9049 fix: refs #5919 rollback 2024-04-29 11:46:58 +02:00
Jorge Penadés 7240269f5b fix: refs #5919 rollback 2024-04-29 11:45:54 +02:00
Jorge Penadés 50ea41f99a fix: refs #5919 rollback 2024-04-29 11:43:56 +02:00
Jorge Penadés 0003779681 fix: refs 5919 apply version 2024-04-29 11:35:08 +02:00
Jorge Penadés 8adb52aac4 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker 2024-04-29 09:24:10 +02:00
Carlos Satorres bf796c445d refs #5919 fix section
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-01-17 13:20:28 +01:00
Carlos Satorres c0c3d913b7 refs #5919 locker
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-12 09:03:54 +01:00
Carlos Satorres 69739fca9c refs #5919 locker relation
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-03 08:17:37 +01:00
Carlos Satorres e2eebf96f7 refs #5919 locker insert prod
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-29 11:29:48 +01:00
Carlos Satorres 3a429a31da refs #5919 locker
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-29 08:44:42 +01:00
Carlos Satorres 6ceee45b13 refs #5919 fix locker
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-28 16:40:13 +01:00
Carlos Satorres f35b2a4905 refs #5919 back chooseLocker
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-26 13:44:52 +01:00
Carlos Satorres aa33c28468 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker
gitea/salix/pipeline/head This commit looks good Details
2023-12-26 12:15:43 +01:00
Carlos Satorres c5c314eb43 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5919-locker
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-10 11:59:01 +01:00
Carlos Satorres fd64cb7e80 refs #5919 front back
gitea/salix/pipeline/head This commit looks good Details
2023-10-17 13:08:00 +02:00
Carlos Satorres 5a375ebfda refs #5919 front back
gitea/salix/pipeline/head This commit looks good Details
2023-10-16 13:22:36 +02:00
Carlos Satorres 38bf90da66 refs #5919 sql
gitea/salix/pipeline/head There was a failure building this commit Details
2023-10-11 13:26:27 +02:00
Carlos Satorres c061841cac refs #5919 locker and back
gitea/salix/pipeline/head This commit looks good Details
2023-10-10 13:58:33 +02:00
Carlos Satorres 3c58f86c2a refs #5919 locker back y front
gitea/salix/pipeline/head This commit looks good Details
2023-10-10 13:44:22 +02:00
12 changed files with 194 additions and 16 deletions

View File

@ -3789,4 +3789,6 @@ INSERT INTO vn.workerTeam(id, team, workerFk)
(8, 1, 19);
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
UPDATE vn.locker SET workerFk = 1110 WHERE id = 147;

View File

@ -28,5 +28,9 @@ mainLabel:BEGIN
UPDATE `client` c
SET c.salesPersonFk = null
WHERE c.salesPersonFk = vUserId;
UPDATE locker l
SET l.workerFk = NULL
WHERE l.workerFk = vUserId;
END$$
DELIMITER ;

View File

@ -0,0 +1,60 @@
-- Eliminar locker
ALTER TABLE `vn`.`worker` DROP COLUMN `locker`;
CREATE TABLE `vn`.`locker` (
`id` int(100) auto_increment,
`code` varchar(10) DEFAULT NULL,
`gender` ENUM('M','F') DEFAULT NULL,
`workerFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`),
UNIQUE KEY `workerFk` (`workerFk`),
CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
ALTER TABLE `vn`.`workerLog`
MODIFY COLUMN changedModel enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl', 'Locker') NOT NULL DEFAULT 'Worker';
-- Insertar taquillas disponibles para hombres (1A - 73A / 1B - 73B)
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
('1A', 'M', NULL), ('2A', 'M', NULL), ('3A', 'M', NULL), ('4A', 'M', NULL), ('5A', 'M', NULL),
('6A', 'M', NULL), ('7A', 'M', NULL), ('8A', 'M', NULL), ('9A', 'M', NULL), ('10A', 'M', NULL),
('11A', 'M', NULL), ('12A', 'M', NULL), ('13A', 'M', NULL), ('14A', 'M', NULL), ('15A', 'M', NULL),
('16A', 'M', NULL), ('17A', 'M', NULL), ('18A', 'M', NULL), ('19A', 'M', NULL), ('20A', 'M', NULL),
('21A', 'M', NULL), ('22A', 'M', NULL), ('23A', 'M', NULL), ('24A', 'M', NULL), ('25A', 'M', NULL),
('26A', 'M', NULL), ('27A', 'M', NULL), ('28A', 'M', NULL), ('29A', 'M', NULL), ('30A', 'M', NULL),
('31A', 'M', NULL), ('32A', 'M', NULL), ('33A', 'M', NULL), ('34A', 'M', NULL), ('35A', 'M', NULL),
('36A', 'M', NULL), ('37A', 'M', NULL), ('38A', 'M', NULL), ('39A', 'M', NULL), ('40A', 'M', NULL),
('41A', 'M', NULL), ('42A', 'M', NULL), ('43A', 'M', NULL), ('44A', 'M', NULL), ('45A', 'M', NULL),
('46A', 'M', NULL), ('47A', 'M', NULL), ('48A', 'M', NULL), ('49A', 'M', NULL), ('50A', 'M', NULL),
('51A', 'M', NULL), ('52A', 'M', NULL), ('53A', 'M', NULL), ('54A', 'M', NULL), ('55A', 'M', NULL),
('56A', 'M', NULL), ('57A', 'M', NULL), ('58A', 'M', NULL), ('59A', 'M', NULL), ('60A', 'M', NULL),
('61A', 'M', NULL), ('62A', 'M', NULL), ('63A', 'M', NULL), ('64A', 'M', NULL), ('65A', 'M', NULL),
('66A', 'M', NULL), ('67A', 'M', NULL), ('68A', 'M', NULL), ('69A', 'M', NULL), ('70A', 'M', NULL),
('71A', 'M', NULL), ('72A', 'M', NULL), ('73A', 'M', NULL),
('1B', 'M', NULL), ('2B', 'M', NULL), ('3B', 'M', NULL), ('4B', 'M', NULL), ('5B', 'M', NULL),
('6B', 'M', NULL), ('7B', 'M', NULL), ('8B', 'M', NULL), ('9B', 'M', NULL), ('10B', 'M', NULL),
('11B', 'M', NULL), ('12B', 'M', NULL), ('13B', 'M', NULL), ('14B', 'M', NULL), ('15B', 'M', NULL),
('16B', 'M', NULL), ('17B', 'M', NULL), ('18B', 'M', NULL), ('19B', 'M', NULL), ('20B', 'M', NULL),
('21B', 'M', NULL), ('22B', 'M', NULL), ('23B', 'M', NULL), ('24B', 'M', NULL), ('25B', 'M', NULL),
('26B', 'M', NULL), ('27B', 'M', NULL), ('28B', 'M', NULL), ('29B', 'M', NULL), ('30B', 'M', NULL),
('31B', 'M', NULL), ('32B', 'M', NULL), ('33B', 'M', NULL), ('34B', 'M', NULL), ('35B', 'M', NULL),
('36B', 'M', NULL), ('37B', 'M', NULL), ('38B', 'M', NULL), ('39B', 'M', NULL), ('40B', 'M', NULL),
('41B', 'M', NULL), ('42B', 'M', NULL), ('43B', 'M', NULL), ('44B', 'M', NULL), ('45B', 'M', NULL),
('46B', 'M', NULL), ('47B', 'M', NULL), ('48B', 'M', NULL), ('49B', 'M', NULL), ('50B', 'M', NULL),
('51B', 'M', NULL), ('52B', 'M', NULL), ('53B', 'M', NULL), ('54B', 'M', NULL), ('55B', 'M', NULL),
('56B', 'M', NULL), ('57B', 'M', NULL), ('58B', 'M', NULL), ('59B', 'M', NULL), ('60B', 'M', NULL),
('61B', 'M', NULL), ('62B', 'M', NULL), ('63B', 'M', NULL), ('64B', 'M', NULL), ('65B', 'M', NULL),
('66B', 'M', NULL), ('67B', 'M', NULL), ('68B', 'M', NULL), ('69B', 'M', NULL), ('70B', 'M', NULL),
('71B', 'M', NULL), ('72B', 'M', NULL), ('73B', 'M', NULL);
-- Insertar taquillas disponibles para mujeres (200A - 217A / 200B - 217B)
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
('200A', 'F', NULL), ('201A', 'F', NULL), ('202A', 'F', NULL), ('203A', 'F', NULL), ('204A', 'F', NULL),
('205A', 'F', NULL), ('206A', 'F', NULL), ('207A', 'F', NULL), ('208A', 'F', NULL), ('209A', 'F', NULL),
('210A', 'F', NULL), ('211A', 'F', NULL), ('212A', 'F', NULL), ('213A', 'F', NULL), ('214A', 'F', NULL),
('215A', 'F', NULL), ('216A', 'F', NULL), ('217A', 'F', NULL),
('200B', 'F', NULL), ('201B', 'F', NULL), ('202B', 'F', NULL), ('203B', 'F', NULL), ('204B', 'F', NULL),
('205B', 'F', NULL), ('206B', 'F', NULL), ('207B', 'F', NULL), ('208B', 'F', NULL), ('209B', 'F', NULL),
('210B', 'F', NULL), ('211B', 'F', NULL), ('212B', 'F', NULL), ('213B', 'F', NULL), ('214B', 'F', NULL),
('215B', 'F', NULL), ('216B', 'F', NULL), ('217B', 'F', NULL);

View File

@ -0,0 +1,6 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES ('Locker', '__get__codes', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Locker', '*', '*', 'ALLOW', 'ROLE', 'hr'),
('Locker', '*', '*', 'ALLOW', 'ROLE', 'productionBoss'),
('Worker', '__get__locker', 'READ', 'ALLOW', 'ROLE', 'hr'),
('Worker', '__get__locker', 'READ', 'ALLOW', 'ROLE', 'productionBoss');

View File

@ -25,7 +25,6 @@ describe('Worker basic data path', () => {
await page.overwrite(selectors.workerBasicData.name, 'David C.');
await page.overwrite(selectors.workerBasicData.surname, 'H.');
await page.overwrite(selectors.workerBasicData.phone, '444332211');
await page.overwrite(selectors.workerBasicData.locker, '1');
await page.click(selectors.workerBasicData.saveButton);
const message = await page.waitForSnackbar();
@ -37,6 +36,5 @@ describe('Worker basic data path', () => {
expect(await page.waitToGetProperty(selectors.workerBasicData.name, 'value')).toEqual('David C.');
expect(await page.waitToGetProperty(selectors.workerBasicData.surname, 'value')).toEqual('H.');
expect(await page.waitToGetProperty(selectors.workerBasicData.phone, 'value')).toEqual('444332211');
expect(await page.waitToGetProperty(selectors.workerBasicData.locker, 'value')).toEqual('1');
});
});

View File

@ -121,6 +121,9 @@
},
"Operator": {
"dataSource": "vn"
},
"Locker": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,21 @@
module.exports = Self => {
Self.observe('before save', async ctx => {
const models = Self.app.models;
const changes = ctx.data || ctx.instance;
const instance = ctx.currentInstance;
const workerFk = changes?.workerFk || instance?.workerFk;
if (workerFk) {
const locker = await models.Locker.findOne({
where: {workerFk}
}, ctx.options);
if (locker) {
await Self.rawSql(
'UPDATE locker SET workerFk = NULL where workerFk = ?',
[workerFk],
ctx.options);
}
}
});
};

View File

@ -0,0 +1,23 @@
{
"name": "Locker",
"base": "VnModel",
"description": "Worker's locker",
"options": {
"mysql": {
"table": "locker"
}
},
"properties": {
"code": {
"type": "string"
},
"gender": {
"type": "string"
}
},
"scopes": {
"codes": {
"fields": ["id","code"]
}
}
}

View File

@ -0,0 +1,56 @@
const {models} = require('vn-loopback/server/server');
describe('locker model ', () => {
const productionBossId = 50;
const hrBuyerId = 124;
const hrId = 37;
const jessicaJonesId = 1110;
const bruceBannerId = 1109;
const lockerMaleId = 1;
const lockerFemaleId = 147;
let ctx;
let options;
let tx;
beforeEach(async() => {
ctx = {
req: {
accessToken: {userId: hrId},
headers: {origin: 'http://localhost'}
},
};
options = {transaction: tx};
tx = await models.Locker.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should allocate a locker', async() => {
ctx.req.accessToken.userId = productionBossId;
const locker = await models.Locker.findById(lockerMaleId, null, options);
await locker.updateAttributes({workerFk: bruceBannerId}, options);
expect(locker.workerFk).toEqual(bruceBannerId);
});
it('should take away a locker', async() => {
ctx.req.accessToken.userId = hrBuyerId;
const locker = await models.Locker.findById(lockerFemaleId, null, options);
await locker.updateAttributes({workerFk: null}, options);
expect(locker.workerFk).toEqual(null);
});
it('should change a locker', async() => {
const locker = await models.Locker.findById(148, null, options);
await locker.updateAttributes({workerFk: jessicaJonesId}, options);
const oldLocker = await models.Locker.findById(lockerFemaleId, null, options);
expect(locker.workerFk).toEqual(jessicaJonesId);
expect(oldLocker.workerFk).toEqual(null);
});
});

View File

@ -21,10 +21,6 @@ module.exports = Self => {
require('../methods/worker/isAuthorized')(Self);
require('../methods/worker/setPassword')(Self);
Self.validatesUniquenessOf('locker', {
message: 'This locker has already been assigned'
});
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'
});

View File

@ -48,9 +48,6 @@
"code": {
"type" : "string"
},
"locker": {
"type" : "number"
},
"fi": {
"type" : "string"
},
@ -60,6 +57,9 @@
"isF11Allowed": {
"type" : "boolean"
},
"sex": {
"type" : "string"
},
"isFreelance": {
"type" : "boolean"
}
@ -94,6 +94,20 @@
"type": "hasMany",
"model": "WorkerTeamCollegues",
"foreignKey": "workerFk"
},
"locker": {
"type": "hasMany",
"model": "Locker",
"foreignKey": "workerFk"
}
}
},
"acls":[
{
"property": "__get__locker",
"accessType": "READ",
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$owner"
}
]
}

View File

@ -75,11 +75,6 @@
ng-model="$ctrl.worker.SSN"
rule>
</vn-textfield>
<vn-input-number
min="0"
label="Locker"
ng-model="$ctrl.worker.locker">
</vn-input-number>
</vn-horizontal>
</vn-vertical>
</vn-card>