Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
8729d1c765
|
@ -56,15 +56,19 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
let entitlementRate = 0;
|
||||
absences.forEach(absence => {
|
||||
const isHoliday = absence.absenceType().code === 'holiday';
|
||||
const isHalfHoliday = absence.absenceType().code === 'halfHoliday';
|
||||
const absenceType = absence.absenceType();
|
||||
const isHoliday = absenceType.code === 'holiday';
|
||||
const isHalfHoliday = absenceType.code === 'halfHoliday';
|
||||
|
||||
if (isHoliday)
|
||||
calendar.holidaysEnjoyed += 1;
|
||||
if (isHalfHoliday)
|
||||
calendar.holidaysEnjoyed += 0.5;
|
||||
|
||||
entitlementRate += absenceType.holidayEntitlementRate;
|
||||
|
||||
absence.dated = new Date(absence.dated);
|
||||
absence.dated.setHours(0, 0, 0, 0);
|
||||
});
|
||||
|
@ -119,6 +123,9 @@ module.exports = Self => {
|
|||
|
||||
workedDays += Math.floor((endedTime - startedTime) / dayTimestamp);
|
||||
|
||||
if (workedDays > daysInYear())
|
||||
workedDays = daysInYear();
|
||||
|
||||
// Workcenter holidays
|
||||
let holidayList = contract.workCenter().holidays();
|
||||
for (let day of holidayList) {
|
||||
|
@ -137,10 +144,22 @@ module.exports = Self => {
|
|||
const maxHolidays = currentContract.holidays().days;
|
||||
calendar.totalHolidays = maxHolidays;
|
||||
|
||||
if (workedDays < 365)
|
||||
calendar.totalHolidays = Math.round(2 * maxHolidays * (workedDays) / 365) / 2;
|
||||
workedDays -= entitlementRate;
|
||||
|
||||
if (workedDays < daysInYear())
|
||||
calendar.totalHolidays = Math.round(2 * maxHolidays * (workedDays) / daysInYear()) / 2;
|
||||
}
|
||||
|
||||
function daysInYear() {
|
||||
const year = yearStarted.getFullYear();
|
||||
|
||||
return isLeapYear(year) ? 366 : 365;
|
||||
}
|
||||
|
||||
return [calendar, absences, holidays];
|
||||
};
|
||||
|
||||
function isLeapYear(year) {
|
||||
return year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
},
|
||||
"code": {
|
||||
"type": "String"
|
||||
},
|
||||
"holidayEntitlementRate": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
Loading…
Reference in New Issue