public bool InsertarPartidas(List <RNPartidasRecepcion> partidas, string cveDoc, int folio, List <Lotes> lotes, int numEmpresa, out decimal cant_total, out decimal imp1, out decimal imp2, out decimal imp3, out decimal imp4, out decimal total, out decimal desc, out decimal descind, out decimal desfin)
        {
            cant_total = 0;
            imp1       = 0;
            imp2       = 0;
            imp3       = 0;
            imp4       = 0;
            total      = 0;
            desc       = 0;
            descind    = 0;
            desfin     = 0;
            RNConexion conexion = new RNConexion(numEmpresa);

            conexion.baseDatos.AbrirConexion();
            bool result = false;

            foreach (var p in partidas)
            {
                RNProducto prod     = RNProducto.ObtenerProductoPorClave(numEmpresa, p.CVE_ART);
                decimal    precio   = RNProducto.ObtenerPrecioProducto(p.CVE_ART, 1, numEmpresa);
                decimal    IMPU1    = 0.0M;
                decimal    IMPU2    = 0.0M;
                decimal    IMPU3    = 0.0M;
                decimal    IMPU4    = 0.0M;
                int        IMP1APLA = 0;
                int        IMP2APLA = 0;
                int        IMP3APLA = 0;
                int        IMP4APLA = 0;
                if (prod.CVE_ESQIMPU.Value > 0 && prod.CVE_ESQIMPU != null)
                {
                    RNProducto.ObtenerImpuestos(p.CVE_ART, prod.CVE_ESQIMPU.Value, numEmpresa, out IMPU1, out IMPU2, out IMPU3, out IMPU4, out IMP1APLA, out IMP2APLA, out IMP3APLA, out IMP4APLA);
                }
                cant_total += (prod.ULT_COSTO.Value * p.CANT);
                imp1       += prod.ULT_COSTO.Value * (IMPU1 / 100) * p.CANT;
                imp2       += prod.ULT_COSTO.Value * (IMPU2 / 100) * p.CANT;
                imp3       += prod.ULT_COSTO.Value * (IMPU3 / 100) * p.CANT;
                imp4       += prod.ULT_COSTO.Value * (IMPU4 / 100) * p.CANT;
                total      += (prod.ULT_COSTO.Value * p.CANT) + imp1 + imp2 + imp3 + imp4;
                desc       += 0;
                descind    += 0;
                desfin     += 0;
                conexion.baseDatos.LimpiarParametros();
                conexion.baseDatos.AgregarParametro("@CVE_DOC", p.CVE_DOC);
                conexion.baseDatos.AgregarParametro("@NUM_PAR", p.NUM_PAR);
                conexion.baseDatos.AgregarParametro("@CVE_ART", p.CVE_ART);
                conexion.baseDatos.AgregarParametro("@CANT", p.CANT);
                conexion.baseDatos.AgregarParametro("@PXR", p.PXR);
                conexion.baseDatos.AgregarParametro("@PREC", precio);
                conexion.baseDatos.AgregarParametro("@COST", prod.ULT_COSTO);
                conexion.baseDatos.AgregarParametro("@IMPU1", IMPU1);
                conexion.baseDatos.AgregarParametro("@IMPU2", IMPU2);
                conexion.baseDatos.AgregarParametro("@IMPU3", IMPU3);
                conexion.baseDatos.AgregarParametro("@IMPU4", IMPU4);
                conexion.baseDatos.AgregarParametro("@IMP1APLA", IMP1APLA);
                conexion.baseDatos.AgregarParametro("@IMP2APLA", IMP2APLA);
                conexion.baseDatos.AgregarParametro("@IMP3APLA", IMP3APLA);
                conexion.baseDatos.AgregarParametro("@IMP4APLA", IMP4APLA);
                conexion.baseDatos.AgregarParametro("@TOTIMP2", IMP2APLA == 1?(prod.ULT_COSTO * (IMPU1 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP3", IMP3APLA == 1?(prod.ULT_COSTO * (IMPU2 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP4", IMP4APLA == 1?(prod.ULT_COSTO * (IMPU3 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP1", IMP1APLA == 1?(prod.ULT_COSTO * (IMPU4 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@DESCU", p.DESCU);
                conexion.baseDatos.AgregarParametro("@ACT_INV", p.ACT_INV);
                conexion.baseDatos.AgregarParametro("@TIP_CAM", p.TIP_CAM);
                conexion.baseDatos.AgregarParametro("@UNI_VENTA", p.UNI_VENTA);
                conexion.baseDatos.AgregarParametro("@TIPO_ELEM", p.TIPO_ELEM);
                conexion.baseDatos.AgregarParametro("@TIPO_PROD", p.TIPO_PROD);
                conexion.baseDatos.AgregarParametro("@CVE_OBS", p.CVE_OBS);
                conexion.baseDatos.AgregarParametro("@E_LTPD", RNLbInventory.RegistrarEnlace(lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).reg_ltpd, lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).contador, numEmpresa));
                conexion.baseDatos.AgregarParametro("@REG_SERIE", p.REG_SERIE);
                conexion.baseDatos.AgregarParametro("@FACTCONV", p.FACTCONV);
                conexion.baseDatos.AgregarParametro("@COST_DEV", prod.ULT_COSTO);
                conexion.baseDatos.AgregarParametro("@NUM_ALM", p.NUM_ALM);
                conexion.baseDatos.AgregarParametro("@MINDIRECTO", p.MINDIRECTO);
                conexion.baseDatos.AgregarParametro("@NUM_MOV", RNLbInventory.RegistrarMovInveRemision(p, RNOrdenRemision.ObtenerRemision(cveDoc, numEmpresa), lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).reg_ltpd, 1, numEmpresa));
                conexion.baseDatos.AgregarParametro("@TOT_PARTIDA", prod.ULT_COSTO * p.CANT);
                conexion.baseDatos.AgregarParametro("@MAN_IEPS", p.MAN_IEPS);
                conexion.baseDatos.AgregarParametro("@APL_MAN_IMP", p.APL_MAN_IMP);
                conexion.baseDatos.AgregarParametro("@CUOTA_IEPS", p.CUOTA_IEPS);
                conexion.baseDatos.AgregarParametro("@APL_MAN_IEPS", p.APL_MAN_IEPS);
                conexion.baseDatos.AgregarParametro("@MTO_PORC", p.MTO_PORC);
                conexion.baseDatos.AgregarParametro("@MTO_CUOTA", p.MTO_CUOTA);
                conexion.baseDatos.AgregarParametro("@CVE_ESQ", p.CVE_ESQ);
                conexion.baseDatos.AgregarParametro("@DESCR_ART", p.DESCR_ART);
                result = conexion.baseDatos.EjecutarSinConsulta("insert into PAR_COMPR{0} (CVE_DOC,NUM_PAR,CVE_ART,CANT,PXR,PREC,COST,IMPU1,IMPU2,IMPU3,IMPU4,IMP1APLA,IMP2APLA,IMP3APLA,IMP4APLA,TOTIMP1,TOTIMP2,TOTIMP3,TOTIMP4,DESCU,ACT_INV,TIP_CAM,UNI_VENTA,TIPO_ELEM,TIPO_PROD,CVE_OBS,E_LTPD,REG_SERIE,FACTCONV,COST_DEV,NUM_ALM,MINDIRECTO,NUM_MOV,TOT_PARTIDA,MAN_IEPS,APL_MAN_IMP,CUOTA_IEPS,APL_MAN_IEPS,MTO_PORC,MTO_CUOTA,CVE_ESQ,DESCR_ART) values " +
                                                                "(@CVE_DOC,@NUM_PAR,@CVE_ART,@CANT,@PXR,@PREC,@COST,@IMPU1,@IMPU2,@IMPU3,@IMPU4,@IMP1APLA,@IMP2APLA,@IMP3APLA,@IMP4APLA,@TOTIMP1,@TOTIMP2,@TOTIMP3,@TOTIMP4,@DESCU,@ACT_INV,@TIP_CAM,@UNI_VENTA,@TIPO_ELEM,@TIPO_PROD,@CVE_OBS,@E_LTPD,@REG_SERIE,@FACTCONV,@COST_DEV,@NUM_ALM,@MINDIRECTO,@NUM_MOV,@TOT_PARTIDA,@MAN_IEPS,@APL_MAN_IMP,@CUOTA_IEPS,@APL_MAN_IEPS,@MTO_PORC,@MTO_CUOTA,@CVE_ESQ,@DESCR_ART)") > 0;
            }
            bool abn = InsertarPartidasCL(partidas, numEmpresa);

            return(result);
        }
Exemplo n.º 2
0
        public static bool GenerarPartidas(RNOrdenRemision orden, string cvedoc, int folio, int numEmpresa, List <RNPartidasRecepcion> partidas, List <RNRecepcion.Lotes> lotes, out decimal cant_total, out decimal imp1, out decimal imp2, out decimal imp3, out decimal imp4, out decimal total, out decimal desc, out decimal descind, out decimal desfin)
        {
            RNConexion conexion = new RNConexion(numEmpresa);

            conexion.baseDatos.AbrirConexion();
            bool result = false;

            cant_total = 0;
            imp1       = 0;
            imp2       = 0;
            imp3       = 0;
            imp4       = 0;
            total      = 0;
            desc       = 0;
            descind    = 0;
            desfin     = 0;
            foreach (var p in partidas)
            {
                RNProducto prod     = RNProducto.ObtenerProductoPorClave(numEmpresa, p.CVE_ART);
                decimal    precio   = RNProducto.ObtenerPrecioProducto(p.CVE_ART, 1, numEmpresa);
                decimal    IMPU1    = 0.0M;
                decimal    IMPU2    = 0.0M;
                decimal    IMPU3    = 0.0M;
                decimal    IMPU4    = 0.0M;
                int        IMP1APLA = 0;
                int        IMP2APLA = 0;
                int        IMP3APLA = 0;
                int        IMP4APLA = 0;
                RNProducto.ObtenerImpuestos(p.CVE_ART, prod.CVE_ESQIMPU.Value, numEmpresa, out IMPU1, out IMPU2, out IMPU3, out IMPU4, out IMP1APLA, out IMP2APLA, out IMP3APLA, out IMP4APLA);
                cant_total += (precio * p.CANT);
                imp1       += precio * (IMPU1 / 100) * p.CANT;
                imp2       += precio * (IMPU2 / 100) * p.CANT;
                imp3       += precio * (IMPU3 / 100) * p.CANT;
                imp4       += precio * (IMPU4 / 100) * p.CANT;
                total      += (precio + imp1 + imp2 + imp3 + imp4) * p.CANT;
                desc       += 0;
                descind    += 0;
                desfin     += 0;
                conexion.baseDatos.LimpiarParametros();
                conexion.baseDatos.AgregarParametro("@CVE_DOC", cvedoc);
                conexion.baseDatos.AgregarParametro("@NUM_PAR", p.NUM_PAR);
                conexion.baseDatos.AgregarParametro("@CVE_ART", p.CVE_ART);
                conexion.baseDatos.AgregarParametro("@CANT", p.CANT);
                conexion.baseDatos.AgregarParametro("@PXS", p.CANT);
                conexion.baseDatos.AgregarParametro("@PREC", precio);
                conexion.baseDatos.AgregarParametro("@COST", p.COST);
                conexion.baseDatos.AgregarParametro("@IMPU1", IMPU1);
                conexion.baseDatos.AgregarParametro("@IMPU2", IMPU2);
                conexion.baseDatos.AgregarParametro("@IMPU3", IMPU3);
                conexion.baseDatos.AgregarParametro("@IMPU4", IMPU4);
                conexion.baseDatos.AgregarParametro("@IMP1APLA", IMP1APLA);
                conexion.baseDatos.AgregarParametro("@IMP2APLA", IMP2APLA);
                conexion.baseDatos.AgregarParametro("@IMP3APLA", IMP3APLA);
                conexion.baseDatos.AgregarParametro("@IMP4APLA", IMP4APLA);
                conexion.baseDatos.AgregarParametro("@TOTIMP1", IMP2APLA == 1 ? (precio * (IMPU1 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP2", IMP3APLA == 1 ? (precio * (IMPU2 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP3", IMP4APLA == 1 ? (precio * (IMPU3 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@TOTIMP4", IMP1APLA == 1 ? (precio * (IMPU4 / 100)) * p.CANT : 0.00M);
                conexion.baseDatos.AgregarParametro("@DESC1", 0);
                conexion.baseDatos.AgregarParametro("@DESC2", 0);
                conexion.baseDatos.AgregarParametro("@DESC3", 0);
                conexion.baseDatos.AgregarParametro("@COMI", 0);
                conexion.baseDatos.AgregarParametro("@APAR", 0);
                conexion.baseDatos.AgregarParametro("@ACT_INV", "S");
                conexion.baseDatos.AgregarParametro("@NUM_ALM", p.NUM_ALM);
                conexion.baseDatos.AgregarParametro("@POLIT_APLI", "");
                conexion.baseDatos.AgregarParametro("@TIP_CAM", p.TIP_CAM);
                conexion.baseDatos.AgregarParametro("@UNI_VENTA", p.UNI_VENTA);
                conexion.baseDatos.AgregarParametro("@TIPO_PROD", p.TIPO_PROD);
                conexion.baseDatos.AgregarParametro("@CVE_OBS", 0);
                conexion.baseDatos.AgregarParametro("@REG_SERIE", 0);
                conexion.baseDatos.AgregarParametro("@E_LTPD", RNLbInventory.RegistrarEnlace(lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).reg_ltpd, lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).contador, numEmpresa));
                conexion.baseDatos.AgregarParametro("@TIPO_ELEM", "N");
                conexion.baseDatos.AgregarParametro("@NUM_MOV", RNLbInventory.RegistrarMovInveRemision(p, orden, lotes.FirstOrDefault(x => x.partida == p.NUM_PAR).reg_ltpd, -1, numEmpresa));
                conexion.baseDatos.AgregarParametro("@TOT_PARTIDA", precio * p.CANT);
                conexion.baseDatos.AgregarParametro("@IMPRIMIR", "S");
                conexion.baseDatos.AgregarParametro("@UUID", "");
                conexion.baseDatos.AgregarParametro("@VERSION_SINC", DateTime.Today);
                conexion.baseDatos.AgregarParametro("@MAN_IEPS", p.MAN_IEPS);
                conexion.baseDatos.AgregarParametro("@APL_MAN_IMP", p.APL_MAN_IMP);
                conexion.baseDatos.AgregarParametro("@CUOTA_IEPS", p.CUOTA_IEPS);
                conexion.baseDatos.AgregarParametro("@APL_MAN_IEPS", p.APL_MAN_IEPS);
                conexion.baseDatos.AgregarParametro("@MTO_PORC", p.MTO_PORC);
                conexion.baseDatos.AgregarParametro("@MTO_CUOTA", p.MTO_CUOTA);
                conexion.baseDatos.AgregarParametro("@CVE_ESQ", p.CVE_ESQ);
                conexion.baseDatos.AgregarParametro("@DESCR_ART", p.DESCR_ART);
                result = conexion.baseDatos.EjecutarSinConsulta("insert into PAR_FACTR{0} (CVE_DOC,NUM_PAR,CVE_ART,CANT,PXS,PREC,COST,IMPU1,IMPU2,IMPU3,IMPU4,IMP1APLA,IMP2APLA,IMP3APLA,IMP4APLA,TOTIMP1,TOTIMP2,TOTIMP3,TOTIMP4,DESC1,DESC2,DESC3,COMI,APAR,ACT_INV,NUM_ALM,POLIT_APLI,TIP_CAM,UNI_VENTA,TIPO_PROD,CVE_OBS,REG_SERIE,E_LTPD,TIPO_ELEM,NUM_MOV,TOT_PARTIDA,IMPRIMIR,UUID,VERSION_SINC,MAN_IEPS,APL_MAN_IMP,CUOTA_IEPS,APL_MAN_IEPS,MTO_PORC,MTO_CUOTA,CVE_ESQ,DESCR_ART) values " +
                                                                "(@CVE_DOC,@NUM_PAR,@CVE_ART,@CANT,@PXS,@PREC,@COST,@IMPU1,@IMPU2,@IMPU3,@IMPU4,@IMP1APLA,@IMP2APLA,@IMP3APLA,@IMP4APLA,@TOTIMP1,@TOTIMP2,@TOTIMP3,@TOTIMP4,@DESC1,@DESC2,@DESC3,@COMI,@APAR,@ACT_INV,@NUM_ALM,@POLIT_APLI,@TIP_CAM,@UNI_VENTA,@TIPO_PROD,@CVE_OBS,@REG_SERIE,@E_LTPD,@TIPO_ELEM,@NUM_MOV,@TOT_PARTIDA,@IMPRIMIR,@UUID,@VERSION_SINC,@MAN_IEPS,@APL_MAN_IMP,@CUOTA_IEPS,@APL_MAN_IEPS,@MTO_PORC,@MTO_CUOTA,@CVE_ESQ,@DESCR_ART)") > 0;
                bool b = InsertarPartidasCL(cvedoc, p.NUM_PAR, numEmpresa);
            }
            return(result);
        }
        public static RNProducto ObtenerProductoPorClave(int numEmpresa, string clave)
        {
            RNConexion conexion = new RNConexion(numEmpresa);

            conexion.baseDatos.AbrirConexion();
            conexion.baseDatos.LimpiarParametros();
            conexion.baseDatos.AgregarParametro("@clave", clave);
            var        result   = conexion.baseDatos.ObtenerTabla("select * from INVE{0} where CVE_ART =@clave");
            RNProducto producto = new RNProducto();

            foreach (DataRow fila in result.AsEnumerable())
            {
                producto.CVE_ART       = fila["CVE_ART"].ToString();
                producto.DESCR         = fila["DESCR"].ToString();
                producto.LIN_PROD      = fila["LIN_PROD"].ToString();
                producto.CON_SERIE     = fila["CON_SERIE"].ToString();
                producto.UNI_MED       = fila["UNI_MED"].ToString();
                producto.UNI_EMP       = Convert.ToDecimal(fila["UNI_EMP"].ToString());
                producto.CTRL_ALM      = fila["CTRL_ALM"].ToString();
                producto.TIEM_SURT     = Convert.ToInt32(fila["TIEM_SURT"].ToString());
                producto.STOCK_MIN     = Convert.ToDecimal(fila["STOCK_MIN"].ToString());
                producto.STOCK_MAX     = Convert.ToDecimal(fila["STOCK_MAX"].ToString());
                producto.TIP_COSTEO    = fila["TIP_COSTEO"].ToString();
                producto.NUM_MON       = Convert.ToInt32(fila["NUM_MON"].ToString());
                producto.FCH_ULTCOM    = Convert.ToDateTime(fila["FCH_ULTCOM"].ToString());
                producto.COMP_X_REC    = Convert.ToDecimal(fila["COMP_X_REC"].ToString());
                producto.FCH_ULTVTA    = Convert.ToDateTime(fila["FCH_ULTVTA"].ToString());
                producto.PEND_SURT     = Convert.ToDecimal(fila["PEND_SURT"].ToString());
                producto.EXIST         = Convert.ToDecimal(fila["EXIST"].ToString());
                producto.COSTO_PROM    = Convert.ToDecimal(fila["COSTO_PROM"].ToString());
                producto.ULT_COSTO     = Convert.ToDecimal(fila["ULT_COSTO"].ToString());
                producto.CVE_OBS       = Convert.ToInt32(fila["CVE_OBS"].ToString());
                producto.TIPO_ELE      = fila["TIPO_ELE"].ToString();
                producto.UNI_ALT       = fila["UNI_ALT"].ToString();
                producto.FAC_CONV      = Convert.ToDecimal(fila["FAC_CONV"].ToString());
                producto.APART         = Convert.ToDecimal(fila["APART"].ToString());
                producto.CON_LOTE      = fila["CON_LOTE"].ToString();
                producto.CON_PEDIMENTO = fila["CON_PEDIMENTO"].ToString();
                producto.PESO          = Convert.ToDecimal(fila["PESO"].ToString());
                producto.VOLUMEN       = Convert.ToDecimal(fila["VOLUMEN"].ToString());
                producto.CVE_ESQIMPU   = Convert.ToInt32(fila["CVE_ESQIMPU"].ToString());
                producto.CVE_BITA      = 0;
                producto.VTAS_ANL_C    = Convert.ToDecimal(fila["VTAS_ANL_C"].ToString());
                producto.VTAS_ANL_M    = Convert.ToDecimal(fila["VTAS_ANL_M"].ToString());
                producto.COMP_ANL_C    = Convert.ToDecimal(fila["COMP_ANL_C"].ToString());
                producto.COMP_ANL_M    = Convert.ToDecimal(fila["COMP_ANL_M"].ToString());
                producto.PREFIJO       = fila["PREFIJO"].ToString();
                producto.TALLA         = fila["TALLA"].ToString();
                producto.COLOR         = fila["COLOR"].ToString();
                producto.CUENT_CONT    = fila["CUENT_CONT"].ToString();
                producto.CVE_IMAGEN    = fila["CVE_IMAGEN"].ToString();
                producto.BLK_CST_EXT   = fila["BLK_CST_EXT"].ToString();
                producto.STATUS        = fila["STATUS"].ToString();
                producto.MAN_IEPS      = fila["MAN_IEPS"].ToString();
                producto.APL_MAN_IMP   = Convert.ToInt32(fila["APL_MAN_IMP"].ToString());
                producto.CUOTA_IEPS    = Convert.ToDecimal(fila["CUOTA_IEPS"].ToString());
                producto.APL_MAN_IEPS  = fila["APL_MAN_IEPS"].ToString();
                producto.UUID          = fila["UUID"].ToString();
                producto.CVE_PRODSERV  = fila["CVE_PRODSERV"].ToString();
                producto.CVE_UNIDAD    = fila["CVE_UNIDAD"].ToString();
            }
            return(producto);
        }