@extends('layouts.app') @php function getCategoryIcon($iconKey) { $icons = [ 'salary' => '', 'freelance' => '', 'investments' => '', 'gifts_received' => '', 'refunds' => '', 'rent' => '', 'mortgage' => '', 'utilities' => '', 'groceries' => '', 'dining_out' => '', 'fuel' => '', 'public_transport' => '', 'healthcare' => '', 'insurance' => '', 'entertainment' => '', 'shopping' => '', 'education' => '', 'subscriptions' => '', 'travel' => '', 'transfer' => '', 'adjustment' => '', ]; $path = $icons[$iconKey] ?? ''; return '' . $path . ''; } @endphp @section('title', 'Account Structure — Financial OS') @push('styles') @endpush @section('content') @php $user = Auth::user(); $canEdit = $canEdit ?? true; $familyInfo = $familyInfo ?? ['is_family_member' => false, 'family_role' => null]; $hasAccounts = ($counts->total_accounts ?? 0) > 0; $userType = $user->user_type ?? 'individual'; @endphp {{-- TOASTS --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Permission Banner --}} @if($familyInfo['is_family_member'] && !$canEdit) @endif {{-- Stats Cards --}}
Total Accounts
{{ $counts->total_accounts ?? 0 }}
Income Categories
{{ $incomeCategories->total() }}
Expense Categories
{{ $expenseCategories->total() }}
Account Type
{{ ucfirst($userType) }}
{{-- Generate Button --}} @if(!$hasAccounts && $canEdit)

Welcome! Generate Your Chart of Accounts

Based on your account type: {{ ucfirst($userType) }}

This will create accounts, income categories, and expense categories for you.

@endif {{-- Tabs --}} @if($hasAccounts)
{{-- Tab 1: Balance Sheet --}}
@if($canEdit)

Add New Account

@csrf
@endif {{-- Assets --}}

Assets What you own ({{ $counts->asset_count ?? 0 }})

@if($assetAccounts->isEmpty())
No asset accounts yet.
@else
@if($canEdit)@endif@foreach($assetAccounts as $account)@if($canEdit)@endif@endforeach
CodeAccount NameDescriptionStatusActions
{{ $account->account_code }}{{ $account->account_name }}{{ $account->description ?: '-' }}{{ $account->is_active ? 'Active' : 'Inactive' }}
@if($assetAccounts->hasPages())@endif @endif
{{-- Liabilities --}}

Liabilities What you owe ({{ $counts->liability_count ?? 0 }})

@if($liabilityAccounts->isEmpty())
No liability accounts yet.
@else
@if($canEdit)@endif@foreach($liabilityAccounts as $account)@if($canEdit)@endif@endforeach @if($liabilityAccounts->hasPages())@endif @endif {{-- Equity --}}

Equity Owner's interest ({{ $counts->equity_count ?? 0 }})

@if($equityAccounts->isEmpty())
No equity accounts yet.
@else
CodeAccount NameDescriptionStatusActions
{{ $account->account_code }}{{ $account->account_name }}{{ $account->description ?: '-' }}{{ $account->is_active ? 'Active' : 'Inactive' }}
@if($canEdit)@endif@foreach($equityAccounts as $account)@if($canEdit)@endif@endforeach
CodeAccount NameDescriptionStatusActions
{{ $account->account_code }}{{ $account->account_name }}{{ $account->description ?: '-' }}{{ $account->is_active ? 'Active' : 'Inactive' }}
@if($equityAccounts->hasPages())@endif @endif
{{-- Tab 2: Income & Expense Accounts --}}
{{-- Income Accounts --}}

Income Accounts Money earned ({{ $counts->income_account_count ?? 0 }})

@if($incomeAccounts->isEmpty())
No income accounts yet.
@else
@if($canEdit)@endif@foreach($incomeAccounts as $account)@if($canEdit)@endif
CodeAccount NameDescriptionStatusActions
{{ $account->account_code }}{{ $account->account_name }}{{ $account->description ?: '-' }}{{ $account->is_active ? 'Active' : 'Inactive' }}
@endforeach
@if($incomeAccounts->hasPages())@endif @endif {{-- Expense Accounts --}}

Expense Accounts Money spent ({{ $counts->expense_account_count ?? 0 }})

@if($expenseAccounts->isEmpty())
No expense accounts yet.
@else
@if($canEdit)@endif@foreach($expenseAccounts as $account)@if($canEdit)@endif@endforeach
CodeAccount NameDescriptionStatusActions
{{ $account->account_code }}{{ $account->account_name }}{{ $account->description ?: '-' }}{{ $account->is_active ? 'Active' : 'Inactive' }}
@if($expenseAccounts->hasPages())@endif @endif
{{-- Tab 3: Income Categories --}}
@if($canEdit)

Add Income Category

@csrf
@endif

Income Categories {{ $incomeCategories->total() }} categories

@if($incomeCategories->isEmpty())
No income categories yet.
@else
@if($canEdit)@endif@foreach($incomeCategories as $cat)@if($canEdit)@endif@endforeach
IconCategory NameColorTransactionsActions
{!! getCategoryIcon($cat->icon) !!}
{{ $cat->name }}
{{ $cat->transaction_count ?? 0 }}
@if($incomeCategories->hasPages())@endif @endif {{-- Tab 4: Expense Categories --}}
@if($canEdit)

Add Expense Category

@csrf
@endif

Expense Categories {{ $expenseCategories->total() }} categories

@if($expenseCategories->isEmpty())
No expense categories yet.
@else
@if($canEdit)@endif@foreach($expenseCategories as $cat)@if($canEdit)@endif@endforeach
IconCategory NameColorTransactionsActions
{!! getCategoryIcon($cat->icon) !!}
{{ $cat->name }}
{{ $cat->transaction_count ?? 0 }}
@if($expenseCategories->hasPages())@endif @endif
@endif {{-- Modals --}} @endsection