refactor: refs #7952 Deprecate creditInsurance.creditClassification #2951

Merged
ivanm merged 3 commits from 7952-DeprecateCreditInsurance.creditClassification into dev 2024-09-12 11:25:17 +00:00
18 changed files with 81 additions and 53 deletions
Showing only changes of commit 4f9eb865d0 - Show all commits

View File

@ -2488,7 +2488,7 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
(1104, 2), (1104, 2),
(1104, 3); (1104, 3);
INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`) INSERT INTO `vn`.`workerDms`(`id`, `workerFk`, `dmsFk`,`isReadableByWorker`)
VALUES VALUES
(1, 1106, 4, TRUE), (1, 1106, 4, TRUE),
(2, 1107, 3, FALSE); (2, 1107, 3, FALSE);

View File

@ -55,7 +55,6 @@ BEGIN
i.itemPackingTypeFk, i.itemPackingTypeFk,
isa.`size`, isa.`size`,
isa.Estado, isa.Estado,
isa.sectorProdPriority,
isa.available, isa.available,
isa.sectorFk, isa.sectorFk,
isa.matricula, isa.matricula,

View File

@ -36,7 +36,7 @@ BEGIN
UPDATE tmp.ticket_problems UPDATE tmp.ticket_problems
SET totalProblems = ( SET totalProblems = (
(isFreezed) + (isFreezed) +
(hasRisk) + (hasHighRisk) +
(hasTicketRequest) + (hasTicketRequest) +
(!isTaxDataChecked) + (!isTaxDataChecked) +
(hasComponentLack) + (hasComponentLack) +

View File

@ -1,11 +1,11 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_afterDelete` CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_afterDelete`
AFTER DELETE ON `workerDocument` AFTER DELETE ON `workerDms`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
INSERT INTO workerLog INSERT INTO workerLog
SET `action` = 'delete', SET `action` = 'delete',
`changedModel` = 'WorkerDocument', `changedModel` = 'WorkerDms',
`changedModelId` = OLD.id, `changedModelId` = OLD.id,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
END$$ END$$

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeInsert` CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeInsert`
BEFORE INSERT ON `workerDocument` BEFORE INSERT ON `workerDms`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeUpdate` CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeUpdate`
BEFORE UPDATE ON `workerDocument` BEFORE UPDATE ON `workerDms`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();

View File

@ -10,7 +10,6 @@ AS SELECT `s`.`id` AS `saleFk`,
`s`.`concept` AS `concept`, `s`.`concept` AS `concept`,
`i`.`size` AS `size`, `i`.`size` AS `size`,
`st`.`name` AS `Estado`, `st`.`name` AS `Estado`,
`st`.`sectorProdPriority` AS `sectorProdPriority`,
`stock`.`visible` AS `available`, `stock`.`visible` AS `available`,
`stock`.`sectorFk` AS `sectorFk`, `stock`.`sectorFk` AS `sectorFk`,
`stock`.`shelvingFk` AS `matricula`, `stock`.`shelvingFk` AS `matricula`,

View File

@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `id`,
`s`.`order` AS `order`, `s`.`order` AS `order`,
`s`.`alertLevel` AS `alert_level`, `s`.`alertLevel` AS `alert_level`,
`s`.`code` AS `code`, `s`.`code` AS `code`,
`s`.`sectorProdPriority` AS `sectorProdPriority`,
`s`.`nextStateFk` AS `nextStateFk`, `s`.`nextStateFk` AS `nextStateFk`,
`s`.`isPreviousPreparable` AS `isPreviousPreparable`, `s`.`isPreviousPreparable` AS `isPreviousPreparable`,
`s`.`isPicked` AS `isPicked` `s`.`isPicked` AS `isPicked`

View File

@ -0,0 +1,16 @@
ALTER TABLE IF EXISTS `vn`.`payrollWorker`
MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15';
ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter`
MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15',
MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15';

View File

@ -0,0 +1 @@
ALTER TABLE vn.state DROP COLUMN sectorProdPriority;

View File

@ -0,0 +1 @@
ALTER TABLE vn.workerDocument CHANGE worker workerFk int(10) unsigned DEFAULT NULL NULL;

View File

@ -0,0 +1 @@
ALTER TABLE vn.workerDocument CHANGE document dmsFk int(11) DEFAULT NULL NULL;

View File

@ -0,0 +1 @@
RENAME TABLE vn.workerDocument TO vn.workerDms;

View File

@ -8,19 +8,19 @@ module.exports = Self => {
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',
type: 'Number', type: 'number',
description: 'The worker id', description: 'The worker id',
http: {source: 'path'} http: {source: 'path'}
}, },
{ {
arg: 'filter', arg: 'filter',
type: 'Object', type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'} http: {source: 'query'}
} }
], ],
returns: { returns: {
type: ['Object'], type: ['object'],
root: true root: true
}, },
http: { http: {
@ -36,38 +36,50 @@ module.exports = Self => {
// Get ids alloweds // Get ids alloweds
const account = await models.VnUser.findById(userId); const account = await models.VnUser.findById(userId);
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT d.id, d.id dmsFk `SELECT d.id, d.id dmsFk
FROM workerDocument wd FROM workerDms wd
JOIN dms d ON d.id = wd.document JOIN dms d ON d.id = wd.dmsFk
JOIN dmsType dt ON dt.id = d.dmsTypeFk JOIN dmsType dt ON dt.id = d.dmsTypeFk
LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk
AND rr.role = ?
`, [account.roleFk] `, [account.roleFk]
); );
const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; const yourOwnDms = {
const where = { or: [
or: [yourOwnDms, { {and: [
{isReadableByWorker: true},
{worker: userId}
]},
{
role: { role: {
neq: null neq: null
} }
}] }]
}; };
stmt.merge(conn.makeSuffix(mergeWhere(filter.where, where)));
// Get workerDms alloweds const where = mergeWhere(filter.where, yourOwnDms);
stmt.merge(conn.makeSuffix({where}));
const dmsIds = await conn.executeStmt(stmt); const dmsIds = await conn.executeStmt(stmt);
const allowedIds = dmsIds.map(dms => dms.id); const allowedIds = dmsIds.map(dms => dms.id);
const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}});
let workerDms = await models.WorkerDms.find(allowedFilter);
// Get docuware info const workerDms = await models.WorkerDms.find(allowedFilter);
const docuware = await models.Docuware.findOne({
const workerDocuware = filter.skip ? [] : await getDocuware(ctx, id);
return workerDms.concat(workerDocuware);
async function getDocuware(ctx, id) {
const {dmsTypeFk} = await models.Docuware.findOne({
fields: ['dmsTypeFk'], fields: ['dmsTypeFk'],
where: {code: 'hr', action: 'find'} where: {code: 'hr', action: 'find'}
}); });
const docuwareDmsType = docuware.dmsTypeFk;
if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return [];
let workerDocuware = []; let workerDocuware = [];
if (!filter.skip && (!docuwareDmsType || (docuwareDmsType && await models.DmsType.hasReadRole(ctx, docuwareDmsType)))) {
const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']});
const docuwareParse = { const docuwareParse = {
'Filename': 'dmsFk', 'Filename': 'dmsFk',
@ -105,7 +117,7 @@ module.exports = Self => {
}; };
Object.assign(document, defaultData); Object.assign(document, defaultData);
} }
return workerDocuware;
} }
return workerDms.concat(workerDocuware);
}; };
}; };

View File

@ -6,7 +6,7 @@
}, },
"options": { "options": {
"mysql": { "mysql": {
"table": "workerDocument" "table": "workerDms"
} }
}, },
"properties": { "properties": {
@ -16,17 +16,11 @@
}, },
"dmsFk": { "dmsFk": {
"type": "number", "type": "number",
"required": true, "required": true
"mysql": {
"columnName": "document"
}
}, },
"workerFk": { "workerFk": {
"type": "number", "type": "number",
"required": true, "required": true
"mysql": {
"columnName": "worker"
}
}, },
"isReadableByWorker": { "isReadableByWorker": {
"type": "boolean" "type": "boolean"

View File

@ -2,6 +2,7 @@ code: vn-database
versionSchema: util versionSchema: util
replace: true replace: true
sumViews: false sumViews: false
defaultDefiner: vn@localhost
mockDate: '2001-01-01 12:00:00' mockDate: '2001-01-01 12:00:00'
subdir: db subdir: db
schemas: schemas:
@ -375,7 +376,7 @@ localFixtures:
- workerBosses - workerBosses
- workerBusinessType - workerBusinessType
- workerConfig - workerConfig
- workerDocument - workerDms
- workerLog - workerLog
- workerMana - workerMana
- workerManaExcluded - workerManaExcluded

View File

@ -60,7 +60,7 @@
"@babel/register": "^7.7.7", "@babel/register": "^7.7.7",
"@commitlint/cli": "^19.2.1", "@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0", "@commitlint/config-conventional": "^19.1.0",
"@verdnatura/myt": "^1.6.9", "@verdnatura/myt": "^1.6.10",
"angular-mocks": "^1.7.9", "angular-mocks": "^1.7.9",
"babel-jest": "^26.0.1", "babel-jest": "^26.0.1",
"babel-loader": "^8.2.4", "babel-loader": "^8.2.4",

View File

@ -143,8 +143,8 @@ devDependencies:
specifier: ^19.1.0 specifier: ^19.1.0
version: 19.1.0 version: 19.1.0
'@verdnatura/myt': '@verdnatura/myt':
specifier: ^1.6.9 specifier: ^1.6.10
version: 1.6.9 version: 1.6.10
angular-mocks: angular-mocks:
specifier: ^1.7.9 specifier: ^1.7.9
version: 1.8.3 version: 1.8.3
@ -2846,8 +2846,8 @@ packages:
dev: false dev: false
optional: true optional: true
/@verdnatura/myt@1.6.9: /@verdnatura/myt@1.6.10:
resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} resolution: {integrity: sha512-fih/TFll5Sn/SxxafUmYh6CW0Qwpck8PpQ63/CKm4ya8rz8gYPq0THM2B5N8yEJ3PiolMg0wrWWas9j+taAh6w==}
hasBin: true hasBin: true
dependencies: dependencies:
'@sqltools/formatter': 1.2.5 '@sqltools/formatter': 1.2.5
@ -3306,6 +3306,7 @@ packages:
/are-we-there-yet@1.1.7: /are-we-there-yet@1.1.7:
resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==}
deprecated: This package is no longer supported.
dependencies: dependencies:
delegates: 1.0.0 delegates: 1.0.0
readable-stream: 2.3.8 readable-stream: 2.3.8
@ -6593,6 +6594,7 @@ packages:
/gauge@2.7.4: /gauge@2.7.4:
resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==} resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==}
deprecated: This package is no longer supported.
dependencies: dependencies:
aproba: 1.2.0 aproba: 1.2.0
console-control-strings: 1.1.0 console-control-strings: 1.1.0
@ -10814,6 +10816,7 @@ packages:
/npmlog@4.1.2: /npmlog@4.1.2:
resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==}
deprecated: This package is no longer supported.
dependencies: dependencies:
are-we-there-yet: 1.1.7 are-we-there-yet: 1.1.7
console-control-strings: 1.1.0 console-control-strings: 1.1.0
@ -11055,6 +11058,7 @@ packages:
/osenv@0.1.5: /osenv@0.1.5:
resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==}
deprecated: This package is no longer supported.
dependencies: dependencies:
os-homedir: 1.0.2 os-homedir: 1.0.2
os-tmpdir: 1.0.2 os-tmpdir: 1.0.2