up
This commit is contained in:
@@ -102,42 +102,6 @@ class EditConfeccion extends EditRecord
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
||||
}
|
||||
|
||||
$this->redirect(route('filament.admin.resources.confeccions.edit', ['record' => $record->id]));
|
||||
}),
|
||||
|
||||
// Cobros: descontar inventario y descontar valor del total a pagar
|
||||
Actions\Action::make('cobros')
|
||||
->label('Cobros')
|
||||
->modalHeading('Registrar Cobro')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('cantidad')
|
||||
->label('Cantidad')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(1),
|
||||
Forms\Components\TextInput::make('valor')
|
||||
->label('Valor a descontar')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(0),
|
||||
Forms\Components\Textarea::make('notas'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$record = $this->getRecord();
|
||||
|
||||
$cantidad = (int) ($data['cantidad'] ?? 0);
|
||||
$valor = (float) ($data['valor'] ?? 0);
|
||||
|
||||
try {
|
||||
$record->registerCobro($cantidad, $valor, $data['notas'] ?? null, auth()->id() ?? null);
|
||||
|
||||
\Filament\Notifications\Notification::make()->success()->title('Cobro registrado')->body('Se descontó del inventario y se aplicó el descuento al valor a pagar.')->send();
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first() ?? 'Error al registrar cobro.')->send();
|
||||
} catch (\Throwable $e) {
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
||||
}
|
||||
|
||||
$this->redirect(route('filament.admin.resources.confeccions.edit', ['record' => $record->id]));
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user