Add the billing material with drafts, combined invoices and billed marks
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]>
This commit is contained in:
@@ -8,7 +8,8 @@ use App\Modules\Expenses\Domain\ValueObjects\ExpenseDetails;
|
||||
|
||||
/**
|
||||
* An expense on a customer job: whose it is, who recorded it (management
|
||||
* records subcontractors' expenses) and what it is.
|
||||
* records subcontractors' expenses) and what it is. A billed expense (on a
|
||||
* billing material) can no longer be changed or removed.
|
||||
*/
|
||||
final class Expense
|
||||
{
|
||||
@@ -18,6 +19,7 @@ final class Expense
|
||||
private int $userId,
|
||||
private int $recordedBy,
|
||||
private ExpenseDetails $details,
|
||||
private ?int $billingExportId = null,
|
||||
) {}
|
||||
|
||||
public static function record(int $jobId, int $userId, int $recordedBy, ExpenseDetails $details): self
|
||||
@@ -25,9 +27,19 @@ final class Expense
|
||||
return new self(null, $jobId, $userId, $recordedBy, $details);
|
||||
}
|
||||
|
||||
public static function reconstitute(int $id, int $jobId, int $userId, int $recordedBy, ExpenseDetails $details): self
|
||||
public static function reconstitute(int $id, int $jobId, int $userId, int $recordedBy, ExpenseDetails $details, ?int $billingExportId = null): self
|
||||
{
|
||||
return new self($id, $jobId, $userId, $recordedBy, $details);
|
||||
return new self($id, $jobId, $userId, $recordedBy, $details, $billingExportId);
|
||||
}
|
||||
|
||||
public function isBilled(): bool
|
||||
{
|
||||
return $this->billingExportId !== null;
|
||||
}
|
||||
|
||||
public function billingExportId(): ?int
|
||||
{
|
||||
return $this->billingExportId;
|
||||
}
|
||||
|
||||
public function change(int $userId, ExpenseDetails $details): void
|
||||
|
||||
Reference in New Issue
Block a user