Skip to content

[72676] 'Actual costs per months' widget does not show previous 11 months#22149

Open
HDinger wants to merge 1 commit intorelease/17.2from
bug/72676-actual-costs-per-months-widget-does-not-show-previous-11-months
Open

[72676] 'Actual costs per months' widget does not show previous 11 months#22149
HDinger wants to merge 1 commit intorelease/17.2from
bug/72676-actual-costs-per-months-widget-does-not-show-previous-11-months

Conversation

@HDinger
Copy link
Contributor

@HDinger HDinger commented Mar 2, 2026

Ticket

https://community.openproject.org/wp/72676

What are you trying to accomplish?

Show last 11month and current month instead of the current year

@HDinger HDinger added this to the 17.2.x milestone Mar 2, 2026
@HDinger HDinger force-pushed the bug/72676-actual-costs-per-months-widget-does-not-show-previous-11-months branch from 35c8ee5 to c420236 Compare March 2, 2026 12:34
super

@aggregated_costs = Costs::AggregatedCosts.new(project:, current_user:, date_range: Date.current.all_year)
@aggregated_costs = Costs::AggregatedCosts.new(project:, current_user:, date_range: 11.months.ago.to_date..Date.current)
Copy link
Contributor

@myabc myabc Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first (and likely last) month bars in the chart will show an incomplete month's data (unless Date.current happens to be on the 1st of the month)

Do we want to show rolling 12 months, as you've implemented? - or the last 12 full calendar months?

Suggested change
@aggregated_costs = Costs::AggregatedCosts.new(project:, current_user:, date_range: 11.months.ago.to_date..Date.current)
start_date = Date.current.beginning_of_month - 11.months
end_date = Date.current.end_of_month
@aggregated_costs = Costs::AggregatedCosts.new(project:, current_user:, date_range: start_date..end_date)
start_date..end_date
# => Tue, 01 Apr 2025..Tue, 31 Mar 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants