示例#1
0
        public void loadgrid(int idempresa)
        {
            try
            {
                List <in_producto_x_cp_proveedor_Info> tabint    = new List <in_producto_x_cp_proveedor_Info>();
                in_producto_x_cp_proveedor_Bus         busTabint = new in_producto_x_cp_proveedor_Bus();

                List <cp_proveedor_Info> LstProvee = new List <cp_proveedor_Info>();
                cp_proveedor_Bus         busProvee = new cp_proveedor_Bus();

                tabint = busTabint.ObtenerProducto_Proveedor(idempresa);

                foreach (var item in tabint)
                {
                    cp_proveedor_Info provee = new cp_proveedor_Info();
                    provee = busProvee.Get_Info_Proveedor(item.IdEmpresa_prov, item.IdProveedor);
                    LstProvee.Add(provee);
                }

                gridCtrlProveedor.DataSource = LstProvee;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        void cargagrid()
        {
            try
            {
                //  LstInfo = BusInfo.Obtener_list_Movi_inven_Recepcion(param.IdEmpresa,idSucuIni,idSucuFin,idBodegaIni,idBodegaFin,fechaIni,fechaFin);
                //LstInfo.ForEach(var => var.prov_nombre = BusProv.ObtenerProveedor(param.IdEmpresa, Convert.ToDecimal(var.IdProvedor)).pr_nombre);
                LstInfo = BusInfo.Get_list_Movi_inven_Recepcion(param.IdEmpresa
                                                                , ucGe_Menu_Mantenimiento_x_usuario.getIdSucursal, ucGe_Menu_Mantenimiento_x_usuario.getIdSucursal
                                                                , ucGe_Menu_Mantenimiento_x_usuario.getIdBodega, ucGe_Menu_Mantenimiento_x_usuario.getIdBodega
                                                                , ucGe_Menu_Mantenimiento_x_usuario.fecha_desde, ucGe_Menu_Mantenimiento_x_usuario.fecha_hasta);

                if (LstInfo != null)
                {
                    foreach (var item in LstInfo)
                    {
                        var prov = BusProv.Get_Info_Proveedor(param.IdEmpresa, Convert.ToDecimal(item.IdProvedor));
                        if (prov != null)
                        {
                            item.prov_nombre = prov.pr_nombre;
                        }
                    }
                    gridCtrlListRepcMat.DataSource   = LstInfo;
                    gridViewRepcMat.FocusedRowHandle = 0;
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
            }
        }
示例#3
0
        public cp_proveedor_Info Get_Info_Proveedor()
        {
            try
            {
                cp_proveedor_Info InfoProveedor = new cp_proveedor_Info();


                if (cmb_beneficiario.EditValue != null && IdTipo_Persona == Cl_Enumeradores.eTipoPersona.PROVEE)
                {
                    Info_Beneficiario = list_Beneficiario.FirstOrDefault(v => v.IdBeneficiario == Convert.ToString(cmb_beneficiario.EditValue));
                    cp_proveedor_Bus BusProvee = new cp_proveedor_Bus();

                    InfoProveedor = BusProvee.Get_Info_Proveedor(param.IdEmpresa, Info_Beneficiario.IdEntidad);
                }



                return(InfoProveedor);
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
                return(new cp_proveedor_Info());
            }
        }
        private void btnVerificarCarpeta_Click(object sender, EventArgs e)
        {
            try
            {
                ListaProveedorProducto = new List <cp_proveedor_producto_Info>();
                ListaProveedor         = new List <cp_proveedor_Info>();
                bus_ruta.GuardarDB(new cp_RutaPorEmpresaPorUsuario_Info
                {
                    IdEmpresa = param.IdEmpresa,
                    IdUsuario = param.IdUsuario,
                    RutaXML   = txtRutaXml.Text
                });

                blst = new BindingList <cp_XML_Documento_Info>();
                string   folder = txtRutaXml.Text;
                string   filter = "*.XML*";
                string[] files  = Directory.GetFiles(folder, filter);

                foreach (var item in files)
                {
                    string      readText             = File.ReadAllText(item);
                    XmlDocument xmlComprobanteOrigen = new XmlDocument();
                    xmlComprobanteOrigen.Load(new StringReader(readText));
                    string mensajeErrorOut      = string.Empty;
                    string sXml_a_descerializar = Quitar_a_xml_CDATA_y_Signature(xmlComprobanteOrigen.GetElementsByTagName("comprobante")[0].InnerXml, ref mensajeErrorOut);

                    var rootElement             = XElement.Parse(sXml_a_descerializar);
                    var infoFactura             = rootElement.Element("infoFactura");
                    var infoTributaria          = rootElement.Element("infoTributaria");
                    var IdentificacionComprador = infoFactura.Element("identificacionComprador").Value;

                    if (IdentificacionComprador == param.InfoEmpresa.em_ruc)
                    {
                        #region Cabecera
                        var Documento = new cp_XML_Documento_Info
                        {
                            XML                       = sXml_a_descerializar,
                            Tipo                      = infoTributaria.Element("codDoc").Value == "01" ? "FACTURA" : "NOTA DE CREDITO",
                            emi_Ruc                   = infoTributaria.Element("ruc").Value,
                            emi_RazonSocial           = infoTributaria.Element("razonSocial").Value,
                            emi_NombreComercial       = infoTributaria.Element("nombreComercial") == null?infoTributaria.Element("razonSocial").Value : infoTributaria.Element("nombreComercial").Value,
                            ClaveAcceso               = infoTributaria.Element("claveAcceso").Value,
                            emi_ContribuyenteEspecial = infoFactura.Element("contribuyenteEspecial") == null ? "NO" : infoFactura.Element("contribuyenteEspecial").Value,
                            CodDocumento              = infoTributaria.Element("codDoc").Value,
                            Establecimiento           = infoTributaria.Element("estab").Value,
                            PuntoEmision              = infoTributaria.Element("ptoEmi").Value,
                            NumeroDocumento           = infoTributaria.Element("secuencial").Value,
                            emi_DireccionMatriz       = infoTributaria.Element("dirMatriz").Value,


                            FechaEmision       = DateTime.ParseExact(infoFactura.Element("fechaEmision").Value, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture),
                            rec_RazonSocial    = infoFactura.Element("razonSocialComprador").Value,
                            rec_Identificacion = infoFactura.Element("identificacionComprador").Value
                        };
                        Documento.FormaPago   = infoFactura.Element("pagos") == null ? null : infoFactura.Element("pagos").Element("pago") == null ? null : (infoFactura.Element("pagos").Element("pago").Element("formaPago") == null ? null : infoFactura.Element("pagos").Element("pago").Element("formaPago").Value);
                        Documento.IdFormaPago = Documento.FormaPago;
                        Documento.Plazo       = infoFactura.Element("pagos") == null ? 0 : infoFactura.Element("pagos").Element("pago") == null ? 0 : (infoFactura.Element("pagos").Element("pago").Element("plazo") == null ? 0 : Convert.ToInt32(Convert.ToDecimal(infoFactura.Element("pagos").Element("pago").Element("plazo").Value)));
                        #endregion

                        #region Detalle
                        var list = infoFactura.Element("totalConImpuestos").Elements("totalImpuesto")
                                   .Select(element => element)
                                   .ToList();
                        Documento.SubtotalIVA = 0;
                        Documento.Subtotal0   = 0;
                        Documento.ValorIVA    = 0;

                        foreach (var Impuesto in list)
                        {
                            if (Impuesto.Element("codigo").Value.ToString() != "3")
                            {
                                Documento.Porcentaje = Convert.ToDouble(Impuesto.Element("valor").Value);

                                if (Documento.Porcentaje == 0)
                                {
                                    Documento.Descuento += Impuesto.Element("descuentoAdicional") == null ? 0 : Convert.ToDouble(Impuesto.Element("descuentoAdicional").Value);
                                    Documento.Subtotal0 += Convert.ToDouble(Impuesto.Element("baseImponible").Value) - Documento.Descuento;
                                }
                                else
                                {
                                    Documento.Descuento   += Impuesto.Element("descuentoAdicional") == null ? 0 : Convert.ToDouble(Impuesto.Element("descuentoAdicional").Value);
                                    Documento.SubtotalIVA += Convert.ToDouble(Impuesto.Element("baseImponible").Value) - Documento.Descuento;
                                    Documento.ValorIVA    += Convert.ToDouble(Impuesto.Element("valor").Value);
                                    Documento.Porcentaje   = bus_impuesto.Get_Info_impuesto(param.Get_Parametro_Info(tb_parametro_enum.P_IVA).Valor).porcentaje;
                                }
                            }
                        }
                        Documento.Total = Documento.Subtotal0 + Documento.SubtotalIVA + Documento.ValorIVA;
                        double ValorIva = Math.Round((double)Documento.SubtotalIVA * 0.12, 2, MidpointRounding.AwayFromZero);
                        if (ValorIva != Documento.ValorIVA)
                        {
                            MessageBox.Show("Revisar: \n" + item + "\nIVA no cuadra con el subtotal con IVA :\nIVA calculado: " + ValorIva.ToString("c2") + "\nIVA en factura: " + Convert.ToDouble(Documento.ValorIVA).ToString("c2"));
                        }
                        Documento.Comprobante = Documento.CodDocumento + '-' + Documento.Establecimiento + "-" + Documento.PuntoEmision + "-" + Documento.NumeroDocumento;

                        var listD = rootElement.Element("detalles").Elements("detalle")
                                    .Select(element => element)
                                    .ToList();

                        Documento.lstDetalle = new List <cp_XML_DocumentoDet_Info>();
                        int Contador = 1;
                        foreach (var Detalle in listD)
                        {
                            var d = new cp_XML_DocumentoDet_Info
                            {
                                CodigoProducto = Detalle.Element("codigoPrincipal") == null ? "" : Detalle.Element("codigoPrincipal").Value.ToString(),
                                NombreProducto = Detalle.Element("descripcion").Value.ToString(),
                                Cantidad       = Convert.ToDouble(Detalle.Element("cantidad").Value),
                                Precio         = Convert.ToDouble(Detalle.Element("precioTotalSinImpuesto").Value)
                            };
                            if (Contador == 1)
                            {
                                Documento.Observacion = d.NombreProducto;
                                Contador = 2;
                            }
                            var ImpuestoD = Detalle.Element("impuestos").Elements("impuesto")
                                            .Select(element => element)
                                            .FirstOrDefault();

                            d.PorcentajeIVA = Convert.ToDouble(ImpuestoD.Element("tarifa").Value);
                            d.ValorIva      = Convert.ToDouble(ImpuestoD.Element("valor").Value);
                            d.Total         = d.Precio + d.ValorIva;
                            Documento.lstDetalle.Add(d);
                        }

                        if (Documento.Total == 0)
                        {
                            Documento.Descuento = infoFactura.Element("totalDescuento") == null ? 0 : Convert.ToDouble(infoFactura.Element("totalDescuento").Value);
                            Documento.Subtotal0 = Convert.ToDouble(infoFactura.Element("totalSinImpuestos").Value) - Documento.Descuento;
                            Documento.Total     = Documento.Subtotal0;
                        }
                        #endregion

                        #region Valida contabilización automática
                        var proveedor = ListaProveedor.Where(q => q.IdEmpresa == param.IdEmpresa && q.Persona_Info.pe_cedulaRuc == Documento.emi_Ruc).FirstOrDefault();
                        if (proveedor == null)
                        {
                            proveedor = busProveedor.Get_Info_Proveedor(param.IdEmpresa, Documento.emi_Ruc);
                            if (proveedor != null)
                            {
                                ListaProveedor.Add(proveedor);
                            }
                        }

                        if (proveedor != null && !string.IsNullOrEmpty(proveedor.IdCtaCble_Gasto) && !string.IsNullOrEmpty(proveedor.IdCtaCble_CXP))
                        {
                            Documento.SeContabiliza = true;
                        }
                        #endregion

                        #region Proveedor producto
                        if (proveedor != null && ListaProveedorProducto.Where(q => q.IdProveedor == proveedor.IdProveedor).Count() == 0)
                        {
                            ListaProveedorProducto.AddRange(busProveedorProducto.GetList(param.IdEmpresa, proveedor.IdProveedor));
                        }
                        #endregion

                        #region Info adicional
                        if (rootElement.Element("infoAdicional") != null)
                        {
                            var listAdicional = rootElement.Element("infoAdicional").Elements("campoAdicional")
                                                .Select(element => element).ToList();
                            if (listAdicional.Count > 0)
                            {
                                var Kilometraje = listAdicional.Where(x => (string)x.Attribute("nombre") == "kilometraje").FirstOrDefault();
                                var Placa       = listAdicional.Where(x => (string)x.Attribute("nombre") == "placa").FirstOrDefault();
                                var Disco       = listAdicional.Where(x => (string)x.Attribute("nombre") == "disco").FirstOrDefault();

                                if (Kilometraje != null && Placa != null && Disco != null)
                                {
                                    Documento.Observacion = (Documento.lstDetalle.Count > 0 ? Documento.lstDetalle.First().NombreProducto : "") + "-km" + Kilometraje.Value.ToString() + "-D" + Disco.Value.ToString() + "-" + Placa.Value.ToString() + "-";
                                    int numValue = 0;
                                    if (Int32.TryParse(Disco.Value.ToString(), out numValue))
                                    {
                                        var PuntoCargo = lstPuntoCargo.Where(q => q.codPunto_cargo == "DISCO " + Convert.ToInt32(Disco.Value).ToString()).FirstOrDefault();
                                        if (PuntoCargo != null)
                                        {
                                            Documento.IdPunto_cargo = PuntoCargo.IdPunto_cargo;
                                            Documento.IdCentroCosto = PuntoCargo.IdCentroCosto_Scc;
                                            Documento.IdCentroCosto_sub_centro_costo = PuntoCargo.IdCentroCosto_sub_centro_costo_Scc;
                                        }
                                    }
                                }
                            }
                        }
                        #endregion

                        #region Codigos de retención
                        Documento.Imagen       = bus_xml.Existe(param.IdEmpresa, Documento.emi_Ruc, Documento.CodDocumento, Documento.Establecimiento, Documento.PuntoEmision, Documento.NumeroDocumento, Documento.ClaveAcceso);
                        Documento.lstRetencion = new List <cp_XML_Documento_Retencion_Info>();


                        bool DividirBases = false;

                        if (ListaCodigoProveedor.Where(q => q.IdEmpresa == param.IdEmpresa && q.pe_cedulRuc == Documento.emi_Ruc).Count() == 0)
                        {
                            var ListaDet = bus_codigoProveedor.GetList(param.IdEmpresa, Documento.emi_Ruc);
                            if (ListaDet.Count > 0)
                            {
                                if (ListaDet.Where(q => string.IsNullOrEmpty(q.BienServicio)).Count() == 1)
                                {
                                    DividirBases = true;
                                }

                                Documento.Automatico   = true;
                                Documento.lstRetencion = new List <cp_XML_Documento_Retencion_Info>();
                                var lstDup = ListaDet.GroupBy(q => q.re_tipo).Select(q => new
                                {
                                    re_tipo  = q.Key,
                                    Contador = q.Count()
                                }).ToList();


                                if (lstDup.Where(q => q.Contador > 1).Count() > 0 && Documento.Imagen == 1)
                                {
                                    foreach (var Detalle in ListaDet)
                                    {
                                        double BaseImponible = Documento.Subtotal0 + Documento.SubtotalIVA;
                                        cp_XML_Documento_Retencion_Info deta = new cp_XML_Documento_Retencion_Info
                                        {
                                            re_tipoRet          = Detalle.re_tipo,
                                            IdCodigo_SRI        = Detalle.IdCodigo_SRI,
                                            re_Codigo_impuesto  = Detalle.re_Codigo_impuesto,
                                            re_Porcen_retencion = Detalle.re_Porcen_retencion
                                        };
                                        if (DividirBases && Detalle.re_tipo != "IVA")
                                        {
                                            var LstBase = (from a in Documento.lstDetalle
                                                           join b in ListaProveedorProducto
                                                           on a.CodigoProducto equals b.CodProducto
                                                           select new
                                            {
                                                b.BienServicio,
                                                a.Precio
                                            }).ToList();

                                            if (LstBase.Count == 0)
                                            {
                                                deta.re_baseRetencion   = Math.Round(BaseImponible, 2, MidpointRounding.AwayFromZero);
                                                deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                            }
                                            else
                                            {
                                                if (!string.IsNullOrEmpty(Detalle.BienServicio))
                                                {
                                                    BaseImponible = Math.Round(LstBase.Sum(q => q.Precio ?? 0), 2, MidpointRounding.AwayFromZero);
                                                }
                                                else
                                                {
                                                    BaseImponible = BaseImponible - Math.Round(LstBase.Sum(q => q.Precio ?? 0), 2, MidpointRounding.AwayFromZero);
                                                }
                                                deta.re_baseRetencion   = Math.Round(BaseImponible, 2, MidpointRounding.AwayFromZero);
                                                deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                            }
                                        }
                                        else
                                        {
                                            deta.re_baseRetencion   = Math.Round(Detalle.re_tipo == "IVA" ? Documento.ValorIVA : BaseImponible, 2, MidpointRounding.AwayFromZero);
                                            deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                        }
                                        Documento.lstRetencion.Add(deta);
                                    }

                                    frmCP_XML_RetencionSubida frmRet = new frmCP_XML_RetencionSubida();
                                    frmRet.info = Documento;
                                    frmRet.ShowDialog();
                                    Documento = frmRet.info;
                                }
                                ListaCodigoProveedor.AddRange(ListaDet);
                            }
                        }
                        else
                        {
                            var ListaDet = ListaCodigoProveedor.Where(q => q.IdEmpresa == param.IdEmpresa && q.pe_cedulRuc == Documento.emi_Ruc).ToList();
                            var lstDup   = ListaDet.GroupBy(q => q.re_tipo).Select(q => new
                            {
                                re_tipo  = q.Key,
                                Contador = q.Count()
                            }).ToList();

                            if (ListaDet.Where(q => string.IsNullOrEmpty(q.BienServicio)).Count() == 1)
                            {
                                DividirBases = true;
                            }

                            if (lstDup.Where(q => q.Contador > 1).Count() > 0 && Documento.Imagen == 1)
                            {
                                foreach (var Detalle in ListaDet)
                                {
                                    double BaseImponible = Documento.Subtotal0 + Documento.SubtotalIVA;
                                    cp_XML_Documento_Retencion_Info deta = new cp_XML_Documento_Retencion_Info
                                    {
                                        re_tipoRet          = Detalle.re_tipo,
                                        IdCodigo_SRI        = Detalle.IdCodigo_SRI,
                                        re_Codigo_impuesto  = Detalle.re_Codigo_impuesto,
                                        re_Porcen_retencion = Detalle.re_Porcen_retencion
                                    };
                                    if (DividirBases && Detalle.re_tipo != "IVA")
                                    {
                                        var LstBase = (from a in Documento.lstDetalle
                                                       join b in ListaProveedorProducto
                                                       on a.CodigoProducto equals b.CodProducto
                                                       select new
                                        {
                                            b.BienServicio,
                                            a.Precio
                                        }).ToList();
                                        if (LstBase.Count == 0)
                                        {
                                            deta.re_baseRetencion   = Math.Round(BaseImponible, 2, MidpointRounding.AwayFromZero);
                                            deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                        }
                                        else
                                        {
                                            if (!string.IsNullOrEmpty(Detalle.BienServicio))
                                            {
                                                BaseImponible = Math.Round(LstBase.Sum(q => q.Precio ?? 0), 2, MidpointRounding.AwayFromZero);
                                            }
                                            else
                                            {
                                                BaseImponible = BaseImponible - Math.Round(LstBase.Sum(q => q.Precio ?? 0), 2, MidpointRounding.AwayFromZero);
                                            }
                                            deta.re_baseRetencion   = Math.Round(BaseImponible, 2, MidpointRounding.AwayFromZero);
                                            deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                        }
                                    }
                                    else
                                    {
                                        deta.re_baseRetencion   = Math.Round(Detalle.re_tipo == "IVA" ? Documento.ValorIVA : BaseImponible, 2, MidpointRounding.AwayFromZero);
                                        deta.re_valor_retencion = Math.Round(Math.Round(deta.re_baseRetencion, 2, MidpointRounding.AwayFromZero) * (Detalle.re_Porcen_retencion / 100), 2, MidpointRounding.AwayFromZero);
                                    }
                                    Documento.lstRetencion.Add(deta);
                                }

                                frmCP_XML_RetencionSubida frmRet = new frmCP_XML_RetencionSubida();
                                frmRet.info = Documento;
                                frmRet.ShowDialog();
                                Documento = frmRet.info;
                            }
                            Documento.Automatico = true;
                        }
                        if (blst.Where(q => q.Comprobante == Documento.Comprobante && q.emi_Ruc == Documento.emi_Ruc).Count() == 0)
                        {
                            blst.Add(Documento);
                        }
                        #endregion

                        gcDetalle.DataSource = null;
                        gcDetalle.DataSource = blst;
                    }
                }
                lblContador.Text     = blst.Count.ToString();
                gcDetalle.DataSource = blst;
            }
            catch (Exception ex)
            {
                gcDetalle.DataSource = blst;
                lblContador.Text     = blst.Count.ToString();
                MessageBox.Show(ex.Message, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
        private bool GetInfo()
        {
            btn_Buscar.Focus();
            lst_info = new List <com_CotizacionPedido_Info>();
            var lst = blst.Where(q => q.A == true && q.opd_EstadoProceso == "A").ToList();

            if (lst.Count == 0)
            {
                MessageBox.Show("Seleccione registros para cotizar", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (lst.Where(q => q.IdProducto == null || q.IdProveedor == null || q.cd_precioCompra == 0 || string.IsNullOrEmpty(q.IdUnidadMedida) || string.IsNullOrEmpty(q.IdCod_Impuesto)).Count() > 0)
            {
                MessageBox.Show("La información de la cotización se encuentra incompleta, por favor revise los registros seleccionados", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            var lstProvDep = lst.GroupBy(q => new { q.IdProveedor, q.IdDepartamento, q.IdSolicitante, q.IdSucursalOrigen, q.IdComprador, q.opd_IdOrdenPedido, q.IdSucursalDestino }).Select(q => new
            {
                q.Key.IdSolicitante,
                q.Key.IdDepartamento,
                q.Key.IdProveedor,
                q.Key.IdSucursalOrigen,
                q.Key.IdComprador,
                q.Key.opd_IdOrdenPedido,
                q.Key.IdSucursalDestino
            }).ToList();

            lst_termino = bus_termino.Get_List_TerminoPago().Where(q => q.Estado == "A").ToList();

            foreach (var item in lstProvDep)
            {
                var proveedor = bus_proveedor.Get_Info_Proveedor(param.IdEmpresa, item.IdProveedor ?? 0);
                if (proveedor == null)
                {
                    return(false);
                }
                var    Pedido                 = blst.Where(q => q.opd_IdOrdenPedido == item.opd_IdOrdenPedido).FirstOrDefault();
                string Observacion            = (Pedido != null ? Pedido.op_Observacion : string.Empty);
                com_CotizacionPedido_Info cab = new com_CotizacionPedido_Info
                {
                    IdEmpresa      = param.IdEmpresa,
                    IdSucursal     = item.IdSucursalOrigen,
                    IdProveedor    = item.IdProveedor ?? 0,
                    cp_Fecha       = DateTime.Now.Date,
                    cp_Observacion = Observacion,
                    IdDepartamento = item.IdDepartamento,
                    IdSolicitante  = item.IdSolicitante,
                    IdComprador    = item.IdComprador,
                    IdTerminoPago  = (proveedor.pr_plazo ?? 0) == 0 ? "1" : lst_termino.Where(q => q.Dias == (proveedor.pr_plazo ?? 0)).FirstOrDefault() == null ? "1" : lst_termino.Where(q => q.Dias == (proveedor.pr_plazo ?? 0)).FirstOrDefault().IdTerminoPago,
                    cp_Plazo       = proveedor.pr_plazo ?? 0,
                    pe_correo      = proveedor.Persona_Info.pe_correo_secundario1,
                    IdPersona      = proveedor.IdPersona,

                    IdOrdenPedido = item.opd_IdOrdenPedido,
                    ListaDetalle  = new List <com_CotizacionPedidoDet_Info>()
                };

                cab.ListaDetalle = lst.Where(q => q.IdProveedor == item.IdProveedor && q.IdDepartamento == item.IdDepartamento && q.IdSolicitante == item.IdSolicitante && q.IdSucursalOrigen == item.IdSucursalOrigen && q.opd_IdOrdenPedido == item.opd_IdOrdenPedido && q.IdSucursalDestino == item.IdSucursalDestino).Select(q => new com_CotizacionPedidoDet_Info {
                    IdEmpresa         = param.IdEmpresa,
                    opd_IdEmpresa     = q.opd_IdEmpresa,
                    opd_IdOrdenPedido = q.opd_IdOrdenPedido,
                    opd_Secuencia     = q.opd_Secuencia,
                    IdProducto        = q.IdProducto ?? 0,
                    cd_Cantidad       = q.cd_Cantidad,
                    cd_precioCompra   = q.cd_precioCompra,
                    cd_porc_des       = q.cd_porc_des,
                    cd_descuento      = q.cd_descuento,
                    cd_precioFinal    = q.cd_precioFinal,
                    cd_subtotal       = q.cd_subtotal,
                    IdCod_Impuesto    = q.IdCod_Impuesto,
                    Por_Iva           = q.Por_Iva,
                    cd_iva            = q.cd_iva,
                    cd_total          = q.cd_total,
                    IdUnidadMedida    = q.IdUnidadMedida,
                    IdPunto_cargo     = q.IdPunto_cargo,
                    cd_DetallePorItem = q.cd_DetallePorItem,
                    IdSucursalDestino = q.IdSucursalDestino,
                    IdSucursalOrigen  = q.IdSucursalOrigen
                }).ToList();
                cab.Subtotal = cab.ListaDetalle.Sum(q => q.cd_subtotal);
                cab.IVA      = cab.ListaDetalle.Sum(q => q.cd_iva);
                cab.Total    = cab.ListaDetalle.Sum(q => q.cd_total);
                lst_info.Add(cab);
            }
            return(true);
        }
示例#6
0
        void Liquidar_Importacion()
        {
            try
            {
                accion = Cl_Enumeradores.eTipo_action.grabar;

                if (txtDiarioLiquidacion.Text != "" && lblAnulado.Visible == false)
                {
                    MessageBox.Show("La importación Ya se encuentra Liquidada");
                    return;
                }

                if (txtIdCbteCbl.Text == "")
                {
                    MessageBox.Show("Falta Diario FOB No se puede Realizar Liquidación");
                    return;
                }

                var     Gasto   = (List <vwImp_LiquidacionImportacion_Info>)gridControlLiquidacion.DataSource;
                string  Diarios = "";
                Boolean valido  = true;
                foreach (var item in Gasto)
                {
                    if (item.CodCbteCble == null)
                    {
                        Diarios += "," + item.ga_decripcion;
                        valido   = false;
                    }
                }
                if (!valido)
                {
                    MessageBox.Show("Falta Diario Contable En los Siguientes Gastos" + Diarios, "Mensaje ERP");
                    return;
                }


                cp_proveedor_Bus _Prove_D = new cp_proveedor_Bus();
                var proveedor             = _Prove_D.Get_Info_Proveedor(param.IdEmpresa, Obj.IdProveedor);

                if (MessageBox.Show("¿Está seguro que desea Realizar La Liquidación de la Importación  " + txtCodImportacion.Text + "?", "Mensaje ERP", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Obj.ci_fecha_liquidacion = Convert.ToDateTime(dtpFecha.Value.ToShortDateString());
                    Obj.Fecha_Transac        = Convert.ToDateTime(param.Fecha_Transac.ToShortDateString());
                    Obj.IdEstadoLiquidacion  = "LIQDADO";
                    //  if (BusImportacion.Liquidar(param.IdEmpresa, Obj.IdSucusal, Obj.IdOrdenCompraExt, Convert.ToDateTime(param.Fecha_Transac.ToShortDateString()), "LIQDADO"))
                    if (BusImportacion.Liquidar(Obj, ref mensaje, accion))
                    {
                        if (mensaje != "")
                        {
                            MessageBox.Show(mensaje, "Sistemas");
                        }
                        else
                        {
                            MessageBox.Show("Operación Realizada Con Exito", "Mensaje ERP");
                        }

                        txtDiarioLiquidacion.Text = Obj.CodCbteCble;
                        lblAnulado.Visible        = false;
                        btnAnular.Enabled         = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());

                MessageBox.Show(ex.ToString());
            }
        }