Skip to content

Commit

Permalink
fix for assignments that span the entire FY
Browse files Browse the repository at this point in the history
  • Loading branch information
markdturner committed Aug 23, 2024
1 parent fb263ca commit ccbd5d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/api/rse/services/rse.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ module.exports = createCoreService("api::rse.rse", ({ strapi }) => ({
end: {
$between: [startDate.toISODate(), endDate.toISODate() ]
}
},
{
start: {
$lt: startDate.toISODate()
},
end: {
$gt: endDate.toISODate()
}
}
]
}
Expand Down Expand Up @@ -456,12 +464,22 @@ module.exports = createCoreService("api::rse.rse", ({ strapi }) => ({

let day = {
date: date.toISODate(),
day: date.day,
month: date.month,
year: date.year,
dayOfWeek: date.weekday,
isWeekend: date.weekday > 5,
capacity: dateCapacity,
metadata: {
day: date.day,
month: date.month,
year: date.year,
dayOfWeek: date.weekday,
isWeekend: date.weekday > 5
},
utilisation: {
capacity: dateCapacity,
allocated: currentAssignments.reduce((total, assignment) => total + assignment.fte, 0),
unallocated: dateCapacity - currentAssignments.reduce((total, assignment) => total + assignment.fte, 0),
recorded: {
billable: timesheetSummary.reduce((total, timesheet) => total + (timesheet.billable ? timesheet.duration : 0), 0),
nonBillable: timesheetSummary.reduce((total, timesheet) => total + (timesheet.billable ? 0 : timesheet.duration), 0)
}
},
holiday: holiday ? holiday : null,
leave: leaveDay ? { type: leaveDay.TYPE, duration: leaveDay.DURATION, status: leaveDay.STATUS } : null,
assignments: currentAssignments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-08-23T13:12:47.118Z"
"x-generation-date": "2024-08-23T21:16:04.397Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit ccbd5d4

Please sign in to comment.