From ac833ac62553d15231ff972de2e46df7d9fe560b Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 24 Dec 2021 11:30:28 +0100 Subject: [PATCH] feat: add field payedHolidays --- modules/worker/back/methods/worker/holidays.js | 10 ++++++++-- modules/worker/back/models/worker-labour.json | 3 +++ modules/worker/front/calendar/index.html | 5 +++-- modules/worker/front/calendar/index.js | 18 ++++-------------- 4 files changed, 18 insertions(+), 18 deletions(-) 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..b954c54833 100644 --- a/modules/worker/back/models/worker-labour.json +++ b/modules/worker/back/models/worker-labour.json @@ -19,6 +19,9 @@ }, "ended": { "type": "date" + }, + "payedHolidays": { + "type": "Number" } }, "relations": { diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 4e0da8a96a..947da0ae04 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -29,8 +29,9 @@ {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}}
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'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 82195f1d90..6e0cf0d9af 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -23,7 +23,6 @@ class Controller extends Section { this.refresh() .then(() => this.repaint()) .then(() => this.getContractHolidays()) - .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()); } @@ -37,7 +36,6 @@ class Controller extends Section { this.refresh() .then(() => this.repaint()) .then(() => this.getContractHolidays()) - .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()); } } @@ -73,6 +71,10 @@ class Controller extends Section { } } + get payedHolidays() { + return this._businessId; + } + buildYearFilter() { const now = new Date(); now.setFullYear(now.getFullYear() + 1); @@ -106,15 +108,6 @@ class Controller extends Section { }, data => this.contractHolidays = data); } - getPayedHolidays() { - this.getContractHolidays(); - if (this.contractHolidays !== undefined) {// && business.reasonEndFk !== null - const daysToPay = this.contractHolidays.totalHolidays - this.contractHolidays.holidaysEnjoyed; - console.log(this.businessId, this.contractHolidays.totalHolidays, this.contractHolidays.holidaysEnjoyed); - console.log(daysToPay); - } - } - getYearHolidays() { this.getHolidays({ year: this.year @@ -236,7 +229,6 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) - .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); }); @@ -258,7 +250,6 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) - .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); }); @@ -274,7 +265,6 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) - .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); });