This commit is contained in:
Lizandro Guarnizo
2026-01-29 21:15:11 -05:00
parent f183512bc8
commit ba211d21d8
4 changed files with 118 additions and 77 deletions
@@ -24,19 +24,31 @@ class CobrosRelationManager extends RelationManager
])
->filters([])
->headerActions([
Tables\Actions\CreateAction::make()->form([
\Filament\Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
\Filament\Forms\Components\TextInput::make('valor')->numeric()->required()->minValue(0),
\Filament\Forms\Components\Textarea::make('notas'),
])->action(function (array $data) {
$owner = $this->getOwnerRecord();
try {
$owner->registerCobro((int)$data['cantidad'], (float)$data['valor'], $data['notas'] ?? null, auth()->id() ?? null);
\Filament\Notifications\Notification::make()->success()->title('Cobro registrado')->send();
} catch (\Throwable $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
}
}),
Tables\Actions\CreateAction::make()
->label('Agregar cobro')
->form([
\Filament\Forms\Components\TextInput::make('cantidad')
->numeric()
->required()
->minValue(1)
->helperText('Prendas que NO llegaron y se cobran a la tintorería'),
\Filament\Forms\Components\TextInput::make('valor')
->numeric()
->required()
->minValue(0)
->label('Valor a descontar'),
\Filament\Forms\Components\Textarea::make('notas'),
])->action(function (array $data) {
$owner = $this->getOwnerRecord();
try {
$owner->registerCobro((int)$data['cantidad'], (float)$data['valor'], $data['notas'] ?? null, auth()->id() ?? null);
\Filament\Notifications\Notification::make()->success()->title('Cobro registrado')->send();
} catch (\Illuminate\Validation\ValidationException $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first())->send();
} catch (\Throwable $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
}
}),
])
->actions([])
->bulkActions([]);