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:
@@ -13,6 +13,7 @@ use Illuminate\Support\Carbon;
|
||||
* Persistence model, used only inside the Billing Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $number
|
||||
* @property ExportStatus $status
|
||||
* @property string|null $period Y-m
|
||||
* @property int $created_by
|
||||
@@ -21,7 +22,7 @@ use Illuminate\Support\Carbon;
|
||||
* @property Carbon $created_at
|
||||
*/
|
||||
#[Table('billing_exports')]
|
||||
#[Fillable(['status', 'period', 'created_by', 'finalized_by', 'finalized_at'])]
|
||||
#[Fillable(['number', 'status', 'period', 'created_by', 'finalized_by', 'finalized_at'])]
|
||||
class BillingExportModel extends Model
|
||||
{
|
||||
/**
|
||||
@@ -39,6 +40,7 @@ class BillingExportModel extends Model
|
||||
{
|
||||
return [
|
||||
'status' => ExportStatus::class,
|
||||
'number' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
'finalized_by' => 'integer',
|
||||
'finalized_at' => 'datetime',
|
||||
|
||||
+7
@@ -45,6 +45,7 @@ class EloquentBillingExportRepository implements BillingExportRepository
|
||||
$model = $export->id() === null ? new BillingExportModel : BillingExportModel::query()->findOrFail($export->id());
|
||||
|
||||
$model->fill([
|
||||
'number' => $export->number(),
|
||||
'status' => $export->status(),
|
||||
'period' => $export->period(),
|
||||
'created_by' => $export->createdBy(),
|
||||
@@ -116,6 +117,11 @@ class EloquentBillingExportRepository implements BillingExportRepository
|
||||
BillingExportModel::query()->whereKey($export->id())->delete();
|
||||
}
|
||||
|
||||
public function nextNumber(): int
|
||||
{
|
||||
return (int) BillingExportModel::query()->max('number') + 1;
|
||||
}
|
||||
|
||||
public function fixedPriceBilledJobIds(array $jobIds): array
|
||||
{
|
||||
if ($jobIds === []) {
|
||||
@@ -175,6 +181,7 @@ class EloquentBillingExportRepository implements BillingExportRepository
|
||||
|
||||
return BillingExport::reconstitute(
|
||||
$model->id,
|
||||
$model->number,
|
||||
$model->status,
|
||||
$model->period ?? $model->created_at->format('Y-m'),
|
||||
$model->created_by,
|
||||
|
||||
@@ -43,6 +43,7 @@ class EloquentBillingQueries implements BillingQueries
|
||||
|
||||
return $models->map(fn (BillingExportModel $model): ExportSummary => new ExportSummary(
|
||||
$model->id,
|
||||
$model->number,
|
||||
$model->status,
|
||||
DateTimeImmutable::createFromInterface($model->created_at),
|
||||
$names[$model->created_by] ?? '',
|
||||
|
||||
Reference in New Issue
Block a user