public IEnumerable <PLUInfoDto> ListCatalogoActual(PLUInfo ObjPluInfoRequest)
        {
            List <PLUInfo> lista = new List <PLUInfo>();;

            IEnumerable <PLUInfoDto> ListaDto;
            PLU module = new PLU("conexion");

            //--------------------------------------------------------------------------------------------------------
            //--------------------------------------------------------------------------------------------------------
            ListaDto = module.ListCatalogoActual(ObjPluInfoRequest.Campana);

            if (lista != null && lista.Count > 0)
            {
            }
            else
            {
                lista = new List <PLUInfo>();
            }


            return(ListaDto);
        }
Example #2
0
        public PLUInfo ListarxCodigoRapido(PLUInfo ObjPLUInfo)
        {
            PLUInfo lista = new PLUInfo();

            bool    ExcentoIVA           = false; //MRG: Arreglar esta bandera para que se ponga en true si hay IVA x ciudad x zona x articulo x cliente.
            string  CodCiudadCliente     = ObjPLUInfo.SessionEmpresaria.CodCiudadCliente.Trim();
            decimal PrecioCat            = 0;
            decimal IVAPrecioCat         = 0;
            int     CantidadSeleccionada = 0;
            decimal PrecioTotal          = 0;
            decimal PrecioUnitario       = 0;
            int     Cantidad             = 1;
            decimal PrecioCatalogo       = 0;
            decimal ValorIVA             = 0;

            PLUInfo objPLU = new PLUInfo();
            PLU     module = new PLU("conexion");

            PLUInfo objPLUPrecioCat = new PLUInfo();

            CatalogoPluInfo objCatalogoPluInfo = new CatalogoPluInfo();
            CatalogoPlu     objCatalogoPlu     = new CatalogoPlu("conexion");


            objCatalogoPluInfo = objCatalogoPlu.ListxCodigoRapidoSinCatalogo(ObjPLUInfo.CodigoRapido.ToUpper());

            if (objCatalogoPluInfo != null)
            {
                objPLU = module.ListxArticulosxPLUxTipoPrecio(objCatalogoPluInfo.PLU, ((int)TipoPrecioEnum.PrecioEmpresaria).ToString());

                if (objPLU != null)
                {
                    objPLU.CatalogoReal = objCatalogoPluInfo.CatalogoReal;
                    objPLU.CodigoRapido = ObjPLUInfo.CodigoRapido.ToUpper();
                    string   strProducto     = objPLU.NombreProducto.Trim().ToUpper();
                    string[] strProductoList = strProducto.Split(',');
                    objPLU.NombreProducto = strProductoList[0].Trim().ToUpper();
                    objPLU.NombreColor    = strProductoList[1].Trim().ToUpper();
                    objPLU.NombreTalla    = strProductoList[2].Trim().ToUpper();
                    objPLU.IdZona         = ObjPLUInfo.SessionEmpresaria.IdZona.Trim().ToUpper();
                    objPLU.PLU            = objCatalogoPluInfo.PLU;
                    objPLU.Referencia     = objCatalogoPluInfo.Referencia.Trim().ToUpper();
                    objPLU.Campana        = ObjPLUInfo.SessionEmpresaria.Campana.Trim().ToUpper();
                    objPLU.PrecioPuntos   = objPLU.PrecioPuntos;
                    objPLU.PuntosGanados  = objPLU.PuntosGanados;

                    if (!ExcentoIVA)
                    {
                        //()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
                        ArtExcentosxCiudad     objArtExcentosxCiudad     = new ArtExcentosxCiudad("conexion");
                        ArtExcentosxCiudadInfo objArtExcentosxCiudadInfo = new ArtExcentosxCiudadInfo();
                        //()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()

                        //()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
                        //Se valida si el articulo se encuentra excento de iva en la ciudad del cliente.

                        objArtExcentosxCiudadInfo = objArtExcentosxCiudad.ListxCiudadxPlu(ObjPLUInfo.SessionEmpresaria.CodCiudadCliente.Trim(), objPLU.PLU);

                        //Si se encuentra exento el iva debe ser 0.
                        if (objArtExcentosxCiudadInfo != null)
                        {
                            PrecioCat    = objPLU.PrecioSinIVA;
                            IVAPrecioCat = 0;

                            PrecioUnitario = objPLU.PrecioSinIVA;
                            //PrecioCatalogo = objPLU.PrecioSinIVA;
                            ValorIVA = 0;
                        }
                        else
                        {
                            PrecioCat    = objPLU.PrecioSinIVA;
                            IVAPrecioCat = objPLU.IVA;

                            PrecioUnitario = objPLU.PrecioConIVA;
                            //PrecioCatalogo = objPLU.PrecioConIVA;
                            ValorIVA = objPLU.IVA;
                        }
                    }
                    else
                    {
                        PrecioCat      = objPLU.PrecioSinIVA;
                        IVAPrecioCat   = 0;
                        PrecioUnitario = objPLU.PrecioSinIVA;
                        //PrecioCatalogo = objPLU.PrecioSinIVA;
                        ValorIVA = 0;
                    }

                    PrecioTotal          = PrecioUnitario * Cantidad;
                    CantidadSeleccionada = Cantidad;
                    objPLU.Cantidad      = Cantidad;

                    //---------------------------------------------------------------------------------------
                    //Descuento y Consulta la disponibilidad de cada articulo.

                    DescuentoGlod  glod       = new DescuentoGlod("conexion");
                    DescuentoInfo  info3      = new DescuentoInfo();
                    decimal        descuento  = 0M;
                    string         bodegasel  = "";
                    Inventario     inventario = new Inventario("conexion");
                    InventarioInfo info       = new InventarioInfo();

                    string grupodscto = "";
                    if (ObjPLUInfo.SessionEmpresaria.GrupoDescuento != null)
                    {
                        grupodscto = ObjPLUInfo.SessionEmpresaria.GrupoDescuento;
                    }
                    KardexInfo info5 = new Kardex("conexion").ListxArticuloxPLU(Convert.ToInt32(objCatalogoPluInfo.PLU));
                    descuento = this.CalcularDescuentoPrivilegioProdEstrella(info5.UnidadNegocio.Trim(), info5.GrupoProducto.Trim(), ObjPLUInfo.SessionEmpresaria.Campana, objCatalogoPluInfo.CatalogoReal.Trim().ToUpper(), info5.ProdEstrella, PrecioUnitario, grupodscto);
                    bodegasel = "";
                    if (ObjPLUInfo.SessionEmpresaria.Bodegas != null)
                    {
                        bodegasel = ObjPLUInfo.SessionEmpresaria.Bodegas.Bodega;
                    }
                    info = inventario.ListSaldosBodegaxPLUxEmpresaria(bodegasel, Convert.ToInt32(objCatalogoPluInfo.PLU));
                    decimal punitario           = PrecioUnitario; //Ver codigo de arriba xq aqui ya viene sumado o no el IVA excluido.
                    decimal precioempivadesc    = 0M;
                    decimal precioempsiniva     = 0;
                    decimal ivaprecioempresaria = 0;
                    if (ReferenceEquals(info, null))
                    {
                        descuento           = 0M;
                        objPLU.Disponible   = false;
                        precioempsiniva     = 0;
                        ivaprecioempresaria = 0;
                        precioempsiniva     = PrecioCat;
                        precioempivadesc    = PrecioTotal;
                    }
                    else if (info.Saldo > 0M)
                    {
                        //PrecioEmpresaria= objPLU.PrecioTotalConIVA* objPLU.PorcentajeDescuento
                        precioempivadesc = punitario - (punitario * (descuento / 100M));

                        objPLU.Disponible = true;

                        precioempsiniva = PrecioCat - (PrecioCat * (descuento / 100));
                        //ivaprecioempresaria = (((1 + (objPLU.PorcentajeIVA / 100)) * precioempsiniva) - precioempsiniva);
                        ivaprecioempresaria = precioempsiniva * ((objPLU.PorcentajeIVA / 100));
                    }
                    else
                    {
                        descuento           = 0M;
                        precioempsiniva     = 0;
                        ivaprecioempresaria = 0;
                        objPLU.Disponible   = false;
                        precioempsiniva     = PrecioCat;
                        precioempivadesc    = PrecioTotal;
                    }

                    objPLU.PorcentajeDescuento = descuento;


                    objPLU.PrecioEmpresaria = precioempivadesc;

                    //-------------------------------------------------------------
                    //MRG: Se envian los precios del producto PLU con la configuracion de ExcentoIVA IVA.
                    objPLU.PrecioTotalConIVA      = PrecioTotal; //MRG: Este es el valor que se carga en el front en la sesion DetallePedidoService con IVA o sin IVA.
                    objPLU.PrecioCatalogoSinIVA   = objPLU.PrecioSinIVA;
                    objPLU.PrecioEmpresariaSinIVA = precioempsiniva;
                    objPLU.IVAPrecioCatalogo      = ValorIVA;
                    objPLU.IVAPrecioEmpresaria    = ivaprecioempresaria;
                    objPLU.PorcentajeIVA          = objPLU.PorcentajeIVA;
                    objPLU.ExcentoIVA             = ExcentoIVA;
                    //-------------------------------------------------------------



                    objPLU.SessionEmpresaria = new SessionEmpresariaInfo();
                    objPLU.SessionEmpresaria = ObjPLUInfo.SessionEmpresaria;
                    //........................................................................................
                    //Path de imagenes

                    objPLU.SessionEmpresaria.CarpetaImagenes = ObjPLUInfo.SessionEmpresaria.CarpetaImagenes.Trim();

                    /*llenar variable de sesion con el % Descuento asingado en la busqeuda de la cedula
                     *  validar path de imagenes para que cargue lo que es y dejar ese path desde bd, sino trae imagenes x default
                     *  organizar calculos de detalle articulo con lo obtenido desde aqui
                     *  mostrar bien disponible en verde o rojo*/
                }
            }
            else
            {
                objPLU.PLU = -1;

                objPLU.Error             = new Error();
                objPLU.Error.Id          = -1;
                objPLU.Error.Descripcion = "No se encontraron resultados. Por favor verifique. Codigo Rapido: " + ObjPLUInfo.CodigoRapido.ToUpper();
                objPLU.CodigoRapido      = ObjPLUInfo.CodigoRapido.ToUpper();
            }


            return(objPLU);
        }
Example #3
0
        private void tryAgainDensiScale(StoreScales sc, IEnumerable <CurrentPrices> cp)
        {
            int iRtn = -1;

            try
            {
                string RefLFZKFileName = "";
                string RefCFGFileName  = "";
                iRtn = rtsdrv.rtscaleConnectEx(RefLFZKFileName, RefCFGFileName, sc.IpAdress);
                if (iRtn < 0)
                {
                    UpdateScaleStatus(false, $"Connection Error : {iRtn} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                    return;
                }
                ;
                rtsdrv.rtscaleClearPLUData();
                PLU[] plu           = new PLU[4];
                int   i             = 0;
                bool  processResult = true;
                foreach (var line in cp)
                {
                    int    k           = i % 4;
                    string productname = line.ProductName.ToUpper();
                    if (productname.Length > 20)
                    {
                        productname = productname.Substring(0, 20);
                    }
                    productname = String.Join("", productname.Normalize(NormalizationForm.FormD).Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)).Replace("ı", "i");

                    int price   = Convert.ToInt32(Math.Round(((decimal)line.SalePrice * 100), 0));
                    int barcode = int.Parse(line.Barcode.Replace("290", "000"));

                    plu[k].Name       = productname;
                    plu[k].LFCode     = barcode;
                    plu[k].Code       = barcode.ToString();
                    plu[k].BarCode    = 40;
                    plu[k].UnitPrice  = price;
                    plu[k].WeightUnit = 4;
                    plu[k].Deptment   = 29;
                    plu[k].ShlefTime  = 30;

                    i++;

                    if (i % 4 == 0)
                    {
                        int result = rtsdrv.rtscaleTransferPLUCluster(plu);
                        if (result != 0)
                        {
                            UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                            processResult = false;
                        }
                        plu = new PLU[4];
                    }
                }

                if (i > 0 && i % 4 != 0)
                {
                    int result = rtsdrv.rtscaleTransferPLUCluster(plu);
                    if (result != 0)
                    {
                        UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                        processResult = false;
                    }
                }

                if (i > 0 && processResult)
                {
                    UpdateScaleStatus(true, $"OK : {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                }
                rtsdrv.rtscaleDisConnectEx(sc.IpAdress);
            }
            catch (Exception ex)
            {
                _logger.Error($"tryAgainDensiScale error : {ex.Message}");
                if (iRtn >= 0) // connection exist
                {
                    rtsdrv.rtscaleDisConnectEx(sc.IpAdress);
                }
            }
        }
Example #4
0
        private void sendtoDensiScale(StoreScales sc)
        {
            int iRtn = -1;

            try
            {
                string RefLFZKFileName = "";
                string RefCFGFileName  = "";
                iRtn = rtsdrv.rtscaleConnectEx(RefLFZKFileName, RefCFGFileName, sc.IpAdress);
                if (iRtn < 0)
                {
                    UpdateScaleStatus(false, $"Connection Error : {iRtn} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                    return;
                }
                ;
                rtsdrv.rtscaleClearPLUData();
                PLU[] plu           = new PLU[4];
                int   i             = 0;
                bool  processResult = true;
                foreach (var line in _scalePrices)
                {
                    // if (line.Plu1 == "2902011") continue;
                    int    k           = i % 4;
                    string productname = line.ProductName.ToUpper();
                    if (productname.Length > 20)
                    {
                        productname = productname.Substring(0, 20);
                    }
                    productname = String.Join("", productname.Normalize(NormalizationForm.FormD).Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)).Replace("ı", "i");

                    int price   = Convert.ToInt32(Math.Round(((decimal)line.PriceAmount * 100), 0));
                    int barcode = int.Parse(line.Plu1.Replace("290", "000"));

                    plu[k].Name       = productname;
                    plu[k].LFCode     = barcode;
                    plu[k].Code       = barcode.ToString();
                    plu[k].BarCode    = 40;
                    plu[k].UnitPrice  = price;
                    plu[k].WeightUnit = 4;
                    plu[k].Deptment   = 29;
                    plu[k].ShlefTime  = 30;

                    i++;

                    if (i % 4 == 0)
                    {
                        int result = rtsdrv.rtscaleTransferPLUCluster(plu);
                        if (result != 0)
                        {
                            UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                            processResult = false;
                        }
                        plu = new PLU[4];
                    }
                }

                if (i > 0 && i % 4 != 0)
                {
                    int result = rtsdrv.rtscaleTransferPLUCluster(plu);
                    if (result != 0)
                    {
                        UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                        processResult = false;
                    }
                }
                if (i > 0 && processResult)
                {
                    UpdateScaleStatus(true, $"OK : {DateTime.Now.ToString("MM - dd HH: mm")}", sc);
                }

                // send hotkeys
                _logger.Debug($"hotkeys sent started");
                int[] pHotKeys   = new int[84];
                int   index      = 0;
                int   tableIndex = 0;
                foreach (HotKey h in _hotkeys)
                {
                    pHotKeys[index++] = h.Code;
                    if (index == 84)
                    {
                        rtsdrv.rtscaleTransferHotkey(pHotKeys, tableIndex++);
                        _logger.Debug($"hotkeys sent : { Newtonsoft.Json.JsonConvert.SerializeObject(pHotKeys)}");
                        index    = 0;
                        pHotKeys = new int[84];
                    }
                }
                if (pHotKeys.Length > 0)
                {
                    rtsdrv.rtscaleTransferHotkey(pHotKeys, tableIndex++);
                    _logger.Debug($"hotkeys sent : { Newtonsoft.Json.JsonConvert.SerializeObject(pHotKeys)}");
                }

                rtsdrv.rtscaleDisConnectEx(sc.IpAdress);
            }
            catch (Exception ex)
            {
                _logger.Error($"sendtoDensiScale error : {ex.Message}");
                if (iRtn >= 0) // connection exist
                {
                    rtsdrv.rtscaleDisConnectEx(sc.IpAdress);
                }
            }
        }