Management builds the monthly billing material (laskuaineisto) as a draft: done jobs are added as invoices of their own, combined when the customer, billing unit and reference allow it, and their billable hours are set per work type. Creating the material checks the jobs again, marks the approved hours and billable expenses billed, forms invoice lines with price and VAT snapshots and moves the jobs to "Lasku luotu". Fixed price jobs bill their quoted amount once. Billed hours keep their approval and billed expenses can no longer change. The Fennoa export and monthly fee lines come later. Co-Authored-By: Claude Opus 5.5 <[email protected]>
34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Billing\Infrastructure;
|
|
|
|
use App\Modules\Billing\Application\Contracts\BillingHours;
|
|
use App\Modules\Billing\Application\DTOs\JobHours;
|
|
use App\Modules\TimeTracking\Application\Contracts\TimeEntryQueries;
|
|
use App\Modules\TimeTracking\Application\DTOs\JobBillingHours;
|
|
use App\Modules\TimeTracking\Application\UseCases\MarkJobHoursBilled;
|
|
|
|
/**
|
|
* Hours for billing through the TimeTracking module.
|
|
*/
|
|
class HoursForBilling implements BillingHours
|
|
{
|
|
public function __construct(
|
|
private TimeEntryQueries $entries,
|
|
private MarkJobHoursBilled $markBilled,
|
|
) {}
|
|
|
|
public function forJobs(array $jobIds): array
|
|
{
|
|
return array_map(
|
|
fn (JobBillingHours $hours): JobHours => new JobHours($hours->jobId, $hours->approvedQuartersByWorkType, $hours->unapprovedQuarters),
|
|
$this->entries->billingHours($jobIds),
|
|
);
|
|
}
|
|
|
|
public function markBilled(int $jobId, int $billingExportId): array
|
|
{
|
|
return $this->markBilled->execute($jobId, $billingExportId);
|
|
}
|
|
}
|