up
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Models\OrdenProduccion;
|
||||
use App\Models\InventarioPrenda;
|
||||
use App\Models\TrasladoPrenda;
|
||||
|
||||
class InventarioPrendaAutoCantidadTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_auto_fill_cantidad_terminada_from_traslados()
|
||||
{
|
||||
$op = OrdenProduccion::create(['numero_orden' => 'OP-500', 'prenda_modelo' => 'AutoCantidad', 'cantidad_total' => 100, 'metros_requeridos' => 0, 'fecha_inicio' => now(), 'fecha_entrega_estimada' => now()->addDays(7)]);
|
||||
|
||||
// Crear dos traslados hacia bodega (simulando recibidos)
|
||||
TrasladoPrenda::create(['orden_produccion_id' => $op->id, 'origen' => 'acabados', 'destino' => 'bodega', 'cantidad_enviada' => 0, 'cantidad_recibida' => 20, 'fecha_recepcion' => now()]);
|
||||
TrasladoPrenda::create(['orden_produccion_id' => $op->id, 'origen' => 'acabados', 'destino' => 'bodega', 'cantidad_enviada' => 0, 'cantidad_recibida' => 10, 'fecha_recepcion' => now()]);
|
||||
|
||||
// Crear un inventario sin especificar cantidad_terminada
|
||||
$inv = InventarioPrenda::create(['orden_produccion_id' => $op->id, 'cantidad_terminada' => null, 'fecha_ingreso' => now(), 'estado' => 'en_bodega']);
|
||||
|
||||
$this->assertEquals(30, $inv->cantidad_terminada);
|
||||
$this->assertEquals(30, $inv->cantidad_disponible);
|
||||
}
|
||||
|
||||
public function test_cannot_create_inventory_when_no_available()
|
||||
{
|
||||
$op = OrdenProduccion::create(['numero_orden' => 'OP-501', 'prenda_modelo' => 'AutoCantidad2', 'cantidad_total' => 100, 'metros_requeridos' => 0, 'fecha_inicio' => now(), 'fecha_entrega_estimada' => now()->addDays(7)]);
|
||||
|
||||
$this->expectException(\Illuminate\Validation\ValidationException::class);
|
||||
|
||||
InventarioPrenda::create(['orden_produccion_id' => $op->id, 'cantidad_terminada' => null, 'fecha_ingreso' => now(), 'estado' => 'en_bodega']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user