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]>
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?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,
|
|
];
|
|
}
|
|
}
|
|
}
|
|
}
|