Ejemplo n.º 1
0
 protected function GenerateResponse()
 {
     try {
         $this->response = AlmacenesController::NuevoLote(isset($_POST['id_almacen']) ? $_POST['id_almacen'] : null, isset($_POST['folio']) ? $_POST['folio'] : null);
     } catch (Exception $e) {
         //Logger::error($e);
         throw new ApiException($this->error_dispatcher->invalidDatabaseOperation($e->getMessage()));
     }
 }
Ejemplo n.º 2
0
 /**
  *
  *
  *	Lotes
  *
  **/
 public function testLotes()
 {
     $almacenes = AlmacenesController::Buscar(true);
     $almacenId = $almacenes["resultados"][0]->getIdAlmacen();
     //nuevo lote
     $nLote = AlmacenesController::NuevoLote($almacenId);
     $this->assertNotNull($l = LoteDAO::getByPK($nLote["id_lote"]));
     $producto = new Producto(array("compra_en_mostrador" => false, "metodo_costeo" => "precio", "precio" => 123.123, "activo" => true, "codigo_producto" => time() . "tp", "nombre_producto" => time() . "np", "costo_estandar" => 12.3123, "id_unidad" => 1));
     ProductoDAO::save($producto);
     $r = AlmacenesController::EntradaLote($nLote["id_lote"], array(array("id_producto" => $producto->getIdProducto(), "cantidad" => 23)));
     //Vamos a validar estas tablas
     $this->assertNotNull(LoteEntradaDAO::getByPK($r["id_entrada_lote"]));
     $this->assertNotNull(LoteProductoDAO::getByPK($nLote["id_lote"], $producto->getIdProducto()));
     $this->assertNotNull(LoteEntradaProductoDAO::getByPK($r["id_entrada_lote"], $producto->getIdProducto(), 1));
     //sacar de ese lote, uno por uno hasta llegar a retirar todo
     for ($i = 0; $i < 23; $i++) {
         AlmacenesController::SalidaLote($nLote["id_lote"], array(array("id_producto" => $producto->getIdProducto(), "cantidad" => 1, "id_unidad" => 1)));
     }
     Logger::log("la siguiente vez que retire algo, debe de arrojar una exception");
     try {
         AlmacenesController::SalidaLote($nLote["id_lote"], array(array("id_producto" => $producto->getIdProducto(), "cantidad" => 1, "id_unidad" => 1)));
         //esto nunca se deberia de ejecutar
         $this->assertTrue(false);
     } catch (InvalidDataException $ivde) {
         $this->assertNotNull($ivde);
     }
 }