feat: add field payedHolidays
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2021-12-24 11:30:28 +01:00
parent e1c4f144a7
commit ac833ac625
4 changed files with 18 additions and 18 deletions

View File

@ -112,6 +112,13 @@ module.exports = Self => {
const contracts = await models.WorkerLabour.find(filter, myOptions); 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 totalHolidays = 0;
let holidaysEnjoyed = 0; let holidaysEnjoyed = 0;
@ -166,8 +173,7 @@ module.exports = Self => {
return isLeapYear(year) ? 366 : 365; return isLeapYear(year) ? 366 : 365;
} }
return {totalHolidays, holidaysEnjoyed, payedHolidays};
return {totalHolidays, holidaysEnjoyed};
}; };
function isLeapYear(year) { function isLeapYear(year) {

View File

@ -19,6 +19,9 @@
}, },
"ended": { "ended": {
"type": "date" "type": "date"
},
"payedHolidays": {
"type": "Number"
} }
}, },
"relations": { "relations": {

View File

@ -29,8 +29,9 @@
{{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}}
</div> </div>
<br> <br>
<div> <div
{{'Paid holidays' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed}} {{'days' | translate}} ng-if="::$ctrl.isContractEnded">
{{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays}} {{'days' | translate}}
</div> </div>
</div> </div>

View File

@ -23,7 +23,6 @@ class Controller extends Section {
this.refresh() this.refresh()
.then(() => this.repaint()) .then(() => this.repaint())
.then(() => this.getContractHolidays()) .then(() => this.getContractHolidays())
.then(() => this.getPayedHolidays())
.then(() => this.getYearHolidays()); .then(() => this.getYearHolidays());
} }
@ -37,7 +36,6 @@ class Controller extends Section {
this.refresh() this.refresh()
.then(() => this.repaint()) .then(() => this.repaint())
.then(() => this.getContractHolidays()) .then(() => this.getContractHolidays())
.then(() => this.getPayedHolidays())
.then(() => this.getYearHolidays()); .then(() => this.getYearHolidays());
} }
} }
@ -73,6 +71,10 @@ class Controller extends Section {
} }
} }
get payedHolidays() {
return this._businessId;
}
buildYearFilter() { buildYearFilter() {
const now = new Date(); const now = new Date();
now.setFullYear(now.getFullYear() + 1); now.setFullYear(now.getFullYear() + 1);
@ -106,15 +108,6 @@ class Controller extends Section {
}, data => this.contractHolidays = data); }, 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() { getYearHolidays() {
this.getHolidays({ this.getHolidays({
year: this.year year: this.year
@ -236,7 +229,6 @@ class Controller extends Section {
this.refresh() this.refresh()
.then(calendar.repaint()) .then(calendar.repaint())
.then(() => this.getContractHolidays()) .then(() => this.getContractHolidays())
.then(() => this.getPayedHolidays())
.then(() => this.getYearHolidays()) .then(() => this.getYearHolidays())
); );
}); });
@ -258,7 +250,6 @@ class Controller extends Section {
this.refresh() this.refresh()
.then(calendar.repaint()) .then(calendar.repaint())
.then(() => this.getContractHolidays()) .then(() => this.getContractHolidays())
.then(() => this.getPayedHolidays())
.then(() => this.getYearHolidays()) .then(() => this.getYearHolidays())
); );
}); });
@ -274,7 +265,6 @@ class Controller extends Section {
this.refresh() this.refresh()
.then(calendar.repaint()) .then(calendar.repaint())
.then(() => this.getContractHolidays()) .then(() => this.getContractHolidays())
.then(() => this.getPayedHolidays())
.then(() => this.getYearHolidays()) .then(() => this.getYearHolidays())
); );
}); });