Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exclude non-billable entries from revenue - #6076

Open
Marukome0743 wants to merge 2 commits into
kimai:mainfrom
Marukome0743:pr6076
Open

Exclude non-billable entries from revenue#6076
Marukome0743 wants to merge 2 commits into
kimai:mainfrom
Marukome0743:pr6076

Conversation

@Marukome0743

@Marukome0743 Marukome0743 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

Non-billable timesheet entries were included in values labeled as Revenue, even though the same reports correctly tracked their billable duration separately.

This change uses the existing billable revenue aggregation throughout the single-user and all-user week, month, and year reports, including their XLSX exports. Customer monthly projects now calculates rate with a conditional SQL sum, so project, activity, user, and export totals all exclude entries where billable = false.

Duration and internal price continue to include all entries.

Fixes #5920

Visual comparison

The same report contains one billable entry worth EUR 100 and one non-billable entry worth EUR 40.

Before After
Revenue before: non-billable entry included in EUR 140 total Revenue after: only billable EUR 100 is included

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Validation

  • Focused PHPUnit: 65 tests, 290 assertions
  • Revenue regression tests: 7 tests, 29 assertions
  • ./php-cs-fixer.sh core
  • ./phpstan.sh core
  • ./phpstan.sh test
  • Browser verification with billable EUR 100 and non-billable EUR 40 entries

Checklist

  • I verified that my code applies to the guidelines (composer code-check equivalent checks listed above)
  • Documentation is not required because this fixes existing report calculations without changing public behavior or configuration
  • I agree that this code is used in Kimai (see license)

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.76%. Comparing base (589296c) to head (b6b37d9).
⚠️ Report is 64 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6076      +/-   ##
============================================
+ Coverage     88.70%   88.76%   +0.05%     
- Complexity    10055    10057       +2     
============================================
  Files           889      889              
  Lines         32051    32060       +9     
============================================
+ Hits          28432    28459      +27     
+ Misses         3619     3601      -18     
Files with missing lines Coverage Δ
...troller/Reporting/AbstractUserReportController.php 98.73% <100.00%> (+0.16%) ⬆️
...thlyProjects/CustomerMonthlyProjectsRepository.php 100.00% <100.00%> (+9.01%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes reporting “Revenue” calculations so that non-billable timesheet entries no longer contribute to revenue totals (while duration and internal price continue to include all entries). It updates both on-screen reports and their XLSX exports to consistently use billable-only rate aggregation.

Changes:

  • Switched multiple reporting templates (weekly/monthly user and user-list period views, including exports) from totalRate to billableRate when rendering “Revenue”.
  • Extended user-report aggregation to track and roll up billableRate alongside existing duration, total rate, and internal rate totals.
  • Updated the customer monthly projects reporting query to compute revenue via a conditional SUM that excludes billable = false, and added regression tests for the corrected behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Controller/Reporting/CustomerMonthlyProjectsControllerTest.php Adds an integration regression test to ensure customer monthly project revenue excludes non-billable entries.
tests/Controller/Reporting/AbstractUsersPeriodControllerTestCase.php Adds shared regression coverage to ensure “all users” period reports exclude non-billable entries from revenue.
tests/Controller/Reporting/AbstractUserPeriodControllerTestCase.php Adds shared regression coverage to ensure “single user” period reports exclude non-billable entries from revenue.
templates/reporting/user_list_period_data.html.twig Updates user-period total accumulation to use billableRate for revenue totals.
templates/reporting/report_user_list.html.twig Renders revenue using billableRate in the (non-monthly) user list report.
templates/reporting/report_user_list_monthly.html.twig Renders revenue using billableRate in the monthly user list report.
templates/reporting/report_user_list_monthly_export.html.twig Updates XLSX export values to output billableRate for revenue.
templates/reporting/report_user_list_export.html.twig Updates XLSX export values to output billableRate for revenue.
templates/reporting/report_by_user_data.html.twig Updates week/month “by user” report rendering and totals to use billableRate for revenue.
src/Reporting/CustomerMonthlyProjects/CustomerMonthlyProjectsRepository.php Changes revenue aggregation to a conditional SUM excluding non-billable entries.
src/Controller/Reporting/AbstractUserReportController.php Aggregates and propagates billableRate through customer/project/activity rollups for report rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Controller/Reporting/CustomerMonthlyProjectsControllerTest.php Outdated
Comment thread tests/Controller/Reporting/AbstractUserPeriodControllerTestCase.php Outdated
Comment thread tests/Controller/Reporting/AbstractUsersPeriodControllerTestCase.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-billable tasks listed in reports as revenue

3 participants