Skip to content

Commit

Permalink
[#14] Exclude other absent days from totalDays calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLin-TWer committed Feb 21, 2017
1 parent a740005 commit 2dfaa8a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
59 changes: 35 additions & 24 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions src/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export class Report {
client: client.title.client,
time: this.timeService.millisToHoursAndMinsFormat(client.time),
projects: client.items.map(project => {
let effectiveDays = this.isWeekdayProjects(project.title.project) ?
let effectiveDays = this.isWeekdayProject(project.title.project) ?
this.weekdayService.actualWeekdays(since, until) :
this.timeService.daysBetween(since, until)
this.timeService.daysBetween(since, until)
- this.weekdayService.otherAbsent().length
let millisPerDay = project.time / effectiveDays

return {
Expand All @@ -33,9 +34,10 @@ export class Report {
getClientData(reports, since, until) {

return reports.map(client => {
let effectiveDays = this.isWeekdayClients(client.title.client) ?
let effectiveDays = this.isWeekdayClient(client.title.client) ?
this.weekdayService.actualWeekdays(since, until)
: this.timeService.daysBetween(since, until)
- this.weekdayService.otherAbsent().length

let percentage = client.time / this.timeService.totalMillis(since, until)
let millisPerDay = client.time / effectiveDays
Expand All @@ -59,22 +61,22 @@ export class Report {

return {
totalGrand: this.timeService.millisToHoursAndMinsFormat(totalGrand),
totalDays: this.timeService.daysBetween(since, until),
totalDays: totalDays - otherAbsent.length,
weekdays, holidays, leaves,
actualWeekdays: weekdays - (holidays.length + leaves.length + otherAbsent.length),
grandPercentage: `${grandPercentage}%`,
grandHoursPerDay: this.timeService.millisToHoursAndMinsFormat(totalGrand / totalDays)
}
}

isWeekdayClients(client) {
isWeekdayClient(client) {
if (!client) return false

let weekdayClients = Settings.weekdayClients
return weekdayClients.some(registered => client.startsWith(registered))
}

isWeekdayProjects(project) {
isWeekdayProject(project) {
if (!project) return false

let weekdayProjects = Settings.weekdayProjects
Expand Down

0 comments on commit 2dfaa8a

Please sign in to comment.