fixed worker calendar total holidays #1299
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-03 11:36:10 +02:00
parent 06c67636d3
commit 892e267a16
1 changed files with 3 additions and 3 deletions

View File

@ -124,7 +124,7 @@ module.exports = Self => {
let totalHolidays = contract.holidays().days; let totalHolidays = contract.holidays().days;
if (contract.started && contract.ended) if (contract.started && contract.ended)
totalHolidays = getHolidaysByContract(contract); totalHolidays = getHolidaysByContract(started, contract);
calendar.totalHolidays += totalHolidays; calendar.totalHolidays += totalHolidays;
@ -141,10 +141,10 @@ module.exports = Self => {
return [calendar, absences, holidays]; return [calendar, absences, holidays];
}; };
function getHolidaysByContract(contract) { function getHolidaysByContract(started, contract) {
const dayTimestamp = 1000 * 60 * 60 * 24; const dayTimestamp = 1000 * 60 * 60 * 24;
const endedTime = contract.ended.getTime(); const endedTime = contract.ended.getTime();
const startedTime = contract.started.getTime(); const startedTime = started.getTime();
const contractDays = Math.floor((endedTime - startedTime) / dayTimestamp); const contractDays = Math.floor((endedTime - startedTime) / dayTimestamp);
if (contractDays < 365) if (contractDays < 365)