Add the unbilled hours report

Hours on customers' billable jobs that no billing material has taken,
by job and work type up to a day, valued at the hourly rates for jobs
billed by the hour, with a chart by service unit and CSV.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-25 08:41:43 +02:00
co-authored by Claude Sonnet 5.5
parent 64f1e7c54a
commit a57b383e4d
17 changed files with 697 additions and 45 deletions
@@ -0,0 +1,49 @@
<?php
namespace App\Modules\Reports\Presentation\Csv;
use App\Modules\Reports\Application\UseCases\UnbilledHoursReport;
use App\Modules\Reports\Presentation\ReportFormat;
use Illuminate\Http\Request;
/**
* Unbilled hours as CSV: a row per job and work type, values in cents.
*/
class UnbilledCsv implements ReportCsv
{
public function __construct(private UnbilledHoursReport $report) {}
public function fileName(Request $request): string
{
return __('reports.unbilled.file').'-'.CsvFilters::day($request, 'paiva');
}
public function headers(): array
{
return array_values(__('reports.unbilled.csv'));
}
public function rows(Request $request): iterable
{
$report = $this->report->execute(CsvFilters::day($request, 'paiva'), CsvFilters::id($request, 'yksikko'));
foreach ($report->jobs as $row) {
foreach ($row->workTypes as $line) {
yield [
$row->job->number,
$row->job->name,
$row->job->customerName,
__('jobs.statuses.'.$row->job->status),
$row->job->paymentBasis === null ? '' : __('jobs.payment_bases.'.$row->job->paymentBasis),
$line->serviceUnitName,
$line->name,
ReportFormat::csvHours($line->approvedQuarters),
ReportFormat::csvHours($line->unapprovedQuarters),
$line->rateCents ?? '',
$line->valueCents ?? '',
$row->oldestDay,
];
}
}
}
}