Files
MKM/app/Filament/Resources/ClientResource/RelationManagers/AccountsRelationManager.php
Jp 1548e178bc feat(client): add journals relation and improve transaction ledger handling
- Add journals relation to Client model via Branch
- Update branch selection in JournalsRelationManager to use code instead of name
- Improve tax, withholding, and cash account ledger queries by adding client_id filter and amount checks
- Add missing import for GenerateVoucher command in ExpensesRelationManager
- Label 'Normal Balance' column in AccountsRelationManager
2026-02-09 22:16:10 +08:00

60 lines
2.2 KiB
PHP

<?php
namespace App\Filament\Resources\ClientResource\RelationManagers;
use App\Filament\Exports\ClientAccountsExporter;
use App\Models\Account;
use Filament\Actions\Exports\Enums\ExportFormat;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
class AccountsRelationManager extends RelationManager
{
protected static string $relationship = 'accounts';
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('account')->required(),
Forms\Components\Textarea::make('description')->nullable(),
Forms\Components\Select::make('account_type_id')
->relationship('accountType', 'type')
->required(),
Forms\Components\Select::make('normal_balance')->options(
['debit' => 'Debit', 'credit' => 'Credit']
)->required(),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('client_id')
->columns([
Tables\Columns\TextColumn::make('account')->description(fn (Account $record): string => $record->description ?? ''),
Tables\Columns\TextColumn::make('accountType.type'),
Tables\Columns\TextColumn::make('accountType.normal_balance')->label('Normal Balance'),
])
->filters([
//
])
->headerActions([
Tables\Actions\ExportAction::make('Export Accounts')->exporter(ClientAccountsExporter::class)->formats([ExportFormat::Csv]),
Tables\Actions\CreateAction::make()->label('New Account')->icon('heroicon-o-plus')->slideOver(),
])
->actions([
Tables\Actions\EditAction::make()->slideOver(),
Tables\Actions\DeleteAction::make()->requiresConfirmation(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make()->icon('heroicon-s-trash')->requiresConfirmation(),
]),
]);
}
}