Skip to content

Commit

Permalink
fix bug calculating monthly capacity in previous years
Browse files Browse the repository at this point in the history
  • Loading branch information
markdturner committed Sep 26, 2024
1 parent 2c525d7 commit 2aabd5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/api/timesheet/services/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ module.exports = ({ strapi }) => ({
const summary = await fetchSummaryReport(year, userIDs, projectIDs),
annuaLeave = await strapi.services['api::timesheet.timesheet'].leave(query),
holidays = await fetchBankHolidays(year),
rses = await strapi.services['api::rse.rse'].find({populate: { capacities: { filters: dateRangeFilter } }, filters: { active: true } })
rses = await strapi.services['api::rse.rse'].find({populate: { capacities: { filters: dateRangeFilter } } })


const holidayDates = holidays.map(holiday => DateTime.fromISO(holiday.date).toISODate())
Expand All @@ -624,6 +624,8 @@ module.exports = ({ strapi }) => ({

let profile = rses.results.find(r => r.clockifyID === rse._id)

if(!profile) console.log(rse)

const rseLeave = annuaLeave.data.filter(leave => leave.ID === profile.username)

let months = []
Expand All @@ -633,7 +635,7 @@ module.exports = ({ strapi }) => ({
let billableTime = month.children.reduce((total, project) => project.amount > 0 ? total + project.duration : 0, 0)

const start = DateTime.fromFormat(month.name, 'MMM yyyy').startOf('month'),
end = start.month === DateTime.now().month ? DateTime.now() : start.endOf('month')
end = start.month === DateTime.now().month && start.year === DateTime.now().year ? DateTime.now() : start.endOf('month')

let date = start

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-09-21T10:08:19.492Z"
"x-generation-date": "2024-09-26T05:17:23.053Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit 2aabd5a

Please sign in to comment.