Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
2.6 kB
3
Indexable
Never
function calculateAverageSpend() {
  let spend =
    this.dailyStatistics.workerCost / this.dailyStatistics.workerCount;
  spend = parseFloat(spend.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,"));
  if (isNaN(spend) || !isFinite(spend)) {
    return 0;
  } else {
    return spend;
  }
}

function calculateWorkersForecast() {
  let forecast =
    (this.dailyStatistics.workerCount -
      this.dailyStatistics.workerEstimatedCount) /
    this.dailyStatistics.workerEstimatedCount;
  forecast = forecast * 100;
  forecast = parseFloat(forecast.toFixed(2));
  if (isNaN(forecast) || !isFinite(forecast)) {
    return 0;
  } else {
    return forecast;
  }
}

function calculateWorkersLastWeek() {
  let lastweek =
    (this.dailyStatistics.workerCount - this.dailyStatistics.workerPrevCount) /
    this.dailyStatistics.workerPrevCount;
  lastweek = lastweek * 100;
  lastweek = parseFloat(lastweek.toFixed(2));
  if (isNaN(lastweek) || !isFinite(lastweek)) {
    return 0;
  } else {
    return lastweek;
  }
}

function calculateWorkingHoursForecast() {
  let forecast =
    (this.dailyStatistics.workingHoursCount -
      this.dailyStatistics.workingHoursEstimatedCount) /
    this.dailyStatistics.workingHoursEstimatedCount;
  forecast = forecast * 100;
  forecast = parseFloat(forecast.toFixed(2));
  if (isNaN(forecast) || !isFinite(forecast)) {
    return 0;
  } else {
    return forecast;
  }
}

function calculateWorkingHoursLastWeek() {
  let lastweek =
    (this.dailyStatistics.workingHoursCount -
      this.dailyStatistics.workingHoursPrevCount) /
    this.dailyStatistics.workingHoursPrevCount;
  lastweek = lastweek * 100;
  lastweek = parseFloat(lastweek.toFixed(2));
  if (isNaN(lastweek) || !isFinite(lastweek)) {
    return 0;
  } else {
    return lastweek;
  }
}

function calculateWorkersCostForecast() {
  let forecast =
    (this.dailyStatistics.workerCost -
      this.dailyStatistics.workerEstimatedCost) /
    this.dailyStatistics.workerEstimatedCost;
  forecast = forecast * 100;
  forecast = parseFloat(forecast.toFixed(2));
  if (isNaN(forecast) || !isFinite(forecast)) {
    return 0;
  } else {
    return forecast;
  }
}

function calculateWorkersCostLastWeek() {
  let lastweek =
    (this.dailyStatistics.workerCost - this.dailyStatistics.workerPrevCost) /
    this.dailyStatistics.workerPrevCost;
  lastweek = lastweek * 100;
  lastweek = parseFloat(lastweek.toFixed(2));
  if (isNaN(lastweek) || !isFinite(lastweek)) {
    return 0;
  } else {
    return lastweek;
  }
}