Faza 3.4: Finanțe — Plăți + Cheltuieli + Cashflow
Schema: - payments: client_id, work_order_id, user_id (operator), paid_at, amount, method (cash/card/transfer/mobile), reference, notes - expenses: supplier_id, purchase_id, paid_at, category (salary/purchase/rent/ utilities/advance/tax/fuel/tools/marketing/other), name, amount, method, ref Logică auto: - Payment::saved/deleted recalculează automat work_order.pay_status (unpaid → partial → paid) based on suma totală vs work_order.total - WO model are noi metode: payments(), paidAmount(), balanceDue() Filament resources (group Finanțe): - PaymentResource: form cu legare opțională la WO + client; tabel cu Sum summary, filtre azi/luna_curentă/method - ExpenseResource: 10 categorii preset, badge categ, total summary, filtru luna curentă - PaymentsRelationManager pe WO: "Plăți" tab cu auto-fill client_id + user_id la creare Widget FinanceOverview: - Încasări (luna), Cheltuieli (luna), Profit (luna), Datorii clienți - color coded: profit verde sau roșu, datorii galben/verde Settings page fix (Filament v5): - mount() folosește acum $this->form->fill([...]) în loc de $this->data direct - Filament v5 cere fill explicit pentru a inițializa state-ul schemei Seed: - 1 plată parțială pe fișa BMW (200 din 750) - 6 cheltuieli demo: 3 salarii, chirie, electricitate, achiziție piese Total Filament tenant routes: 69.
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Tenancy\TenantManager;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class Settings extends Page
|
||||
@@ -27,9 +28,13 @@ class Settings extends Page
|
||||
public function mount(): void
|
||||
{
|
||||
$company = app(TenantManager::class)->current();
|
||||
if (! $company) {
|
||||
return;
|
||||
}
|
||||
$settings = (array) ($company->settings ?? []);
|
||||
|
||||
$this->data = [
|
||||
// Filament v5: fill via $this->form->fill() (initializes the schema state).
|
||||
$this->form->fill([
|
||||
'display_name' => $company->display_name ?? $company->name,
|
||||
'city' => $company->city,
|
||||
'phone' => $company->phone,
|
||||
@@ -40,7 +45,7 @@ class Settings extends Page
|
||||
'labor_rate' => $settings['labor_rate'] ?? 400,
|
||||
'services' => isset($settings['services']) ? implode(', ', (array) $settings['services']) : '',
|
||||
'cars' => isset($settings['cars']) ? implode(', ', (array) $settings['cars']) : '',
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
@@ -88,6 +93,10 @@ class Settings extends Page
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
$company = app(TenantManager::class)->current();
|
||||
if (! $company) {
|
||||
Notification::make()->title('Tenant not resolved')->danger()->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$company->update([
|
||||
'display_name' => $data['display_name'] ?? null,
|
||||
|
||||
Reference in New Issue
Block a user