diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 86fadd90b..0ce4261a0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1866,29 +1866,21 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`) (5, 1102), (9, 1201); -INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`) - SELECT w.id, w.lastName, u.nickname,CONCAT(RPAD(CONCAT(w.id,9),8,w.id),'A'),w.firstName,w.id - FROM `vn`.`worker` `w` - JOIN `account`.`user` `u` ON `u`.`id` = `w`.`userFk`; -INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`) - VALUES - (1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL); +INSERT INTO `postgresql`.`profile`(`profile_id`, `workerFk`, `profile_type_id`) + SELECT w.id, w.id, 1 + FROM `vn`.`worker` `w`; -INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`) - SELECT p.person_id, p.person_id, 1 - FROM `postgresql`.`person` `p`; - -INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) - SELECT p.profile_id, p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL +INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) + SELECT p.profile_id, p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL FROM `postgresql`.`profile` `p`; INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`) SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1 FROM `postgresql`.`business` `b`; -INSERT INTO `postgresql`.`business` (`client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) - SELECT p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL +INSERT INTO `postgresql`.`business` (`client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) + SELECT p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL FROM `postgresql`.`profile` `p` WHERE `p`.`profile_id` = 1109; @@ -1897,11 +1889,10 @@ INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_ (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); UPDATE `postgresql`.`business_labour` bl - JOIN `postgresql`.`business` b ON b.business_id = bl.business_id - JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id - JOIN `postgresql`.`person` p ON p.person_id = pr.person_id + JOIN `postgresql`.`business` b ON b.business_id = bl.business_id + JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id SET bl.`professional_category_id` = 31 - WHERE p.`Id_trabajador` = 1110; + WHERE pr.`workerFk` = 1110; UPDATE `postgresql`.`business_labour` bl SET bl.`department_id` = 43 diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 82cb5038e..098dc55fb 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -85,9 +85,8 @@ module.exports = Self => { FROM vn.calendar c JOIN postgresql.business b ON b.business_id = c.businessFk JOIN postgresql.profile p ON p.profile_id = b.client_id - JOIN vn.person pe ON pe.id = p.person_id WHERE c.dayOffTypeFk = 6 - AND pe.workerFk = ? + AND p.workerFk = ? AND c.dated BETWEEN util.firstDayOfYear(CURDATE()) AND LAST_DAY(DATE_ADD(NOW(), INTERVAL 12-MONTH(NOW()) MONTH))`, [id]);