diff --git a/db/changes/10410-january/00-workerLabour.sql b/db/changes/10410-january/00-workerLabour.sql new file mode 100644 index 0000000000..8630eee224 --- /dev/null +++ b/db/changes/10410-january/00-workerLabour.sql @@ -0,0 +1,25 @@ +ALTER TABLE `postgresql`.`business` ADD payedHolidays INT NULL; +ALTER TABLE `postgresql`.`business` CHANGE payedHolidays payedHolidays INT NULL AFTER reasonEndFk; + +CREATE OR REPLACE +ALGORITHM = UNDEFINED VIEW `vn`.`workerLabour` AS +select +`b`.`business_id` AS `businessFk`, +`p`.`id_trabajador` AS `workerFk`, +`bl`.`workcenter_id` AS `workCenterFk`, +`b`.`date_start` AS `started`, +`b`.`date_end` AS `ended`, +`d`.`id` AS `departmentFk`, +`b`.`payedHolidays` AS `payedHolidays` +from +((((`postgresql`.`person` `p` +join `postgresql`.`profile` `pr` on +((`pr`.`person_id` = `p`.`person_id`))) +join `postgresql`.`business` `b` on +((`b`.`client_id` = `pr`.`profile_id`))) +join `postgresql`.`business_labour` `bl` on +((`b`.`business_id` = `bl`.`business_id`))) +join `vn`.`department` `d` on +((`d`.`id` = `bl`.`department_id`))) +order by +`b`.`date_start` desc \ No newline at end of file diff --git a/modules/worker/back/methods/worker/holidays.js b/modules/worker/back/methods/worker/holidays.js index e11d130020..bcf4d7f51c 100644 --- a/modules/worker/back/methods/worker/holidays.js +++ b/modules/worker/back/methods/worker/holidays.js @@ -112,6 +112,13 @@ module.exports = Self => { const contracts = await models.WorkerLabour.find(filter, myOptions); + let [firstContract] = contracts; + let payedHolidays; + + if (firstContract.payedHolidays) + payedHolidays = firstContract.payedHolidays; + else payedHolidays = 0; + let totalHolidays = 0; let holidaysEnjoyed = 0; @@ -166,8 +173,7 @@ module.exports = Self => { return isLeapYear(year) ? 366 : 365; } - - return {totalHolidays, holidaysEnjoyed}; + return {totalHolidays, holidaysEnjoyed, payedHolidays}; }; function isLeapYear(year) { diff --git a/modules/worker/back/models/worker-labour.json b/modules/worker/back/models/worker-labour.json index b80090e579..5d2b56bfc2 100644 --- a/modules/worker/back/models/worker-labour.json +++ b/modules/worker/back/models/worker-labour.json @@ -9,16 +9,19 @@ "properties": { "businessFk": { "id": true, - "type": "Number" + "type": "number" }, "workerFk": { - "type": "Number" + "type": "number" }, "started": { "type": "date" }, "ended": { "type": "date" + }, + "payedHolidays": { + "type": "number" } }, "relations": { diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index ce8bd6275b..7ef586b36b 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -28,6 +28,9 @@ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays}} {{'days' | translate}} +
diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 014a35b635..6e0cf0d9af 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -71,6 +71,10 @@ class Controller extends Section { } } + get payedHolidays() { + return this._businessId; + } + buildYearFilter() { const now = new Date(); now.setFullYear(now.getFullYear() + 1); diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml index 464ad97505..8e9f9cdf8d 100644 --- a/modules/worker/front/calendar/locale/es.yml +++ b/modules/worker/front/calendar/locale/es.yml @@ -8,4 +8,5 @@ days: días Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual -Current day: Día actual \ No newline at end of file +Current day: Día actual +Paid holidays: Vacaciones pagadas \ No newline at end of file