Add the profitability report and the internal hourly cost
Profitability by job and service unit from a period's hours, expenses and the created billing materials of its months. Hours are costed at one internal hourly cost, set on the price list maintenance page; a job of several service units is shared evenly between them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -37,4 +37,9 @@ class CatalogForReports implements ReportCatalog
|
||||
|
||||
return $units;
|
||||
}
|
||||
|
||||
public function internalHourlyCostCents(): ?int
|
||||
{
|
||||
return $this->prices->internalHourlyCostCents();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Reports\Infrastructure\Adapters;
|
||||
|
||||
use App\Modules\Billing\Application\Contracts\BilledRevenueQueries;
|
||||
use App\Modules\Billing\Application\DTOs\BilledJobRevenue;
|
||||
use App\Modules\Reports\Application\Contracts\ReportRevenue;
|
||||
use App\Modules\Reports\Application\DTOs\JobRevenue;
|
||||
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
||||
|
||||
/**
|
||||
* Billed amounts for reports through the Billing module.
|
||||
*/
|
||||
class RevenueForReports implements ReportRevenue
|
||||
{
|
||||
public function __construct(private BilledRevenueQueries $queries) {}
|
||||
|
||||
public function byJob(ReportPeriod $period): array
|
||||
{
|
||||
return array_map(fn (BilledJobRevenue $revenue): JobRevenue => new JobRevenue(
|
||||
$revenue->jobId,
|
||||
$revenue->hoursNetCents + $revenue->fixedPriceNetCents + $revenue->monthlyFeeNetCents,
|
||||
$revenue->expenseNetCents,
|
||||
$revenue->billedQuarters,
|
||||
), $this->queries->byJob($period->fromMonth(), $period->toMonth()));
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,14 @@ use App\Modules\Reports\Application\Contracts\ReportExpenses;
|
||||
use App\Modules\Reports\Application\Contracts\ReportHours;
|
||||
use App\Modules\Reports\Application\Contracts\ReportJobs;
|
||||
use App\Modules\Reports\Application\Contracts\ReportPeople;
|
||||
use App\Modules\Reports\Application\Contracts\ReportRevenue;
|
||||
use App\Modules\Reports\Application\Contracts\ReportSales;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\CatalogForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\ExpensesForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\HoursForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\JobsForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\PeopleForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\RevenueForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\SalesForReports;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@@ -36,6 +38,7 @@ class ReportsServiceProvider extends ServiceProvider
|
||||
ReportPeople::class => PeopleForReports::class,
|
||||
ReportSales::class => SalesForReports::class,
|
||||
ReportExpenses::class => ExpensesForReports::class,
|
||||
ReportRevenue::class => RevenueForReports::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
|
||||
Reference in New Issue
Block a user