Everyone sees their open tasks on an agenda, their open jobs, this week's hours and quick links. Admin and management also get a lazily loaded management panel: things to do, the month so far against the previous month, jobs and late work, and everyone's workload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Dashboard\Infrastructure\Adapters;
|
|
|
|
use App\Modules\Dashboard\Application\Contracts\DashboardFigures;
|
|
use App\Modules\Dashboard\Application\DTOs\PeriodFigures;
|
|
use App\Modules\Reports\Application\UseCases\HoursByPerson;
|
|
use App\Modules\Reports\Application\UseCases\ProfitabilityByJob;
|
|
use App\Modules\Reports\Application\UseCases\QuickSalesReport;
|
|
use App\Modules\Reports\Application\UseCases\UnbilledHoursReport;
|
|
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
|
|
|
/**
|
|
* Key figures through the Reports module's reports, so the panel shows the
|
|
* same numbers as the reports.
|
|
*/
|
|
class FiguresForDashboard implements DashboardFigures
|
|
{
|
|
public function __construct(
|
|
private HoursByPerson $hours,
|
|
private ProfitabilityByJob $profitability,
|
|
private QuickSalesReport $sales,
|
|
private UnbilledHoursReport $unbilled,
|
|
) {}
|
|
|
|
public function between(string $from, string $to): PeriodFigures
|
|
{
|
|
$period = new ReportPeriod($from, $to);
|
|
$hours = $this->hours->execute($period)->total;
|
|
$profit = $this->profitability->execute($period)->total;
|
|
|
|
return new PeriodFigures(
|
|
$hours->customerQuarters,
|
|
$hours->internalQuarters,
|
|
$profit->revenueCents(),
|
|
$profit->marginCents(),
|
|
$this->sales->execute($period)->totalCents(),
|
|
);
|
|
}
|
|
|
|
public function unbilledValueCents(string $day): int
|
|
{
|
|
return $this->unbilled->execute($day)->valueCents;
|
|
}
|
|
}
|