diff --git a/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql index 4c09624e0..3293f0b57 100644 --- a/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -1227,17 +1227,26 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`, `secret`, `caller_id`) (5, 1102, '123456', 'administrative'), (9, 1201, '123456', 'developer'); +INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`) + SELECT w.id, w.name, 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 - (1, 'Haller', 'DavidCharlesHaller', '53136686Q', 'David Charles', 106 ), - (2, 'Pym', 'HankPym', '09854837G', 'Hank', 107), - (3, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL); + (1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL); INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`) - VALUES - (1, 1, 1), - (2, 2, 1), - (3, 3, 6); + 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, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL +6 MONTH), 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`.`media`(`media_id`, `media_type_id`, `value`, `sort`) VALUES @@ -1246,18 +1255,8 @@ INSERT INTO `postgresql`.`media`(`media_id`, `media_type_id`, `value`, `sort`) INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `media_id`) VALUES - (1, 1, 1), - (2, 2, 2); - -INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) - VALUES - (1, 1, 3, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL +6 MONTH), 'E-46-12213123', NULL), - (2, 2, 3, DATE_ADD(CURDATE(), INTERVAL -10 DAY), NULL, 'E-46-87987933', NULL); - -INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`) - VALUES - (1, NULL, 22, 4, 0, 1, 1, 1, 1), - (2, 'From las friday worker ownes the company 1 hour', 23, 1, 0, 1, 0, 1, 1); + (1, 106, 1), + (2, 107, 2); INSERT INTO `vn`.`workCenter` (`id`, `name`, `warehouseFk`) VALUES @@ -1278,17 +1277,17 @@ INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`) INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) VALUES - ('1', '1', DATE_ADD(CURDATE(), INTERVAL 10 DAY)), - ('1', '1', DATE_ADD(CURDATE(), INTERVAL 11 DAY)), - ('1', '1', DATE_ADD(CURDATE(), INTERVAL 12 DAY)), - ('1', '1', DATE_ADD(CURDATE(), INTERVAL 20 DAY)), - ('1', '2', DATE_ADD(CURDATE(), INTERVAL -10 DAY)), - ('1', '1', DATE_ADD(CURDATE(), INTERVAL -12 DAY)), - ('1', '2', DATE_ADD(CURDATE(), INTERVAL -20 DAY)), - ('2', '1', DATE_ADD(CURDATE(), INTERVAL 15 DAY)), - ('2', '1', DATE_ADD(CURDATE(), INTERVAL 16 DAY)), - ('2', '1', DATE_ADD(CURDATE(), INTERVAL 20 DAY)), - ('2', '1', DATE_ADD(CURDATE(), INTERVAL 30 DAY)), - ('2', '2', DATE_ADD(CURDATE(), INTERVAL -10 DAY)), - ('2', '1', DATE_ADD(CURDATE(), INTERVAL -12 DAY)), - ('2', '2', DATE_ADD(CURDATE(), INTERVAL -20 DAY)); + (106, 1, DATE_ADD(CURDATE(), INTERVAL 10 DAY)), + (106, 1, DATE_ADD(CURDATE(), INTERVAL 11 DAY)), + (106, 1, DATE_ADD(CURDATE(), INTERVAL 12 DAY)), + (106, 1, DATE_ADD(CURDATE(), INTERVAL 20 DAY)), + (106, 2, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), + (106, 1, DATE_ADD(CURDATE(), INTERVAL -12 DAY)), + (106, 2, DATE_ADD(CURDATE(), INTERVAL -20 DAY)), + (107, 1, DATE_ADD(CURDATE(), INTERVAL 15 DAY)), + (107, 1, DATE_ADD(CURDATE(), INTERVAL 16 DAY)), + (107, 1, DATE_ADD(CURDATE(), INTERVAL 20 DAY)), + (107, 1, DATE_ADD(CURDATE(), INTERVAL 30 DAY)), + (107, 2, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), + (107, 1, DATE_ADD(CURDATE(), INTERVAL -12 DAY)), + (107, 2, DATE_ADD(CURDATE(), INTERVAL -20 DAY)); diff --git a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js index 625e20dc7..21d710a11 100644 --- a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Worker absences()', () => { - it('should import sales to a claim actions from an specific ticket', async() => { + it('should get the absence calendar for the given dates then evaluate the type of absences', async() => { let ctx = {req: {accessToken: {userId: 106}}}; let workerFk = 106; @@ -14,7 +14,6 @@ describe('Worker absences()', () => { const ended = new Date(); ended.setHours(0, 0, 0, 0); ended.setMonth(monthIndex + 1); - // Last day of previous month (January) ended.setDate(0); let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended); @@ -24,7 +23,10 @@ describe('Worker absences()', () => { expect(calendar.totalHolidays).toEqual(15); expect(calendar.holidaysEnjoyed).toEqual(5); - expect(absences[0].absenceType().id).toEqual(2); - expect(absences[5].absenceType().id).toEqual(1); + let firstType = absences[0].absenceType().name; + let sixthType = absences[5].absenceType().name; + + expect(firstType).toEqual('Leave of absence'); + expect(sixthType).toEqual('Holidays'); }); });