This commit is contained in:
Lizandro Guarnizo
2026-02-04 20:46:05 -05:00
parent 302ebb9abd
commit 202594812d
6 changed files with 31 additions and 14 deletions
@@ -18,8 +18,8 @@ class OjalPresillaResource extends Resource
protected static ?string $model = Ojal::class; protected static ?string $model = Ojal::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Gestión'; protected static ?string $navigationGroup = 'Gestión';
protected static ?string $navigationLabel = 'Ojales y Prensillas'; protected static ?string $navigationLabel = 'Ojales y Presillas';
protected static ?string $pluralModelLabel = 'Ojales y Prensillas'; protected static ?string $pluralModelLabel = 'Ojales y Presillas';
protected static ?int $navigationSort = 4; protected static ?int $navigationSort = 4;
protected static bool $shouldRegisterNavigation = false; protected static bool $shouldRegisterNavigation = false;
@@ -35,7 +35,7 @@ class OjalPresillaResource extends Resource
->label('Tipo de Proceso') ->label('Tipo de Proceso')
->options([ ->options([
'Ojal' => 'Ojal', 'Ojal' => 'Ojal',
'Prensilla' => 'Prensilla', 'Prensilla' => 'Presilla',
]) ])
->required() ->required()
->reactive() ->reactive()
+1 -1
View File
@@ -99,7 +99,7 @@ class OjalResource extends Resource
Forms\Components\Checkbox::make('terminada') Forms\Components\Checkbox::make('terminada')
->label('Marcar como terminado') ->label('Marcar como terminado')
->helperText('\u2713 Al terminar Ojales, las prendas quedar\u00e1n disponibles para Prensillas') ->helperText(' Al terminar Ojales, las prendas quedarán disponibles para Presillas')
->reactive() ->reactive()
->default(false), ->default(false),
]); ]);
+2 -2
View File
@@ -16,7 +16,7 @@ class PrensillaResource extends Resource
protected static ?string $model = Prensilla::class; protected static ?string $model = Prensilla::class;
protected static ?string $navigationIcon = 'heroicon-o-scissors'; protected static ?string $navigationIcon = 'heroicon-o-scissors';
protected static ?string $navigationGroup = 'Gestión'; protected static ?string $navigationGroup = 'Gestión';
protected static ?string $navigationLabel = 'Prensillas'; protected static ?string $navigationLabel = 'Presillas';
protected static ?int $navigationSort = 5; protected static ?int $navigationSort = 5;
public static function canViewAny(): bool public static function canViewAny(): bool
@@ -86,7 +86,7 @@ class PrensillaResource extends Resource
Forms\Components\Checkbox::make('terminada') Forms\Components\Checkbox::make('terminada')
->label('Marcar como terminado') ->label('Marcar como terminado')
->helperText('✓ Al terminar Prensillas, las prendas quedarán disponibles para Tintorería') ->helperText('✓ Al terminar Presillas, las prendas quedarán disponibles para Tintorería')
->reactive() ->reactive()
->default(false), ->default(false),
]); ]);
@@ -12,7 +12,7 @@ class CreatePrensilla extends CreateRecord
protected function mutateFormDataBeforeCreate(array $data): array protected function mutateFormDataBeforeCreate(array $data): array
{ {
$data['fecha_envio'] = now(); $data['fecha_envio'] = now();
$data['tipo'] = 'Prensilla'; $data['tipo'] = 'Presilla';
return $data; return $data;
} }
@@ -14,7 +14,7 @@ class ListPrensillas extends ListRecords
{ {
return [ return [
Actions\CreateAction::make() Actions\CreateAction::make()
->label('Crear Prensilla'), ->label('Crear Presilla'),
]; ];
} }
} }
@@ -80,9 +80,7 @@ class SeguimientoProcesoResource extends Resource
->alignCenter() ->alignCenter()
->state(function (OrdenProduccion $record): string { ->state(function (OrdenProduccion $record): string {
$enviadas = $record->confecciones()->sum('cantidad_enviada'); $enviadas = $record->confecciones()->sum('cantidad_enviada');
$recibidas = $record->confecciones() $recibidas = $record->confecciones()->sum('cantidad_recibida');
->whereNotNull('fecha_recepcion')
->sum('cantidad_recibida');
// Calcular disponibles (recibidas - arreglos - cobros - enviadas a ojales) // Calcular disponibles (recibidas - arreglos - cobros - enviadas a ojales)
$arreglos = \App\Models\Ajuste::where('referencia_type', \App\Models\Confeccion::class) $arreglos = \App\Models\Ajuste::where('referencia_type', \App\Models\Confeccion::class)
@@ -117,6 +115,19 @@ class SeguimientoProcesoResource extends Resource
->color(fn (OrdenProduccion $record) => self::getPendienteOjales($record) > 0 ? 'warning' : 'gray') ->color(fn (OrdenProduccion $record) => self::getPendienteOjales($record) > 0 ? 'warning' : 'gray')
->tooltip('E=Enviadas, T=Terminadas, P=Pendientes'), ->tooltip('E=Enviadas, T=Terminadas, P=Pendientes'),
Tables\Columns\TextColumn::make('presillas')
->label('⚫ Presillas')
->alignCenter()
->state(function (OrdenProduccion $record): string {
$enviadas = $record->prensillas()->sum('cantidad_enviada');
$terminadas = $record->prensillas()->where('terminada', true)->sum('cantidad_enviada');
$pendientes = max(0, $enviadas - $terminadas);
return "E:{$enviadas} T:{$terminadas} P:{$pendientes}";
})
->color(fn (OrdenProduccion $record) => self::getPendientePresillas($record) > 0 ? 'warning' : 'gray')
->tooltip('E=Enviadas, T=Terminadas, P=Pendientes'),
Tables\Columns\TextColumn::make('tintoreria') Tables\Columns\TextColumn::make('tintoreria')
->label('🎨 Tintorería') ->label('🎨 Tintorería')
->alignCenter() ->alignCenter()
@@ -199,9 +210,7 @@ class SeguimientoProcesoResource extends Resource
protected static function getPendienteConfeccion(OrdenProduccion $record): int protected static function getPendienteConfeccion(OrdenProduccion $record): int
{ {
$recibidas = $record->confecciones() $recibidas = $record->confecciones()->sum('cantidad_recibida');
->whereNotNull('fecha_recepcion')
->sum('cantidad_recibida');
$arreglos = \App\Models\Ajuste::where('referencia_type', \App\Models\Confeccion::class) $arreglos = \App\Models\Ajuste::where('referencia_type', \App\Models\Confeccion::class)
->whereHas('referencia', function($q) use ($record) { ->whereHas('referencia', function($q) use ($record) {
@@ -226,6 +235,14 @@ class SeguimientoProcesoResource extends Resource
return max(0, $enviadas - $terminadas); return max(0, $enviadas - $terminadas);
} }
protected static function getPendientePresillas(OrdenProduccion $record): int
{
$enviadas = $record->prensillas()->sum('cantidad_enviada');
$terminadas = $record->prensillas()->where('terminada', true)->sum('cantidad_enviada');
return max(0, $enviadas - $terminadas);
}
protected static function getPendienteTintoreria(OrdenProduccion $record): int protected static function getPendienteTintoreria(OrdenProduccion $record): int
{ {