This commit is contained in:
lizandrogd
2026-01-19 20:08:43 -05:00
parent 132b266948
commit 2e819edbd3
5 changed files with 60 additions and 0 deletions
@@ -29,6 +29,12 @@ class EditConfeccion extends EditRecord
->maxValue(fn () => $this->getRecord()->faltantes ?? 0)
->helperText(fn () => 'Máximo: ' . ($this->getRecord()->faltantes ?? 0))
->default(fn () => $this->getRecord()->faltantes ?? 0),
Forms\Components\TextInput::make('prendas_defectuosas')
->numeric()
->minValue(0)
->maxValue(fn ($get) => (int) ($get('cantidad') ?? 0))
->helperText('Opcional. Se restará del total recibido.'),
Forms\Components\Textarea::make('notas'),
])
->action(function (array $data): void {
@@ -29,6 +29,13 @@ class RecepcionesRelationManager extends RelationManager
->minValue(1)
->maxValue(fn () => $this->getOwnerRecord()?->faltantes ?? 0)
->helperText(fn () => 'Máximo: ' . ($this->getOwnerRecord()?->faltantes ?? 0)),
TextInput::make('prendas_defectuosas')
->numeric()
->minValue(0)
->maxValue(fn ($get) => (int) ($get('cantidad') ?? 0))
->helperText('Opcional. Se restará del total recibido.'),
Textarea::make('notas'),
]);
}
@@ -29,6 +29,13 @@ class RecepcionesRelationManager extends RelationManager
->minValue(1)
->maxValue(fn () => $this->getOwnerRecord()?->faltantes ?? 0)
->helperText(fn () => 'Máximo: ' . ($this->getOwnerRecord()?->faltantes ?? 0)),
TextInput::make('prendas_defectuosas')
->numeric()
->minValue(0)
->maxValue(fn ($get) => (int) ($get('cantidad') ?? 0))
->helperText('Opcional. Se restará del total recibido.'),
Textarea::make('notas'),
]);
}
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('recepciones', function (Blueprint $table) {
$table->integer('prendas_defectuosas')->default(0)->after('cantidad');
});
}
public function down(): void
{
Schema::table('recepciones', function (Blueprint $table) {
$table->dropColumn('prendas_defectuosas');
});
}
};
+18
View File
@@ -56,6 +56,24 @@ class RecepcionFlowTest extends TestCase
->count();
$this->assertEquals(2, $count);
// Crear recepción con defectos y comprobar traslado creado
Recepcion::create([
'referencia_type' => Confeccion::class,
'referencia_id' => $conf->id,
'cantidad' => 50,
'prendas_defectuosas' => 5,
'fecha_recepcion' => now(),
]);
$ultimoTraslado = TrasladoPrenda::where('referencia_type', Confeccion::class)
->where('referencia_id', $conf->id)
->latest('id')
->first();
$this->assertNotNull($ultimoTraslado);
$this->assertEquals(45, $ultimoTraslado->cantidad_recibida);
$this->assertEquals(5, $ultimoTraslado->prendas_defectuosas);
}
/** @test */