recordTitleAttribute('amount') ->description(fn (): string => 'Vom Gast bezahlt: '.Money::format($this->ownerRecord->paidAmount()).' (davon an uns '.Money::format($this->ownerRecord->paidToUs()).', laut Portal ans Portal '.Money::format($this->ownerRecord->paidViaPortal()).') · Auszahlungen vom Portal: '.Money::format($this->ownerRecord->payoutsReceived()).' · offen bei uns: '.Money::format(CaseMoney::of($this->ownerRecord)->openForUs())) ->columns([ TextColumn::make('paid_on')->label('Eingang')->date('d.m.Y'), TextColumn::make('amount')->label('Betrag')->money('EUR', divideBy: 100, locale: 'de'), TextColumn::make('kind')->label('Was')->badge()->state(fn (Payment $record): PaymentKind => $record->kind ?? PaymentKind::Guest), TextColumn::make('method')->label('Zahlweg'), TextColumn::make('source')->label('Quelle')->placeholder('–')->toggleable(isToggledHiddenByDefault: true), TextColumn::make('note')->label('Notiz')->placeholder('–'), TextColumn::make('recorded_by')->label('Erfasst von')->placeholder('–'), ]) ->headerActions([ Action::make('record') ->label('Zahlung erfassen') ->icon(Heroicon::OutlinedBanknotes) ->fillForm(fn (): array => [ 'amount' => number_format(($this->ownerRecord->openDeposit() ?: $this->ownerRecord->openAmount()) / 100, 2, '.', ''), 'paid_on' => today(), 'method' => PaymentMethod::Transfer, 'kind' => $this->ownerRecord->process()->payments() === Responsibility::Portal ? PaymentKind::PortalPayout->value : PaymentKind::Guest->value, ]) ->schema([ Radio::make('kind')->label('Was ist passiert?')->options(PaymentKind::class)->required(), EuroInput::make('amount')->label('Betrag')->helperText('Immer den Betrag ohne Vorzeichen; eine Erstattung wird automatisch abgezogen.')->required(), DatePicker::make('paid_on')->label('Zahlungseingang')->required(), Select::make('method')->label('Art')->options(PaymentMethod::class)->required(), TextInput::make('note')->label('Notiz')->maxLength(255), ]) ->action(function (array $data, RecordPayment $recordPayment): void { $recordPayment->handle( $this->ownerRecord, (int) $data['amount'], CarbonImmutable::parse($data['paid_on']), $data['method'] instanceof PaymentMethod ? $data['method'] : PaymentMethod::from($data['method']), $data['note'] ?: null, auth()->user()?->name, $data['kind'] instanceof PaymentKind ? $data['kind'] : PaymentKind::from($data['kind']), in_array($data['kind'] instanceof PaymentKind ? $data['kind']->value : $data['kind'], [PaymentKind::GuestViaPortal->value, PaymentKind::PortalPayout->value], true) ? ($this->ownerRecord->processChannel()?->name ?? 'Portal') : null, ); Notification::make()->title('Zahlung erfasst – Status: '.$this->ownerRecord->fresh()->status->getLabel())->success()->send(); }), ]) ->recordActions([ DeleteAction::make()->after(fn (Payment $record) => app(RecordPayment::class)->updateStatus($this->ownerRecord->fresh())), ]); } }