Files
Toiminnanohjaus/app/Modules/Reports/Presentation/Csv/HoursCsv.php
T
petriandClaude Sonnet 5.5 a57b383e4d 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]>
2026-11-25 08:41:43 +02:00

48 lines
1.4 KiB
PHP

<?php
namespace App\Modules\Reports\Presentation\Csv;
use App\Modules\Reports\Application\UseCases\HoursByPerson;
use App\Modules\Reports\Presentation\ReportFormat;
use Illuminate\Http\Request;
/**
* Hours by person as CSV: a row per person, job and work type.
*/
class HoursCsv implements ReportCsv
{
public function __construct(private HoursByPerson $report) {}
public function fileName(Request $request): string
{
$period = CsvFilters::period($request);
return __('reports.hours.file').'-'.$period->from.'-'.$period->to;
}
public function headers(): array
{
return array_values(__('reports.hours.csv'));
}
public function rows(Request $request): iterable
{
$report = $this->report->execute(CsvFilters::period($request), CsvFilters::id($request, 'yksikko'), CsvFilters::id($request, 'asiakas'));
foreach ($report->lines as $line) {
yield [
$line->userName,
$line->jobNumber,
$line->jobName,
$line->customerName,
__($line->isInternal ? 'reports.yes' : 'reports.no'),
$line->serviceUnitName,
$line->workTypeName,
ReportFormat::csvHours($line->quarters),
ReportFormat::csvHours($line->unapprovedQuarters),
ReportFormat::csvHours($line->billedQuarters),
];
}
}
}