Skip to content

fix weekly count #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/services/TeamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {

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

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

if ((!item.startDate || (startDate <= firstDay && startDate < lastDay)) &&
(!item.endDate || (endDate >= lastDay && endDate > firstDay))) {
// normally startDate is smaller than endDate for a resourceBooking so not check if startDate < endDate
if ((!item.startDate || startDate < lastDay) &&
(!item.endDate || endDate > firstDay)) {
res.weeklyCount += item.customerRate
}
}
Expand Down