exports = $exports; $this->transactions = $transactions; } /** * @throws BillingExportNotFound * @throws ExportNotDraft * @throws JobAlreadyInDraft * @throws JobNotBillable */ public function execute(int $exportId, int $jobId): void { $this->changeDraft($exportId, function (BillingExport $export) use ($jobId): void { $snapshot = $this->snapshots->load($export->period(), [$jobId]); $job = $snapshot->jobs[$jobId] ?? throw new JobNotBillable($jobId, NotBillableReason::WrongStatus); $reason = $snapshot->reasonNotBillable($job); if ($reason !== null) { throw new JobNotBillable($jobId, $reason); } $export->addJob($job->toDraftJob()); }); } }