Add an editable menu name and reserve billing material numbers on creation

- Company details get an optional "Valikon nimi", shown at the left of the
  main menu; it falls back to the application name when empty.
- A billing material gets its running number (billing_exports.number) only
  when it is created, so discarded drafts leave no gaps. Drafts have no
  number; existing created materials are numbered by the migration, and the
  CSV file name uses the number.
- TaskAssigneeMigrationTest rolls back from its own migration onward instead
  of assuming it is the last one.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-24 19:41:57 +02:00
co-authored by Claude Sonnet 5.5
parent 48030e7689
commit 7d7b72989d
25 changed files with 195 additions and 23 deletions
@@ -26,6 +26,11 @@ interface BillingExportRepository
public function delete(BillingExport $export): void;
/**
* The next free number of a created material (1, 2, ...), without gaps.
*/
public function nextNumber(): int;
/**
* The jobs among the given ones whose fixed price is already on a created material.
*
@@ -30,6 +30,7 @@ final class BillingExport
*/
private function __construct(
private ?int $id,
private ?int $number,
private ExportStatus $status,
private string $period,
private int $createdBy,
@@ -44,15 +45,15 @@ final class BillingExport
*/
public static function startDraft(int $createdBy, DateTimeImmutable $now): self
{
return new self(null, ExportStatus::Draft, $now->format('Y-m'), $createdBy, $now, null, null, []);
return new self(null, null, ExportStatus::Draft, $now->format('Y-m'), $createdBy, $now, null, null, []);
}
/**
* @param list<BillingInvoice> $invoices
*/
public static function reconstitute(int $id, ExportStatus $status, string $period, int $createdBy, DateTimeImmutable $createdAt, ?int $finalizedBy, ?DateTimeImmutable $finalizedAt, array $invoices): self
public static function reconstitute(int $id, ?int $number, ExportStatus $status, string $period, int $createdBy, DateTimeImmutable $createdAt, ?int $finalizedBy, ?DateTimeImmutable $finalizedAt, array $invoices): self
{
return new self($id, $status, $period, $createdBy, $createdAt, $finalizedBy, $finalizedAt, $invoices);
return new self($id, $number, $status, $period, $createdBy, $createdAt, $finalizedBy, $finalizedAt, $invoices);
}
/**
@@ -170,14 +171,14 @@ final class BillingExport
}
/**
* Forms the invoice lines and locks the material.
* Forms the invoice lines, gives the material its number and locks it.
*
* @param array<int, list<InvoiceLine>> $linesByJob Keyed by job id.
*
* @throws ExportNotDraft
* @throws ExportEmpty
*/
public function finalize(array $linesByJob, int $finalizedBy, DateTimeImmutable $now): void
public function finalize(array $linesByJob, int $number, int $finalizedBy, DateTimeImmutable $now): void
{
$this->ensureDraft();
@@ -193,6 +194,7 @@ final class BillingExport
$invoice->setLines($lines);
}
$this->number = $number;
$this->status = ExportStatus::Created;
$this->finalizedBy = $finalizedBy;
$this->finalizedAt = $now;
@@ -240,6 +242,14 @@ final class BillingExport
return $this->id;
}
/**
* The running number, reserved when the material is created; a draft has none.
*/
public function number(): ?int
{
return $this->number;
}
public function status(): ExportStatus
{
return $this->status;