Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class Bancos_PopIECompras Inherits ClsPaginas #Region "Propiedades" Private Property DtDeudores As DataTable Get Return CType(ViewState("DtDeudores"), DataTable) End Get Set(value As DataTable) ViewState("DtDeudores") = value End Set End Property Private Property DtAcreedores As DataTable Get Return CType(ViewState("DtAcreedores"), DataTable) End Get Set(value As DataTable) ViewState("DtAcreedores") = value End Set End Property Private Property DtDeudoresDetalle As DataTable Get Return CType(ViewState("DtDeudoresDetalle"), DataTable) End Get Set(value As DataTable) ViewState("DtDeudoresDetalle") = value End Set End Property 'Configuración Private Property CveIE As Integer Get Return ViewState("CveIE").ToString.ToEntero End Get Set(value As Integer) ViewState("CveIE") = value End Set End Property Private Property CveCompra As Integer Get Return ViewState("CveCompra").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCompra") = value End Set End Property Private Property CveTipoConcepto As Integer Get Return ViewState("CveTipoConcepto").ToString.ToEntero End Get Set(value As Integer) ViewState("CveTipoConcepto") = value End Set End Property Private Property IdPoliza As Integer Get Return ViewState("IdPoliza").ToString.ToEntero End Get Set(value As Integer) ViewState("IdPoliza") = value End Set End Property Private Property FechaCompra As Date Get Return ViewState("FechaCompra").ToString.ToDate End Get Set(value As Date) ViewState("FechaCompra") = value End Set End Property Private Property CveProveedor As Integer Get Return ViewState("CveProveedor").ToString.ToEntero End Get Set(value As Integer) ViewState("CveProveedor") = value End Set End Property Private ReadOnly Property CtaProveedor As Integer Get Return ViewState("CtaProveedor").ToString.ToEntero End Get End Property Private ReadOnly Property CtaProveedorDeudores As Integer Get Return ViewState("CtaProveedorDeudores").ToString.ToEntero End Get End Property Private ReadOnly Property CtaProveedorAcreedores As Integer Get Return ViewState("CtaProveedorAcreedores").ToString.ToEntero End Get End Property Private Property IdCuentaBancaria As Integer Get Return ViewState("IdCuentaBancaria").ToString.ToEntero End Get Set(value As Integer) ViewState("IdCuentaBancaria") = value End Set End Property Private Property IdCuentaBancariaComplementaria As Integer Get Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero End Get Set(value As Integer) ViewState("IdCuentaBancariaComplementaria") = value End Set End Property Private ReadOnly Property IdCtaContMonedaExtranjera As Integer Get Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContComplementaria As Integer Get Return ViewState("IdCtaContComplementaria").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaProveedorExtranjera As Integer Get Return ViewState("IdCtaProveedorExtranjera").ToString.ToEntero End Get End Property Private ReadOnly Property CveCuentaProveedorExtranjera As Integer Get Return ViewState("CveCuentaProveedorExtranjera").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContRetIVA As Integer Get Return ViewState("IdCtaContRetIVA").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContRetISR As Integer Get Return ViewState("IdCtaContRetISR").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaAnticipo As Integer Get Return ViewState("IdCtaAnticipo").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContRetIVAAcreditable As Integer Get Return ViewState("IdCtaContRetIVAAcreditable").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContRetISRAcreditable As Integer Get Return ViewState("IdCtaContRetISRAcreditable").ToString.ToEntero End Get End Property Private Property CveCuentaBancaria As Integer Get Return ViewState("CveCuentaBancaria").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCuentaBancaria") = value End Set End Property Private Property CveMoneda As Integer Get Return ViewState("CveMoneda").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMoneda") = value End Set End Property Private Property TipoTransaccion As String Get Return ViewState("TipoTransaccion").ToString End Get Set(value As String) ViewState("TipoTransaccion") = value End Set End Property Private Property SaldoVenta As Decimal Get Return ViewState("SaldoVenta").ToString.ToDecimal End Get Set(value As Decimal) ViewState("SaldoVenta") = value End Set End Property Private Property MovimientoPagar As IEMovimiento Get Return CType(ViewState("MovimientoPagar"), IEMovimiento) End Get Set(value As IEMovimiento) ViewState("MovimientoPagar") = value End Set End Property Private Property ArrIE As ArrayList Get Return CType(ViewState("ArrIE"), ArrayList) End Get Set(value As ArrayList) ViewState("ArrIE") = value End Set End Property Private Property ArrIEFuncionariosEmpleados As ArrayList Get Return CType(ViewState("ArrIEFuncionariosEmpleados"), ArrayList) End Get Set(value As ArrayList) ViewState("ArrIEFuncionariosEmpleados") = value End Set End Property Private Property DTFuenteRecaudacion As DataTable Get Return CType(ViewState("DTFuenteRecaudacion"), DataTable) End Get Set(value As DataTable) ViewState("DTFuenteRecaudacion") = value End Set End Property Private Property DTFuncionarioEmpleado As DataTable Get Return CType(ViewState("DTFuncionarioEmpleado"), DataTable) End Get Set(value As DataTable) ViewState("DTFuncionarioEmpleado") = value End Set End Property Private Property EmpresaPrueba As Boolean Get Return CBool(ViewState("EmpresaPrueba")) End Get Set(value As Boolean) ViewState("EmpresaPrueba") = value End Set End Property Private Property NombreProveedor As String Get Return ViewState("NombreProveedor").ToString End Get Set(value As String) ViewState("NombreProveedor") = value End Set End Property Private Property SerieFolio As String Get Return ViewState("SerieFolio").ToString End Get Set(value As String) ViewState("SerieFolio") = value End Set End Property Private Property CveMonedaCompra As Integer Get Return ViewState("CveMonedaVenta").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMonedaVenta") = value End Set End Property Private Property TipoCambioOriginal As Decimal Get Return ViewState("TipoCambioOriginal").ToString.ToDecimal End Get Set(value As Decimal) ViewState("TipoCambioOriginal") = value End Set End Property Public Class Anticipos Public Property CveIE As Integer Public Property Importe As Decimal Public Property CvePersonal As Integer End Class Public Class IEMovimiento Public Property SubTotal As Decimal Public Property IVA As Decimal Public Property IVADeducible As Decimal Public Property IVANoDeducible As Decimal Public Property RetIVA As Decimal Public Property RetISR As Decimal Public Property Total As Decimal Public Property Saldo As Decimal Public Property IEPS As Decimal Public Property ConceptoRetIVA As Integer Public Property ConceptoRetISR As Integer Public Property PorcentajeIVA As Decimal Public Property IVAPorPagar As Decimal End Class Private Property CveMonedaFiltros As Integer Get Return ViewState("CveMonedaFiltros").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMonedaFiltros") = value End Set End Property Private Property RFCProveedor As String Get Return ViewState("RFCProveedor").ToString End Get Set(value As String) ViewState("RFCProveedor") = value End Set End Property Private Property IdCuentaCliente As Integer Get Return ViewState("IdCuentaCliente").ToString.ToEntero End Get Set(value As Integer) ViewState("IdCuentaCliente") = value End Set End Property Private ReadOnly Property IdCtaContRetIVACliente As Integer Get Return ViewState("IdCtaContRetIVACliente").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContRetISRCliente As Integer Get Return ViewState("IdCtaContRetISRCliente").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContComplementariaCliente As Integer Get Return ViewState("IdCtaContComplementariaCliente").ToString.ToEntero End Get End Property Private ReadOnly Property IdCtaContMonedaExtranjeraCliente As Integer Get Return ViewState("IdCtaContMonedaExtranjeraCliente").ToString.ToEntero End Get End Property Private Property CveCuentaCliente As Integer Get If ViewState("CveCuentaCliente") Is Nothing Then Return -1 Else Return ViewState("CveCuentaCliente").ToString.ToEntero End If End Get Set(value As Integer) ViewState("CveCuentaCliente") = value End Set End Property Private Property OriReferenciaCIE As String Get If ViewState("OriReferenciaCIE") Is Nothing Then Return "" Else Return ViewState("OriReferenciaCIE").ToString End If End Get Set(value As String) ViewState("OriReferenciaCIE") = value End Set End Property Private Property OriConceptoCIE As String Get If ViewState("OriConceptoCIE") Is Nothing Then Return "" Else Return ViewState("OriConceptoCIE").ToString End If End Get Set(value As String) ViewState("OriConceptoCIE") = value End Set End Property Private Property NotificarA As String Get If ViewState("NotificarA") Is Nothing Then Return "" Else Return ViewState("NotificarA").ToString End If End Get Set(value As String) ViewState("NotificarA") = value End Set End Property Private Property CveSubProyecto As Integer Get If ViewState("CveSubProyecto") Is Nothing Then Return -1 Else Return ViewState("CveSubProyecto").ToString.ToEntero End If End Get Set(value As Integer) ViewState("CveSubProyecto") = value End Set End Property Private Property EsImportacion As Boolean Get If ViewState("EsImportacion") Is Nothing Then Return False Else Return CBool(ViewState("EsImportacion")) End If End Get Set(value As Boolean) ViewState("EsImportacion") = value End Set End Property Private Property DtCheques As DataTable Get If ViewState("DtCheques") Is Nothing Then ViewState("DtCheques") = New DataTable End If Return CType(ViewState("DtCheques"), DataTable) End Get Set(value As DataTable) ViewState("DtCheques") = value End Set End Property #End Region Private Sub Bancos_PopIECompras_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then If Not UsuarioActual.Empresa.UsaAC Then EmpresaPrueba = True ViewState("IdCtaContMonedaExtranjera") = 0 ViewState("IdCtaContComplementaria") = 0 ViewState("IdCtaContRetIVA") = 0 ViewState("IdCtaContRetISR") = 0 ViewState("IdCuentaBancaria") = 0 ViewState("IdCuentaBancariaComplementaria") = 0 ViewState("IdCtaAnticipo") = 0 ViewState("CtaProveedorDeudores") = 0 ViewState("CtaProveedorAcreedores") = 0 ViewState("CveCuentaProveedorDeudores") = 0 ViewState("NombreProveedor") = "" End If CType(Me.Master, BaseMasterPage).EsPopup = True CType(Me.Master, BaseMasterPage).PopupWidth = 750 RegistraScript("$get('tdContenido').style.height='350px'") CveProveedor = -1 CveCompra = -1 CveTipoConcepto = 1 IdPoliza = -1 CveMoneda = 0 TipoTransaccion = "Egs" MovimientoPagar = Nothing ArrIE = New ArrayList() ArrIEFuncionariosEmpleados = New ArrayList() RFCProveedor = "" TxtFechaDocumento.Text = Now.ToShortDateString If Request("CveProveedor") IsNot Nothing Then HdnCveProveedor.Value = Request("CveProveedor").ToString CveProveedor = Request("CveProveedor").ToString.ToEntero End If If Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then CveCompra = Request("CveCompra").ToEntero CargaCompra(CveCompra) End If If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 72, 80) Then rowComisiones.Visible = True End If 'SI USUARIO USA AMORTIZACIÓN CONTABLE If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then Dim AC As New ClsAC If AC.GetPresupuestoIngresos(-1, -1, True, UsuarioActual.CveEmpresa) Then DdlFuenteRecaudacion.DataSource = AC.DtResultados() DdlFuenteRecaudacion.DataBind() ViewState("DTFuenteRecaudacion") = AC.DtResultados() End If TrFR.Visible = True AC.Dispose() End If CargaTipoTransaccion(TipoTransaccion) CargaCuentas() Dim ObjVentas As New ClsVentas If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then RBLContado.Items(4).Enabled = True End If ObjVentas.Dispose() If CveMoneda = 2 Then ChkPagarPesos.Visible = True TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4) Else ChkPagarDolares.Visible = True TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4) End If UpDatos.Update() End If End Sub #Region "C A M B I A R P A N E L" Private Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged Select Case RBLContado.SelectedValue Case "1" ' Bancos PanelBancos.Visible = True PanelFyE.Visible = False PanelIngresos.Visible = False PanelDeudores.Visible = False PanelAcreedores.Visible = False PanelVentas.Visible = False TxtImporte.Text = SaldoVenta.FormatoNumero Case "2" ' F y E PanelBancos.Visible = False PanelFyE.Visible = True PanelIngresos.Visible = False PanelDeudores.Visible = False PanelAcreedores.Visible = False PanelVentas.Visible = False CargaFuncionariosEmpleados() TxtImporte.Text = SaldoVenta.FormatoNumero Case "3" 'Ingresos x Comprobar PanelBancos.Visible = False PanelFyE.Visible = False PanelIngresos.Visible = True PanelDeudores.Visible = False PanelAcreedores.Visible = False PanelVentas.Visible = False CargaOtrosIngresos(CveMoneda) TxtImporte.Text = "0.00" Case "4" 'Deudores PanelBancos.Visible = False PanelFyE.Visible = False PanelIngresos.Visible = False PanelDeudores.Visible = True PanelAcreedores.Visible = False PanelVentas.Visible = False CargaDeudores(CveMoneda) TxtImporte.Text = "0.00" Case "5" ' Acreedores PanelBancos.Visible = False PanelFyE.Visible = False PanelIngresos.Visible = False PanelDeudores.Visible = False PanelAcreedores.Visible = True PanelVentas.Visible = False CargaAcreedores(CveMoneda) Case "6" 'Ventas PanelBancos.Visible = False PanelFyE.Visible = False PanelIngresos.Visible = False PanelDeudores.Visible = False PanelAcreedores.Visible = False PanelVentas.Visible = True CargaVentas(CveMoneda) TxtImporte.Text = "0.00" End Select End Sub #End Region #Region "C A R G A R I N F O R M A C I O N" Private Sub CargaCompra(pCveCompra As Integer) Dim ObjCompra As New ClsCompras() If ObjCompra.GetCompras(pCveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) If UsuarioActual.Empresa.Funcionalidad(306) = "1" And dr("AplicaNotaCredito").ToString = "True" Then BtnGuardar.Enabled = False LbNANota.Visible = True End If 'Datos Generales de la Compra FechaCompra = dr("Fecha").ToString.ToDate Dim Validada As Boolean = False If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then 'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui Dim Valida As New ClsValidaCFDi(dr("UUID").ToString(), dr("RFC").ToString, UsuarioActual.Empresa.RFC, dr("Total").ToString.ToDecimal) If Valida.EsValida > 0 Then If Valida.EsValida = 2 Then Validada = False 'Dim ObjDatos As New ClsCompras 'If ObjDatos.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then 'End If 'ObjDatos.Dispose() BtnGuardar.Enabled = False If UsuarioActual.Empresa.UsaAC Then RegistraScript("if (confirm('La factura está cancelada ante el SAT., ¿Desea eliminar la compra?')) { $get('BtnEliminarCompra').click();}") Else Alert("La factura está cancelada ante el SAT.", TipoMensaje.MsgError) End If Else Validada = True End If Else 'no se pudo validar, pero ya tuvo la primera vuelta de validacion Validada = True End If Valida.Dispose() Else Validada = True End If 'CargaProveedor CveProveedor = dr("CveProveedor").ToString.ToEntero HdnCveProveedor.Value = CveProveedor.ToString CargaProveedor(CveProveedor, "-1") CveMoneda = dr("CveMoneda").ToString.ToEntero CveTipoConcepto = dr("CveTipoConcepto").ToString.ToEntero CveMonedaCompra = dr("CveMoneda").ToString.ToEntero CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero SerieFolio = dr("SerieFolio").ToString TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDecimal NombreProveedor = dr("RazonSocial").ToString 'GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor)) CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero LtlTitulo.Text = "Cuentas por Pagar" LtlTipo2.Text = "Folio" LtlTipo3.Text = "Fecha" LtlFechaVenta.Text = dr("Fecha").ToString.ToDate.ToShortDateString() LtlFolio.Text = dr("SerieFolio").ToString LtlSaldo.Text = If(CveMoneda = 1, $"{dr("Saldo").ToString.FormatoNumero}{" MXN"}", $"{dr("Saldo").ToString.FormatoNumero}{" USD"}") 'Configuración de Modalidad Update MovimientoPagar = New IEMovimiento MovimientoPagar.SubTotal = dr("SubTotal").ToString.ToDecimal MovimientoPagar.IVA = dr("IVA").ToString.ToDecimal MovimientoPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal.RoundSQL MovimientoPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal.RoundSQL MovimientoPagar.RetIVA = dr("RetIVA").ToString.ToDecimal MovimientoPagar.RetISR = dr("RetISR").ToString.ToDecimal MovimientoPagar.Total = dr("Total").ToString.ToDecimal MovimientoPagar.Saldo = dr("Saldo").ToString.ToDecimal MovimientoPagar.IEPS = dr("IEPS").ToString.ToDecimal MovimientoPagar.ConceptoRetIVA = dr("CveRetIVAConcepto").ToString.ToEntero MovimientoPagar.ConceptoRetISR = dr("CveRetISRConcepto").ToString.ToEntero MovimientoPagar.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal MovimientoPagar.IVAPorPagar = dr("IVAPorPagar").ToString.ToDecimal If Validada Then TxtFolio.Enabled = True TxtFechaDocumento.Enabled = True Calendario.Enabled = True TxtPagueseA.Enabled = False TxtImporte.Enabled = True DdlCuenta.Enabled = True DdlTipoTransaccion.Enabled = True TxtObservaciones.Enabled = True BtnGuardar.Visible = True 'RVImporte.Enabled = True 'RVImporte.Enabled = True 'RVImporte.MaximumValue = dr("Saldo").ToString.ToDecimal.ToString.FormatoNumero TxtImporte.Text = dr("Saldo").ToString.ToDecimal.FormatoNumero SaldoVenta = dr("Saldo").ToString.ToDecimal EsImportacion = CBool(dr("EsImportacion")) End If End If End If ObjCompra.Dispose() End Sub Private Sub CargaProveedor(ByVal CveProveedor As Integer, RFC As String) Dim ObjProveedor As New ClsCompProveedores() If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then If ObjProveedor.DtResultados.Rows.Count > 0 Then TxtPagueseA.Text = ObjProveedor.RazonSocial RFCProveedor = ObjProveedor.RFC 'Conta ContPAQ ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores ViewState("CtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR ViewState("IdCtaContRetISRAcreditable") = ObjProveedor.IdCtaContRetISRAcreditable ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA ViewState("IdCtaContRetIVAAcreditable") = ObjProveedor.IdCtaContRetIVAAcreditable ViewState("IdCtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera ViewState("IdCtaContComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria Else Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia) End If End If ObjProveedor.Dispose() End Sub Private Sub CargaTipoTransaccion(Optional Tipo As String = "Egs") DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}'", Tipo)) DdlTipoTransaccion.DataBind() DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) End Sub Private Sub CargaCuentas() DdlCuenta.Items.Clear() Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) 'dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)) If ChkPagarPesos.Checked Then dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1)) RegistraScript("CambiaPesosDolares();") ElseIf ChkPagarDolares.Checked Then dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2)) RegistraScript("CambiaDolaresPesos();") Else If CveMoneda > 0 Then dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)) End If End If DdlCuenta.DataSource = dt DdlCuenta.DataBind() DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) End Sub Private Sub CargaGridTarjetas() Dim ObjCreditos As New ClsBancos ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero) DdlTarjeta.Items.Clear() DdlTarjeta.DataSource = ObjCreditos.DtResultados DdlTarjeta.DataBind() DdlTarjeta.Items.Insert(0, New ListItem("Seleccione", "-1")) ObjCreditos.Dispose() DivTarjeta.Visible = True End Sub Protected Sub CargaFuncionariosEmpleados() If CveCompra > 0 Then Dim objGastosXComprobar As New ClsMovimientos If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then 'TRATAR DE HACERLO CON LINQ DTFuncionarioEmpleado = New DataTable DTFuncionarioEmpleado.Columns.Add("CvePersonal", GetType(Integer)) DTFuncionarioEmpleado.Columns.Add("NombreCompleto", GetType(String)) DTFuncionarioEmpleado.Columns.Add("CveIE", GetType(String)) For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros($"CvePersonal > 0 AND CveMoneda = {CveMoneda}", "NombreCompleto").Rows Dim RowFE As DataRow = Nothing RowFE = DTFuncionarioEmpleado.NewRow() RowFE("CvePersonal") = Row("CvePersonal").ToString.ToEntero RowFE("NombreCompleto") = String.Format("{0} - ${1}", Row("NombreCompleto").ToString.Trim, Row("Saldo").ToString.FormatoNumero(2)) RowFE("CveIE") = Row("CveIE").ToString DTFuncionarioEmpleado.Rows.Add(RowFE) Next DdlFuncionarioEmpleado.DataSource = DTFuncionarioEmpleado DdlFuncionarioEmpleado.DataBind() DdlFuncionarioEmpleado.Items.Insert(0, New ListItem("Seleccione", "-1")) End If objGastosXComprobar.Dispose() End If End Sub Protected Sub CargaOtrosIngresos(Optional CveMoneda As Integer = 1) Dim IngresosXcomprobar As New ClsMovimientos DdlIngreso.Items.Clear() If IngresosXcomprobar.GetIngresosSaldos(-1, UsuarioActual.CveEmpresa) Then DtDeudores = IngresosXcomprobar.DtResultados.FiltraParametros($"CveCliente > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}") DdlIngreso.DataSource = DtDeudores DdlIngreso.DataBind() DdlIngreso.Items.Insert(0, New ListItem("Seleccione Ingreso", "-1")) UpDatos.Update() CambieIngreso() End If IngresosXcomprobar.Dispose() End Sub Protected Sub CargaDeudores(Optional CveMoneda As Integer = 1) Dim Deudores As New ClsMovimientos DdlDeudor.Items.Clear() If CveCompra > 0 Then If Deudores.GetDeudoresSaldos2(-1, UsuarioActual.CveEmpresa) Then DtDeudores = Deudores.DtResultados.FiltraParametros($"CveProveedor > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}") DdlDeudor.DataSource = DtDeudores DdlDeudor.DataBind() DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1")) UpDatos.Update() CambieDeudor() End If End If Deudores.Dispose() End Sub Protected Sub CargaAcreedores(Optional CveMoneda As Integer = 1) Dim ObjMov As New ClsMovimientos If ObjMov.GetAcreedoresSaldos(-1, UsuarioActual.CveEmpresa) Then DtAcreedores = ObjMov.DtResultados.FiltraParametros($"CveProveedor > 0 AND CveMoneda = {CveMoneda}") DdlAcreedor.DataSource = DtAcreedores DdlAcreedor.DataBind() DdlAcreedor.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1")) UpDatos.Update() CambieAcreedor() End If ObjMov.Dispose() End Sub Protected Sub CargaVentas(Optional CveMoneda As Integer = 1) Dim ObjCliente As New ClsClientes Dim ObjMovtos As New ClsMovimientos Dim CveCliente As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", String.Format("RFC = '{0}'", RFCProveedor)).ToEntero If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1) Then GvVentas.DataSource = ObjMovtos.DtResultados.FiltraParametros($" Saldo > 0 AND CveVenta > 0 AND CveMoneda = {CveMoneda}") End If ObjMovtos.Dispose() GvVentas.DataBind() If CveCliente > 0 Then If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then ViewState("IdCuentaCliente") = ObjCliente.IdCtaContClientes ViewState("IdCtaContRetIVACliente") = ObjCliente.IdCtaContRetIVA ViewState("IdCtaContRetISRCliente") = ObjCliente.IdCtaContRetISR ViewState("IdCtaContComplementariaCliente") = ObjCliente.IdCtaContComplementaria ViewState("IdCtaContMonedaExtranjeraCliente") = ObjCliente.IdCtaContMonedaExtranjera End If End If ObjCliente.Dispose() UpDatos.Update() End Sub Private Sub CambieIngreso() Dim stringDeudor As String = DdlIngreso.SelectedItem.ToString Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal If DdlIngreso.SelectedValue.ToEntero > 0 Then Dim Deudores As New ClsMovimientos If Deudores.GetIngresosSaldosDetalle(DdlIngreso.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0") GvIngresos.DataSource = DtDeudoresDetalle GvIngresos.DataBind() End If Deudores.Dispose() Else GvIngresos.DataSource = Nothing GvIngresos.DataBind() End If UpIngresos.Update() End Sub Private Sub CambieDeudor() Dim stringDeudor As String = DdlDeudor.SelectedItem.ToString Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal If DdlDeudor.SelectedValue.ToEntero > 0 Then Dim Deudores As New ClsMovimientos Dim OpcionSaldo As Integer = 1 If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0") GvDeudores.DataSource = DtDeudoresDetalle GvDeudores.DataBind() End If Deudores.Dispose() Else GvDeudores.DataSource = Nothing GvDeudores.DataBind() End If UpDeudores.Update() End Sub Private Sub CambieAcreedor() If DdlAcreedor.SelectedValue.ToEntero > 0 Then Dim dr As DataRow dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) If dr IsNot Nothing Then Dim tSaldo As Decimal = dr("Saldo").ToString.ToDecimal 'si el saldo es mayor de la compra poner el valor de la compra sino el valor del saldo TxtImporte.Text = If(tSaldo > TxtTotal.Text.ToDecimal, TxtTotal.Text, tSaldo.ToString).FormatoNumero Dim ObjMov As New ClsMovimientos If ObjMov.GetAcreedoresSaldosDetalles(-1, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then GvAcreedores.DataSource = ObjMov.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue)) GvAcreedores.DataBind() End If ObjMov.Dispose() End If Else GvAcreedores.DataSource = Nothing GvAcreedores.DataBind() End If UpAcreedores.Update() End Sub Private Sub CargaCuentasDepositos() DdlCuentaDeposito.Items.Clear() If DdlTipoTransaccion.SelectedValue.Contiene("2", "9", "17") Then ' transferencias y layout trCuentaDeposito.Visible = False Dim Dep As New ClsGenerales If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then If DdlTipoTransaccion.SelectedValue = "9" Then DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then trCuentaDeposito.Visible = True DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) Else BtnGuardar.Enabled = False Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) End If DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) ElseIf DdlTipoTransaccion.SelectedValue = "17" Then If Dep.DtResultados.Rows.Count > 0 Then DdlCuentaDeposito.DataSource = Dep.DtResultados trCuentaDeposito.Visible = True BtnGuardar.ToolTip = "" Else BtnGuardar.Enabled = False BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" End If UpGuardar.Update() DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) Else DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'") If Dep.DtResultados.Rows.Count > 0 Then trCuentaDeposito.Visible = True DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) End If End If Else If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then BtnGuardar.Enabled = False BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" Else trCuentaDeposito.Visible = True BtnGuardar.Enabled = True BtnGuardar.ToolTip = "" End If UpGuardar.Update() End If Dep.Dispose() DdlCuentaDeposito.DataBind() Else trCuentaDeposito.Visible = False DdlCuentaDeposito.Items.Clear() 'TrReferenciaCIE.Visible = False End If 'RecargaGlobalCuentasBancarias() UpCuentaDeposito.Update() End Sub #End Region #Region "DDL'S CHANGED" Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged Dim valor As Integer = DirectCast(sender, DropDownList).SelectedValue.ToEntero Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing Select Case valor Case 1 LblPagueseA.Text = "Páguese a" Case 2 LblPagueseA.Text = "Beneficiario" End Select CargaCuentas() CargaCuentasDepositos() UpDatos.Update() End Sub Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged Dim Folio As Long Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) Dim TCveMoneda = -1 If dr IsNot Nothing Then If ChkPagarPesos.Checked Then CveMoneda = 1 RegistraScript("CambiaPesosDolares();") Else CveMoneda = dr("CveMoneda").ToString.ToEntero RegistraScript("CambiaDolaresPesos();") End If IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero If dr("UsaTarjeta").ToString = "True" Then CargaGridTarjetas() Else DivTarjeta.Visible = False End If End If If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then Dim Banco As New ClsBancos Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) TxtFolio.Text = Folio.ToString Banco.Dispose() End If End Sub Private Sub DdlOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged Dim EsOtrosEgresos As Boolean = (DdlOtrosPagos.SelectedValue.Equals("2")) rowComision.Visible = EsOtrosEgresos rowTotal.Visible = EsOtrosEgresos TxtComision.Text = "0.00" TxtTotal.Text = TxtImporte.Text End Sub Protected Sub DdlFuncionarioEmpleado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuncionarioEmpleado.SelectedIndexChanged ArrIEFuncionariosEmpleados = New ArrayList() ArrIE = New ArrayList() DtCheques = New DataTable 'Dim objGastosXComprobar As New ClsMovimientos Dim CvePersonal As Integer = DdlFuncionarioEmpleado.SelectedValue.ToEntero 'If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then 'For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND FechaDocumento IS NOT NULL").Rows ' ArrIE.Add(New Anticipos With {.CveIE = Row("CveIE").ToString.ToEntero, .Importe = Row("Saldo").ToString.ToDecimal, .CvePersonal = Row("CvePersonal").ToString.ToEntero}) 'Next Dim ObjMovtos As New ClsMovimientos RowCheque.Visible = True ObjMovtos.GetEgresosSinComprobarPersonalDetalle(DdlFuncionarioEmpleado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) DtCheques = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha") 'Limpia Ddl Cheques DDlCheques.Items.Clear() If DtCheques.Rows.Count > 0 Then DDlCheques.DataSource = DtCheques End If ObjMovtos.Dispose() DDlCheques.DataBind() 'EstaAsociadoAPersonal = True DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty) UpDatos.Update() 'End If End Sub Protected Sub DDlCheques_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDlCheques.SelectedIndexChanged 'Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal 'TxtDocumentoImporteFE.Text = If(saldo < TxtTotal.Text.ToDouble, saldo.FormatoNumero, TxtTotal.Text) 'lblSaldoFE.Text = saldo.FormatoNumero If CveCompra > 0 Then 'Dim tSaldo As Decimal = DdlFuncionarioEmpleado.SelectedItem.Text.Split(CChar("-"))(1).ToDecimal If saldo < MovimientoPagar.Saldo Then TxtImporte.Text = saldo.FormatoNumero() Else TxtImporte.Text = MovimientoPagar.Saldo.FormatoNumero() End If End If UpDatos.Update() End Sub Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged CambieIngreso() End Sub Private Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged CambieDeudor() End Sub Private Sub DdlAcreedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAcreedor.SelectedIndexChanged CambieAcreedor() End Sub #End Region #Region "CHK TIPO CAMBIO" #Region "PAGAR CON PESOS" Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarPesos.Checked Then DivTipoCambio.Visible = True CargaCuentas() CargaOtrosIngresos(1) CargaDeudores(1) CargaAcreedores(1) CargaVentas(1) CveMonedaFiltros = 1 TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) GvIngresos.Columns(5).Visible = True GvIngresos.Columns(6).Visible = True GvDeudores.Columns(5).Visible = True GvDeudores.Columns(6).Visible = True 'RVImporte.Enabled = False ' RVImporte.MaximumValue = "0.00" CVImporteDolares.Enabled = True Else DivTipoCambio.Visible = False CargaCuentas() CargaOtrosIngresos(2) CargaDeudores(2) CargaAcreedores(2) CargaVentas(2) CveMonedaFiltros = 2 TxtFechaDocumento.Attributes.Remove("onchange") GvIngresos.Columns(5).Visible = False GvIngresos.Columns(6).Visible = False GvDeudores.Columns(5).Visible = False GvDeudores.Columns(6).Visible = False 'RVImporte.Enabled = True 'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString CVImporteDolares.Enabled = False CVImportePesos.Enabled = False End If UpDatos.Update() RegistraScript("CambiaPesosDolares();") End Sub Protected Sub CVImporteDolares_ServerValidate(source As Object, args As ServerValidateEventArgs) If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDecimal <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDecimal Then args.IsValid = True Else args.IsValid = False End If End Sub #End Region #Region "PAGAR CON DOLARES" Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarDolares.Checked Then DivTipoCambio.Visible = True CargaCuentas() CargaOtrosIngresos(2) CargaDeudores(2) CargaAcreedores(2) CargaVentas(2) CveMonedaFiltros = 2 TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) GvIngresos.Columns(5).Visible = True GvIngresos.Columns(6).Visible = True GvDeudores.Columns(5).Visible = True GvDeudores.Columns(6).Visible = True 'RVImporte.Enabled = False 'RVImporte.MaximumValue = "0.00" CVImportePesos.Enabled = True Else DivTipoCambio.Visible = False CargaCuentas() CargaOtrosIngresos(1) CargaDeudores(1) CargaAcreedores(1) CargaVentas(1) CveMonedaFiltros = 1 TxtFechaDocumento.Attributes.Remove("onchange") GvIngresos.Columns(5).Visible = False GvIngresos.Columns(6).Visible = False GvDeudores.Columns(5).Visible = False GvDeudores.Columns(6).Visible = False ' RVImporte.Enabled = True 'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString CVImporteDolares.Enabled = False CVImportePesos.Enabled = False End If UpDatos.Update() RegistraScript("CambiaDolaresPesos();") End Sub Protected Sub CVImportePesos_ServerValidate(source As Object, args As ServerValidateEventArgs) If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDecimal <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDecimal Then args.IsValid = True Else args.IsValid = False End If End Sub #End Region Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) CambiaTipoMoneda() End Sub Private Sub CambiaTipoMoneda() If ChkPagarPesos.Visible Then TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) RegistraScript("CambiaPesosDolares();") End If If ChkPagarDolares.Visible Then TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) RegistraScript("CambiaDolaresPesos();") End If UpDatos.Update() End Sub #End Region #Region "GV ROW DATA BOUND" Private Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIngresos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim total As Decimal Dim saldo As Decimal saldo = e.Row.DataKey("Saldo").ToDecimal total = SaldoVenta e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();") e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN") Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) End If End Sub Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim total As Decimal Dim saldo As Decimal saldo = e.Row.DataKey("Saldo").ToDecimal total = SaldoVenta e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();") e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN") Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) End If End Sub Private Sub GvAcreedores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcreedores.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim total As Decimal Dim saldo As Decimal saldo = e.Row.DataKey("Saldo").ToDecimal total = SaldoVenta e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();") e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN") Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) End If End Sub Private Sub GvVentas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvVentas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim total As Decimal Dim saldo As Decimal saldo = e.Row.DataKey("Saldo").ToDecimal total = SaldoVenta e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo)) e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();") e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN") Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) End If End Sub #End Region #Region "G U A R D A R" Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click Dim FechaFactura As Date = FechaCompra Dim FechaDocumentoPago As Date = TxtFechaDocumento.Text.ToDate Dim AnioFactura As Integer = FechaFactura.Year Dim MesFactura As Integer = FechaFactura.Month Dim AnioDocumento As Integer = FechaDocumentoPago.Year Dim MesDocumento As Integer = FechaDocumentoPago.Month If AnioFactura > AnioDocumento Then Alert($"El mes de la fecha de compra no puede ser mayor al mes de la la fecha de pago
Fecha de compra: { FechaCompra.ToString("dd/MM/yyyy") }", TipoMensaje.MsgAdvertencia) Exit Sub ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then Alert($"El mes de la fecha de compra no puede ser mayor al mes de la la fecha de pago
Fecha de compra: { FechaCompra.ToString("dd/MM/yyyy") }", TipoMensaje.MsgAdvertencia) Exit Sub End If 'VALIDACION PARA LOS IMPORTES CUANDO SE QUIERE PAGAR EN DIFERENTE MONEDA If Not Page.IsValid Then Exit Sub End If Dim Dep As New ClsGenerales If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then Dim Row = Dep.DtResultados.FiltroPrimero(String.Format("CveCuentaDeposito = {0}", DdlCuentaDeposito.SelectedValue.ToEntero)) If Row IsNot Nothing AndAlso Row("Estatus").ToString = "False" Then Alert("La cuenta depósito del proveedor esta inactiva.", TipoMensaje.MsgAdvertencia) Dep.Dispose() Exit Sub End If End If Dep.Dispose() Dim MsgError As String = "" Dim CveConcepto As Integer = -1 Dim CveConcepto2 As Integer = -1 Dim CvePersonal As Integer = -1 Dim Inserta As Boolean = True Dim ImportePagado As Decimal = 0 Dim TipoMovimiento As Boolean = False Dim PorcentajePago As Decimal = 0 Dim CveProveedor2 As Integer = CveProveedor Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate Dim CompraSaldo As Decimal = 0 If Not EmpresaPrueba Then CveIE = -1 Select Case RBLContado.SelectedValue Case "1" ' Bancos ImportePagado = TxtImporte.Text.Trim.ToDecimal Fecha = TxtFechaDocumento.Text.Trim.ToDate TipoMovimiento = True Case "2" 'FyE ImportePagado = TxtImporte.Text.Trim.ToDecimal Fecha = TxtFechaDocumento.Text.Trim.ToDate CveConcepto = 29 CveIE = DDlCheques.SelectedValue.ToEntero If Not CveIE > 0 Then Alert("No se encontro movimientos bancarios de perosonal", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal If TxtImporte.Text.ToDecimal > saldo Then Alert("El importe no debe de superar el saldo del cheque seleccionado.", TipoMensaje.MsgAdvertencia) Exit Sub End If TipoMovimiento = True Dim stringPersonal As String = DdlFuncionarioEmpleado.SelectedItem.ToString CvePersonal = DdlFuncionarioEmpleado.SelectedValue.ToEntero Case "3" 'Ingresos X Comprobar ImportePagado = TxtImporte.Text.Trim.ToDecimal Case "4" 'Deudores Diversos ImportePagado = TxtImporte.Text.Trim.ToDecimal CveConcepto = 17 CveConcepto2 = 37 CveIE = -1 CveProveedor2 = DdlDeudor.SelectedValue.ToEntero Case "5" 'Acreedores Diversos ImportePagado = TxtImporte.Text.Trim.ToDecimal CveConcepto = 17 CveConcepto2 = 56 CveProveedor2 = DdlAcreedor.SelectedValue.ToEntero CveIE = -1 'verifica que se halla selccionado algun acreedor If DdlAcreedor.SelectedValue.ToEntero <= 0 Then Inserta = False Alert("Debe especificar el Acreedor.", TipoMensaje.MsgAdvertencia) Exit Sub End If Case "6" 'Ventas ImportePagado = TxtImporte.Text.Trim.ToDecimal CveProveedor2 = CveProveedor CveIE = -1 Case Else ImportePagado = 0 End Select If ImportePagado <= 0 Then Inserta = False Alert("Debe ingresar un importe.", TipoMensaje.MsgAdvertencia) Exit Sub End If If CveCompra > 0 Then If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then Dim ObjCompra As New ClsCompras() If ObjCompra.GetComprasSaldos(CveCompra) Then CompraSaldo = ObjCompra.DtResultados(0)("Saldo").ToString.ToDecimal End If ObjCompra.Dispose() End If End If Dim ObjIE As New ClsBancos() Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) Dim CvePlantillaPoliza As Integer = 2 Dim ConceptoPoliza As String = String.Format("{0} {1}", NombreProveedor, SerieFolio) Dim CveCuentaDeposito As Integer = If(DdlCuentaDeposito.Items.Count > 0, DdlCuentaDeposito.SelectedValue.ToEntero, 0) Dim FechaDocumento = FechaCompra 'Saca moneda en que se va a pagar segun metodo de pago Select Case RBLContado.SelectedValue Case "1" ' Banco If DdlCuenta.SelectedValue.ToEntero > 0 Then CveMoneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero End If Case "2", "3", "4", "5", "6" 'FyE, Ingresos, Deudores, Acreedores If ChkPagarDolares.Checked Then CveMoneda = 2 ElseIf ChkPagarPesos.Checked Then CveMoneda = 1 End If End Select 'cuando es pago con ventas, debe de ser de Diario Dim CveTipoPoliza As Integer = ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa) If RBLContado.SelectedValue = "6" Then CveTipoPoliza = 3 Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/PopIECompras", CvePlantillaPoliza, ImportePagado, ImportePagado, CveMoneda, Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=CveTipoPoliza) If Inserta Then If CvePrePoliza > 0 Then 'SE AGREGA DETALLE DE UNA COMPRA If CveCompra > 0 Then If EmpresaPrueba Then PorcentajePago = 100 'SE AGREGA DETALLE CUANDO ES UNA COMPRA If MovimientoPagar IsNot Nothing Then Dim tipoCambioPago As Decimal = 1 Dim tipoCambioCompra As Decimal = 1 Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:

" Dim idCuentaContabilizacion As Long = 1 Dim CuentasContablesInvalidas As New StringBuilder Dim CveCuentaContabilizacion As Long = 1 Dim CuentasContablesInvalidasSIG As New StringBuilder Dim FechaPago As Date = TxtFechaDocumento.Text.ToDate() 'VERIFICA SI SE ESTA PAGANDO EN EL MISMO MES DE LA FACTURA Dim PagoMismoMes As Boolean = True If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso (FechaDocumento < FechaPago) AndAlso ((FechaDocumento.Month < FechaPago.Month AndAlso FechaDocumento.Year = FechaPago.Year) OrElse (FechaDocumento.Year < FechaPago.Year)) Then PagoMismoMes = False End If Dim TCUltimaFluctuacion As Decimal = 1 'Tipos de cambio segun metodo de pago If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos tipoCambioPago = 1 tipoCambioCompra = 1 PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos tipoCambioPago = TxtTipoCambio.Text.ToDecimal tipoCambioCompra = TipoCambioOriginal PorcentajePago = (ImportePagado.ToString.ToDecimal / tipoCambioPago) / MovimientoPagar.Total ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES tipoCambioPago = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal tipoCambioCompra = TipoCambioOriginal PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES tipoCambioPago = TxtTipoCambio.Text.ToDecimal tipoCambioCompra = 1 PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total End If Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(TxtFechaDocumento.Text.ToDate) If UltimaFluctuacion IsNot Nothing Then If UltimaFluctuacion.FechaFluctuacion < TxtFechaDocumento.Text.ToDate Then TCUltimaFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If Select Case RBLContado.SelectedValue Case "1" ' Banco CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, tipoCambioPago, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), ConceptoCIE:=If(TxtConceptoCIE.Text.Trim.Length > 0, TxtConceptoCIE.Text, "-1")) If CveIE > 0 Then CveConcepto = 17 Else MsgError = "Ocurrio un Error al registrarse el movimiento bancario." Inserta = False End If Case "2" ' F Y E Case Else CveIE = -1 End Select If DdlOtrosPagos.SelectedValue = "2" AndAlso TxtComision.Text.ToDecimal > 0 Then 'Agrego el movimiento a Comisiones If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtComision.Text.ToDecimal, TxtObservaciones.Text, 78, TxtObservaciones.Text, Fecha, 0, -1, CveIE, CveCompra, -1, -1, If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1)) Then MsgError = "Detalle" End If End If 'inserto las compras que voy a pagar If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then For Each Row As DataRow In ObjMov.DtResultados.Rows Dim CveSubProyectoInsertar As Integer = -1 Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then If ConceptoContable.Contiene(14, 19) AndAlso CveCompra > 0 Then If EsImportacion Then If ConceptoContable = 14 Then ConceptoContable = 287 Else ConceptoContable = 288 End If End If End If End If TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) Dim ImporteMovimiento As Decimal = 0 Dim ImporteMX As Decimal = 0 Dim ImporteMovimientoNoDeducible As Decimal = 0 Dim ImporteMXNoDeducible As Decimal = 0 Dim IdCtaContable As Integer = 0 Dim ConceptoMovimiento = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, NombreProveedor, TxtObservaciones.Text, TxtFolio.Text.Trim) Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) Dim TimpocambioGeneral As Decimal = 1 Dim PorcentajeImpuesto As Decimal = 0 Select Case ConceptoContable Case 17 'Pago Proveedores If CveTipoConcepto = 2 Then ConceptoContable = 308 'cuando es acreedor If CveMoneda <> 1 Then Select Case ConceptoContable Case 17 ConceptoContable = 312 Case 308 ConceptoContable = 309 Case Else End Select End If Dim CveConceptoContableComplementaria As Integer = 206 If CveTipoConcepto = 2 Then CveConceptoContableComplementaria = 310 'cuando es acreedor If RBLContado.SelectedValue.Contiene("3", "4", "5", "6") Then For Each rw As GridViewRow In GvIngresos.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then ImporteMX = ImporteMovimiento End If IdCtaContable = IdCtaProveedorExtranjera Else IdCtaContable = CtaProveedor End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 Then Dim ImporteMN As Decimal = (ImporteMovimiento * tipoCambioCompra - ImporteMovimiento).RoundSQL If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMN, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then MsgError = "No se pudo insertar la póliza" End If End If ImporteMX = ImporteMovimiento IdCtaContable = IdCtaProveedorExtranjera End If End If Next For Each rw As GridViewRow In GvDeudores.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then ImporteMX = ImporteMovimiento End If IdCtaContable = IdCtaProveedorExtranjera Else IdCtaContable = CtaProveedor End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If ImporteMX = ImporteMovimiento IdCtaContable = IdCtaProveedorExtranjera End If End If Next For Each rw As GridViewRow In GvAcreedores.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then ImporteMX = ImporteMovimiento End If IdCtaContable = IdCtaProveedorExtranjera Else IdCtaContable = CtaProveedor End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If '123456789 If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If ImporteMX = ImporteMovimiento IdCtaContable = IdCtaProveedorExtranjera End If End If Next For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If CveMonedaCompra <> 1 Then 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe If IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119 Then ImporteMX = ImporteMovimiento End If IdCtaContable = IdCtaProveedorExtranjera Else IdCtaContable = CtaProveedor End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra = 2 Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If ImporteMX = ImporteMovimiento IdCtaContable = IdCtaProveedorExtranjera End If End If Next ImporteMovimiento = 0 Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal / tipoCambioPago ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If If CveMonedaCompra = 1 Then IdCtaContable = CtaProveedor Else IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If ImporteMX = ImporteMovimiento IdCtaContable = IdCtaProveedorExtranjera End If End If Case 15 'Ret IVA X Acreditar Honorarios/Serv. Prof. If MovimientoPagar.ConceptoRetIVA > 0 Then Dim Funcionalidad As Integer = 0 If MovimientoPagar.ConceptoRetIVA = 1 Then Funcionalidad = 307 ConceptoContable = 15 ElseIf MovimientoPagar.ConceptoRetIVA = 2 Then Funcionalidad = 309 ConceptoContable = 183 ElseIf MovimientoPagar.ConceptoRetIVA = 3 Then Funcionalidad = 311 ConceptoContable = 185 ElseIf MovimientoPagar.ConceptoRetIVA = 4 Then Funcionalidad = 313 ConceptoContable = 248 ElseIf MovimientoPagar.ConceptoRetIVA = 5 Then Funcionalidad = 577 ConceptoContable = 285 End If If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" If UsuarioActual.Empresa.TipoContabilidad = 2 Then If IdCtaContRetIVA > 0 Then IdCtaContable = IdCtaContRetIVA ElseIf UsuarioActual.Empresa.Funcionalidad(307).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(307).ToEntero Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero End If End If End If End If End If Case 22 'Ret IVA Acreditable Honorarios/Serv. Prof. If MovimientoPagar.ConceptoRetIVA > 0 Then Dim Funcionalidad As Integer = 0 If MovimientoPagar.ConceptoRetIVA = 1 Then Funcionalidad = 308 ConceptoContable = 22 ElseIf MovimientoPagar.ConceptoRetIVA = 2 Then Funcionalidad = 310 ConceptoContable = 184 ElseIf MovimientoPagar.ConceptoRetIVA = 3 Then Funcionalidad = 312 ConceptoContable = 186 ElseIf MovimientoPagar.ConceptoRetIVA = 4 Then Funcionalidad = 314 ConceptoContable = 249 ElseIf MovimientoPagar.ConceptoRetIVA = 5 Then Funcionalidad = 578 ConceptoContable = 286 End If If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.RetIVA * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetIVA * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetIVAAcreditable > 0 Then IdCtaContable = IdCtaContRetIVAAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(Funcionalidad).ToEntero Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero End If End If End If End If End If Case 16 'Ret ISR X Acreditar If MovimientoPagar.ConceptoRetISR > 0 Then Dim funcionalidad As Integer = 0 If MovimientoPagar.ConceptoRetISR = 1 Then funcionalidad = 315 ConceptoContable = 16 ElseIf MovimientoPagar.ConceptoRetISR = 2 Then funcionalidad = 317 ConceptoContable = 243 ElseIf MovimientoPagar.ConceptoRetISR = 3 Then funcionalidad = 348 ConceptoContable = 327 End If If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetISR > 0 Then IdCtaContable = IdCtaContRetISR ElseIf UsuarioActual.Empresa.Funcionalidad(funcionalidad).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(funcionalidad).ToEntero Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero End If End If End If End If End If Case 23 'Ret ISR Acreditable If MovimientoPagar.ConceptoRetISR > 0 Then Dim funcionalidad As Integer = 0 If MovimientoPagar.ConceptoRetISR = 1 Then funcionalidad = 316 ConceptoContable = 23 ElseIf MovimientoPagar.ConceptoRetISR = 2 Then funcionalidad = 318 ConceptoContable = 244 ElseIf MovimientoPagar.ConceptoRetISR = 3 Then funcionalidad = 348 ConceptoContable = 328 End If If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.RetISR * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.RetISR * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, tipoCambioPago) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetISRAcreditable > 0 Then IdCtaContable = IdCtaContRetISRAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(funcionalidad).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(funcionalidad).ToEntero Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero End If End If End If End If End If Case 14 'Iva por Acreditar If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 ImporteMX = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then 'ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" End If PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA Dim IdCtaIVAXAcreditar As Integer = 0 Dim IdCtaIVAAcreditable As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero End If IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) If UsuarioActual.Empresa.TipoContabilidad = 2 Then If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero End If End If End If Case 19 'Iva Acreditable If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVADeducible ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 ImporteMX = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago).RoundSQL ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" End If If MovimientoPagar.IVANoDeducible.ToString.ToDecimal > 0 Then If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible ImporteMXNoDeducible = ImporteMovimientoNoDeducible ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimientoNoDeducible = ImporteMovimientoNoDeducible.RoundSQL ImporteMXNoDeducible = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}" Else ImporteMovimientoNoDeducible = 0 ImporteMXNoDeducible = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible * PorcentajePago ImporteMXNoDeducible = ImporteMovimientoNoDeducible ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimientoNoDeducible = ImporteMovimientoNoDeducible.RoundSQL ImporteMXNoDeducible = ImporteMXNoDeducible.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}" End If End If PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA Dim IdCtaIVAXAcreditar As Integer = 0 Dim IdCtaIVAAcreditable As Integer = 0 Dim IdCtaContableNoIVA As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero IdCtaContableNoIVA = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVANoAcreditable").ToString.ToEntero End If IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero End If End If If MovimientoPagar.IVANoDeducible > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, If(ConceptoContable = 30, TxtFolio.Text.Trim, TxtObservaciones.Text), 280, ConceptoMovimiento, Fecha, IdCtaContableNoIVA, -1, CveIE, -1, CveCompra, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMXNoDeducible, TipoCambio:=TimpocambioGeneral, CvePersonal:=CvePersonal, PorcentajeImpuesto:=PorcentajeImpuesto, CveSubProyecto:=CveSubProyecto) Then MsgError = "No se pudo insertar la póliza" Else ImporteMovimiento = 0 ImporteMX = 0 End If End If Case 287 'Iva por Acreditar If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = MovimientoPagar.IVA ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 ImporteMX = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVA * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVA * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" End If PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA Dim IdCtaIVAXAcreditar As Integer = 0 Dim IdCtaIVAAcreditable As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero End If IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero End If End If Case 288 'Iva Acreditable If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IVADeducible ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 ImporteMX = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago).RoundSQL ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IVADeducible * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" End If If MovimientoPagar.IVANoDeducible.ToString.ToDecimal > 0 Then If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva Dim TotalImporte As Decimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then TotalImporte = ImportePagado.ToString.ToDecimal ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal / tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then TotalImporte = Math.Round(ImportePagado.ToString.ToDecimal * tipoCambioPago, 2) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then TotalImporte = ImportePagado.ToString.ToDecimal End If If TotalImporte = CompraSaldo Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible ImporteMXNoDeducible = ImporteMovimientoNoDeducible ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimientoNoDeducible = ImporteMovimientoNoDeducible.RoundSQL ImporteMXNoDeducible = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}" Else ImporteMovimientoNoDeducible = 0 ImporteMXNoDeducible = 0 End If Else If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = MovimientoPagar.IVANoDeducible * PorcentajePago ImporteMXNoDeducible = ImporteMovimientoNoDeducible ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimientoNoDeducible = (MovimientoPagar.IVANoDeducible * PorcentajePago) ImporteMXNoDeducible = ImporteMovimientoNoDeducible * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimientoNoDeducible = ImporteMovimientoNoDeducible.RoundSQL ImporteMXNoDeducible = ImporteMXNoDeducible.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If tipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimientoNoDeducible.FormatoNumero(2)}" End If End If PorcentajeImpuesto = MovimientoPagar.PorcentajeIVA Dim IdCtaIVAXAcreditar As Integer = 0 Dim IdCtaIVAAcreditable As Integer = 0 Dim IdCtaContableNoIVA As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero IdCtaContableNoIVA = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVANoAcreditable").ToString.ToEntero End If IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero End If End If If MovimientoPagar.IVANoDeducible > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, If(ConceptoContable = 30, TxtFolio.Text.Trim, TxtObservaciones.Text), 280, ConceptoMovimiento, Fecha, IdCtaContableNoIVA, -1, CveIE, -1, CveCompra, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMXNoDeducible, TipoCambio:=TimpocambioGeneral, CvePersonal:=CvePersonal, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" End If End If Case 25 'IEPS por Acreditar If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IEPS * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioCompra If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero End If End If Case 26 'IEPS Acreditable If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = MovimientoPagar.IEPS * PorcentajePago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = (MovimientoPagar.IEPS * PorcentajePago) ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero End If End If Case 64 'Ganancia CveSubProyectoInsertar = CveSubProyecto If CveSubProyectoInsertar <= 0 Then MsgError = "No se pudo obtener el sub proyecto o centro de costo" End If If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) TimpocambioGeneral = TCImpuestos Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago < tipoCambioCompra AndAlso CveMonedaCompra = 2 Or (CveMonedaCompra = 2 AndAlso UsuarioActual.CveEmpresa = 119 AndAlso PagoMismoMes = False AndAlso tipoCambioPago < TCUltimaFluctuacion) Then ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) 'Añadimos la diferencia de ganancia en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR ImporteMovimiento -= ((MovimientoPagar.IEPS * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IEPS * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IEPS ImporteMovimiento = Math.Abs(ImporteMovimiento.RoundSQL) ImporteMX = ImporteMovimiento End If Else ImporteMovimiento = 0 End If Case 65 'Perdida CveSubProyectoInsertar = CveSubProyecto If CveSubProyectoInsertar <= 0 Then MsgError = "No se pudo obtener el sub proyecto o centro de costo" End If If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago > tipoCambioCompra AndAlso CveMonedaCompra = 2 Or (CveMonedaCompra = 2 AndAlso UsuarioActual.CveEmpresa = 119 AndAlso PagoMismoMes = False AndAlso tipoCambioPago > TCUltimaFluctuacion) Then ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR ImporteMovimiento -= ((MovimientoPagar.IEPS * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IEPS * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS ImporteMovimiento = Math.Abs(ImporteMovimiento.RoundSQL) ImporteMX = ImporteMovimiento End If Else ImporteMovimiento = 0 End If Case 30 'Bancos If RBLContado.SelectedValue = "1" Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioPago If CveMoneda = 1 Then If DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then Dim ObjCreditos As New ClsBancos ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero, DdlTarjeta.SelectedValue.ToEntero) If ObjCreditos.DtResultados.Rows.Count > 0 AndAlso (ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero > 0 Or ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjetaSIG").ToString.ToEntero > 0) Then IdCtaContable = ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero Else IdCtaContable = CtaProveedor End If ObjCreditos.Dispose() Else IdCtaContable = IdCuentaBancaria End If Else IdCtaContable = IdCuentaBancariaComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 204, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If ImporteMX = ImporteMovimiento IdCtaContable = IdCuentaBancaria End If End If End If Case 92 'Ingresos X Comprobar If RBLContado.SelectedValue = "3" Then For Each rw As GridViewRow In GvIngresos.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL CveIE = rw.DataKey("CveIE").ToString.ToEntero If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, CveCliente:=rw.DataKey("CveProveedor").ToString.ToEntero, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If Next End If ImporteMovimiento = 0 Case 41 'Acreedores If RBLContado.SelectedValue = "5" Then For Each rw As GridViewRow In GvAcreedores.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL CveIE = rw.DataKey("CveIE").ToString.ToEntero ConceptoContable = If(CveMoneda <> 1, 346, 56) IdCtaContable = CtaProveedorAcreedores If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If Next End If ImporteMovimiento = 0 Case 29 'Funcionario y Empleados If RBLContado.SelectedValue = "2" Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL TimpocambioGeneral = tipoCambioPago IdCtaContable = GlobalDTRHPersonal(UsuarioActual.CveEmpresa, CvePersonal:=CvePersonal).FiltroPrimeroValor("IdCtaContPersonal", "").ToEntero Else ImporteMovimiento = 0 End If Case 37 'Deudores If RBLContado.SelectedValue = "4" Then For Each rw As GridViewRow In GvDeudores.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL CveIE = rw.DataKey("CveIE").ToString.ToEntero IdCtaContable = CtaProveedorDeudores If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If Next End If ImporteMovimiento = 0 Case 2 'Pago Cliente If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If rw.DataKey("CveMoneda").ToEntero = 1 Then IdCtaContable = IdCuentaCliente Else ConceptoMovimiento += $" TC:{tipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" IdCtaContable = IdCtaContComplementariaCliente If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then ImporteMX = ImporteMovimiento If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 207, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToString.ToEntero, CveCompra, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, ImporteMX:=(ImporteMovimiento * tipoCambioPago - ImporteMovimiento).RoundSQL, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If IdCtaContable = IdCtaContMonedaExtranjeraCliente End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If Next End If ImporteMovimiento = 0 Case 8 'Ret IVA VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetIVACliente <> 0 Then IdCtaContable = IdCtaContRetIVACliente Else If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero End If End If End If End If If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 9 'Ret ISR VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetISR <> 0 Then IdCtaContable = IdCtaContRetISR Else If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero End If End If End If End If If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 13 'IVA VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL PorcentajeImpuesto = rw.DataKey("PorcentajeIVA").ToDecimal Dim IdCtaIVAXTrasladar As Integer = 0 Dim IdCtaIVATrasladado As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero End If IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar) If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 61 'Iva Trasladado VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL PorcentajeImpuesto = rw.DataKey("PorcentajeIVA").ToDecimal Dim IdCtaIVAXTrasladar As Integer = 0 Dim IdCtaIVATrasladado As Integer = 0 If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero End If IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado) If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, rw.DataKey("TipoCambio").ToString.ToDecimal), PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 38 'IEPS por trasladar VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * rw.DataKey("TipoCambio").ToString.ToDecimal End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 39 'IEPS Trasladado VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("IEPS").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 62 'Ret IVA Trasladado VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetIVA").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetIVA <> 0 Then IdCtaContable = IdCtaContRetIVA Else If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero End If End If End If End If If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case 63 'Ret ISR Trasladado VENTA If RBLContado.SelectedValue = "6" Then For Each rw As GridViewRow In GvVentas.Rows If rw.FCCheckBox("Chk").Checked Then Dim PorcentajePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / rw.DataKey("Total").ToString.ToDecimal If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.DataKey("RetISR").ToString.ToDecimal * PorcentajePagoVenta ImporteMX = ImporteMovimiento * tipoCambioPago End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL If UsuarioActual.Empresa.TipoContabilidad = 2 Then 'Conta ContPAQ If IdCtaContRetISR <> 0 Then IdCtaContable = IdCtaContRetISR Else If ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacion").ToString.ToEntero End If End If End If End If If ImporteMovimiento > 0 Then If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, CveCompra:=CveCompra, CveVenta:=rw.DataKey("CveVenta").ToString.ToEntero, CveCliente:=rw.DataKey("CveCliente").ToString.ToEntero, CvePersonal:=CvePersonal, ImporteMX:=ImporteMX, TipoCambio:=rw.DataKey("TipoCambio").ToString.ToDecimal) Then MsgError = "No se pudo insertar la póliza" End If End If End If Next ImporteMovimiento = 0 End If Case Else ImporteMovimiento = 0 End Select If ImporteMovimiento <> 0 AndAlso MsgError = "" Then 'Conta ContPAQ If IdCtaContable = 0 Then CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) idCuentaContabilizacion = 0 End If ''Conta SIG 'If CveCuenta = 0 Then ' CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) ' CveCuentaContabilizacion = 0 'End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, If(ConceptoContable = 30, TxtFolio.Text.Trim, TxtObservaciones.Text), ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, CveSubProyecto:=CveSubProyectoInsertar, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=TimpocambioGeneral, CvePersonal:=CvePersonal, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" End If End If Next If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then If ObjMov.ValorPolizaDescuadre > 0 Then MsgError = ObjMov.MensajePolizaDescuadre GuardaLogAD($"Bancos/PopIECompras | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") End If End If 'Conta ContPAQ If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If idCuentaContabilizacion > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IdPoliza = ObjMov.ContaIdPoliza Else Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico") End If Else Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas)) End If End If End If End If End If End If Else MsgError = "No se pudo insertar la póliza" End If Else MsgError = "No se insertó el encabezado" End If If MsgError = "" Then ObjIE.Commit() Dim StrMsg As New StringBuilder StrMsg.Append("El Documento se guardó correctamente.
") If TipoTransaccion = "Egs" AndAlso CveIE > 0 Then GeneraChequePDF(CveIE, UsuarioActual.Empresa) If IdPoliza > 0 Then StrMsg.AppendFormat("
Ver Póliza", IdPoliza) End If If RBLContado.SelectedValue.ToEntero = 6 And ChkEmitirComplementoPago.Checked Then GeneraTimbre(CvePrePoliza) Else Alert(StrMsg.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();") EnviarCorreoNotificacion(CveIE, NotificarA, "", UsuarioActual, False) Else ObjIE.RollBack() Alert(MsgError, TipoMensaje.MsgError) End If ObjIE.Dispose() ObjMov.Dispose() End Sub #End Region #Region "ENVIAR CORREO NOTIFICACION DE PAGO" Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean) Try Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) 'Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) Hilo.Start() If MostarAlert Then Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) End If Catch ex As Exception If MostarAlert Then Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) End If End Try End Sub Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) Try Dim ObjBancos As New ClsBancos() If ObjBancos.NotificacionPago(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) Then Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) Else Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) End If ObjBancos.Dispose() Catch ex As Exception GuardaLog("Error al enviar notificación de pago PopIECompras --> " & ex.StackTrace.ToString) End Try End Sub #End Region #Region "COMPLEMENTO DE PAGO" Private Sub GeneraTimbre(CvePrePoliza As Integer) Dim Str As New StringBuilder Dim Banco As New ClsBancos Banco.IniciaTransacSQL() If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then If Banco.Mensaje = "" Then Banco.Commit() PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False) Str.AppendFormat("Folio: {0}  ", Banco.ComplementoSerieFolio) Str.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) Str.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) 'Str.AppendFormat("{1}   {2}
", CveIE, SerieFolio, NombreProveedor) MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo) End If Else Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", SerieFolio, Banco.Mensaje) Banco.RollBack() End If Banco.Dispose() Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();") End Sub Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True) If Not DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(9, 17) Then Try Dim Msg As String = "" If NombreArchivo <> "-1" Then ' Dim ObjMail As New ClsSisMail() Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo) Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo) Dim Cuerpo As String = "Se hace entrega del comprobante de pago" Dim Asunto As String = "Entrega de comprobante de pago" If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then If ConAlerta Then RegistraScript("$('#ModalDivMail').modal('hide');") Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) End If Else Msg = "No se pudo enviar el correo electrónico." End If Else Msg = "No se pudo adjuntar el correo electrónico." End If End If If ConAlerta AndAlso Msg <> "" Then Alert(Msg, TipoMensaje.MsgError) End If Catch ex As Exception OnError("Ocurrió error al mandar MAIL", ex) End Try End If End Sub #End Region Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) Dim Dep As New ClsGenerales If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then If Dep.DtResultados.Rows.Count > 0 Then If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then TrReferenciaCIE.Visible = True TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString TxtConceptoCIE.Text = Dep.DtResultados.Rows(0)("ConceptoCIE").ToString OriReferenciaCIE = Dep.DtResultados.Rows(0)("Referencia").ToString OriConceptoCIE = Dep.DtResultados.Rows(0)("ConceptoCIE").ToString Else TrReferenciaCIE.Visible = False End If If Boolean.Parse(Dep.DtResultados.Rows(0)("EstatusPagoElectronicoGrupos").ToString) = True AndAlso Dep.DtResultados.Rows(0)("CveSATBanco").ToString.ToEntero <= 0 Then Alert("Es necesario establecer el banco de la cuenta deposito", TipoMensaje.MsgAdvertencia) BtnGuardar.Enabled = False Else BtnGuardar.Enabled = True End If Else TrReferenciaCIE.Visible = False End If Else TrReferenciaCIE.Visible = False End If Dep.Dispose() UpCuentaDeposito.Update() UpGuardar.Update() End Sub Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init RVTxtFechaDocumento.MaximumValue = DateTime.Now.ToShortDateString Calendario.EndDate = DateTime.Now End Sub Protected Sub CVTxtImporte_ServerValidate(source As Object, args As ServerValidateEventArgs) Dim Saldo As Decimal = LtlSaldo.Text.Replace("USD", "").Replace("MXN", "").Replace(",", "").ToDecimal Dim ImportePagado As Decimal = TxtImporte.Text.ToDecimal If ChkPagarPesos.Checked Then Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal Dim PagoEnDollares As Decimal = (ImportePagado / TC).RoundSQL() If PagoEnDollares <= Saldo Then args.IsValid = True Else args.IsValid = False End If Else If ImportePagado <= Saldo Then args.IsValid = True Else args.IsValid = False End If End If End Sub End Class