Skip to content
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

3602: Billable unbilled hours report #195

Merged
merged 23 commits into from
Jan 22, 2025

Conversation

jeppekroghitk
Copy link
Contributor

@jeppekroghitk jeppekroghitk commented Jan 17, 2025

Link to ticket

#3602

Description

Added Billable unbilled hours report, for viewing billable worklogs that have not been billed.

Screenshot of the result

N/A

Checklist

  • My code is covered by test cases.
  • My code passes our test (all our tests).
  • My code passes our static analysis suite.
  • My code passes our continuous integration process.

@jeppekroghitk jeppekroghitk requested a review from tuj January 20, 2025 08:13
$totalHoursForAllProjects = 0;

foreach ($billableWorklogs as $billableWorklog) {
if (false === $billableWorklog->isBilled()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this you should add a parameter "$isBilled = null" to findBillableWorklogsByWorkerAndDateRange repository method that only applies if $isBilled is not null. That would limit the number of entities you get from the database and thereby limit the memory use and execution time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great idea. I don't see a situation where it is relevant to get is_billed=null from findBillableWorklogsByWorkerAndDateRange at all, so i added a filter for this in the select.

I still want to be able to get billable worklogs, even after they are billed.

@jeppekroghitk jeppekroghitk requested a review from tuj January 20, 2025 12:34
@@ -113,7 +113,7 @@ public function findWorklogsByWorkerAndDateRange(string $workerIdentifier, \Date
->getQuery()->getResult();
}

public function findBillableWorklogsByWorkerAndDateRange(string $workerIdentifier, \DateTime $dateFrom, \DateTime $dateTo)
public function findBillableWorklogsByWorkerAndDateRange(\DateTime $dateFrom, \DateTime $dateTo, ?string $workerIdentifier = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking something along these lines:

public function findBillableWorklogsByWorkerAndDateRange(\DateTime $dateFrom, \DateTime $dateTo, ?string $workerIdentifier = null, bool? $isBilled = null)
{
  ...
 
  if ($isBilled !== null) {
    $qb->andWhere($qb->expr()->eq('worklog.isBilled', ':isBilled'))
    ->setParameter('isBilled', $isBilled);
  }

}        

And then in BillableUnbilledHoursReportService call

$billableWorklogs = $this->worklogRepository->findBillableWorklogsByWorkerAndDateRange($dateFrom, $dateTo, null, true);

Then the

   if (false === $billableWorklog->isBilled()) {

would not be needed in BillableUnbilledHoursReportService. And you would process fewer entities.

@jeppekroghitk jeppekroghitk requested a review from tuj January 22, 2025 09:31
@jeppekroghitk jeppekroghitk merged commit eae6382 into develop Jan 22, 2025
9 checks passed
@jeppekroghitk jeppekroghitk deleted the feature/3602-unbilled-billable-hours-report branch January 22, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants