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:
@@ -4,6 +4,7 @@ namespace App\Modules\Billing\Presentation\Http\Controllers;
|
||||
|
||||
use App\Modules\Billing\Application\DTOs\ExportRow;
|
||||
use App\Modules\Billing\Application\Services\ExportRows;
|
||||
use App\Modules\Billing\Application\Services\ExportViews;
|
||||
use App\Modules\Billing\Domain\Enums\LineKind;
|
||||
use App\Modules\Billing\Domain\Exceptions\BillingExportNotFound;
|
||||
use App\Modules\Billing\Domain\Exceptions\ExportNotCreated;
|
||||
@@ -19,7 +20,7 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
*/
|
||||
class DownloadBillingCsv
|
||||
{
|
||||
public function __invoke(int $export, ExportRows $exportRows): StreamedResponse
|
||||
public function __invoke(int $export, ExportRows $exportRows, ExportViews $exportViews): StreamedResponse
|
||||
{
|
||||
Gate::authorize('billing.manage');
|
||||
|
||||
@@ -29,6 +30,8 @@ class DownloadBillingCsv
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$number = $exportViews->of($export)->number ?? abort(404);
|
||||
|
||||
return response()->streamDownload(function () use ($rows): void {
|
||||
$out = fopen('php://output', 'w');
|
||||
|
||||
@@ -44,7 +47,7 @@ class DownloadBillingCsv
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
}, __('billing.csv.file', ['number' => $export]), [
|
||||
}, __('billing.csv.file', ['number' => $number]), [
|
||||
'Content-Type' => 'text/csv; charset=UTF-8',
|
||||
'Cache-Control' => 'no-store, private',
|
||||
]);
|
||||
|
||||
@@ -210,9 +210,19 @@ new class extends Component
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* A draft has no number yet: it is reserved when the material is created.
|
||||
*/
|
||||
public function heading(): string
|
||||
{
|
||||
$number = $this->export->number;
|
||||
|
||||
return $number === null ? __('billing.export.draft_title') : __('billing.export.title', ['number' => $number]);
|
||||
}
|
||||
|
||||
public function render(): mixed
|
||||
{
|
||||
return $this->view()->title(__('billing.export.title', ['number' => $this->exportId]));
|
||||
return $this->view()->title($this->heading());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,7 +318,7 @@ new class extends Component
|
||||
|
||||
<div class="space-y-2">
|
||||
<p><x-link :href="route('billing.index')" navigate>{{ __('billing.export.back') }}</x-link></p>
|
||||
<h1 class="text-2xl font-semibold">{{ __('billing.export.title', ['number' => $export->id]) }}</h1>
|
||||
<h1 class="text-2xl font-semibold">{{ $this->heading() }}</h1>
|
||||
<p class="flex items-center gap-2 text-sm">
|
||||
@if ($export->isDraft())
|
||||
<x-icon name="pencil-square" class="size-5 shrink-0" aria-hidden="true" />
|
||||
|
||||
@@ -106,7 +106,7 @@ new class extends Component
|
||||
@else
|
||||
<x-table :headers="$this->headers()" :rows="$this->exports">
|
||||
@interact('column_number', $export)
|
||||
<x-link :href="route('billing.export', $export->id)" navigate>{{ __('billing.index.export_label', ['number' => $export->id]) }}</x-link>
|
||||
<x-link :href="route('billing.export', $export->id)" navigate>{{ $export->number === null ? __('billing.index.draft_label') : __('billing.index.export_label', ['number' => $export->number]) }}</x-link>
|
||||
@endinteract
|
||||
|
||||
@interact('column_status', $export)
|
||||
@@ -142,7 +142,7 @@ new class extends Component
|
||||
|
||||
@interact('column_file', $export)
|
||||
@if ($export->status->value === 'created')
|
||||
<x-link :href="route('billing.csv', $export->id)" icon="arrow-down-tray" :aria-label="__('billing.csv.download_named', ['number' => $export->id])">{{ __('billing.csv.download_short') }}</x-link>
|
||||
<x-link :href="route('billing.csv', $export->id)" icon="arrow-down-tray" :aria-label="__('billing.csv.download_named', ['number' => $export->number])">{{ __('billing.csv.download_short') }}</x-link>
|
||||
@endif
|
||||
@endinteract
|
||||
</x-table>
|
||||
|
||||
Reference in New Issue
Block a user