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:
@@ -3,7 +3,6 @@
|
||||
namespace App\Modules\Reports\Presentation\Csv;
|
||||
|
||||
use App\Modules\Reports\Application\UseCases\HoursByPerson;
|
||||
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
||||
use App\Modules\Reports\Presentation\ReportFormat;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -14,14 +13,21 @@ 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(ReportPeriod $period, Request $request): iterable
|
||||
public function rows(Request $request): iterable
|
||||
{
|
||||
$report = $this->report->execute($period, self::id($request, 'yksikko'), self::id($request, 'asiakas'));
|
||||
$report = $this->report->execute(CsvFilters::period($request), CsvFilters::id($request, 'yksikko'), CsvFilters::id($request, 'asiakas'));
|
||||
|
||||
foreach ($report->lines as $line) {
|
||||
yield [
|
||||
@@ -38,11 +44,4 @@ class HoursCsv implements ReportCsv
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function id(Request $request, string $key): ?int
|
||||
{
|
||||
$value = $request->query($key);
|
||||
|
||||
return is_string($value) && ctype_digit($value) ? (int) $value : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user