Option Explicit On Option Strict On Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Bancos_ProveedoresAbonar Inherits ClsPaginas #Region "Propiedades" 'Configuración 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 Property FechaI As String Get Return ViewState("FechaI").ToString End Get Set(value As String) ViewState("FechaI") = value End Set End Property Private Property FechaF As String Get Return ViewState("FechaF").ToString End Get Set(value As String) ViewState("FechaF") = value End Set End Property Private Property CveUsuarioProgramo As Integer Get Return ViewState("CveUsuarioProgramo").ToString.ToEntero End Get Set(value As Integer) ViewState("CveUsuarioProgramo") = value End Set End Property Private Property TipoPago As Integer Get Return ViewState("TipoPago").ToString.ToEntero End Get Set(value As Integer) ViewState("TipoPago") = value End Set End Property Private Property CveUsuarioRegistro As Integer Get Return ViewState("CveUsuarioRegistro").ToString.ToEntero End Get Set(value As Integer) ViewState("CveUsuarioRegistro") = value End Set End Property Private Property CveUsuarioResponsable As Integer Get Return ViewState("CveUsuarioResponsable").ToString.ToEntero End Get Set(value As Integer) ViewState("CveUsuarioResponsable") = value End Set End Property Private Property CveClasificacionProveedor As Integer Get Return ViewState("CveClasificacionProveedor").ToString.ToEntero End Get Set(value As Integer) ViewState("CveClasificacionProveedor") = value End Set End Property Private Property CveAplicaNC As Integer Get Return ViewState("CveAplicaNC").ToString.ToEntero End Get Set(value As Integer) ViewState("CveAplicaNC") = value End Set End Property Private Property CveMoneda As Integer Get Return If(IsNothing(ViewState("CveMoneda")), -1, ViewState("CveMoneda").ToString.ToEntero) End Get Set(value As Integer) ViewState("CveMoneda") = value End Set End Property Private Property CveMonedaFiltro As Integer Get Return ViewState("CveMonedaFiltro").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMonedaFiltro") = value End Set End Property Private Property CveEstatus As Integer Get Return ViewState("CveEstatus").ToString.ToEntero End Get Set(value As Integer) ViewState("CveEstatus") = value End Set End Property Private Property Serie As String Get Return ViewState("Serie").ToString End Get Set(value As String) ViewState("Serie") = value End Set End Property Private ReadOnly Property CtaProveedor As Integer Get Return ViewState("CtaProveedor").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 CveCuentaProveedor As Integer Get Return ViewState("CveCuentaProveedor").ToString.ToEntero End Get End Property Private ReadOnly Property CveCuentaProveedorExtranjera As Integer Get Return ViewState("CveCuentaProveedorExtranjera").ToString.ToEntero End Get End Property Private Property IdCuenta As Integer Get Return ViewState("IdCuenta").ToString.ToEntero End Get Set(value As Integer) ViewState("IdCuenta") = value End Set End Property Private Property CveCuentaB As Integer Get Return ViewState("CveCuentaB").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCuentaB") = value End Set End Property Private Property CveProveedorSucursal As Integer Get Return ViewState("CveProveedorSucursal").ToString.ToEntero End Get Set(value As Integer) ViewState("CveProveedorSucursal") = 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 Property CveCuentaBancariaComplementaria As Integer Get Return ViewState("CveCuentaBancariaComplementaria").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCuentaBancariaComplementaria") = value End Set End Property Private Property PermiteModificarImporte As Boolean Get Return CType(ViewState("PermiteModificarImporte").ToString, Boolean) End Get Set(value As Boolean) ViewState("PermiteModificarImporte") = 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 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 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 ReadOnly Property CveCuentaMonedaExtranjera As Integer Get Return ViewState("CveCuentaMonedaExtranjera").ToString.ToEntero End Get End Property Private ReadOnly Property CveCuentaComplementaria As Integer Get Return ViewState("CveCuentaComplementaria").ToString.ToEntero End Get End Property Private ReadOnly Property CveCuentaRetIVA As Integer Get Return ViewState("CveCuentaRetIVA").ToString.ToEntero End Get End Property Private ReadOnly Property CveCuentaRetISR As Integer Get Return ViewState("CveCuentaRetISR").ToString.ToEntero End Get 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 ComprobanteIE As String Get Return ViewState("ComprobanteIE").ToString End Get Set(value As String) ViewState("ComprobanteIE") = value End Set End Property Private Property CodigoProgramacion As String Get Return ViewState("CodigoProgramacion").ToString End Get Set(value As String) ViewState("CodigoProgramacion") = value End Set End Property Private Property DtDatos As DataTable Get Return DirectCast(ViewState("DtDatos"), DataTable) End Get Set(value As DataTable) ViewState("DtDatos") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then If Not UsuarioActual.Empresa.UsaAC Then EmpresaPrueba = True ViewState("IdCtaContMonedaExtranjera") = 0 ViewState("IdCtaContComplementaria") = 0 ViewState("IdCtaContRetIVA") = 0 ViewState("IdCtaContRetISR") = 0 ViewState("CveCuentaMonedaExtranjera") = 0 ViewState("CveCuentaComplementaria") = 0 ViewState("CveCuentaRetIVA") = 0 ViewState("CveCuentaRetISR") = 0 End If IdCuenta = 0 CveCuentaB = 0 PermiteModificarImporte = True TxtFechaIncobrable.Text = Now.ToShortDateString If Request("CveProveedor") IsNot Nothing AndAlso Request("CveProveedor").ToString.ToEntero > 0 Then CveProveedor = IfNull(Request("CveProveedor"), "-1").ToString.ToEntero FechaI = IfNull(Request("FechaI"), "-1").ToString FechaF = IfNull(Request("FechaF"), "-1").ToString CveUsuarioProgramo = IfNull(Request("CveUsuarioProgramo"), "-1").ToString.ToEntero TipoPago = IfNull(Request("TipoPago"), "-1").ToString.ToEntero CveUsuarioRegistro = IfNull(Request("CveUsuarioRegistro"), "-1").ToString.ToEntero CveUsuarioResponsable = IfNull(Request("CveUsuarioResponsable"), "-1").ToString.ToEntero CveClasificacionProveedor = IfNull(Request("CveClasificacion"), "-1").ToString.ToEntero CveMoneda = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero CveMonedaFiltro = IfNull(Request("CveMoneda"), "-1").ToString.ToEntero CveEstatus = IfNull(Request("CveEstatus"), "-1").ToString.ToEntero Serie = IfNull(Request("Serie"), "").ToString CveAplicaNC = IfNull(Request("CveAplicaNC"), "-1").ToString.ToEntero CveProveedorSucursal = IfNull(Request("CveProveedorSucursal"), "-1").ToString.ToEntero CodigoProgramacion = IfNull(Request("CodigoProgramacion"), "-1").ToString TxtOtrosImportes.Attributes.Add("onKeyUp", String.Format("FnSuma(this,{0},{1});", "TxtTotal", 0)) 'proceso para que solo pague lo que este programada If UsuarioActual.TienePermisoProceso(98) Then PermiteModificarImporte = False End If Calendario.StartDate = Now.AddMonths(-2) 'proceso que restringue solo el pago de apartir del dia de hoy y como limite fin de mes If UsuarioActual.TienePermisoProceso(105) Then Calendario.StartDate = Now Calendario.EndDate = Now.LastDayOfMonth MEVCalendario.MinimumValue = Now.ToShortDateString MEVCalendario.MaximumValue = Now.LastDayOfMonth.ToShortDateString MEVCalendario.Enabled = True End If CargaProveedor(Request("CveProveedor").ToString.ToEntero) End If ' If UsuarioActual.Empresa.Funcionalidad(142) = "1" Then trNotificar.Visible = True UpDatos.Visible = True 'End If If UsuarioActual.Empresa.UsaAC Then PnlAC.Visible = True ' Dim AC As New ClsAC ' If AC.GetPresupuestoEgresos(-1, True, usuarioactual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then ' 'DdlProgramaOperativo.DataSource = AC.DtResultados ' 'DdlProgramaOperativo.DataBind() ' GvAC.DataSource = AC.DtResultados ' GvAC.DataBind() ' End If ' AC.Dispose() End If 'BANDERA DE SURTIDO If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Or UsuarioActual.Empresa.Funcionalidad(134).ToEntero > 0 Then GvCxP.Columns(3).Visible = True End If If CveMoneda > 0 Then LbTipoMoneda.Text = String.Format("Pago en {0}", GlobalDTMonedas.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda)).Rows(0)("Moneda")) End If If CveMoneda = 2 Then ChkPagarPesos.Visible = True TxtTC.Text = GlobalTipoCambio(Now).FormatoNumero(4) TxtTCDolaresDolares.Text = GlobalTipoCambio(Now).FormatoNumero(4) DivDolaresDolares.Visible = True TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") Else ChkPagarDolares.Visible = True TxtTCDolares.Text = GlobalTipoCambio(Now).FormatoNumero(4) End If RegistraScript($"TipoCambioActual = {GlobalTipoCambio(Now).FormatoNumero(4)}") UpDatos.Update() If UsuarioActual.TienePermisoProceso(215) Or UsuarioActual.TienePermisoProceso(204) Then HlSaldarCuentasSinPagar.Visible = True End If If UsuarioActual.CveEmpresa = 119 And CveUsuarioProgramo <> -1 Then LnkPDFSolicitud.Visible = True LnkExcelSolicitud.Visible = True End If End If End Sub Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) CambiaTipoMoneda() End Sub Private Sub CambiaTipoMoneda() If DivTC.Visible Then TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) RegistraScript("CambiaPesosDolares();") End If If DivTCDolares.Visible Then TxtTCDolares.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) RegistraScript("CambiaDolaresPesos();") End If If DivDolaresDolares.Visible Then TxtTCDolaresDolares.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) End If UpDatos.Update() End Sub #Region " CARGA DATOS " Private Sub CargaDatos(Optional tCveMoneda As Integer = -1) 'pCveProveedor As Integer, tCveMoneda As Integer, FechaVencimientoInicio As String, FechaVencimientoFin As String, CveUsuarioRegistro As Integer, CveUsuarioPrograma As Integer, Serie As String) If tCveMoneda = -1 Then tCveMoneda = CveMoneda Dim Mov As New ClsMovimientos TxtObservaciones.Text = "" TxtImporte.Text = "" TxtTotal.Text = "" 'If Mov.GetCxPProveedor(pCveProveedor, Serie, tCveMoneda, FechaVencimientoInicio:=FechaVencimientoInicio, FechaVencimientoFin:=FechaVencimientoFin, CveUsuarioRegistro:=CveUsuarioRegistro, CveUsuarioProgramo:=CveUsuarioPrograma) Then If Mov.GetCxPProveedor(CveProveedor, FechaI, FechaF, CveUsuarioProgramo, CveUsuarioRegistro, CveUsuarioResponsable, CveClasificacionProveedor, tCveMoneda, CveEstatus, CveProveedorSucursal, CveAplicaNC, "-1", "-1", CodigoProgramacion) Then DtDatos = Mov.DtResultados.FiltraParametros("Saldo > 0", "Fecha,SerieFolio") GvCxP.DataSource = DtDatos DtDatos.Columns.Add("Movimiento") If DtDatos.Rows.Count > 0 Then DVBusqueda.Visible = True DtDatos.Rows(0)("Movimiento") = "FACTURA DE ACREEDOR" End If End If Mov.Dispose() GvCxP.DataBind() UPCompras.Update() UpBusqueda.Update() End Sub Private Sub CargaProveedor(tCveProveedor As Integer) Dim ObjProveedor As New ClsCompProveedores() If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, tCveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then If ObjProveedor.DtResultados.Rows.Count > 0 Then 'Campos para Modificación 'GeneralesLblEncabezado CargaTipoTransaccion() CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) TxtFechaDocumento.Text = Now.ToShortDateString TxtPagueseA.Enabled = False HplProveedor.Text = ObjProveedor.RazonSocial HplProveedor.NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", tCveProveedor) TxtPagueseA.Text = ObjProveedor.RazonSocial TxtImporte.Attributes.Add("disabled", "disabled") If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False TxtNotificarA.Text = $"{ObjProveedor.NotificarA.Trim}" If ObjProveedor.CorreoCobranza.Trim <> "" Then TxtNotificarA.Text = $"{TxtNotificarA.Text};{ObjProveedor.CorreoCobranza.Trim}" ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA ViewState("IdCtaContRetIVAAcreditable") = ObjProveedor.IdCtaContRetIVAAcreditable ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR ViewState("IdCtaContRetISRAcreditable") = ObjProveedor.IdCtaContRetISRAcreditable ViewState("CveCuentaRetIVA") = ObjProveedor.CveCuentaRetIVA ViewState("CveCuentaRetISR") = ObjProveedor.CveCuentaRetISR 'Sección de pago a proveedor LtlNombreProveedor.Text = ObjProveedor.RazonSocial LtlRFCProveedor.Text = ObjProveedor.RFC ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores ViewState("IdCtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera ViewState("IdCtaContComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria ViewState("CveCuentaProveedor") = ObjProveedor.CveCuentaProveedores ViewState("CveCuentaProveedorExtranjera") = ObjProveedor.CveCuentaProveedoresExtranjera ViewState("CveCuentaComplementaria") = ObjProveedor.CveCuentaProveedoresComplementaria If Serie <> "" AndAlso Serie <> "-1" Then Dim dr As DataRow = GlobalDTProveedorSucursales(CveProveedor, UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Serie = '{0}'", Serie)) If dr IsNot Nothing Then TxtObservaciones.Text = String.Format("Suc. {0}", dr("ProveedorSucursal")) HdnObs.Value = TxtObservaciones.Text End If End If CargaDatos() '(tCveProveedor, CveMoneda, FechaI, FechaF, CveUsuarioRegistro, CveUsuarioProgramo, Serie) CargaCuentasDepositos() 'CUANDO VIENE PROGRAMADO LLENA EL TEXTO OBSERVACIONES If CveUsuarioProgramo <> -1 Then RegistraScript("SumaValores();") Else Alert("El Proveedor Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) End If End If ObjProveedor.Dispose() End Sub #End Region #Region " GV CXP " Protected Sub GvCxP_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxP.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"))) If e.Row.RowIndex = 0 Then e.Row.FCHyperLink("HplF").Text = (CType(GvCxP.DataSource, DataTable).Rows.Count - 1).ToString e.Row.BackColor = Drawing.Color.LightGray End If If e.Row.DBCampo("CveCompra") = "" Then e.Row.FCTextBox("TxtAbonar").Visible = False e.Row.FCCheckBox("Chk").Visible = False e.Row.FCTextBox("TxtComision").Visible = False Else e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}',1);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo")) e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,'{2}',2);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo")) 'e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}');", e.Row.FCCheckBox("Chk").ClientID, If(UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0, e.Row.DBCampo("ImporteAlmacen"), e.Row.DBCampo("Saldo")), If(UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0, "El importe no debe exceder el importe de entrada a almacen", "El Importe no debe de exceder el saldo"))) 'e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,'{2}');", e.Row.FCCheckBox("Chk").ClientID, If(UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0, e.Row.DBCampo("ImporteAlmacen"), e.Row.DBCampo("Saldo")), If(UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0, "El importe no debe exceder el importe de entrada a almacen", "El Importe no debe de exceder el saldo"))) End If If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" If e.Row.DBCampo("Folio") = "N/D" Then e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("Folio") End If If e.Row.DBCampo("CveCompra").ToEntero > 0 Then Dim FiltroInv As String = "" If UsuarioActual.Empresa.Funcionalidad(134).ToEntero > 0 Then Dim PorcentajeSaldo = e.Row.DBCampo("ImporteAlmacenPorcentaje").ToString.ToDouble + e.Row.DBCampo("ImporteServiciosPorcentaje").ToString.ToDouble + e.Row.DBCampo("ImporteDevolucionPorcentaje").ToString.ToDouble Dim SaldoInv = (e.Row.DBCampo("Saldo").ToString.ToDouble * (PorcentajeSaldo / 100)) If UsuarioActual.Empresa.Funcionalidad(134) = "1" Then 'cuando es proporcional FiltroInv = $"FnCambia({e.Row.FCCheckBox("Chk").ClientID},this,{SaldoInv},1,'{"El importe no debe exceder lo recibido en almacén"}',1);" ElseIf UsuarioActual.Empresa.Funcionalidad(134) = "2" Then FiltroInv = "" 'queno considera lo proporcional End If End If e.Row.FCLiteral("LtlAux").Text = String.Format("Ir", e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveCompra")) e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}',1);{3}", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo", FiltroInv)) If Not PermiteModificarImporte Then e.Row.FCTextBox("TxtAbonar").Enabled = False If e.Row.DBCampo("CveCompraNC").ToEntero > 0 Then e.Row.FCHyperLink("HplNC").Visible = True e.Row.FCHyperLink("HplNC").ImageUrl = "/Imagenes/flag_green.png" e.Row.FCHyperLink("HplNC").ToolTip = "Notas de Crédito Aplicadas" End If If e.Row.DBCampo("ImporteProgramo").ToDouble > 0 Then e.Row.FCCheckBox("chk").Checked = True e.Row.FCTextBox("TxtAbonar").Text = e.Row.DBCampo("ImporteProgramo").ToDouble.FormatoNumero() ' N O T A: si el importe programado es mayor al Saldo de la factura, se pone el saldo If e.Row.DBCampo("ImporteProgramo").ToDouble > e.Row.DBCampo("Saldo").ToDouble Then e.Row.FCTextBox("TxtAbonar").ToolTip = "El importe programado es mayor al saldo. El Importe visible es el saldo " 'e.Row.FCTextBox("TxtAbonar").BackColor = Drawing.Color.OrangeRed e.Row.FCTextBox("TxtAbonar").CssClass = "bg-yellow-gold" e.Row.FCTextBox("TxtAbonar").Text = e.Row.DBCampo("Saldo").FormatoNumero() 'se va acumulando el importe de cada renglon para sacar el pago del IE TxtImporte.Text = (TxtImporte.Text.ToDouble + e.Row.DBCampo("Saldo").ToDouble).FormatoNumero() Else 'se va acumulando el importe de cada renglon para sacar el pago del IE TxtImporte.Text = (TxtImporte.Text.ToDouble + e.Row.DBCampo("ImporteProgramo").ToDouble).FormatoNumero() End If End If If UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 Or UsuarioActual.Empresa.Funcionalidad(134).ToEntero > 0 Then Dim Str As New StringBuilder Str.AppendFormat("Importe Almacen: ${0} ({1}%)
", e.Row.DBCampo("ImporteAlmacen").FormatoNumero, e.Row.DBCampo("ImporteAlmacenPorcentaje")) If e.Row.DBCampo("ImporteServicios").ToDouble > 0 Then Str.AppendFormat("Importe Servicios: ${0} ({1}%)
", e.Row.DBCampo("ImporteServicios").FormatoNumero, e.Row.DBCampo("ImporteServiciosPorcentaje")) If e.Row.DBCampo("ImporteDevolucion").ToDouble > 0 Then Str.AppendFormat("Importe Devuelto: ${0} ({1}%)
", e.Row.DBCampo("ImporteDevolucion").FormatoNumero, e.Row.DBCampo("ImporteDevolucionPorcentaje")) Str.AppendFormat(" Importes SIN IVA") e.Row.FCLabel("LbEstatusInv").Attributes.Add("title", Str.ToString) Select Case e.Row.DBCampo("EstatusInventario").ToEntero Case 1 e.Row.FCLabel("LbEstatusInv").Text = "" e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Red If UsuarioActual.Empresa.Funcionalidad(134).ToEntero.Contiene(1, 2) Then ' si se recibió mercancía se paga lo proporcional If UsuarioActual.CveEmpresa = 72 Then If e.Row.DBCampo("Fecha").ToDate > "12/02/2017".ToDate Then e.Row.FCCheckBox("Chk").Enabled = False e.Row.FCTextBox("TxtAbonar").Enabled = False End If Else e.Row.FCCheckBox("Chk").Enabled = False e.Row.FCTextBox("TxtAbonar").Enabled = False End If End If Case 2 e.Row.FCLabel("LbEstatusInv").Text = "" e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.DarkOrange 'condición que bloquea que se pueda pagar sin aun es parcial la recepción, If UsuarioActual.Empresa.Funcionalidad(134).ToEntero = 2 Then e.Row.FCCheckBox("Chk").Enabled = False e.Row.FCTextBox("TxtAbonar").Enabled = False ' si tiene un porcentaje mayor ingresado, que este halla sido por OC, debe de permitirlo If e.Row.DBCampo("ImporteAlmacenPorcentaje").ToDecimal >= 99.0 Then 'si ya se recibió el 100% e.Row.FCCheckBox("Chk").Enabled = True e.Row.FCTextBox("TxtAbonar").Enabled = True End If End If Case 3 e.Row.FCLabel("LbEstatusInv").Text = "" e.Row.FCLabel("LbEstatusInv").ForeColor = Drawing.Color.Green Case Else End Select 'si está bloqueada y es refacturación, debe de permitirlo, sin importar lo que se halla ingresado If e.Row.DBCampo("CveCompraRefacturacion").ToEntero > 0 AndAlso Not e.Row.FCCheckBox("Chk").Enabled Then e.Row.FCCheckBox("Chk").Enabled = True e.Row.FCTextBox("TxtAbonar").Enabled = True End If End If End If If UsuarioActual.Empresa.Funcionalidad(306) = "1" And e.Row.DBCampo("AplicaNotaCredito").ToString = "True" Then e.Row.FCCheckBox("Chk").Enabled = False End If End If End Sub #End Region #Region " GUARDAR " Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click If DdlTipoTransaccion.SelectedValue.ToEntero < 0 Then Alert("Seleccione un tipo de transacción", TipoMensaje.MsgAdvertencia) Exit Sub End If If DdlCuenta.SelectedValue.ToEntero < 0 Then Alert("Seleccione una cuenta bancaria", TipoMensaje.MsgAdvertencia) Exit Sub End If If CveMoneda <= 0 Then Alert("Seleccione la Moneda del pago", TipoMensaje.MsgAdvertencia) 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() 'proceso que restringue solo el pago de apartir del dia de hoy y como limite fin de mes If UsuarioActual.TienePermisoProceso(105) AndAlso (TxtFechaDocumento.Text.ToDate < Now.Date Or TxtFechaDocumento.Text.ToDate > Now.LastDayOfMonth) Then Alert("Fecha No permitida", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim ImporteSeleccionado As Decimal = 0 If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then Dim Validada As Boolean = False Dim MsgValidadas As New StringBuilder Dim Valida As New ClsValidaCFDi() 'veririco ante el SAT las compras que voy a pagar For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal If gvr.DataKey("UUID") <> "" Then '529 Valida.Verificar(gvr.DataKey("UUID"), gvr.DataKey("RFC"), UsuarioActual.Empresa.RFC, gvr.DataKey("Original").ToDecimal) If UsuarioActual.CveEmpresa < 2 Then Valida.EsValida = 1 End If If Valida.EsValida <> 1 Then Validada = False If Valida.EsValida = 2 Then 'Cancelada 'estatus inventario, no surtida If gvr.DataKey("EstatusInventario") = "1" Then Dim HuboError As Boolean = False Dim ObjCompra As New ClsCompras Dim ObjEventos As New ClsOIEventos(ObjCompra.IniciaTransacSQL()) If ObjCompra.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then If ObjCompra.CancelarCompra(gvr.DataKey("CveCompra").ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1}
", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion")) If Not ObjEventos.AddEventoBitacora("La compra se ha detectado como cancelada ante el SAT", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompra:=gvr.DataKey("CveCompra").ToEntero) Then HuboError = True End If Else HuboError = True End If Else HuboError = True End If If Not HuboError Then ObjCompra.Commit() Else ObjCompra.RollBack() ObjCompra.Dispose() Else MsgValidadas.AppendFormat("Factura Cancelada: {0} - {1} con movimientos de almacen, relacione su factura nueva para descontar saldo
", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion")) End If Else MsgValidadas.AppendFormat("Factura No se pudo Validar: {0} - {1}
", gvr.DataKey("SerieFolio"), gvr.DataKey("Descripcion")) End If End If End If End If Next Valida.Dispose() 'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui If MsgValidadas.Length > 0 Then Alert(String.Format("
Las Facturas presentan la siguiente situación ante el SAT.
{0}", MsgValidadas.ToString), TipoMensaje.MsgAdvertencia) Exit Sub End If Else For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then ImporteSeleccionado += gvr.FCTextBox("TxtAbonar").Text.ToDecimal End If Next End If If ImporteSeleccionado <= 0 Then Alert("Seleccione facturas", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim ObjIE As New ClsBancos() Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL) Dim ObjConta As ClsContPAQi = Nothing If UsuarioActual.Empresa.UsaContabilidad Then ObjConta = New ClsContPAQi(UsuarioActual.Empresa) ObjConta.IniciaTransacSQL() End If Dim MsgError As String = "" Dim IDPoliza As Integer = 0 Dim FolioPoliza As Integer = 0 Dim CveCuentaDeposito As Integer = 0 Dim CveConceptoCompra As Integer = 6 Dim CvePrePoliza As Integer = 0 If DdlCuentaDeposito.Items.Count > 0 Then CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero End If 'Saca moneda en que se va a pagar segun metodo de pago If DdlCuenta.SelectedValue.ToEntero > 0 Then CveMoneda = GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero End If If TxtImporte.Text.ToDouble > 0 Then If TxtFolio.Text.Trim <> "" Then Dim Fecha As Date = TxtFechaDocumento.Text.ToDate Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos Dim filemove As String = "" Dim Comprobante As String = "" ComprobanteIE = "" For Each fileItem As Archivo In filesgral Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") filemove = fileItem.filename Next Dim ConceptoPoliza As String = String.Format("{0} {1}", HplProveedor.Text, TxtObservaciones.Text) Dim FolioFijo As Integer = 0 Dim TipoCambio As Decimal = 0 'cheque If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa.Contiene(13, 83) Then FolioFijo = TxtFolio.Text.ToEntero CvePrePoliza = ObjMov.AddPrePolizas("Bancos/ProveedoresAbonar", 2, ImporteSeleccionado, ImporteSeleccionado, GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, Nothing, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)) If CveMoneda = 2 Then If TxtTCDolares.Visible Then TipoCambio = TxtTCDolares.Text.ToDecimal Else TipoCambio = TxtTCDolaresDolares.Text.ToDecimal End If Else If TxtTC.Visible Then TipoCambio = TxtTC.Text.ToDecimal End If End If Dim CveIE As Integer = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, TxtImporte.Text.ToDecimal, GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TipoCambio, TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1)) If CveIE > 0 Then ComprobanteIE = $"{CveIE}.{Comprobante}" 'guardo el archivo If filemove <> "" Then filemove.FilesMove(CveIE.ToString, String.Format("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta)) End If Anexo.Text = "" 'inserto los movimientos de la conta para abonar al saldo If CvePrePoliza > 0 Then If EmpresaPrueba Then Dim PorcentajePago As Decimal = 100 Dim CvePlantillaPoliza As Integer = 2 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 ConceptoContable As Integer Dim TipoMovimiento As Boolean Dim ImporteMovimiento As Decimal Dim importeMX As Decimal Dim FechaMovimiento As Date = TxtFechaDocumento.Text.ToDate Dim IdCtaContable As Integer = 0 Dim CveCuenta As Integer = 0 Dim ConceptoMovimiento As String Dim Referencia As String Dim tipoCambioCompra As Decimal Dim TipoCambioPago As Decimal = 0 Dim TipoCambioGeneral As Decimal = 0 Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) 'inserto las compras que voy a pagar For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then 'Tipos de cambio If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos TipoCambioPago = 1 tipoCambioCompra = 1 PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos TipoCambioPago = TxtTC.Text.ToDecimal tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal PorcentajePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal).RoundSQL ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES 'TipoCambioPago = 'GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES TipoCambioPago = TxtTCDolares.Text.ToDecimal tipoCambioCompra = 1 PorcentajePago = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal End If If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then For Each Row As DataRow In ObjMov.DtResultados.Rows ConceptoContable = Row("CveConcepto").ToString.ToEntero TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) ImporteMovimiento = 0 IdCtaContable = 0 CveCuenta = 0 ConceptoMovimiento = $"{HplProveedor.Text} F:{gvr.DataKey("SerieFolio")}" Referencia = gvr.DataKey("SerieFolio").ToString Dim PorcentajeImpuesto As Decimal = 0 Select Case ConceptoContable Case 17 'Pago Proveedores If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = tipoCambioCompra ConceptoMovimiento = $"{HplProveedor.Text} F:{gvr.DataKey("SerieFolio")}" 'cuando son dolares, y tienen complementaria, se hace el registro If gvr.DataKey("CveMoneda").ToEntero = 1 Then IdCtaContable = CtaProveedor CveCuenta = CveCuentaProveedor Else ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" IdCtaContable = IdCtaContComplementaria CveCuenta = CveCuentaProveedorExtranjera If ImporteMovimiento <> 0 AndAlso (UsuarioActual.CveEmpresa = 119 Or IdCtaContable > 0) Then 'Cuando tiene complementaria lo dividimos en dos importeMX = ImporteMovimiento If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0.00D, Referencia, 206, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuentaComplementaria) Then MsgError = "No se pudo insertar la póliza" End If End If IdCtaContable = IdCtaProveedorExtranjera CveCuenta = CveCuentaProveedorExtranjera End If Case 15 'Ret IVA X Acreditar Honorarios/Serv. Prof. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 1 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ 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 'Conta SIG If CveCuentaRetIVA <> 0 Then CveCuenta = CveCuentaRetIVA Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero End If End If End If End If Case 22 'Ret IVA Acreditable Honorarios/Serv. Prof. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 1 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVAAcreditable > 0 Then IdCtaContable = IdCtaContRetIVAAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(308).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(308).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 Case 183 'Ret IVA X Acreditar Fletes P.F. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 2 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVA > 0 Then IdCtaContable = IdCtaContRetIVA ElseIf UsuarioActual.Empresa.Funcionalidad(309).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(309).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 'Conta SIG If CveCuentaRetIVA <> 0 Then CveCuenta = CveCuentaRetIVA Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero End If End If End If End If Case 184 'Ret IVA Acreditable Fletes P.F. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 2 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVAAcreditable > 0 Then IdCtaContable = IdCtaContRetIVAAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(310).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(310).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 Case 185 'Ret IVA X Acreditar Fletes P.M. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 3 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVA > 0 Then IdCtaContable = IdCtaContRetIVA ElseIf UsuarioActual.Empresa.Funcionalidad(311).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(311).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 'Conta SIG If CveCuentaRetIVA <> 0 Then CveCuenta = CveCuentaRetIVA Else If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero End If End If End If End If Case 186 'Ret IVA Acreditable Fletes P.M. If gvr.DataKey("CveRetIVAConcepto").ToEntero = 3 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVAAcreditable > 0 Then IdCtaContable = IdCtaContRetIVAAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(312).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(312).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 Case 248 'Ret IVA X Acreditar Arrendamiento If gvr.DataKey("CveRetIVAConcepto").ToEntero = 4 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVA > 0 Then IdCtaContable = IdCtaContRetIVA ElseIf UsuarioActual.Empresa.Funcionalidad(313).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(313).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 Case 249 'Ret IVA Acreditable Arrendamiento If gvr.DataKey("CveRetIVAConcepto").ToEntero = 4 Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" 'Conta ContPAQ If IdCtaContRetIVAAcreditable > 0 Then IdCtaContable = IdCtaContRetIVAAcreditable ElseIf UsuarioActual.Empresa.Funcionalidad(314).ToEntero > 0 Then IdCtaContable = UsuarioActual.Empresa.Funcionalidad(314).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 'Case 16 'Ret ISR X Acreditar ' If gvr.DataKey("CveRetISRConcepto").ToEntero = 1 Then ' If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago ' importeMX = ImporteMovimiento ' ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' End If ' ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) ' importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) ' TipoCambioGeneral = tipoCambioCompra ' If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" ' 'Conta ContPAQ ' If IdCtaContRetISR > 0 Then ' IdCtaContable = IdCtaContRetISR ' ElseIf UsuarioActual.Empresa.Funcionalidad(315).ToEntero > 0 Then ' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(315).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 ' 'Conta SIG ' If CveCuentaRetISR <> 0 Then ' CveCuenta = CveCuentaRetISR ' Else ' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then ' If ObjMov.DtResultados.Rows.Count > 0 Then ' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero ' End If ' End If ' End If ' End If 'Case 23 'Ret ISR Acreditable ' If gvr.DataKey("CveRetISRConcepto").ToEntero = 1 Then ' If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago ' importeMX = ImporteMovimiento ' ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' End If ' ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) ' importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) ' TipoCambioGeneral = TipoCambioPago ' If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" ' 'Conta ContPAQ ' If IdCtaContRetISRAcreditable > 0 Then ' IdCtaContable = IdCtaContRetISRAcreditable ' ElseIf UsuarioActual.Empresa.Funcionalidad(316).ToEntero > 0 Then ' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(316).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 ' 'Conta SIG ' If CveCuentaRetISR <> 0 Then ' CveCuenta = CveCuentaRetISR ' Else ' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then ' If ObjMov.DtResultados.Rows.Count > 0 Then ' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero ' End If ' End If ' End If ' End If 'Case 243 'Ret ISR x Acreditar Terceros y Arrendamiento ' If gvr.DataKey("CveRetISRConcepto").ToEntero = 2 Then ' If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago ' importeMX = ImporteMovimiento ' ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' End If ' ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) ' importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) ' TipoCambioGeneral = TipoCambioPago ' If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" ' 'Conta ContPAQ ' If IdCtaContRetISR > 0 Then ' IdCtaContable = IdCtaContRetISR ' ElseIf UsuarioActual.Empresa.Funcionalidad(317).ToEntero > 0 Then ' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(317).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 ' 'Conta SIG ' If CveCuentaRetISR <> 0 Then ' CveCuenta = CveCuentaRetISR ' Else ' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then ' If ObjMov.DtResultados.Rows.Count > 0 Then ' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero ' End If ' End If ' End If ' End If 'Case 244 'Ret ISR Acreditable Terceros y Arrendamiento ' If gvr.DataKey("CveRetISRConcepto").ToEntero = 2 Then ' If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = gvr.DataKey("RetISR").ToDecimal * PorcentajePago ' importeMX = ImporteMovimiento ' ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * tipoCambioCompra ' ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ' ImporteMovimiento = (gvr.DataKey("RetISR").ToDecimal * PorcentajePago) ' importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, tipoCambioCompra, TipoCambioPago) ' End If ' ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) ' importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) ' TipoCambioGeneral = TipoCambioPago ' If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" ' 'Conta ContPAQ ' If IdCtaContRetISRAcreditable > 0 Then ' IdCtaContable = IdCtaContRetISRAcreditable ' ElseIf UsuarioActual.Empresa.Funcionalidad(318).ToEntero > 0 Then ' IdCtaContable = UsuarioActual.Empresa.Funcionalidad(318).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 ' 'Conta SIG ' If CveCuentaRetISR <> 0 Then ' CveCuenta = CveCuentaRetISR ' Else ' If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then ' If ObjMov.DtResultados.Rows.Count > 0 Then ' CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaRetISRCirculacionSIG").ToString.ToEntero ' End If ' End If ' End If ' End If Case 14 'Iva X Acreditar Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2) If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 importeMX = 0 End If Else If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" End If TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal 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 ImporteMovimiento <> 0 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 CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAxAcreditarSIG").ToString.ToEntero End If End If Case 19 'Iva Acreditado Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then 'funcionalidad que toma el 100% del pago para acreditamiento de iva If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = gvr.DataKey("IVADeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" Else ImporteMovimiento = 0 importeMX = 0 End If Else If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" End If TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal 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) 'se registra el iva no acreditable If gvr.DataKey("IVANoDeducible").ToDecimal > 0 Then Dim ImporteNOIVA As Decimal = gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteNOIVA, Referencia, 280, ConceptoMovimiento, FechaMovimiento, IdCtaContableNoIVA, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=ImporteNOIVA, ImporteME:=If(TipoCambioPago = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" Exit For End If End If If ImporteMovimiento <> 0 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 CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero End If End If Case 25 'IEPS X Acreditar Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = tipoCambioCompra If tipoCambioCompra > 1 Then ConceptoMovimiento += $" TC:{tipoCambioCompra} ${ImporteMovimiento.FormatoNumero(2)}" If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero End If End If Case 26 'IEPS Acreditable Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjMov.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero End If End If Case 64 'Ganancia If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal 'Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) TipoCambioGeneral = TCImpuestos '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If TipoCambioPago < tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta ImporteMovimiento -= (IVA * TCImpuestos) - (IVA * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR ImporteMovimiento -= (IEPS * TCImpuestos) - (IEPS * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IEPS ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) importeMX = ImporteMovimiento End If Else ImporteMovimiento = 0 End If Case 65 'Perdida If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If TipoCambioPago > tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) 'Añadimos la diferencia de ganancia en la venta ImporteMovimiento -= (IVA * tipoCambioCompra) - (IVA * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR ImporteMovimiento -= (IEPS * tipoCambioCompra) - (IEPS * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) importeMX = ImporteMovimiento End If Else ImporteMovimiento = 0 End If Case 255 'Otros egresos If DdlOtrosPagos.SelectedValue = "2" Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal importeMX = ImporteMovimiento * TipoCambioPago ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal importeMX = ImporteMovimiento '* TipoCambioPago ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtComision").Text.ToDecimal importeMX = ImporteMovimiento * TipoCambioPago End If If gvr.FCTextBox("TxtComision").Text.ToDecimal < 0 Then TipoMovimiento = True ImporteMovimiento = ImporteMovimiento * -1 importeMX = importeMX * -1 IdCtaContable = UsuarioActual.Empresa.IdCuentaOtrosIngresos Else TipoMovimiento = False IdCtaContable = UsuarioActual.Empresa.Funcionalidad(266).ToEntero() End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) TipoCambioGeneral = TipoCambioPago End If Case 42 'Acreedores 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 CveCuenta = ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjetaSIG").ToString.ToEntero Else IdCtaContable = IdCuenta CveCuenta = CveCuentaB End If ImporteMovimiento = TxtImporte.Text.ToDecimal importeMX = If(CveMoneda = 2, If(DivTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal * TipoCambioPago, TxtImporte.Text.ToDecimal * TipoCambioPago), TxtImporte.Text.ToDecimal) TipoCambioGeneral = TipoCambioPago End If Case 30 'Conta ContPAQ If IdCuenta < 1 Then CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) idCuentaContabilizacion = 0 End If 'Conta SIG If CveCuentaB < 1 Then CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString) CveCuentaContabilizacion = 0 End If ImporteMovimiento = 0 Case Else ImporteMovimiento = 0 End Select If MsgError <> "" Then Exit For End If If ImporteMovimiento <> 0 Then 'Conta ContPAQ If IdCtaContable = 0 Then CuentasContablesInvalidas.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimeroValor("ConceptoContable", String.Format("CveConceptoContable = {0}", ConceptoContable))) idCuentaContabilizacion = 0 End If 'Conta SIG If CveCuenta = 0 Then CuentasContablesInvalidasSIG.Append("
" & GlobalDTContaConceptosContables(-1).FiltroPrimeroValor("ConceptoContable", String.Format("CveConceptoContable = {0}", ConceptoContable))) CveCuentaContabilizacion = 0 End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=importeMX, ImporteME:=If(TipoCambioPago = 1, 0, ImporteMovimiento), CveCuenta:=CveCuenta, TipoCambio:=TipoCambioGeneral, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "No se pudo insertar la póliza" Exit For End If End If Next 'Unificacion de PrePolizas If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(219) = "1" Then If Not ObjMov.PrePolizaUnificacion(CvePrePoliza, gvr.DataKey("CvePrePoliza").ToEntero) Then MsgError = "No se pudo unificar la prepoliza" Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) End If End If End If 'DESPROGRAMA LO PROGRAMADO DESPUES DE HACERLE UN PAGO ' If DdlTipoTransaccion.SelectedValue <> "9" Then 'SI ES LAYOUT SE DESPROGRAMA EN BANCOS/PAGOELECTRONICO, se comentó, 2018.07.31 peticion marilú. If MsgError = "" AndAlso gvr.DataKey("ImporteProgramo").ToDouble > 0 Then ObjComp.ProgramarCompra(gvr.DataKey("CveCompra").ToEntero, 0, UsuarioActual.CveUsuario, -1) End If ' End If End If Next ConceptoMovimiento = $"{TxtPagueseA.Text.Trim} - {TxtObservaciones.Text} {If(TipoCambioPago > 1, $" TC:{TipoCambioPago}", "")}" Referencia = $"{HdnTipoTransaccionAbreviatura.Value}: {TxtFolio.Text.Trim}" If (Not DivTarjeta.Visible Or DdlTarjeta.SelectedValue.ToEntero = -1) Then If TipoCambioPago > 1 AndAlso CveMoneda = 2 Then If UsuarioActual.CveEmpresa = 119 Or (CveCuentaBancariaComplementaria > 0 OrElse IdCuentaBancariaComplementaria > 0) Then If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES TipoCambioPago = TxtTCDolares.Text.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=If(TipoCambioPago = 1, 0, TxtImporte.Text.ToDecimal), CveCuenta:=CveCuentaB, TipoCambio:=TipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), Referencia, 204, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuentaBancariaComplementaria, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round((TxtImporte.Text.Trim.ToDecimal * TipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 1, 0, TxtImporte.Text.ToDecimal), TipoCambio:=TipoCambioPago, CveCuenta:=CveCuentaBancariaComplementaria) Then MsgError = "No se pudo insertar la póliza" End If Else If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES TipoCambioPago = TxtTCDolares.Text.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), CveCuenta:=CveCuentaB, TipoCambio:=TipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If Else If CveMoneda = 2 AndAlso CveMonedaFiltro = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES TipoCambioPago = TxtTCDolares.Text.ToDecimal ElseIf CveMoneda = 2 AndAlso CveMonedaFiltro = 2 Then TipoCambioPago = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal End If If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), CveCuenta:=CveCuentaB, TipoCambio:=TipoCambioPago) Then MsgError = "No se pudo insertar la póliza" End If End If End If If MsgError <> "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then If ObjMov.ValorPolizaDescuadre > 0 Then MsgError = ObjMov.MensajePolizaDescuadre + " " + ObjMov.ValorDiferencia GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") End If End If If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(220) <> "" Then If Not ObjMov.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then MsgError = "No se pudo simplificar los movimientos" Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) 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, ObjConta:=ObjConta) Then ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) IDPoliza = ObjMov.ContaIdPoliza Else Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) MsgError = "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), TipoMensaje.MsgAdvertencia) MsgError = "No se puede contabilizar la Prepoliza" End If End If Else 'Empresa Prueba 'Movimientos de Bancos If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteSeleccionado, TxtFolio.Text.Trim, 30, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, ImporteSeleccionado * TipoCambio, ImporteSeleccionado)) Then MsgError = "no se pudo insertar el detalle de la poliza" End If Dim PorcentajePago As Decimal = 100 'inserto las compras que voy a pagar For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then If TipoPago = 3 Then 'cuando es pago con crediproveedores ' CveConceptoCompra = 50 ' prestamo documentos por pagar 'debo de actualizar el estatus dela compra a pagada Dim ObjCreditos As New ClsBancos If ObjCreditos.GetCreditos(-1, -1, -1, CveProveedor, 1, UsuarioActual.CveEmpresa) Then Dim DTCreditos As DataTable = ObjCreditos.DtResultados.FiltraParametros(String.Format("CveCompra = {0}", gvr.DataKey("CveCompra"))) If DTCreditos.Rows.Count > 0 Then 'actualizo el estatus Dim drC As DataRow = DTCreditos.Rows(0) Dim Estatus As Integer = 103 ' Estatus = If(drE("Estatus").ToString = "P", 103, Estatus) If Not ObjCreditos.UpdateCreditosDetalle(drC("CveCreditoDetalle").ToString.ToEntero, drC("FechaVencimiento").ToString.ToDate, drC("CreditoValor").ToString.ToDouble, -1, -1.0, -1.0, -1.0, -1.0, Estatus) Then ' ErrorCredito = True End If End If End If ObjCreditos.Dispose() End If 'Saco el porcentaje de pago If gvr.DataKey("Original").ToDouble > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDecimal / gvr.DataKey("Original").ToDecimal Else PorcentajePago = 1 If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, gvr.FCTextBox("TxtAbonar").Text.ToDecimal, TxtObservaciones.Text, 17, "", Now, 0, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=gvr.FCTextBox("TxtAbonar").Text.ToDecimal) Then MsgError = "Detalle" Exit For Else 'IVA. siempre se registra aunque sea cero If MsgError = "" Then Dim IdCtaIVAXAcreditar As Integer = 0 Dim IdCtaIVAAcreditable As Integer = 0 Dim PorcentajeImpuesto As Decimal = gvr.DataKey("PorcentajeIVA").ToDecimal 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 'Agrego el IVA If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, gvr.DataKey("IVA").ToDecimal * PorcentajePago, TxtObservaciones.Text, 14, TxtObservaciones.Text, Now, IdCtaIVAXAcreditar, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=gvr.DataKey("IVA").ToDecimal * PorcentajePago) Then MsgError = "Detalle" If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, gvr.DataKey("IVA").ToDecimal * PorcentajePago, TxtObservaciones.Text, 19, TxtObservaciones.Text, Now, IdCtaIVAAcreditable, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=gvr.DataKey("IVA").ToDecimal * PorcentajePago) Then MsgError = "Detalle" End If End If If MsgError = "" AndAlso gvr.DataKey("RetIVA").ToDouble > 0 Then 'Agrego el RetIVA If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, gvr.DataKey("RetIVA").ToDecimal * PorcentajePago, TxtObservaciones.Text, 22, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) Then MsgError = "Detalle" End If End If 'If MsgError = "" AndAlso gvr.DataKey("RetISR").ToDouble > 0 Then ' 'Agrego el RetIVA ' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, gvr.DataKey("RetISR").ToDecimal * PorcentajePago, TxtObservaciones.Text, 23, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=gvr.DataKey("RetISR").ToDecimal * PorcentajePago) Then ' MsgError = "Detalle" ' End If 'End If 'DESPROGRAMA LO PROGRAMADO DESPUES DE HACERLE UN PAGO If DdlTipoTransaccion.SelectedValue <> "9" Then 'SI ES LAYOUT SE DESPROGRAMA EN BANCOS/PAGOELECTRONICO If gvr.DataKey("ImporteProgramo").ToDouble > 0 Then ObjComp.ProgramarCompra(gvr.DataKey("CveCompra").ToEntero, 0, UsuarioActual.CveUsuario, -1) End If End If End If End If End If Next End If 'Empresa Prueba Else MsgError = "No se pudo insertar la póliza" End If Else MsgError = "No se insertó el encabezado" End If If MsgError = "" Then 'Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "window.close();") Dim TieneError As Boolean = False If UsuarioActual.Empresa.UsaAC Then Dim Total As Double = TxtImporte.Text.ToDouble If ChkACEjercer.Checked Then Total = Total * 3 Else Total = Total * 2 End If Dim TipoChq As String = "" If DdlTipoTransaccion.SelectedValue = "1" Then TipoChq = "CHQ" 'se multiplica por dos, porque se esta juntando el ejercido y el pagado al mismo tiempo If UsuarioActual.Empresa.UsaContabilidad Then IDPoliza = ObjConta.AddPoliza(2, "Pagado " & TxtPagueseA.Text.Trim, Total, Total, UsuarioActual.CveUsuario, Fecha, TxtFolio.Text, TipoChq) If IDPoliza > 0 Then FolioPoliza = ObjConta.Folio Dim ConceptoRenglon, Referencia As String ConceptoRenglon = "" Referencia = TxtFolio.Text 'NECESITO SACAR LAS PARTIDAS DE CADA PRESUPUESTO DE LAS FACTURAS PARA AFECTARLAS CON EL PAGO Dim dtAC As New DataTable dtAC.Columns.Add("PorcentajePago", Type.GetType("System.Double")) Dim PorcentajePago As Double = 1 'Dim ComprasAC As New ClsCompras For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then 'obtengo su poliza para ver que presupuestos afecto If gvr.DataKey("Original").ToDouble > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDouble / gvr.DataKey("Original").ToDouble Else PorcentajePago = 1 If ObjComp.GetPresupuestosCompras(gvr.DataKey("CveCompra").ToEntero) Then dtAC.Merge(ObjComp.DtResultados) If Not gvr.DataKey("Fecha").ToString.ToDate.Year < Fecha.Year Then ' SI ES EJERCICIO ANTERIOR LA COMPRA QUE EL EJERCICIO DEL PAGO NO AGREGA MOVIMIENTOS PRESUPUESTALES For Each dr As DataRow In ObjComp.DtResultados.Rows Total = dr("TotalPresupuesto").ToString.ToDouble * PorcentajePago If Total > 0 Then 'EJERCIDO If ChkACEjercer.Checked Then ConceptoRenglon = String.Format("GE {0} Fact:{1}", TxtPagueseA.Text.Trim, gvr.DataKey("SerieFolio")) If ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then 'actualizo el idcuenta del presupuesto If Not ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then TieneError = True : Exit For End If Else TieneError = True : Exit For End If End If 'PAGADO ConceptoRenglon = String.Format("GP {0} Fact:{1}", TxtPagueseA.Text.Trim, gvr.DataKey("SerieFolio")) If ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then 'actualizo el idcuenta del presupuesto If Not ObjConta.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then TieneError = True : Exit For End If Else TieneError = True : Exit For End If End If Next End If 'AFECTA PROVEEDOR Total = gvr.FCTextBox("TxtAbonar").Text.ToDouble If Not ObjConta.AddMovimiento(IDPoliza, CtaProveedor, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then TieneError = True Exit For End If End If End If Next If Not TieneError Then ConceptoRenglon = String.Format("GP {0} {1}", TxtPagueseA.Text.Trim, TxtObservaciones.Text) Total = TxtImporte.Text.ToDouble If Not ObjConta.AddMovimiento(IDPoliza, IdCuenta, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then TieneError = True End If End If Else TieneError = True End If End If If Not TieneError Then 'actualizar la conta del IE ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0) Else IDPoliza = 0 End If End If If Not TieneError Then ObjIE.Commit() If ObjConta IsNot Nothing Then ObjConta.Commit() Anexo.Text = "[]" 'RMF. comentado para verificar proceso. ''actualizo el notificar A del proveedor 'If UsuarioActual.Empresa.Funcionalidad(142) = "1" Then ' Dim Prov As New ClsCompProveedores ' Prov.UpdateProveedorNotificarA(CveProveedor, TxtNotificarA.Text.Trim) ' Prov.Dispose() 'End If 'IMPRIME CHEQUE 'GeneraChequePDF(CveIE, UsuarioActual.Empresa, IDPoliza) Dim Msg As New StringBuilder 'Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero)) 'If Archivo.Exists Then Msg.AppendFormat("
  • Imprimir movimiento
  • ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE))) 'End If Msg.AppendFormat("
  • Listado
  • ", CveIE) If IDPoliza > 0 Then Msg.AppendFormat("
  • Póliza
  • ", IDPoliza) Dim Mensaje As String = String.Format("
    El Documento se generó correctamente.


    Descargas:", Msg.ToString) Alert(Mensaje.ToString, TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""RepProveedoresPagos.aspx""")) 'LIMPIA TxtFolio.Text = "" TxtObservaciones.Text = "" TxtImporte.Text = "" TxtTotal.Text = "" TxtFechaDocumento.Text = Now.ToShortDateString DdlSelectedValue(DdlCuenta, "-1") DdlSelectedValue(DdlTipoTransaccion, "-1") Anexo.Text = "[]" UpDatos.Update() 'upanexo.Update() CargaDatos() '(CveProveedor, CveMoneda, FechaI, FechaF, CveUsuarioRegistro, CveUsuarioProgramo, Serie) 'Notificación de Pago If TxtNotificarA.Text.Trim <> "" AndAlso ChkEnviarCorreo.Checked Then NotificacionPago(CveIE, TxtNotificarA.Text.Trim) End If End If Else ObjIE.RollBack() If ObjConta IsNot Nothing Then ObjConta.RollBack() Alert(MsgError, TipoMensaje.MsgAdvertencia) End If ObjIE.Dispose() ObjMov.Dispose() ObjComp.Dispose() If ObjConta IsNot Nothing Then ObjConta.Dispose() Else Alert("Debe de llevar un folio", TipoMensaje.MsgAdvertencia) End If Else Alert("Debe de llevar un importe", TipoMensaje.MsgAdvertencia) End If End Sub Private Sub DdlSelectedValue(Ddl As DropDownList, Valor As String) If Ddl.Items.FindByValue(Valor) IsNot Nothing Then Ddl.SelectedValue = Valor Else Ddl.SelectedIndex = 0 End If End Sub #End Region #Region " TIPO TRANSACCION " Private Sub CargaTipoTransaccion() If TipoPago = 1 Then DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) ") DdlTipoTransaccion.DataBind() DdlTipoTransaccion.SelectedValue = TipoPago.ToString ElseIf TipoPago = 2 Then DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) ") DdlTipoTransaccion.DataBind() DdlTipoTransaccion.SelectedValue = TipoPago.ToString RecargaCuentasDepositos() ElseIf TipoPago = 3 Then DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) ") DdlTipoTransaccion.DataBind() DdlTipoTransaccion.SelectedValue = TipoPago.ToString RecargaCuentasDepositos() Else DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") DdlTipoTransaccion.DataBind() End If If DdlTipoTransaccion.Items.Count > 1 Then DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) End Sub Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged BtnIEGuardar.Enabled = True 'cuando es cheque If DdlTipoTransaccion.SelectedValue = "1" Then ChkAbonoCuenta.Visible = True Else ChkAbonoCuenta.Visible = False End If CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) RecargaCuentasDepositos() UpGuardar.Update() End Sub #End Region #Region " CUENTAS MOVTO " Private Sub CargaCuentas(tTipoTransaccion As Integer) DdlCuenta.Items.Clear() Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) 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 CveMonedaFiltro > 0 Then dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMonedaFiltro)) End If End If If TipoPago = 3 Then dt = dt.FiltraParametros("CveTipoCuenta = 7") End If 'cuando es layout If tTipoTransaccion = 9 Then dt = dt.FiltraParametros("UsaLayout = 1") End If DdlCuenta.DataSource = dt DdlCuenta.DataBind() DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) End Sub Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged 'recargo la moneda con la que se va a pagar Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuenta.SelectedValue)) If dr IsNot Nothing Then If ChkPagarPesos.Checked Then CveMoneda = 2 RegistraScript("CambiaPesosDolares();") Else CveMoneda = dr("CveMoneda").ToString.ToEntero RegistraScript("CambiaDolaresPesos();") End If IdCuenta = dr("IdCtaContable").ToString.ToEntero CveCuentaB = dr("IdCtaContableSIG").ToString.ToEntero IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero CveCuentaBancariaComplementaria = dr("IdCtaContableComplementariaSIG").ToString.ToEntero End If ' si no tiene CveMoneda, o es -1, cuando cambia de cuenta filtra las facturas If IfNull(Request("CveMoneda"), "-1").ToString.ToEntero = -1 Then CargaDatos(CveMoneda) If HdnTipoTransaccion.Value = "Egs" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then Dim Folio As Long Dim Banco As New ClsBancos Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) Banco.Dispose() TxtFolio.Text = Folio.ToString Else TxtFolio.Text = "" End If Dim IdCuentaBancaria As Integer Dim dr2 As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) If dr2 IsNot Nothing Then IdCuentaBancaria = dr2("IdCtaContable").ToString.ToEntero If dr("UsaTarjeta").ToString = "True" Then CargaGridTarjetas() Else DivTarjeta.Visible = False End If End If 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 #End Region #Region " CUENTAS DEPOSITOS" Private Sub CargaCuentasDepositos() DdlCuentaDeposito.Items.Clear() ' If DdlTipoTransaccion.SelectedValue.Contiene("2", "9") Then ' transferencias y layout trCuentaDeposito.Visible = False Dim Dep As New ClsGenerales If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then If Dep.DtResultados.FiltraParametros("Estatus ='True'").Rows.Count > 0 Then If DdlTipoTransaccion.SelectedValue = "9" Then If Dep.DtResultados.Rows.Count > 0 Then DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") End If 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 BtnIEGuardar.Enabled = False Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) End If 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 DdlCuentaDeposito.DataBind() If DdlCuentaDeposito.Items.Count > 1 Then DdlCuentaDeposito.SelectedIndex = 1 End If End If End If Dep.Dispose() 'Else ' trCuentaDeposito.Visible = False ' DdlCuentaDeposito.Items.Clear() 'End If 'RecargaGlobalCuentasBancarias() UpnCuentasPago.Update() UpCuentaDeposito.Update() End Sub Private Sub RecargaCuentasDepositos() Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing If dr IsNot Nothing Then HdnTipoTransaccion.Value = dr("Tipo").ToString HdnTipoTransaccionAbreviatura.Value = dr("Abreviatura").ToString End If 'cuando es transferencia bancaria, debe de solicitar a que cuenta se va a depositar CargaCuentasDepositos() End Sub 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(0)("TieneCIE").ToString.ToEntero = 1 Then TrReferenciaCIE.Visible = True TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString Else TrReferenciaCIE.Visible = False End If End If Dep.Dispose() UpCuentaDeposito.Update() End Sub #End Region 'ESTO NO DEBERIA ESTAR AQUI Private Sub RecargaGlobalCuentasBancarias(Optional ByVal CveCuenta As Integer = -1) If CveProveedor > 0 Then Dim ObjCuentasBancos As New ClsGenerales If ObjCuentasBancos.GetCuentasDepositos() Then GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados End If ObjCuentasBancos.Dispose() End If End Sub Protected Sub DdllOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged If DdlOtrosPagos.SelectedValue <> "-1" Then DdlProsepago.Visible = False TxtOtrosImportes.Visible = True TxtTotal.Visible = True GvCxP.Columns(12).Visible = True Else DdlProsepago.Visible = False TxtOtrosImportes.Visible = False TxtTotal.Visible = False GvCxP.Columns(12).Visible = False TxtOtrosImportes.Text = "" TxtTotal.Text = "" RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);") End If UpDatos.Update() UPCompras.Update() End Sub #Region " PAGAR CON PESOS " Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarPesos.Checked Then DivTC.Visible = True DivDolaresDolares.Visible = False CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) Else DivTC.Visible = False DivDolaresDolares.Visible = True CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) TxtFechaDocumento.Attributes.Remove("onchange") End If UpDatos.Update() RegistraScript("CambiaPesosDolares();") End Sub #End Region #Region "PAGAR CON DOLARES" Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs) If ChkPagarDolares.Checked Then DivTCDolares.Visible = True DivDolaresDolares.Visible = False CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTCDolares.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) Else DivTCDolares.Visible = False DivDolaresDolares.Visible = False CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero) TxtFechaDocumento.Attributes.Remove("onchange") End If UpDatos.Update() RegistraScript("CambiaDolaresPesos();") End Sub #End Region #Region " NOTIFICACION PAGO " Private Sub NotificacionPago(CveIE As Integer, CorreoNotificarA As String) 'Dim Param As New List(Of String) 'Param.Add(CorreoNotificarA) 'Para 'Param.Add("Notificaciones de pago") 'Asunto 'Param.Add(GeneraCorreo(CveIE)) 'Body 'Param.Add(CveIE.ToString) 'CveIE Dim Body As String = GeneraCorreo(CveIE) Dim Comprobante = If(ComprobanteIE <> "", String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ComprobanteIE), "") 'Archivo Adjunto Dim File As Byte() = Nothing If UsuarioActual.Empresa.Funcionalidad(545).ToEntero > 0 Then File = NewGeneraBytesCxP(CveProveedor, UsuarioActual.Nombre) End If Dim Hilo As New Threading.Thread(Sub() MandaCorreo(CorreoNotificarA, "Notificaciones de pago", Body, CveIE, Comprobante, File)) Hilo.Start() End Sub Private Sub MandaCorreo(Para As String, Asunto As String, Body As String, CveIE As Integer, Comprobante As String, File As Byte()) 'Dim Parametros As List(Of String) = DirectCast(Data, List(Of String)) Dim Mail As New ClsSisMail() Para = If(Para IsNot Nothing, Para, "") Asunto = If(Asunto IsNot Nothing, Asunto, "") Body = If(Body IsNot Nothing, Body, "") Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail) If Comprobante IsNot Nothing AndAlso Comprobante <> "" Then ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = Comprobante}) End If If File IsNot Nothing Then ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = File, .NombreArchivo = "EstadoCuentaCxP.pdf"}) End If If Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=ListaArchivos) Then Dim objIE As New ClsBancos objIE.UpdateBancos_IENotificaciones(1, "-1", "-1", CveIE) objIE.Dispose() End If End Sub Private Function GeneraCorreo(CveIE As Integer) As String Dim strBody As New StringBuilder Dim objIE As New ClsBancos If objIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) strBody.AppendFormat(" ") strBody.AppendFormat("
    {0}
    Col. {0}
    {0}, {1}, C.P.{2}
    RFC {0}
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("


    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") End If If objIE.CveTipoTransaccion = 2 Then ' cuando es transf strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") End If strBody.Append(" ") strBody.AppendFormat(" ") strBody.Append(" ") strBody.Append("
    Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.
    Notificación de transferencia de pago realizada.
     
    ") strBody.AppendFormat("
    ") strBody.Append("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat(" Beneficiario:{0} ", objIE.PagueseA) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.TipoTransaccion) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.Banco) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.NumCuenta) strBody.AppendFormat(" ") If objIE.CuentaDepositado.ToString <> "" Then strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.CuentaDepositado) strBody.AppendFormat(" ") End If strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.FechaDocumento.ToString("dd/MM/yyyy")) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", objIE.Observaciones) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat("
    Movimiento:{0}
    Banco:{0}
    Cuenta:{0}
    Cuenta Destino:{0}
    Fecha:{0}
    Importe:$ {0} {1}
    Observaciones:{0}
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") 'MOVIMIENTOS CHEQUE If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then Dim Textov33 As String = "" If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" End If strBody.AppendFormat("
    ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat(" Documentos abonados o pagados
    {0}
    ", Textov33) strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows strBody.AppendFormat(" ") strBody.AppendFormat(" ", dr("Fecha").ToString.ToDate.ToShortDateString()) strBody.AppendFormat(" ", dr("SerieFolio").ToString) strBody.AppendFormat(" ", dr("Importe").ToString.FormatoNumero) strBody.AppendFormat(" ", dr("FolioFiscal")) strBody.AppendFormat(" ", dr("ImporteNC").ToString.FormatoNumero) strBody.AppendFormat(" ") Next strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ") strBody.AppendFormat("
    FechaFacturaImporte ($)Folio FiscalNC Aplicadas
    {0}{0}$ {0}{0}{0}
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") strBody.AppendFormat("
    ") End If strBody.Append("
    Favor de no responder a este correo.
    ") strBody.Append("") End If objIE.Dispose() Return strBody.ToString End Function #End Region #Region "SALDAR CUENTAS" Private Sub BtnSaldarCuentasSinPagar_Click(sender As Object, e As EventArgs) Handles BtnSaldarCuentasSinPagar.Click Dim ObjConta As New ClsContabilidad ObjConta.IniciaTransacSQL() Dim CvePrePoliza As Integer = 0 Dim MsgError As String = "" Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) For Each gr As GridViewRow In GvCxP.Rows If gr.FCCheckBox("Chk").Checked Then Dim IdCtaContable As Integer = CtaProveedor Dim CveCuenta As Integer = CveCuentaProveedor Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal Dim TCCompra As Decimal = gr.DataKey("TipoCambio").ToDecimal Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaIncobrable.Text.ToDate).ToDecimal Dim CveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero Dim FechaCompra As Date = gr.DataKey("Fecha").ToDate Dim ConceptoPartida As String = String.Format("Saldar compra {0}", gr.DataKey("SerieFolio").ToString) CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ProveedoresAbonar/Saldar", 98, gr.DataKey("Saldo").ToDecimal, gr.DataKey("Saldo").ToDecimal, gr.DataKey("CveMoneda").ToEntero, TxtFechaIncobrable.Text.ToDate, ConceptoPartida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If CveMoneda > 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria CveCuenta = CveCuentaProveedorExtranjera If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, 0.00D, gr.DataKey("SerieFolio").ToString, 206, ConceptoPartida, Now, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=Math.Round(Saldo * TCCompra - Saldo, 2, MidpointRounding.AwayFromZero), ImporteME:=Saldo, TipoCambio:=TCCompra, CveCuenta:=CveCuentaComplementaria) Then MsgError = "No se pudo insertar la póliza" End If IdCtaContable = IdCtaProveedorExtranjera CveCuenta = CveCuentaProveedorExtranjera If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, gr.DataKey("SerieFolio").ToString, 17, ConceptoPartida, Now, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=Saldo, ImporteME:=If(CveMoneda > 1, Saldo, 0), TipoCambio:=TCCompra, CveCuenta:=CveCuenta) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Else If CveMoneda > 1 Then IdCtaContable = IdCtaProveedorExtranjera CveCuenta = CveCuentaProveedorExtranjera End If If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Saldo, gr.DataKey("SerieFolio").ToString, 17, ConceptoPartida, Now, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=If(CveMoneda = 1, Saldo, Saldo * TCCompra), ImporteME:=If(CveMoneda > 1, Saldo, 0), TipoCambio:=TCCompra, CveCuenta:=CveCuenta) Then MsgError = "Ocurrio un error al saldar el movimiento" End If End If Dim PorcentajePago As Decimal = gr.DataKey("Saldo").ToDecimal / gr.DataKey("Original").ToDecimal If gr.DataKey("IVA").ToDecimal > 0 Then Dim PorcentajeImpuesto As Decimal = gr.DataKey("PorcentajeIVA").ToDecimal 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 Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, gr.DataKey("SerieFolio").ToString, 14, ConceptoPartida, Now, IdCtaContable:=IdCtaIVAXAcreditar, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=If(CveMoneda = 1, IVA, IVA * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), CveCuenta:=CveCuenta, PorcentajeImpuesto:=PorcentajeImpuesto) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Saldo = Saldo - IVA End If If gr.DataKey("IEPS").ToDecimal > 0 Then Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal If ObjConta.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero End If End If If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, gr.DataKey("SerieFolio").ToString, 25, ConceptoPartida, Now, IdCtaContable:=IdCtaContable, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=If(CveMoneda = 1, IEPS, IEPS * If(FuncionalidadFluctuacionImpuestos, TCPago, TCCompra)), CveCuenta:=CveCuenta) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Saldo = Saldo - IEPS End If ' se manda al ot ingresos, los impuestos por acreditar If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Saldo, gr.DataKey("SerieFolio").ToString, 78, ConceptoPartida, Now, IdCtaContable:=UsuarioActual.Empresa.IdCuentaOtrosIngresos, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=If(CveMoneda = 1, Saldo, Saldo * TCPago), TipoCambio:=TCCompra, TipoCambioPago:=TCPago, CveCuenta:=-1) Then MsgError = "Ocurrio un error al saldar el movimiento" End If 'fluctuación. If CveMoneda > 1 Then Dim ImporteFluctuacion As Decimal = 0 ImporteFluctuacion = Saldo * (TCPago - TCCompra) If TCCompra > TCPago Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 64, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCCompra, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If Else If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), gr.DataKey("SerieFolio").ToString, 65, ConceptoPartida, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveProveedor:=gr.DataKey("CveProveedor").ToEntero, CveCompra:=gr.DataKey("CveCompra").ToEntero, ImporteMX:=Math.Abs(ImporteFluctuacion), CveCuenta:=CveCuenta, TipoCambio:=TCCompra, TipoCambioPago:=TCPago) Then MsgError = "Ocurrio un error al saldar el movimiento" End If End If End If If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then If ObjConta.ValorPolizaDescuadre > 0 Then MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia GuardaLogAD($"Bancos/ProveedoresAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") Exit For Else If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) Else Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico" End If End If End If End If End If Next If MsgError = "" Then ObjConta.Commit() CargaDatos(CveMoneda) RegistraScript("$('#ModalSaldarCuentaSinPagar').modal('hide')") Alert("Los movimientos se saldaron correctamente.") Else ObjConta.RollBack() Alert(MsgError, TipoMensaje.MsgError) End If 'BtnSaldar.Visible = False ObjConta.Dispose() End Sub #End Region #Region "GENERAR SOLICITUD" Protected Sub LnkPDFSolicitud_Click(sender As Object, e As EventArgs) GenerarPDFSolicitud("PDF") End Sub Protected Sub LnkExcelSolicitud_Click(sender As Object, e As EventArgs) GenerarPDFSolicitud("EXCEL") End Sub Private Sub GenerarPDFSolicitud(Opcion As String) If DtDatos.Rows.Count > 0 Then Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) Dim StrImporte As String = DtDatos.Rows(0)("Saldo").ToString.FormatoNumero Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString)) params.Add(New ReportParameter("Sucursal", DtDatos.Rows(1)("SubProyecto").ToString)) params.Add(New ReportParameter("Importe", $"${StrImporte}")) params.Add(New ReportParameter("RazonSocial", TxtPagueseA.Text)) params.Add(New ReportParameter("Fecha", TxtFechaDocumento.Text)) Dim Transferencia = "", Banco = "", CLABE = "", Cuenta = "", Correo = "" If DdlTipoTransaccion.SelectedValue.Contiene("2", "8") Then Transferencia = "Si" Else Transferencia = "No" If DdlCuentaDeposito.SelectedValue.ToEntero > 0 Then Dim ObjGral As New ClsGenerales If ObjGral.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) Then If ObjGral.DtResultados.Rows.Count > 0 Then Banco = ObjGral.DtResultados.Rows(0)("BancoNombre").ToString CLABE = ObjGral.DtResultados.Rows(0)("CLABE").ToString Cuenta = ObjGral.DtResultados.Rows(0)("Cuenta").ToString Correo = ObjGral.DtResultados.Rows(0)("Correo").ToString End If End If ObjGral.Dispose() End If params.Add(New ReportParameter("Transferencia", Transferencia)) params.Add(New ReportParameter("Banco", Banco)) params.Add(New ReportParameter("CLABE", CLABE)) params.Add(New ReportParameter("Cuenta", Cuenta)) params.Add(New ReportParameter("Correo", Correo)) If Imagen.Exists Then params.Add(New ReportParameter("LogoPath", logouri)) Else params.Add(New ReportParameter("LogoPath", "")) End If Dim NombreArchivo As String = "SolicitudPago" ''String.Format("SolicitudPago{0}.pdf", TxtPagueseA.Text).Replace(" ", "") ImprimirPDF("Empresas/Grales/Formatos/Solicitud.rdlc", DtDatos, params, NombreArchivo, Opcion) Else Alert("No se encontraron datos.", TipoMensaje.MsgAdvertencia) End If End Sub #End Region End Class