schema([ Forms\Components\Section::make('General') ->schema([ Forms\Components\TextInput::make('name') ->autofocus() ->required() ->maxLength(255), Forms\Components\Textarea::make('description') ->label('Description'), ]), Forms\Components\Section::make('Configuration') ->schema([ Forms\Components\Select::make('category') ->localizeLabel() ->options(AdjustmentCategory::class) ->default(AdjustmentCategory::Tax) ->live() ->required(), Forms\Components\Select::make('type') ->localizeLabel() ->options(AdjustmentType::class) ->default(AdjustmentType::Sales) ->live() ->required(), Forms\Components\Checkbox::make('recoverable') ->label('Recoverable') ->default(false) ->helperText('When enabled, tax is tracked separately as claimable from the government. Non-recoverable taxes are treated as part of the expense.') ->visible(fn (Forms\Get $get) => AdjustmentCategory::parse($get('category'))->isTax() && AdjustmentType::parse($get('type'))->isPurchase()), ]) ->columns() ->visibleOn('create'), Forms\Components\Section::make('Adjustment Details') ->schema([ Forms\Components\Select::make('computation') ->localizeLabel() ->options(AdjustmentComputation::class) ->default(AdjustmentComputation::Percentage) ->live() ->required(), Forms\Components\TextInput::make('rate') ->localizeLabel() ->rate(static fn (Forms\Get $get) => $get('computation')) ->required(), Forms\Components\Select::make('scope') ->localizeLabel() ->options(AdjustmentScope::class), ]) ->columns(), Forms\Components\Section::make('Dates') ->schema([ Forms\Components\DateTimePicker::make('start_date'), Forms\Components\DateTimePicker::make('end_date'), ]) ->columns() ->visible(fn (Forms\Get $get) => AdjustmentCategory::parse($get('category'))->isDiscount()), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name') ->label('Name') ->sortable(), Tables\Columns\TextColumn::make('category') ->searchable(), Tables\Columns\TextColumn::make('type') ->searchable(), Tables\Columns\TextColumn::make('rate') ->localizeLabel() ->rate(static fn (Adjustment $record) => $record->computation->value) ->searchable() ->sortable(), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ // ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListAdjustments::route('/'), 'create' => Pages\CreateAdjustment::route('/create'), 'edit' => Pages\EditAdjustment::route('/{record}/edit'), ]; } }