<?php

namespace App\Filament\Tenant\Resources\PurchaseResource\Pages;

use App\Filament\Tenant\Resources\PurchaseResource;
use App\Models\Tenant\Purchase;
use App\Tenancy\TenantManager;
use Filament\Resources\Pages\CreateRecord;

class CreatePurchase extends CreateRecord
{
    protected static string $resource = PurchaseResource::class;

    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $companyId = app(TenantManager::class)->currentId();
        $data['number'] = Purchase::generateNumber($companyId);
        return $data;
    }
}
