From 671a35f8c97b9e0bc963fa834742ecd8ec443ada Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 23 Dec 2021 13:11:17 +0100 Subject: [PATCH 1/6] upload branch --- modules/worker/front/calendar/index.html | 4 ++++ modules/worker/front/calendar/locale/es.yml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index ce8bd6275..4e0da8a96 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -28,6 +28,10 @@ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'days' | translate}} +
diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml index 464ad9750..8e9f9cdf8 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 -- 2.40.1 From e1c4f144a79e6473a6748499ff8d79dfa0663b45 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 23 Dec 2021 14:57:22 +0100 Subject: [PATCH 2/6] feat: add code --- modules/worker/front/calendar/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 014a35b63..82195f1d9 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -23,6 +23,7 @@ class Controller extends Section { this.refresh() .then(() => this.repaint()) .then(() => this.getContractHolidays()) + .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()); } @@ -36,6 +37,7 @@ class Controller extends Section { this.refresh() .then(() => this.repaint()) .then(() => this.getContractHolidays()) + .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()); } } @@ -104,6 +106,15 @@ 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 @@ -225,6 +236,7 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) + .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); }); @@ -246,6 +258,7 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) + .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); }); @@ -261,6 +274,7 @@ class Controller extends Section { this.refresh() .then(calendar.repaint()) .then(() => this.getContractHolidays()) + .then(() => this.getPayedHolidays()) .then(() => this.getYearHolidays()) ); }); -- 2.40.1 From ac833ac62553d15231ff972de2e46df7d9fe560b Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 24 Dec 2021 11:30:28 +0100 Subject: [PATCH 3/6] 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 e11d13002..bcf4d7f51 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 b80090e57..b954c5483 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 4e0da8a96..947da0ae0 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 82195f1d9..6e0cf0d9a 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()) ); }); -- 2.40.1 From 914fca0814de0930ea560b82f22e3c316158fca3 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 4 Jan 2022 10:28:06 +0100 Subject: [PATCH 4/6] fix: delete unnecessary ng-if --- modules/worker/front/calendar/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 947da0ae0..7ef586b36 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -28,9 +28,7 @@ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
+
{{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays}} {{'days' | translate}}
-- 2.40.1 From f3875518359bfeb0b36cf5c4008166eb82c56769 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jan 2022 12:27:12 +0100 Subject: [PATCH 5/6] add sql --- .../00-smsConfig.sql | 0 db/changes/10410-january/00-workerLabour.sql | 25 +++++++++++++++++++ .../01-smsConfig_update.sql | 0 3 files changed, 25 insertions(+) rename db/changes/{10410-noname => 10410-january}/00-smsConfig.sql (100%) create mode 100644 db/changes/10410-january/00-workerLabour.sql rename db/changes/{10410-noname => 10410-january}/01-smsConfig_update.sql (100%) diff --git a/db/changes/10410-noname/00-smsConfig.sql b/db/changes/10410-january/00-smsConfig.sql similarity index 100% rename from db/changes/10410-noname/00-smsConfig.sql rename to db/changes/10410-january/00-smsConfig.sql diff --git a/db/changes/10410-january/00-workerLabour.sql b/db/changes/10410-january/00-workerLabour.sql new file mode 100644 index 000000000..8630eee22 --- /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/db/changes/10410-noname/01-smsConfig_update.sql b/db/changes/10410-january/01-smsConfig_update.sql similarity index 100% rename from db/changes/10410-noname/01-smsConfig_update.sql rename to db/changes/10410-january/01-smsConfig_update.sql -- 2.40.1 From 13ce7991eca3e7222921ac9b8ca937622679455e Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Jan 2022 09:49:45 +0100 Subject: [PATCH 6/6] refactor: uppercase in model type --- modules/worker/back/models/worker-labour.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/models/worker-labour.json b/modules/worker/back/models/worker-labour.json index b954c5483..5d2b56bfc 100644 --- a/modules/worker/back/models/worker-labour.json +++ b/modules/worker/back/models/worker-labour.json @@ -9,10 +9,10 @@ "properties": { "businessFk": { "id": true, - "type": "Number" + "type": "number" }, "workerFk": { - "type": "Number" + "type": "number" }, "started": { "type": "date" @@ -21,7 +21,7 @@ "type": "date" }, "payedHolidays": { - "type": "Number" + "type": "number" } }, "relations": { -- 2.40.1