src/Repository/ArticuloRepository.php line 400

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\Articulo;
  4. use App\Helper\DateHelper;
  5. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  6. use Doctrine\ORM\QueryBuilder;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. class ArticuloRepository extends ServiceEntityRepository implements AutoCompletableInterface
  10. {
  11.     public function __construct(ManagerRegistry $registry)
  12.     {
  13.         parent::__construct($registryArticulo::class);
  14.     }
  15.     public function getByPage($text$offset 0$perPage 100$filtros = []) {
  16.         $qb $this->createQueryBuilder('a')
  17.             ->where('a.deletedAt is null')
  18.             ->orderBy("REPLACE(a.descripcion, '** ', '')");
  19.         if ($text) {
  20.             $words preg_split('/\s+/'trim($text));
  21.             $andByField = [];
  22.             foreach (['descripcion''codigo''codigotwo'] as $field) {
  23.                 $andX $qb->expr()->andX();
  24.                 foreach ($words as $index => $word) {
  25.                     $paramName "{$field}_word_{$index}";
  26.                     $andX->add($qb->expr()->like("a.$field"":$paramName"));
  27.                     $qb->setParameter($paramName'%' $word '%');
  28.                 }
  29.                 $andByField[] = $andX;
  30.             }
  31.             $orX $qb->expr()->orX();
  32.             foreach ($andByField as $condition) {
  33.                 $orX->add($condition);
  34.             }
  35.             $qb->andWhere($orX);
  36.         }
  37.         if ($filtros["talle"] ?? false) {
  38.             $qb->andWhere('a.talle = :talle')
  39.                 ->setParameter('talle',$filtros['talle']);
  40.         }
  41.         if ($filtros["color"] ?? false) {
  42.             $qb->andWhere('a.color = :color')
  43.                 ->setParameter('color',$filtros['color']);
  44.         }
  45.         if ($filtros["genero"] ?? false) {
  46.             $qb->andWhere('a.genero = :genero')
  47.                 ->setParameter('genero',$filtros['genero']);
  48.         }
  49.         $qb->setFirstResult($offset)
  50.             ->setMaxResults($perPage);
  51.         return $qb->getQuery()->getResult();
  52.     }
  53.     public function getByPagedeleted($text$offset 0$perPage 100) {
  54.         $qb $this->createQueryBuilder('a')
  55.             ->where('a.deletedAt IS NOT NULL')
  56.             ->orderBy('a.id');
  57.         if ($text)
  58.             $qb ->where("a.descripcion LIKE :text")
  59.                 ->orWhere("a.codigo LIKE :text")
  60.                 ->setParameter('text''%'.$text.'%');
  61.         $qb->setFirstResult($offset)
  62.             ->setMaxResults($perPage);
  63.         return $qb->getQuery()->getResult();
  64.     }
  65.     public function getCountdeleted($text) {
  66.         $qb $this->createQueryBuilder('a')
  67.             ->select("Count(a) as count")
  68.             ->where('a.deletedAt is not null');
  69.         if ($text)
  70.             $qb ->where("a.descripcion LIKE :text")
  71.                 ->andWhere('a.deletedAt is null')
  72.                 ->setParameter('text''%'.$text.'%');
  73.         return $qb->getQuery()->getResult()[0]["count"];
  74.     }
  75.     public function getByPage2($text$offset 0$perPage 100) {
  76.         $qb $this->createQueryBuilder('a')
  77.             ->where('a.deletedAt is null')
  78.             ->orderBy('a.id');
  79.         if(is_numeric($text)){
  80.             $codigo $text;
  81.             $qb $this->createQueryBuilder('a2')
  82.             ->select('a2.descripcion')
  83.             ->where('a2.codigo LIKE :codigo')
  84.             ->andWhere('a2.deletedAt is null')
  85.             ->setParameter('codigo'$codigo);
  86.             $descripcion =  $qb->getQuery()->getResult();
  87.             
  88.             $qb $this->createQueryBuilder('m')
  89.                         ->where('m.descripcion= :descripcion')
  90.                         ->setParameter('descripcion'$descripcion);
  91.                       
  92.         }
  93.         else if ($text)
  94.             $qb ->where("a.descripcion LIKE :text")
  95.                 ->andWhere('a.deletedAt is null')
  96.                 ->setParameter('text''%'.$text.'%');
  97.         $qb->setFirstResult($offset)
  98.             ->setMaxResults($perPage);
  99.         return $qb->getQuery()->getResult();
  100.     }
  101.     public function getCount($text) {
  102.         $qb $this->createQueryBuilder('a')
  103.             ->select("Count(a) as count")
  104.             ->where('a.deletedAt is null');
  105.         if ($text)
  106.             $qb ->where("a.descripcion LIKE :text")
  107.                 ->andWhere('a.deletedAt is  null')
  108.                 ->setParameter('text''%'.$text.'%');
  109.         return $qb->getQuery()->getResult()[0]["count"];
  110.     }
  111.     public function getCount2($text) {
  112.         $qb $this->createQueryBuilder('a')
  113.             ->select("Count(a) as count")
  114.             ->where('a.deletedAt is null');
  115.             if(is_numeric($text)){
  116.                 $codigo $text;
  117.                 $qb
  118.                 ->select('a.descripcion')
  119.                 ->where('a.codigo LIKE :codigo')
  120.                 ->setParameter('codigo'$codigo);
  121.                 $descripcion =  $qb->getQuery()->getResult();                
  122.     
  123.                 $qb $this->createQueryBuilder('m')
  124.                             ->select("Count(m) as count")
  125.                             ->where('m.descripcion LIKE :descripcion')
  126.                             ->setParameter('descripcion'$descripcion);
  127.                           
  128.             }
  129.             else if ($text){
  130.             $qb ->where("a.descripcion LIKE :text")
  131.                 ->setParameter('text''%'.$text.'%');
  132.         }        
  133.         return $qb->getQuery()->getResult()[0]["count"];
  134.     }
  135.     /**
  136.      * Consulta para autocomplete
  137.      *
  138.      * @param string $searchField
  139.      * @param string $text
  140.      * @return array
  141.      */
  142.     public function autocompleteQuery(string $searchFieldstring $text$user null): array
  143.     {
  144. //, :marcaproducto_label ,ma.nombre
  145.         $qb $this->createQueryBuilder('a')
  146.             ->select('CONCAT(a.'.$searchField.', :categoria_label ,ca.nombre, :marcaProducto_label ,ma.nombre) as label, a.id as id')
  147. //            ->leftJoin('a.talle', 't')
  148.         //    ->leftJoin('a.color', 'c')
  149.             ->leftJoin('a.categoria''ca')
  150.             ->leftJoin('a.marca_producto''ma')
  151.             ->where('a.deletedAt is NULL')
  152.             ->andWhere('a.'.$searchField.' like :text')
  153.             ->setParameter('text''%'.$text.'%')
  154.             ->setParameter('categoria_label'' categoria: ')
  155.             ->setParameter('marcaProducto_label'' marca: ')
  156.             ->setMaxResults(50)
  157.             ->orderBy('a.'.$searchField);
  158.         return $qb->getQuery()->getResult();
  159.     }
  160.     public function buscar($buscarData,$count,$articulos){
  161.         $palabras explode(' '$buscarData['palabra']);
  162.         $qb $this->createQueryBuilder('a');
  163.         if($count){
  164.             $qb->select('Count(a) as count');
  165.         }
  166.         $qb->where('a.descripcion LIKE  :descripcion')
  167.         ->setParameter('descripcion'' ');
  168.         for ($i=0$i count($palabras) ; $i++) {
  169.             $qb->orWhere('a.descripcion LIKE :descripcion'.$i)
  170.             ->setParameter('descripcion'.$i,'%'.$palabras[$i].'%');
  171.         }
  172.         if($buscarData['codigo']){
  173.             $qb->andWhere('a.codigo LIKE :codigo')
  174.                 ->setParameter('codigo','%'.$buscarData['codigo'].'%');
  175.         }
  176.         if($buscarData['palabra']){
  177.             $qb->andWhere('a.descripcion LIKE :descripcion')
  178.             ->setParameter('descripcion','%'.$buscarData['palabra'].'%');
  179.         }
  180. //        if($buscarData['rubro']){
  181. //            $qb->andWhere('a.rubro = :rubro')
  182. //            ->setParameter('rubro',$buscarData['rubro']);
  183. //        }
  184.         if($buscarData['categoria']){
  185.             $qb->andWhere('a.categoria = :categoria')
  186.             ->setParameter('categoria',$buscarData['categoria']);
  187.         }
  188.         if($buscarData['grupo']){
  189.             $qb->andWhere('a.grupo = :grupo')
  190.             ->setParameter('grupo',$buscarData['grupo']);
  191.         }
  192. //        if($buscarData['disciplina']){
  193. //            $qb->andWhere('a.disciplina = :disciplina')
  194. //            ->setParameter('disciplina',$buscarData['disciplina']);
  195. //        }
  196.         if($buscarData['marca']){
  197.             $qb->andWhere('a.marca_producto = :marca')
  198.             ->setParameter('marca',$buscarData['marca']);
  199.         }
  200.         if($buscarData['proveedor']){
  201.             $qb->andWhere('a.proveedor = :proveedor')
  202.             ->setParameter('proveedor',$buscarData['proveedor']);
  203.         }
  204. //        if($buscarData['talle']){
  205. //            $qb->andWhere('a.talle = :talle')
  206. //                ->setParameter('talle',$buscarData['talle']);
  207. //        }
  208. //        if($buscarData['color']){
  209. //            $qb->andWhere('a.color = :color')
  210. //                ->setParameter('color',$buscarData['color']);
  211. //        }
  212. //        if($buscarData['genero']){
  213. //            $qb->andWhere('a.genero = :genero')
  214. //                ->setParameter('genero',$buscarData['genero']);
  215. //        }
  216.         $qb->andWhere('a.deletedAt is NULL');
  217.         if($articulos){
  218.             $qb->andWhere('a.id NOT IN (:articulos)')
  219.             ->setParameter('articulos',explode(',',$articulos));
  220.         }
  221.         if($count){
  222.             return $qb->getQuery()->getResult()[0]["count"];    
  223.         }
  224.         if(!$articulos){
  225.             $qb->setFirstResult($buscarData['offset'])
  226.             ->setMaxResults($buscarData['length']);
  227.         }
  228.         return $qb->getQuery()->getResult();
  229.     }
  230.     public function buscar2($buscarData,$count,$articulos) {
  231.         $palabras explode(' '$buscarData['palabra']);
  232.         $qb $this->createQueryBuilder('a');
  233.         if($count){
  234.             $qb->select('Count(a) as count');
  235.         }
  236.         $qb->where('a.descripcion LIKE  :descripcion')
  237.             ->setParameter('descripcion'' ');
  238.         for ($i=0$i count($palabras) ; $i++) {
  239.             $qb->orWhere('a.descripcion LIKE :descripcion'.$i)
  240.                 ->setParameter('descripcion'.$i,'%'.$palabras[$i].'%');
  241.         }
  242.      
  243.         if($buscarData['palabra']){
  244.             $qb->andWhere('a.descripcion LIKE :descripcion')
  245.                 ->setParameter('descripcion','%'.$buscarData['palabra'].'%');
  246.         }
  247. //        if($buscarData['rubro']){
  248. //            $qb->andWhere('a.rubro = :rubro')
  249. //                ->setParameter('rubro',$buscarData['rubro']);
  250. //        }
  251.         if($buscarData['categoria']){
  252.             $qb->andWhere('a.categoria = :categoria')
  253.                 ->setParameter('categoria',$buscarData['categoria']);
  254.         }
  255.         if($buscarData['grupo']){
  256.             $qb->andWhere('a.grupo = :grupo')
  257.                 ->setParameter('grupo',$buscarData['grupo']);
  258.         }
  259.         if($buscarData['disciplina']){
  260.             $qb->andWhere('a.disciplina = :disciplina')
  261.                 ->setParameter('disciplina',$buscarData['disciplina']);
  262.         }
  263.         if($buscarData['marca']){
  264.             $qb->andWhere('a.marca_producto = :marca')
  265.                 ->setParameter('marca',$buscarData['marca']);
  266.         }
  267.         if($buscarData['proveedor']){
  268.             $qb->andWhere('a.proveedor = :proveedor')
  269.                 ->setParameter('proveedor',$buscarData['proveedor']);
  270.         }
  271.         if($articulos){
  272.             $qb->andWhere('a.id NOT IN (:articulos)')
  273.                 ->setParameter('articulos',explode(',',$articulos));
  274.         }
  275.         if($count){
  276.             return $qb->getQuery()->getResult()[0]["count"];
  277.         }
  278.         if(!$articulos){
  279.             $qb->setFirstResult($buscarData['offset'])
  280.                 ->setMaxResults($buscarData['length']);
  281.         }
  282.         return $qb->getQuery()->getResult();
  283.     }
  284.     public function totalesPorProducto($fechaStr$filtros = []) {
  285.         $qb $this->createQueryBuilder('AR');
  286.         $qb ->leftJoin('AR.factulineas''FL')
  287.             ->leftJoin('FL.factura''FAC')
  288. //            ->leftJoin('AR.rubro', 'RB')
  289.             ->leftJoin('AR.grupo''GR')
  290.             ->leftJoin('AR.categoria''CAT')
  291.             ->leftJoin('AR.marca_producto''MP')
  292.           //  ->leftJoin('AR.talle', 'TA')
  293.             ->where('FAC.fechaOperacion >= :start AND FAC.fechaOperacion <= :end')
  294.             ->andWhere('AR.categoria != 49');
  295.         $qb ->select'AR.id AS ID, FAC.fechaOperacion AS FECHA,  GR.descripcion AS GRUPO, '.
  296.             'CAT.nombre AS CATEGORIA, MP.nombre as MARCA, CONCAT(\' \', AR.codigo) as CODIGO, AR.descripcion as DESCRIPCION, '.
  297.             'AR.precio AS PRECIO_1, FL.precio AS PRECIO_2,  SUM( FL.cantidad) AS CANTIDAD, '.
  298.             'SUM(FL.importe) AS TOTAL, '.'SUM(AR.costo * FL.cantidad) AS COSTO, '.'(SUM(FL.importe) - SUM(AR.costo * FL.cantidad) ) AS GANANCIA, '
  299.             .'( SUM(FL.importe) - SUM(AR.costo * FL.cantidad) ) / SUM(AR.costo * FL.cantidad) AS PORCENTAJE');
  300.         $range DateHelper::STRING_DATE_TO_RANGE($fechaStr);
  301.         $qb $this->addWhereFiltroProducto($qb$filtros,  [
  302.             'start' => $range["start"],
  303.             'end' => $range["end"]
  304.         ]);
  305.         $qb->groupBy("AR.id, FAC.fechaOperacion");
  306.         $qb ->orderBy("FECHA""DESC")
  307. //            ->orderBy("RUBRO", "ASC")
  308.             ->addOrderBy("GRUPO""ASC")
  309.             ->addOrderBy("CATEGORIA""ASC")
  310.             ->addOrderBy("MARCA""ASC")
  311.             ->addOrderBy("DESCRIPCION""ASC");
  312.         return $qb->getQuery()->getResult();
  313.     }
  314.     public function totalesVentaPorMarca($fechaStr$filtros = [], $global false) {
  315.         $qb $this->createQueryBuilder('AR');
  316.         $qb ->leftJoin('AR.factulineas''FL')
  317.             ->leftJoin('FL.factura''FAC')
  318. //            ->leftJoin('AR.rubro', 'RB')
  319.             ->leftJoin('AR.grupo''GR')
  320.             ->leftJoin('AR.categoria''CAT')
  321.             ->leftJoin('AR.marca_producto''MP')
  322.     //        ->leftJoin('AR.talle', 'TA')
  323.             ->where('FAC.fechaOperacion >= :start AND FAC.fechaOperacion <= :end')
  324.             ->andWhere('AR.categoria != 49');
  325.         if (!$global) {
  326.             $qb ->select'MP.nombre as MARCA, SUM( FL.cantidad) AS CANTIDAD, SUM(FL.importe) AS TOTAL');
  327.             $qb->groupBy("MARCA");
  328.             $qb ->orderBy("MARCA""DESC");
  329.         } else {
  330.             $qb ->select'SUM( FL.cantidad) AS CANTIDAD, SUM(FL.importe) AS TOTAL');
  331.         }
  332.         $range DateHelper::STRING_DATE_TO_RANGE($fechaStr);
  333.         $qb $this->addWhereFiltroProducto($qb$filtros,  [
  334.             'start' => $range["start"],
  335.             'end' => $range["end"]
  336.         ]);
  337.         return $qb->getQuery()->getResult();
  338.     }
  339.     public function productoStock($filtros = [], $stock) {
  340.         $qb $this->createQueryBuilder('AR');
  341.           $qb ->leftJoin('AR.grupo''GR')
  342.             ->leftJoin('AR.categoria''CAT')
  343.             ->leftJoin('AR.marca_producto''MP')
  344.             ->where('1 = 1')
  345.             ->andWhere('AR.deletedAt IS  NULL');
  346.             if($stock)
  347.             $qb->andWhere('AR.stock<=0');
  348.         $qb ->select"
  349.                         GR.descripcion AS GRUPO, 
  350.                         CAT.nombre AS CATEGORIA, 
  351.                         MP.nombre as MARCA, 
  352.                         AR.descripcion as DESCRIPCION, 
  353.                         AR.codigo as CODIGO, 
  354.                         SUM(AR.stock) AS stocks,
  355.                         SUM(AR.stock * AR.costo) AS VAL_COSTO,
  356.                         SUM(AR.stock * AR.precio) AS VAL_VENTA"
  357.         );
  358.         $qb $this->addWhereFiltroProducto($qb$filtros);
  359.         $qb->groupBy("DESCRIPCION");
  360.         //$qb->groupBy("AR.id");
  361.         $qb ->addOrderBy("DESCRIPCION""ASC");
  362.         /*orderBy("RUBRO", "ASC")
  363.             ->addOrderBy("GRUPO", "ASC")
  364.             ->addOrderBy("CATEGORIA", "ASC")
  365.             ->addOrderBy("MARCA", "ASC")*/
  366.         return $qb->getQuery()->getResult();
  367.     }
  368.     /**
  369.      * Obtiene productos solo con stock (sin información de precios/costos)
  370.      * @param array $filtros
  371.      * @return array
  372.      */
  373.     public function productoStockSoloConStock($filtros = []) {
  374.         $qb $this->createQueryBuilder('AR');
  375.         $qb->leftJoin('AR.grupo''GR')
  376.            ->leftJoin('AR.categoria''CAT')  
  377.            ->leftJoin('AR.marca_producto''MP')
  378.            ->leftJoin('AR.proveedor''PRO')
  379.            ->where('1 = 1')
  380.            ->andWhere('AR.deletedAt IS NULL')
  381.            ->andWhere('AR.stock > 0'); // Solo productos con stock
  382.         $qb->select("
  383.             GR.descripcion AS GRUPO, 
  384.             CAT.nombre AS CATEGORIA, 
  385.             MP.nombre as MARCA, 
  386.             PRO.nombre as PROVEEDOR,
  387.             AR.descripcion as DESCRIPCION, 
  388.             AR.codigo as CODIGO, 
  389.             SUM(AR.stock) AS stocks
  390.         ");
  391.         $qb $this->addWhereFiltroProducto($qb$filtros);
  392.         $qb->groupBy("DESCRIPCION")
  393.            ->addOrderBy("DESCRIPCION""ASC");
  394.         return $qb->getQuery()->getResult();
  395.     }
  396.     public function productoTalles($filtros = []) {
  397.         $qb $this->createQueryBuilder('AR');
  398.         $qb ->leftJoin('AR.rubro''RB')
  399.             ->leftJoin('AR.grupo''GR')
  400.             ->leftJoin('AR.categoria''CAT')
  401.             ->leftJoin('AR.marca_producto''MP')
  402.             ->leftJoin('AR.talle''TA')
  403.             ->leftJoin('AR.color''CO')
  404.             ->where('1 = 1');
  405.         $qb ->select"TA.id AS ID, TA.talle AS VALUE, SUM(AR.stock) AS STOCK");
  406.         $qb $this->addWhereFiltroProducto($qb$filtros);
  407.         $qb->groupBy("ID");
  408.         $qb ->addOrderBy("VALUE""ASC");
  409.         return $qb->getQuery()->getResult();
  410.     }
  411. //    public function ExtraColumnsXLS($filtros = []){
  412. //        $qb = $this->createQueryBuilder('AR');
  413. //
  414. //        $qb ->leftJoin('AR.talle', 'TA')->where('1 = 1');
  415. //
  416. //        $qb ->select( 'GROUP_CONCAT(DISTINCT TA.talle) AS TALLES');
  417. //
  418. //        $qb = $this->addWhereFiltroProducto($qb, $filtros);
  419. //
  420. //        $qb->groupBy("TA.talle");
  421. //
  422. //        $qb ->orderBy("TALLES", "ASC");
  423. //
  424. //        return $qb->getQuery()->getResult();
  425. //    }
  426.     private function addWhereFiltroProducto(QueryBuilder $qb$filtros$parameters = []) {
  427. //        if (key_exists("rubros", $filtros)) {
  428. //
  429. //            $qb ->andWhere('AR.rubro in (:rubros)');
  430. //            $parameters["rubros"] =  is_array($filtros["rubros"]) ? :explode(",", $filtros["rubros"]);
  431. //        }
  432.         if (key_exists("grupos"$filtros)) {
  433.             $qb ->andWhere('AR.grupo in (:grupos)');
  434.             $parameters["grupos"] =  is_array($filtros["grupos"]) ? $filtros["grupos"] : explode(","$filtros["grupos"]);
  435.         }
  436.         if (key_exists("categorias"$filtros)) {
  437.             $qb ->andWhere('AR.categoria in (:categorias)');
  438.             $parameters["categorias"] =  is_array($filtros["categorias"]) ? $filtros["categorias"] : explode(","$filtros["categorias"]);
  439.         }
  440.         if (key_exists("marcas"$filtros)) {
  441.             $qb ->andWhere('AR.marca_producto in (:marcas)');
  442.             $parameters["marcas"] = is_array($filtros["marcas"]) ? $filtros["marcas"] : explode(","$filtros["marcas"]);
  443.         }
  444. //        if (key_exists("disciplinas", $filtros)) {
  445. //
  446. //            $qb ->andWhere('AR.disciplina in (:disciplinas)');
  447. //            $parameters["disciplinas"] =  is_array($filtros["disciplinas"]) ? :explode(",", $filtros["disciplinas"]);
  448. //        }
  449. //        if (key_exists("generos", $filtros)) {
  450. //
  451. //            $qb ->andWhere('AR.genero in (:generos)');
  452. //            $parameters["generos"] =  is_array($filtros["generos"]) ? :explode(",", $filtros["generos"]);
  453. //        }
  454.         if (key_exists("proveedores"$filtros) && $filtros["proveedores"]) {
  455.             $qb ->andWhere('AR.proveedor in (:proveedores)');
  456.             $parameters["proveedores"] =  is_array($filtros["proveedores"]) ? $filtros["proveedores"] : explode(","$filtros["proveedores"]);
  457.         }
  458.         $qb->setParameters($parameters);
  459.         return $qb;
  460.     }
  461.     public function getSyncList($date$activo true) {
  462.         $qb $this->createQueryBuilder('u')
  463.             ->leftJoin('u.grupo''g')  // Realiza el LEFT JOIN con la tabla grupo
  464.             ->where('u.cantidadImagenes > 0')
  465.             ->andWhere('g.web_ignored != 1');  // Añade la condición para web_ignored
  466.         if ($activo) {
  467.             $qb->andWhere('u.deletedAt IS NULL');
  468.         } else {
  469.             $qb->andWhere('u.deletedAt IS NOT NULL');
  470.         }
  471.         if ($date) {
  472.             $qb->andWhere('u.updatedAt IS NULL OR u.updatedAt >= :updatedDate')
  473.                 ->setParameter('updatedDate'$date);
  474.         }
  475.         $qb->orderBy('u.updatedAt''DESC');
  476.         return $qb->getQuery()->getResult();
  477.     }
  478.     public function listadePrecios($filtros  = [] )
  479.     {
  480.         $qb $this->createQueryBuilder('AR');
  481.         $qb->leftJoin('AR.grupo''GR')
  482.             ->leftJoin('AR.categoria''CAT')
  483.             ->leftJoin('AR.marca_producto''MP')
  484.             ->where('1 = 1')
  485.             ->andWhere('AR.categoria != 49')
  486.             ->andWhere('AR.deletedAt is null');
  487.         $qb $this->addWhereFiltroProducto($qb$filtros);
  488.         return $qb->getQuery()->getResult();
  489.     }
  490.     public function StockMinimo($filtros  = [] )
  491.     {
  492.         $qb $this->createQueryBuilder('AR');
  493.         $qb->leftJoin('AR.grupo''GR')
  494.             ->leftJoin('AR.categoria''CAT')
  495.             ->leftJoin('AR.marca_producto''MP')
  496.             ->where('1 = 1')
  497.             ->andWhere('AR.deletedAt is null')
  498.             ->andWhere('AR.categoria != 49')
  499.             ->andWhere('AR.stock <= AR.stockMinimo');
  500.         $qb $this->addWhereFiltroProducto($qb$filtros);
  501.         return $qb->getQuery()->getResult();
  502.     }
  503.     public function ActualizoPrecios($codigo)
  504.     {
  505.         $codigo strtoupper(trim($codigo));
  506.         $qb $this->createQueryBuilder('a');
  507.         $qb->where('UPPER(a.codigotwo) = :codigo')
  508.             ->orWhere('UPPER(a.codigo) = :codigo')
  509.             ->setParameter('codigo'$codigo);
  510.         return $qb->getQuery()->getOneOrNullResult();
  511.     }
  512. }