Skip to content

Commit 31c82ee

Browse files
authored
fix weekly count (#20)
1 parent e3dea78 commit 31c82ee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/services/TeamService.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
7171

7272
const firstDay = new Date(curr.setDate(first))
7373
const lastDay = new Date(curr.setDate(last))
74+
lastDay.setHours(23, 59, 59, 59) // the end of the day
75+
logger.debug({ component: 'TeamService', context: 'getTeamDetail', message: `week started: ${firstDay}, week ended: ${lastDay}` })
7476

7577
const result = []
7678
for (const project of projects) {
@@ -104,8 +106,9 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
104106
const startDate = new Date(item.startDate)
105107
const endDate = new Date(item.endDate)
106108

107-
if ((!item.startDate || (startDate <= firstDay && startDate < lastDay)) &&
108-
(!item.endDate || (endDate >= lastDay && endDate > firstDay))) {
109+
// normally startDate is smaller than endDate for a resourceBooking so not check if startDate < endDate
110+
if ((!item.startDate || startDate < lastDay) &&
111+
(!item.endDate || endDate > firstDay)) {
109112
res.weeklyCount += item.customerRate
110113
}
111114
}

0 commit comments

Comments
 (0)