up
This commit is contained in:
@@ -68,7 +68,7 @@ class EditTintoreria extends EditRecord
|
||||
$this->redirect(route('filament.admin.resources.tintorerias.edit', ['record' => $record->id]));
|
||||
}),
|
||||
|
||||
// Reprocesos: registrar reproceso como ajuste
|
||||
// Reprocesos: registrar reproceso como ajuste (igual que arreglos en confecciones)
|
||||
Actions\Action::make('reprocesos')
|
||||
->label('Reprocesos')
|
||||
->modalHeading('Registrar Reproceso')
|
||||
@@ -78,8 +78,7 @@ class EditTintoreria extends EditRecord
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(1)
|
||||
->maxValue(fn () => $this->getRecord()->recibido_total ?? 0)
|
||||
->helperText(fn () => 'Máximo: ' . ($this->getRecord()->recibido_total ?? 0)),
|
||||
->helperText('Prendas que llegaron defectuosas y necesitan reparación'),
|
||||
Forms\Components\Textarea::make('notas'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
@@ -90,7 +89,7 @@ class EditTintoreria extends EditRecord
|
||||
try {
|
||||
$record->registerReproceso($cantidad, $data['notas'] ?? null, auth()->id() ?? null);
|
||||
|
||||
\Filament\Notifications\Notification::make()->success()->title('Reproceso registrado')->body('Se registró el reproceso correctamente.')->send();
|
||||
\Filament\Notifications\Notification::make()->success()->title('Reproceso registrado')->body('Se registró el reproceso correctamente. Estas prendas podrán re-recibirse cuando regresen reparadas.')->send();
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first() ?? 'Error al registrar reproceso.')->send();
|
||||
} catch (\Throwable $e) {
|
||||
@@ -100,7 +99,7 @@ class EditTintoreria extends EditRecord
|
||||
$this->redirect(route('filament.admin.resources.tintorerias.edit', ['record' => $record->id]));
|
||||
}),
|
||||
|
||||
// Cobros: descontar inventario y registrar cobro
|
||||
// Cobros: registrar prendas que no llegaron
|
||||
Actions\Action::make('cobros')
|
||||
->label('Cobros')
|
||||
->modalHeading('Registrar Cobro')
|
||||
@@ -109,7 +108,8 @@ class EditTintoreria extends EditRecord
|
||||
->label('Cantidad')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(1),
|
||||
->minValue(1)
|
||||
->helperText('Prendas que NO llegaron y se cobran a la tintorería'),
|
||||
Forms\Components\TextInput::make('valor')
|
||||
->label('Valor a descontar')
|
||||
->numeric()
|
||||
@@ -126,7 +126,7 @@ class EditTintoreria extends EditRecord
|
||||
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 registró el cobro.')->send();
|
||||
\Filament\Notifications\Notification::make()->success()->title('Cobro registrado')->body('Se registró el cobro correctamente.')->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) {
|
||||
|
||||
+29
-13
@@ -10,6 +10,7 @@ class AjustesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'ajustes';
|
||||
protected static ?string $recordTitleAttribute = 'id';
|
||||
protected static ?string $title = 'Reprocesos';
|
||||
|
||||
public function table(Tables\Table $table): Tables\Table
|
||||
{
|
||||
@@ -22,20 +23,35 @@ class AjustesRelationManager extends RelationManager
|
||||
TextColumn::make('notas')->limit(80)->wrap(),
|
||||
TextColumn::make('created_at')->label('Fecha')->dateTime(),
|
||||
])
|
||||
->filters([])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('tipo')
|
||||
->options([
|
||||
'reproceso' => 'Reproceso',
|
||||
])
|
||||
->default('reproceso')
|
||||
])
|
||||
->modifyQueryUsing(fn ($query) => $query->where('tipo', 'reproceso'))
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make()->form([
|
||||
\Filament\Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
|
||||
\Filament\Forms\Components\Textarea::make('notas'),
|
||||
])->action(function (array $data) {
|
||||
$owner = $this->getOwnerRecord();
|
||||
try {
|
||||
$owner->registerReproceso((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
|
||||
\Filament\Notifications\Notification::make()->success()->title('Reproceso registrado')->send();
|
||||
} catch (\Throwable $e) {
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
||||
}
|
||||
}),
|
||||
Tables\Actions\CreateAction::make()
|
||||
->label('Agregar reproceso')
|
||||
->form([
|
||||
\Filament\Forms\Components\TextInput::make('cantidad')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(1)
|
||||
->helperText('Prendas que llegaron defectuosas y necesitan reparación'),
|
||||
\Filament\Forms\Components\Textarea::make('notas'),
|
||||
])->action(function (array $data) {
|
||||
$owner = $this->getOwnerRecord();
|
||||
try {
|
||||
$owner->registerReproceso((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
|
||||
\Filament\Notifications\Notification::make()->success()->title('Reproceso registrado')->body('Estas prendas podrán re-recibirse cuando regresen reparadas.')->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([]);
|
||||
|
||||
+25
-13
@@ -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([]);
|
||||
|
||||
Reference in New Issue
Block a user