Files
SIG/Bancos/IE.aspx.vb

6756 lines
338 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports System.Web.Services
Imports System.IO
Imports Microsoft.Reporting.WebForms
Imports System.Xml
Partial Class Bancos_IE
Inherits ClsPaginas
#Region "Propiedades"
'Configuración
Private Property CveIE As Integer
Get
Return ViewState("CveIE").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveIE") = value
End Set
End Property
Private Property CveIEDeposito As Integer
Get
Return ViewState("CveIEDeposito").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveIEDeposito") = value
End Set
End Property
Private Property CveIEDeposito2 As Integer
Get
Return ViewState("CveIEDeposito2").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveIEDeposito2") = value
End Set
End Property
Private Property Cuenta As String
Get
Return ViewState("Cuenta").ToString
End Get
Set(value As String)
ViewState("Cuenta") = value
End Set
End Property
Private Property Folio As String
Get
Return ViewState("Folio").ToString
End Get
Set(value As String)
ViewState("Folio") = value
End Set
End Property
Private Property CuentaDepositoPadre As String
Get
Return ViewState("CuentaDepositoPadre").ToString
End Get
Set(value As String)
ViewState("CuentaDepositoPadre") = value
End Set
End Property
Private Property CveCuenta As Integer
Get
Return ViewState("CveCuenta").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCuenta") = value
End Set
End Property
Private Property CveCompra As Integer
Get
Return If(IsNothing(ViewState("CveCompra")), -1, ViewState("CveCompra").ToString.ToEntero)
End Get
Set(value As Integer)
ViewState("CveCompra") = value
End Set
End Property
Private Property CveProveedor As Integer
Get
Return If(IsNothing(ViewState("CveProveedor")), -1, ViewState("CveProveedor").ToString.ToEntero)
End Get
Set(value As Integer)
ViewState("CveProveedor") = value
End Set
End Property
Private Property CveOrdenCompra As Integer
Get
Return If(IsNothing(ViewState("CveOrdenCompra")), -1, ViewState("CveOrdenCompra").ToString.ToEntero)
End Get
Set(value As Integer)
ViewState("CveOrdenCompra") = value
End Set
End Property
Private Property CvePersonal As Integer
Get
Return If(IsNothing(ViewState("CvePersonal")), -1, ViewState("CvePersonal").ToString.ToEntero)
End Get
Set(value As Integer)
ViewState("CvePersonal") = value
End Set
End Property
Private Property CveCliente As Integer
Get
Return If(ViewState("CveCliente") IsNot Nothing, ViewState("CveCliente").ToString.ToEntero, -1)
End Get
Set(value As Integer)
ViewState("CveCliente") = value
End Set
End Property
Private Property CveVentaDevDin As Integer
Get
Return ViewState("CveVentaDevDin").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveVentaDevDin") = value
End Set
End Property
Private Property SerieFolioDevDin As String
Get
Return ViewState("SerieFolioDevDin").ToString
End Get
Set(value As String)
ViewState("SerieFolioDevDin") = value
End Set
End Property
Private Property CvePrePolizaDevDin As Integer
Get
Return ViewState("CvePrePolizaDevDin").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CvePrePolizaDevDin") = value
End Set
End Property
Private Property CveCompraDeCDin As Integer
Get
Return ViewState("CveCompraDeCDin").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCompraDeCDin") = value
End Set
End Property
Private Property SerieFolioDeCDin As String
Get
If ViewState("SerieFolioDeCDin") Is Nothing Then
Return ""
Else
Return ViewState("SerieFolioDeCDin").ToString
End If
End Get
Set(value As String)
ViewState("SerieFolioDeCDin") = value
End Set
End Property
Private Property CvePrePolizaDeCDin As Integer
Get
Return ViewState("CvePrePolizaDeCDin").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CvePrePolizaDeCDin") = value
End Set
End Property
Private Property FechaCompra As Date
Get
Return ViewState("FechaCompra").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaCompra") = value
End Set
End Property
Private Property CveIECancelacion As Integer
Get
If ViewState("CveIECancelacion") Is Nothing Then
Return -1
Else
Return ViewState("CveIECancelacion").ToString().ToEntero()
End If
End Get
Set(value As Integer)
ViewState("CveIECancelacion") = value
End Set
End Property
Private Property CveIECancelado As Integer
Get
If ViewState("CveIECancelado") Is Nothing Then
Return -1
Else
Return ViewState("CveIECancelado").ToString().ToEntero()
End If
End Get
Set(value As Integer)
ViewState("CveIECancelado") = value
End Set
End Property
Private Property ImporteOriginalDevDin As Decimal
Get
Return ViewState("ImporteOriginalDevDin").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("ImporteOriginalDevDin") = value
End Set
End Property
Private Property IDPoliza As Integer
Get
Return ViewState("IDPoliza").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IDPoliza") = value
End Set
End Property
Private Property Opcion As String
Get
Return ViewState("Opcion").ToString
End Get
Set(value As String)
ViewState("Opcion") = value
End Set
End Property
Private Property IDCtaContable As Integer
Get
Return ViewState("IDCtaContable").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IDCtaContable") = value
End Set
End Property
Private Property IDCtaContableComplementaria As Integer
Get
Return ViewState("IDCtaContableComplementaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IDCtaContableComplementaria") = value
End Set
End Property
Private Property IDCtaBeneficiario As Integer
Get
Return ViewState("IDCtaBeneficiario").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IDCtaBeneficiario") = value
End Set
End Property
Private Property IDCtaBeneficiarioComplementaria As Integer
Get
Return ViewState("IDCtaBeneficiarioComplementaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IDCtaBeneficiarioComplementaria") = value
End Set
End Property
Private Property CvePrePoliza As Integer
Get
Return ViewState("CvePrePoliza").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CvePrePoliza") = value
End Set
End Property
Private Property DtIEDevolucion As DataTable
Get
DtIEDevolucion = DirectCast(ViewState("DtIEDevolucion"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtIEDevolucion") = value
End Set
End Property
Private Property Borrar As Boolean
Get
Return CBool(ViewState("Borrar"))
End Get
Set(value As Boolean)
ViewState("Borrar") = value
End Set
End Property
Private Property CveMoneda As Integer
Get
Return ViewState("CveMoneda").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMoneda") = value
End Set
End Property
Private Property CveMonedaOriginal As Integer
Get
Return ViewState("CveMonedaOriginal").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMonedaOriginal") = value
End Set
End Property
Private Property CveOCSolicitudAnticipo As Integer
Get
If ViewState("CveOCSolicitudAnticipo") Is Nothing Then
Return -1
Else
Return ViewState("CveOCSolicitudAnticipo").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveOCSolicitudAnticipo") = value
End Set
End Property
Private Property SaldoOCAnticipo As Decimal
Get
If ViewState("SaldoOCAnticipo") Is Nothing Then
Return -1
Else
Return ViewState("SaldoOCAnticipo").ToString.ToDecimal
End If
End Get
Set(value As Decimal)
ViewState("SaldoOCAnticipo") = value
End Set
End Property
Private Property EstaContabilizado As Boolean
Get
Return CBool(ViewState("EstaContabilizado"))
End Get
Set(value As Boolean)
ViewState("EstaContabilizado") = value
End Set
End Property
Private Property CveSolicitudViatico As Integer
Get
Return ViewState("CveSolicitudViatico").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveSolicitudViatico") = value
End Set
End Property
Private Property CFDIRelacionadoSustitucion As String
Get
If ViewState("CFDIRelacionadoSustitucion") Is Nothing Then
Return "-1"
Else
Return ViewState("CFDIRelacionadoSustitucion").ToString
End If
End Get
Set(value As String)
ViewState("CFDIRelacionadoSustitucion") = value
End Set
End Property
Private Property ComplementoSerieFolio As String
Get
Return ViewState("ComplementoSerieFolio").ToString
End Get
Set(value As String)
ViewState("ComplementoSerieFolio") = value
End Set
End Property
Private Property CorreoCobranzaCliente As String
Get
If ViewState("CorreoCobranzaCliente") Is Nothing Then
Return ""
Else
Return ViewState("CorreoCobranzaCliente").ToString
End If
End Get
Set(value As String)
ViewState("CorreoCobranzaCliente") = value
End Set
End Property
Private Property Tipo As String
Get
If ViewState("Tipo") Is Nothing Then
Return ""
Else
Return ViewState("Tipo").ToString
End If
End Get
Set(value As String)
ViewState("Tipo") = value
End Set
End Property
Private Property RazonSocial As String
Get
If ViewState("RazonSocial") Is Nothing Then
Return ""
Else
Return ViewState("RazonSocial").ToString
End If
End Get
Set(value As String)
ViewState("RazonSocial") = value
End Set
End Property
Private Property DtGvRH As DataTable
Get
DtGvRH = DirectCast(ViewState("DtGvRH"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtGvRH") = 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 PorcentajeCompraDevDinC As Decimal
Get
Return ViewState("PorcentajeCompraDevDinC").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("PorcentajeCompraDevDinC") = value
End Set
End Property
Private Property IdCtaAnticipoComplementaria As Integer
Get
Return ViewState("IdCtaAnticipoComplementaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCtaAnticipoComplementaria") = value
End Set
End Property
Private Property IdCtaAnticipoExtranjera As Integer
Get
Return ViewState("IdCtaAnticipoExtranjera").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCtaAnticipoExtranjera") = value
End Set
End Property
Private Property CveEstatusIE As Integer
Get
If ViewState("CveEstatusIE") Is Nothing Then
Return -1
Else
Return ViewState("CveEstatusIE").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveEstatusIE") = value
End Set
End Property
Private Property PermisoComplementoVigente As Boolean
Get
If ViewState("PermisoComplementoVigente") Is Nothing Then
Return False
Else
Return CBool(ViewState("PermisoComplementoVigente"))
End If
End Get
Set(value As Boolean)
ViewState("PermisoComplementoVigente") = value
End Set
End Property
Private Property CveCorte As Integer
Get
If ViewState("CveCorte") Is Nothing Then
Return -1
Else
Return ViewState("CveCorte").ToString().ToEntero()
End If
End Get
Set(value As Integer)
ViewState("CveCorte") = value
End Set
End Property
Private Property Masivonotas As Boolean
Get
If ViewState("Masivonotas") Is Nothing Then
Return False
Else
Return Boolean.Parse(ViewState("Masivonotas").ToString)
End If
End Get
Set(value As Boolean)
ViewState("Masivonotas") = value
End Set
End Property
Private Property ImporteOriginalDolaras As Decimal
Get
If ViewState("ImporteOriginalDolaras") Is Nothing Then
Return 0
Else
Return ViewState("ImporteOriginalDolaras").ToString().ToDecimal()
End If
End Get
Set(value As Decimal)
ViewState("ImporteOriginalDolaras") = value
End Set
End Property
#Region "CANCELACIÓN COMPLEMENTO MODAL V2"
Property CveComplementoPagoCancelar As Integer
Get
If ViewState("CveComplementoPagoCancelar") Is Nothing Then
Return -1
Else
Return ViewState("CveComplementoPagoCancelar").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveComplementoPagoCancelar") = value
End Set
End Property
Property FolioFiscalCancelar As String
Get
If ViewState("FolioFiscalCancelar") Is Nothing Then
Return ""
Else
Return ViewState("FolioFiscalCancelar").ToString
End If
End Get
Set(value As String)
ViewState("FolioFiscalCancelar") = value
End Set
End Property
Property RFCReceptorCancelar As String
Get
If ViewState("RFCReceptorCancelar") Is Nothing Then
Return ""
Else
Return ViewState("RFCReceptorCancelar").ToString
End If
End Get
Set(value As String)
ViewState("RFCReceptorCancelar") = value
End Set
End Property
Property CvePACCancelacion As Integer
Get
If ViewState("CvePACCancelacion") Is Nothing Then
Return -1
Else
Return ViewState("CvePACCancelacion").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CvePACCancelacion") = value
End Set
End Property
#End Region
#Region " R E F E R E N C I A C O N C E P T O O R I G I N A L E S"
Private Property OriReferenciaCIE As String
Get
If ViewState("OriReferenciaCIE") Is Nothing Then
Return ""
Else
Return ViewState("OriReferenciaCIE").ToString
End If
End Get
Set(value As String)
ViewState("OriReferenciaCIE") = value
End Set
End Property
Private Property OriConceptoCIE As String
Get
If ViewState("OriConceptoCIE") Is Nothing Then
Return ""
Else
Return ViewState("OriConceptoCIE").ToString
End If
End Get
Set(value As String)
ViewState("OriConceptoCIE") = value
End Set
End Property
#End Region
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'PDFReciboDePagos(-1, 1336198, 87212, False) '--pago20
'PDFReciboDePagos(-1, 1361624, 87916, False) '--pago20
''PDFReciboDePagos(-1, 1304037, 87219, False)
'Exit Sub
Me.CveCorte = -1
Folio = ""
IDCtaBeneficiario = 0
IDCtaBeneficiarioComplementaria = 0
IDCtaContable = 0
IdCtaAnticipoComplementaria = 0
IdCtaAnticipoExtranjera = 0
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
TxtImporte.Attributes.Add("onblur", "upIE(this);FncImporteCuenta(this);")
'Calendario.StartDate = Now.AddMonths(-2).FirstDayOfMonth()
ViewState("IDPoliza") = "-1"
CveIEDeposito = -1
CveIEDeposito2 = -1
CveOCSolicitudAnticipo = -1
CveMoneda = -1 'SOLO SE UTILIZA PARA SOLICITUD DE ANTICIPO DE OC - CUANDO SE USE PARA ALGO MAS, INDIQUENLO AQUI
CvePrePoliza = -1
CveSolicitudViatico = -1
ComplementoSerieFolio = ""
'TxtFechaDevuelto.Text = Now.ToShortDateString
TxtFechaCancelacion.Text = Now.ToShortDateString
CveCompraDeCDin = -1
'If UsuarioActual.CveEmpresa.Contiene(66) Then trNotificar.Visible = True
'Guarda el modo actual de la pagina
Opcion = If(Request("Opcion") IsNot Nothing, Request("Opcion").ToString, "-1")
Masivonotas = If(Request("Masivo") IsNot Nothing, True, False)
Session("FileUpload") = ""
TRCveIE.Visible = False
CargaTipoTransaccion()
CargaCuenta()
CargaDDLPersonal()
DdlProveedores.setEsWebService(True)
DdlProveedores.Attributes.Add("data-metodo", "getproveedores")
DdlCliente.setEsWebService(True)
DdlCliente.Attributes.Add("data-metodo", "getcliente")
Dim ObjIE As New ClsBancos
'Carga Estatus IE
If ObjIE.GetBancos_EstatusIE() Then
DdlEstatusIE.DataSource = ObjIE.DtResultados
DdlEstatusIE.DataBind()
End If
ObjIE.Dispose()
If Request("CveOrdenCompra") IsNot Nothing AndAlso IsNumeric(Request("CveOrdenCompra")) AndAlso Request("CveOrdenCompra").ToEntero > 0 Then
CveOrdenCompra = Request("CveOrdenCompra").ToEntero
End If
If Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then
CveProveedor = Request("CveProveedor").ToEntero
CargaProveedor(CveProveedor, "-1")
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion") = "DevDinC" AndAlso Request("CveProveedor") IsNot Nothing AndAlso IsNumeric(Request("CveProveedor")) AndAlso Request("CveProveedor").ToEntero > 0 Then
If Masivonotas Then
'CargaNotas()
DVDevolucion.Visible = True
HdnCveProveedor.Value = Request("CveProveedor")
DivOtrosIngresosEgresos.Visible = False
End If
TxtImporte.Attributes.Add("onkeypress", "javascript: return false;")
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion") = "INGPC" Then
If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
DivOtrosIngresosEgresos.Visible = True
End If
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then
LblPagueseA.Text = ""
LblPagueseA.Visible = False
Dim Dt As DataTable = Nothing
Dim Banc As New ClsBancos
Dim CveCredito As Integer = -1
Dim CveCreditoDetalle As Integer = -1
CveCredito = IfNull(Request("CveCredito"), "-1").ToString.ToEntero
CveCreditoDetalle = IfNull(Request("CveCreditoDetalle"), "-1").ToString.ToEntero
LtlTitulo.Text = "Pago de Créditos"
CveIE = -1
DVInteresMoratorio.Visible = True
If Banc.GetCreditos(CveCredito, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
Dt = Banc.DtResultados
End If
Banc.Dispose()
PnlFyE.Visible = False
PnlCredito.Visible = True
DdlFinanciera.DataSource = Dt.FiltraParametros("", DistinctColumns:={"CveProveedor", "Proveedor"}, Orderby:="Proveedor")
DdlFinanciera.DataBind()
If DdlFinanciera.SelectedValue.ToEntero > 0 Then
CargaProveedor(DdlFinanciera.SelectedValue.ToEntero, "-1")
Else
Alert("No se pudieron cargar los datos del proveedor", TipoMensaje.MsgAdvertencia)
End If
If DdlFinanciera.SelectedValue.ToEntero > 0 Then
DdlCredito.DataSource = Dt.FiltraParametros(String.Format("CveProveedor = {0} And EstatusNum In (1,2,101,102)", DdlFinanciera.SelectedValue), DistinctColumns:={"CveCredito", "ReferenciaCredito"}, Orderby:="ReferenciaCredito")
DdlCredito.DataBind()
End If
DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
If CveCredito > 0 Then
'le asigno el valor
DdlCredito.SelectedValue = CveCredito.ToString
If CveCreditoDetalle > 0 Then
CargaCreditosDetalle(CveCreditoDetalle)
End If
End If
End If
If Request("CveIE") IsNot Nothing AndAlso IsNumeric(Request("CveIE")) AndAlso Request("CveIE").ToEntero > 0 Then
ViewState("CveIE") = Request("CveIE")
'Configuración de Modalidad Update
TxtFolio.Enabled = False
TxtFechaDocumento.Enabled = False
Calendario.Enabled = False
TxtImporte.Enabled = False
TxtImporteLetra.Enabled = False
TxtTipoCambio.Enabled = False
DdlCuenta.Enabled = False
'DdlTipo.Enabled = False
DdlTipoTransaccion.Enabled = False
TxtObservaciones.Enabled = False
ChkAplicaImpuestos.Enabled = False
ChkAbonoCuenta.Enabled = False
Anexo.Visible = False
DdlCliente.Enabled = False
DdlProveedores.Enabled = False
DdlPersonal.Visible = False
CargaDatos()
BtnGuardar.Visible = False
LtlTitulo.Text = "Consulta del Ingreso/Egreso:"
'ImgAddObs.Attributes.Add("onclick", "javascript:PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ")
HlEvento.Visible = True
HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveIE=" & CveIE & "&TB_iframe=true&height=370&width=600;"
CargaOCRelacionadas()
Else
'Configuración de Modalidad Insert
ImgAddObs.Visible = False
CveIE = -1
TxtFechaDocumento.Text = Now.ToShortDateString
ImgUpdateCuentaDeposito.Visible = False
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
End If
InicializaSolicitudAnticipoOC()
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT") AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then
RBL.Items.Add(New ListItem("Acreedores Diversos", "AC"))
End If
'If TabCancelacion.Visible Then
' LnkCancelar.Visible = False
' LnkCancelarComplemento.Visible = False
' 'LnkEliminar.Visible = False
' LnkCancelarComplementoImporte.Visible = False
'End If
UppEliminarIE.Update()
'22/06/2018 - VIATICOS
If Request("CveSolicitudViatico") IsNot Nothing AndAlso IsNumeric(Request("CveSolicitudViatico")) AndAlso Request("CveSolicitudViatico").ToEntero > 0 Then
CargaDatosViaticos()
End If
'14/08/2018- PERMISO PARA EDITAR FOLIO
If UsuarioActual.TienePermisoProceso(246) Then
TxtFolio.Enabled = True
End If
InicializaDevolverDinero()
If UsuarioActual.TienePermisoProceso(275) And CveIE > 0 Then
LnkAjustarMovimiento.Visible = True
End If
'If Not VerificaComplementos(True) Then
' LnkCancelarComplemento.Visible = False
' LnkCancelarComplementoImporte.Visible = False
' UppEliminarIE.Update()
'End If
DdlMotivoCancelacion.DataSource = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa).FiltraParametros("CveSATMotivoCancelacion IN (2,3)")
DdlMotivoCancelacion.DataBind()
DdlMotivoCancelacion.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
DvFolioACCondiciones.Visible = True
End If
End If
End Sub
#Region " CARGA DATOS "
Private Sub CargaDatos()
Dim ObjIE As New ClsBancos()
Dim ObjIE2 As New ClsBancos()
If ObjIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.Rows.Count > 0 Then
Dim NumComplementos As Integer
Try
Tipo = ObjIE.DtResultados.Rows(0)("Tipo").ToString
Catch ex As Exception
End Try
CveIEDeposito = ObjIE.DtResultados(0)("CveIEDepositoPadre").ToString.ToEntero
CuentaDepositoPadre = ObjIE.DtResultados(0)("CuentaDepositoPadre").ToString
Cuenta = ObjIE.DtResultados(0)("NumCuenta").ToString
CveIEDeposito2 = ObjIE.DtResultados(0)("CveIEDeposito2").ToString.ToEntero
NumComplementos = ObjIE.DtResultados(0)("NumComplementos").ToString.ToEntero
If UsuarioActual.TienePermisoProceso(99) Then
'BtnActualizar.Visible = True
TxtFechaDocumento.Enabled = True
Calendario.Enabled = True
End If
If ObjIE.CveEstatusNotificacion > 0 Then
trNotificacion.Visible = True
LtNotificacion.Text = If(ObjIE.CveEstatusNotificacion = 1, "Notificado", String.Format("Entregado el {0} - {1}", ObjIE.FechaEntrega, ObjIE.ObservacionEntrega))
End If
'Pestaña Datos Generales
TxtCveIE.Text = ObjIE.CveIE.ToString
CveCuenta = ObjIE.CveCuenta
RBL.Visible = False
RegistraScript("if($get('imgBuscarProveedor')) $get('imgBuscarProveedor').style.display='none';")
'DdlBanco.SelectedValue = ObjIE.CveBanco.ToString
'Abono es Egreso Egs
CargaTipoTransaccion(If(Tipo = "Abono", "Egs", "Ing"))
DdlTipoTransaccion.SelectedValue = ObjIE.CveTipoTransaccion.ToString
DdlCuenta.SelectedValueExist(ObjIE.CveCuenta.ToString)
DdlCuenta.Visible = False
If ObjIE.DtResultados.Rows(0)("CveCuentaTarjeta").ToString.ToEntero > 0 Then
DivTarjetaCredito.Visible = True
LblInfoTarjeta.Text = ObjIE.DtResultados.Rows(0)("NumeroTarjeta").ToString
LblInfoTarjeta.Font.Bold = True
UpInfoTarjeta.Update()
End If
LblCuenta.Text = ObjIE.BancoNumCuentaMoneda
ViewState("CvePrePoliza") = ObjIE.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero
HpLPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}", ViewState("CvePrePoliza"))
HpLPrePoliza.Visible = True
TxtFechaDocumento.Text = ObjIE.FechaDocumento.ToShortDateString
TxtFolio.Text = ObjIE.Folio
LblBeneficiario.Text = ObjIE.PagueseA
TxtImporte.Text = ObjIE.Importe.FormatoNumero
TxtImporteLetra.Text = ObjIE.Importe.Texto2Letras(ObjIE.CveMoneda)
If ObjIE.TipoCambio > 0 Then
TrTipoCambio.Visible = True
Else
TrTipoCambio.Visible = False
End If
TxtTipoCambio.Text = ObjIE.TipoCambio.ToString
TxtObservaciones.Text = ObjIE.Observaciones
If Year(ObjIE.FechaAplicado) > 1 Then TxtFechaAplicado.Text = ObjIE.FechaAplicado.ToShortDateString
ChkAbonoCuenta.Checked = ObjIE.EsAbonoEnCuenta
'ChkAplicaImpuestos.Checked = ObjIE.AplicaImpuestos
'ChkImpreso.Checked = ObjIE.FueImpreso
ChkConciliado.Checked = ObjIE.FueConciliado
DdlEstatusIE.SelectedValue = ObjIE.CveEstatusIE.ToString
DdlEstatusIE.Visible = False
LblEstatusIE.Visible = True
LblEstatusIE.Text = ObjIE.EstatusIE.ToString
If ObjIE.CveTipoTransaccion.Contiene(3, 4) Then 'cuando es cheque recibido
LnkChqDevuelto.Visible = True
End If
'saco el tipo de transaccion
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", ObjIE.CveTipoTransaccion)) 'Egs o Ing
If dr IsNot Nothing Then
If dr("Tipo").ToString = "Egs" Then
LblPagueseA.Text = "Beneficiario"
Else
LblPagueseA.Text = "Pagador"
End If
'Detectamos a quien se le hizo el cobro (Cliente, proveedor, Funcionario/Empleado, etc.)
If ObjIE2.GetPrePolizasDetalle(-1, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
If ObjIE2.DtResultados.Rows.Count > 0 Then
Dim CveConceptoContable As Integer = ObjIE2.DtResultados.FiltroPrimeroValor("CveConceptoContable", "CveConceptoContable <> 30 and CveConceptoContable <> 61").ToEntero
CveCliente = ObjIE2.DtResultados.Rows(0)("CveCliente").ToString.ToEntero
CvePersonal = ObjIE2.DtResultados.Rows(0)("CvePersonal").ToString.ToEntero
CveProveedor = ObjIE2.DtResultados.Rows(0)("CveProveedor").ToString.ToEntero
Select Case CveConceptoContable
Case 66
If ObjIE2.DtResultados.FiltraParametros("CveConceptoContable <> 30 and CveConceptoContable <> 60").Rows(0)("CveCliente").ToString.ToEntero > 0 Then
LblRecibidoPorNombre.Text = "Clientes"
PnlRecibidoPor.Visible = True
End If
Case 37
'' ElseIf ObjIE2.DtResultados.FiltraParametros("CveConceptoContable <> 30 and CveConceptoContable <> 60").Item(0)("CveProveedor").ToString.ToEntero > 0 Then
LblRecibidoPorNombre.Text = "Deudores Diversos"
PnlRecibidoPor.Visible = True
End Select
End If
End If
End If
If CveCliente > 0 Then
DdlCliente.SelectedText = ObjIE.PagueseA
DdlCliente.SelectedValue = CveCliente.ToString
DdlCliente.Visible = False
DdlCliente.Enabled = False
LblPagarA.Visible = True
LblPagarA.Text = ObjIE.PagueseA
' LnkEmitirComplemento.Visible = True
ElseIf CveProveedor > 0 Then
DdlProveedores.SelectedText = ObjIE.PagueseA
DdlProveedores.SelectedValue = CveProveedor.ToString
DdlProveedores.Visible = False
DdlProveedores.Enabled = False
LblPagarA.Visible = True
LblPagarA.Text = ObjIE.PagueseA
'Se prepara para la generacion del envio de correo con notificacion de pago
LnkEnviarMailPago.Attributes.Add("onclick", "$('#ModalDivMail').modal();")
LnkEnviarMailPago.Visible = True
CargaProveedor(CveProveedor, "-1")
ElseIf CvePersonal > 0 Then
PersonalIndexChange(CvePersonal)
DdlPersonal.Visible = True
DdlPersonal.Enabled = False
End If
'SI TIENE EL DATO DEBE MOSTRALO
If UsuarioActual.CveEmpresa = 119 AndAlso LblPagueseA.Text = "Beneficiario" AndAlso Not String.IsNullOrEmpty(ObjIE.PagueseA) Then
LblPagarA.Visible = True
LblPagarA.Text = ObjIE.PagueseA
End If
IDPoliza = ObjIE.IDPoliza
IDCtaContable = ObjIE.IdCtaContable
If ObjIE.IDPoliza > 0 Then
If UsuarioActual.TienePermisoProceso(107) Then
BtnDescontabilizar.Visible = True
End If
BtnContabilizar.Visible = False
HplIrPoliza.Visible = True
HplIrPoliza.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", ObjIE.IDPoliza)
'ImgEliminarMovimiento.OnClientClick = "return confirm('Esta seguro de eliminar el documento y su póliza?');"
LnkEliminar.OnClientClick = "return confirm('¿Está seguro de eliminar el documento y su póliza?');"
EstaContabilizado = True
TxtFechaDocumento.Enabled = False
ImgCalendario.Visible = False
Else
BtnContabilizar.Visible = True
BtnDescontabilizar.Visible = False
HplIrPoliza.Visible = False
EstaContabilizado = False
'TxtFechaDocumento.Enabled = True
'ImgCalendario.Visible = True
End If
UPPDesContabilizar.Update()
'ImgImprimir.Visible = True
LblRegistroFecha.Text = ObjIE.FechaIng.ToString
LblRegistroUsuario.Text = ObjIE.Usuario
CveEstatusIE = ObjIE.CveEstatusIE
Select Case ObjIE.CveEstatusIE
Case 1
If Not ObjIE.FueConciliado Then
'ELIMINAR IE SIN VALIDACIONES
If UsuarioActual.TienePermisoProceso(80) AndAlso NumComplementos = 0 Then LnkEliminar.Visible = True
'ELIMINA IE CUANDO ES EL MISMO USUARIO QUE LO CREO Y QUE NO ESTE CONTABILIZADO NI CONCILIADO
If UsuarioActual.TienePermisoProceso(154) AndAlso ObjIE.CveUsuario = UsuarioActual.CveUsuario And Not ObjIE.IDPoliza > 0 AndAlso NumComplementos = 0 Then
LnkEliminar.Visible = True
End If
End If
If UsuarioActual.TienePermisoProceso(85) Then LnkCancelar.Visible = True
''COMENTAR - solo para pruebas
'If UsuarioActual.TienePermisoProceso(85) Then LnkCancelar.Visible = True
'If UsuarioActual.TienePermisoProceso(80) Then LnkEliminar.Visible = True
ImprimirIEPDF(ObjIE.CveTipoTransaccion)
Case 2
LblEstatus.Text = ObjIE.EstatusIE
LblEstatus.ForeColor = Drawing.Color.Red
'ELIMINAR IE SIN VALIDACIONES
If UsuarioActual.TienePermisoProceso(80) AndAlso NumComplementos = 0 Then LnkEliminar.Visible = True
'ELIMINA IE CUANDO ES EL MISMO USUARIO QUE LO CREO Y QUE NO ESTE CONTABILIZADO NI CONCILIADO
If UsuarioActual.TienePermisoProceso(154) AndAlso ObjIE.CveUsuario = UsuarioActual.CveUsuario And Not ObjIE.IDPoliza > 0 AndAlso NumComplementos = 0 Then
LnkEliminar.Visible = True
End If
If UsuarioActual.CveUsuario = 100 Then
ImprimirIEPDF(ObjIE.CveTipoTransaccion)
End If
'FALTA AFECTAR POLIZA NEGATIVA
'If UsuarioActual.TienePermisoProceso(136) Then LnkEliminar.Visible = True
End Select
'Mostramos seccion cargar comprobante si no tiene estatus cancelado
If ObjIE.CveEstatusIE <> 2 Then
DivCargaComprobante.Visible = True
If ObjIE.Comprobante <> "" Then
TdNotaComprobante.Visible = True
End If
End If
If ObjIE.Comprobante <> "" Then
HplComprobante.Visible = True
HplComprobante.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta($"OP=IEComprobante&Comprobante={ObjIE.Comprobante}"))
End If
If CveIEDeposito > 0 Then
Dim SbMensaje As New StringBuilder()
Dim StrEncript As String = Encripta($"OP=DC&CveIE={CveIE}&CuentaCaja={CuentaDepositoPadre}&CuentaDepo={Cuenta}")
HplListaProveedores.NavigateUrl = $"/Compras/PopUpVerFactura.aspx?P={StrEncript}"
Else
Dim StrEncript As String = Encripta($"OP=ImprimeMov&CveIE={ObjIE.CveIE}")
HplListaProveedores.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", StrEncript)
End If
If CveIEDeposito2 > 0 Then
divDepositado.Visible = True
HplDepositado.NavigateUrl = $"/Bancos/IE.aspx?CveIE={CveIEDeposito2}"
End If
'LnkCancelarComplemento.Visible = False
'LnkCancelarComplementoImporte.Visible = False
DivCancelarComplemento.Visible = False
UppEliminarIE.Update()
CargaEventoBitacora()
CargaGvBitacora()
'Carga Cuenta Deposito o activa para seleccionar una
If ObjIE.CuentaDepositado <> "" Then
TrCuentaDepositado.Visible = True
LitDepositado.Text = ObjIE.CuentaDepositado
Else
If DdlTipoTransaccion.SelectedValue = "9" Then
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
If dtc IsNot Nothing Then
DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus = 'True' ")
If dtc.Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
End If
End If
DdlCuentaDeposito.DataBind()
UpCuentaDeposito.Update()
End If
End If
LnkComplementoPago.Visible = True
If ObjIE.CveEstatusIE = 1 AndAlso ObjIE.CveIECancelado > 0 Then
'cuando es cheque devuelto
TabCancelacion.Visible = True
LbUsuarioCancelacion.Text = ObjIE.UsuarioCancelacion
LbFechaCancelacion.Text = If(ObjIE.FechaCancelacion.ToShortDateString = "01/01/0001", "", ObjIE.FechaCancelacion.ToShortDateString)
LbFechaIngCancelacion.Text = "" ' If(ObjIE.FechaIngCancelacion.ToShortDateString = "01/01/0001", "", ObjIE.FechaIngCancelacion.ToShortDateString)
TrIECancelacion.Visible = True
LbMovimientoCancelado.Text = "Movimiento:"
HLIECancelacion.NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", ObjIE.CveIECancelado)
HLIECancelacion.Text = ObjIE.FolioIECancelado
LnkCancelar.Visible = False
End If
'DATOS DE CANCELACION
If ObjIE.CveEstatusIE = 2 OrElse (ObjIE.CveEstatusIE = 1 AndAlso ObjIE.CveIECancelacion > 0) Then
TabCancelacion.Visible = True
LbUsuarioCancelacion.Text = ObjIE.UsuarioCancelacion
LbFechaCancelacion.Text = ObjIE.FechaCancelacion.ToShortDateString
LbFechaIngCancelacion.Text = If(ObjIE.FechaIngCancelacion.ToShortDateString = "01/01/0001", "", ObjIE.FechaIngCancelacion.ToShortDateString)
'MOVIMIENTO CANCELACION
If ObjIE.CveIECancelacion > 0 Then
TrIECancelacion.Visible = True
LbMovimientoCancelado.Text = "Movimiento de Cancelación:"
HLIECancelacion.NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", ObjIE.CveIECancelacion)
HLIECancelacion.Text = ObjIE.FolioIECancelacion
CveIECancelacion = ObjIE.CveIECancelacion
End If
'MOVIMIENTO CANCELADO
If ObjIE.CveIECancelado > 0 Then
TrIECancelacion.Visible = True
LbMovimientoCancelado.Text = "Movimiento Cancelado:"
HLIECancelacion.NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", ObjIE.CveIECancelado)
HLIECancelacion.Text = ObjIE.FolioIECancelado
CveIECancelado = ObjIE.CveIECancelacion
End If
'Esconde datos que no tenemos
If ObjIE.UsuarioCancelacion = "" Then TrUsuarioCancelacion.Visible = False
If ObjIE.FechaCancelacion.ToShortDateString = "01/01/0001" Then TrFechaCancelacion.Visible = False
If ObjIE.FechaIngCancelacion.ToShortDateString = "01/01/0001" Then TrFechaIngCancelacion.Visible = False
End If
If ObjIE.CveIECancelacion > 0 Then
CveIECancelacion = ObjIE.CveIECancelacion
End If
UpCancelacion.Update()
'OTROS DATOS - DATOS COMPLEMENTO SUSTITUCION
Dim CveIESustitucion As Integer = ObjIE.DtResultados(0)("CveIESustitucion").ToString.ToEntero
If CveIESustitucion > 0 Then
TRComplementoSustitucion.Visible = True
If ObjIE.GetBancosIE(CveIESustitucion, UsuarioActual.CveEmpresa) And ObjIE.DtResultados.Rows.Count > 0 Then
ARefIESustitucion.HRef = String.Format("/Bancos/IE.aspx?CveIE={0}", CveIESustitucion)
ARefIESustitucion.InnerText = ObjIE.Folio
End If
End If
'DETALLES - MOVIMIENTOS
If ObjIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then
GvM.DataSource = ObjIE.DtResultados
If UsuarioActual.TienePermisoProceso(277) AndAlso Not TabCancelacion.Visible Then
GvM.Columns(8).Visible = True
End If
If ObjIE.DtResultados.FiltraParametros("TCPago > 1").Rows.Count.ToEntero() > 0 Then
GvM.Columns(7).Visible = True
End If
If ObjIE.DtResultados.FiltraParametros("CveMonedaIE <> CveMoneda").Rows.Count.ToEntero > 0 Then
GvM.Columns(5).Visible = True
GvM.Columns(6).Visible = True
End If
GvM.DataBind()
End If
'Movimientos Relacionados Padre
If ObjIE.GetBancosIEMovimientosPadre(CveIE, UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.FiltraParametros("TCPago > 1").Rows.Count.ToEntero() > 0 Then
GvRP.Columns(5).Visible = True
End If
GvRP.DataSource = ObjIE.DtResultados
GvRP.DataBind()
End If
'Movimientos Relacionados Hijo
If ObjIE.GetBancosIEMovimientosHijo(CveIE, UsuarioActual.CveEmpresa) Then
DtGvRH = ObjIE.DtResultados
CargaGvRH()
If UsuarioActual.TienePermisoProceso(80) Then GvRH.Columns(5).Visible = True
End If
Else
Alert("El Documento solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
End If
'2019-08-28 unificados vista de controles complemento (Cancelado, conciliciado, Con complemento vigente, sin complemento vigente)
Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
'Dim ExistenComplementos As Boolean = VerificaComplementos(False)
If Not ChkConciliado.Checked And ObjIE.CveEstatusIE <> 2 And ObjIE.CveIECancelacion <= 0 Then
If (Not ExistenComplementosVigentes) Then
If UsuarioActual.TienePermisoProceso(99) Then ' Proceso 99 Editar IE
BtnEditar.Visible = True
PermisoComplementoVigente = True
End If
DVGenerarComplementoModal.Visible = True
BtnEditar.Visible = True
Else
If UsuarioActual.TienePermisoProceso(99) Then
BtnEditar.Visible = True
PermisoComplementoVigente = True
Else
BtnEditar.Visible = False
End If
LnkEliminar.Visible = False
'LnkCancelar.Visible = False
'LnkCancelarComplemento.Visible = True
'LnkCancelarComplementoImporte.Visible = True
DivCancelarComplemento.Visible = True
End If
Else
BtnEditar.Visible = False
' LnkCancelarComplemento.Visible = False
'LnkCancelarComplementoImporte.Visible = False
DivCancelarComplemento.Visible = False
DVGenerarComplementoModal.Visible = False
End If
UpGuardar.Update()
End If
ObjIE.Dispose()
ObjIE2.Dispose()
UPPP.Update()
End Sub
Private Sub CargaGvRH()
GvRH.DataSource = DtGvRH
GvRH.DataBind()
UpGvRH.Update()
End Sub
Private Sub CargaCorteCaja()
'Checar si hay un Turno Abierto
Dim ObjPVenta As New ClsPuntoVenta
If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then
If ObjPVenta.DtResultados.Rows.Count > 0 Then
CveCorte = ObjPVenta.CveCorte
End If
End If
ObjPVenta.Dispose()
'Dim ObjPVenta As New ClsPuntoVenta
'If ObjPVenta.GetCortesPorCuenta(CveCuenta, UsuarioActual.CveEmpresa) Then
' CveCorte = ObjPVenta.CveCorte
'End If
'ObjPVenta.Dispose()
End Sub
#Region " CARGA PROVEEDOR "
Protected Sub DdlProveedores_selectedindexchange(sender As Object, e As EventArgs)
HdnCveProveedor.Value = DdlProveedores.SelectedValue
HdnCvePersonal.Value = "-1"
ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero
ViewState("CvePersonal") = "-1"
ViewState("CveCliente") = "-1"
CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1")
End Sub
Private Sub CargaProveedor(ByVal CveProveedor As Integer, RFC As String)
Dim ObjProveedor As New ClsCompProveedores()
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjProveedor.DtResultados.Rows.Count > 0 Then
TxtNotificarA.Text = ObjProveedor.NotificarA.Trim
TxtParaMail.Text = ObjProveedor.CorreoCobranza
TxtCC.Text = ObjProveedor.NotificarA.Trim
RazonSocial = ObjProveedor.DtResultados(0)("RazonSocial").ToString
HdnProvPorIVA.Value = ObjProveedor.IVA.ToString
HdnProvPorRetIVA.Value = ObjProveedor.RetIVA.ToString
HdnProvPorRetISR.Value = ObjProveedor.RetISR.ToString
Dim EsDevolucion As Boolean = False
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion") = "DevDinC" Then
CveIE = -1
EsDevolucion = True
RBL.SelectedValue = "P"
RBL.Enabled = False
DdlProveedores.Visible = True
DdlProveedores.Enabled = True
IDCtaBeneficiarioComplementaria = ObjProveedor.IdCtaContProveedoresComplementaria
DdlProveedores.SelectedText = ObjProveedor.NombreComercial
DdlProveedores.SelectedValue = ObjProveedor.CveProveedor.ToString
DivOtrosIngresosEgresos.Visible = True
End If
Select Case RBL.SelectedValue
Case "P"
IDCtaBeneficiario = ObjProveedor.IdCtaContAnticipos
IdCtaAnticipoExtranjera = ObjProveedor.IdCtaContAnticiposExtranjera : IdCtaAnticipoComplementaria = ObjProveedor.IdCtaContAnticiposComplementaria
If EsDevolucion Then
IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores
End If
Case "DD" : IDCtaBeneficiario = ObjProveedor.IdCtaContDeudor
Case "AC" : IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor
Case "DP" : IDCtaBeneficiario = ObjProveedor.IdCtaContDocsXPagar
Case Else
IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores
End Select
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then
IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor
If Not IDCtaBeneficiario > 0 Then
Alert("No se pudo cargar IDCtaBeneficiario", TipoMensaje.MsgAdvertencia)
End If
End If
'If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
' BtnGuardar.Enabled = False
' Else
' BtnGuardar.Enabled = True
' End If
' UpGuardar.Update()
'End If
CargaCuentasDepositos()
Else
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjProveedor.Dispose()
End Sub
#End Region
Private Sub CargaNotas(CvemonedaInterna As Integer)
Dim ObjMovtos As New ClsMovimientos()
If CvemonedaInterna > 0 Then
If ObjMovtos.GetAnticiposProveedor(CveProveedor, -1, CvemonedaInterna, -1) AndAlso ObjMovtos.DtResultados.FiltraParametros("TipoDocto = 'NC'").Rows.Count > 0 Then
GvA.DataSource = ObjMovtos.DtResultados.FiltraParametros("TipoDocto = 'NC' and Saldo > 0 and CveCompra > 0")
Else
GvA.DataSource = Nothing
End If
Else
GvA.DataSource = Nothing
End If
ObjMovtos.Dispose()
GvA.DataBind()
UpGvNotas.Update()
End Sub
Protected Sub GvAH_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvA.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then 'e.Row.BackColor = Drawing.Color.LightGray
e.Row.Cells(1).Width = Unit.Pixel(120)
e.Row.Cells(2).Width = Unit.Pixel(100)
e.Row.Cells(3).Width = Unit.Pixel(100)
e.Row.Cells(4).Width = Unit.Pixel(100)
End If
'If e.Row.DBCampo("TipoDocto") = "Egsc" AndAlso e.Row.DBCampo("SerieFolio") = "" Then
' e.Row.CssClass = "Totales TextCenter"
' e.Row.Cells(1).Text = "Egreso Por Comprobar"
'End If
'If e.Row.DBCampo("TipoDocto") = "Ant" AndAlso e.Row.DBCampo("SerieFolio") = "" Then
' e.Row.CssClass = "Totales TextCenter"
' e.Row.Cells(1).Text = "Anticipos"
'End If
If e.Row.DBCampo("TipoDocto") = "NC" AndAlso e.Row.DataKey("CveCompra").ToString.ToEntero > 0 Then
e.Row.FCCheckBox("Chk").InputAttributes.Add("data-saldo", e.Row.DataKey("Saldo"))
End If
'If e.Row.DBCampo("TipoDocto") = "DEV" AndAlso e.Row.DBCampo("SerieFolio") = "" Then
' e.Row.CssClass = "Totales TextCenter"
' e.Row.Cells(0).Text = "Devolución"
'End If
'If e.Row.DBCampo("CveProveedor") = "" Then
' e.Row.BackColor = Drawing.Color.LightGray
'End If
'If UsuarioActual.TienePermisoProceso(273) Then
' If CType(sender, GridView).ID = "GvA" And e.Row.DBCampo("CveCompra").ToEntero > 0 And e.Row.DBCampo("TipoDocto") = "NC" Then
' Dim Parametros = Encripta($"CveCompra={e.Row.DBCampo("CveCompra").ToEntero}&SerieFolio={e.Row.DBCampo("SerieFolio")}&CveMoneda={e.Row.DBCampo("CveMoneda")}&CveProveedor={CveProveedor}&Saldo={e.Row.DBCampo("Saldo")}&Original={e.Row.DBCampo("Original")}&CvePrePoliza={e.Row.DBCampo("CvePrePoliza")}&FechaCompra={e.Row.DBCampo("Fecha")}")
' e.Row.FCHyperLink("HLDevolverDinero").Visible = True
' e.Row.FCHyperLink("HLDevolverDinero").NavigateUrl = $"/Bancos/IE.aspx?Opcion=DevDinC&P={Parametros}"
' End If
'End If
End If
End Sub
#Region " CARGA CLIENTE "
Protected Sub DdlCliente_selectedindexchange(sender As Object, e As EventArgs)
HdnCveCliente.Value = DdlCliente.SelectedValue
HdnCveProveedor.Value = "-1"
ViewState("CveCliente") = HdnCveCliente.Value.ToEntero
ViewState("CveProveedor") = -1
ViewState("CvePersonal") = -1
CargaCliente(HdnCveCliente.Value.ToEntero)
End Sub
Private Sub CargaCliente(ByVal CveCliente As Integer)
Dim ObjCliente As New ClsClientes
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
HdnProvPorIVA.Value = "0" 'ObjProveedor.IVA.ToString
HdnProvPorRetIVA.Value = "0" 'ObjProveedor.RetIVA.ToString
HdnProvPorRetISR.Value = "0" 'ObjProveedor.RetISR.ToString
IDCtaBeneficiario = ObjCliente.IdCtaContAnticipos
IDCtaBeneficiarioComplementaria = ObjCliente.IdCtaContCompAnticipos
CorreoCobranzaCliente = ObjCliente.CobranzaCorreo
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion") = "DevDinV" Then
IDCtaBeneficiario = ObjCliente.IdCtaContClientes
IDCtaBeneficiarioComplementaria = ObjCliente.IdCtaContCompClientes
DdlCliente.SelectedText = ObjCliente.NombreComercial
DdlCliente.SelectedValue = ObjCliente.CveCliente.ToString
DivOtrosIngresosEgresos.Visible = True
End If
'If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
' Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
' BtnGuardar.Enabled = False
' Else
' BtnGuardar.Enabled = True
' End If
' UpGuardar.Update()
'End If
CargaCuentasDepositos()
Else
Alert("El Cliente solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjCliente.Dispose()
End Sub
#End Region
#Region " CARGA PERSONAL "
Protected Sub CargaDDLPersonal()
Dim ObjPersonal As New ClsRH
If ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa) Then
If ObjPersonal.DtResultados.Rows.Count > 0 Then
DdlPersonal.DataSource = ObjPersonal.DtResultados
DdlPersonal.DataBind()
DdlPersonal.Items.Insert(0, New ListItem("Seleccione Personal", "-1"))
End If
End If
ObjPersonal.Dispose()
End Sub
Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs)
HdnCveProveedor.Value = "-1"
HdnCvePersonal.Value = DdlPersonal.SelectedValue
ViewState("CveProveedor") = "-1"
ViewState("CvePersonal") = HdnCvePersonal.Value
ViewState("CveCliente") = "-1"
PersonalIndexChange(HdnCvePersonal.Value.ToEntero)
End Sub
Private Sub PersonalIndexChange(ByVal CvePersonal As Integer)
Dim ObjPersonal As New ClsRH
If ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) Then
If ObjPersonal.DtResultados.Rows.Count > 0 Then
DdlPersonal.SelectedValue = CvePersonal.ToString
HdnProvPorIVA.Value = "0" 'ObjProveedor.IVA.ToString
HdnProvPorRetIVA.Value = "0" 'ObjProveedor.RetIVA.ToString
HdnProvPorRetISR.Value = "0" 'ObjProveedor.RetISR.ToString
IDCtaBeneficiario = ObjPersonal.IdCtaContPersonal
'If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
' Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
' BtnGuardar.Enabled = False
' Else
' BtnGuardar.Enabled = True
' End If
' UpGuardar.Update()
'End If
CargaCuentasDepositos()
Else
Alert("El Personal solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjPersonal.Dispose()
End Sub
#End Region
#Region " CARGA CUENTAS DEPOSITOS "
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
Dim valor As Integer = DirectCast(sender, DropDownList).SelectedValue.ToEntero
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
If dr IsNot Nothing Then
HdnTipoTransaccion.Value = dr("Tipo").ToString
End If
Select Case valor
Case 1
LblPagueseA.Text = "Páguese a"
Case 2
LblPagueseA.Text = "Beneficiario"
End Select
'RecargaCuentas
CargaCuenta(CveMoneda)
RecargaCuentasDepositos()
UpDatos.Update()
BtnGuardar.Enabled = True
End Sub
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
'si solo es de egreso el movimiento debe de generar el siguiente folio.
Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
Dim ActualizaCuenta As Boolean = False
If (Not ExistenComplementosVigentes) And UsuarioActual.TienePermisoProceso(99) And BtnActualizar.Visible = True Then
ActualizaCuenta = True
End If
If HdnTipoTransaccion.Value = "Egs" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Or Opcion = "DevDinC" Or ActualizaCuenta 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
Dim drI As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If drI IsNot Nothing Then
CargaNotas(drI("CveMoneda").ToString.ToEntero)
Else
CargaNotas(-1)
End If
Else
TxtFolio.Text = ""
End If
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If dr IsNot Nothing Then
CveMoneda = dr("CveMoneda").ToString.ToEntero
IDCtaContable = dr("IdCtaContable").ToString.ToEntero
IDCtaContableComplementaria = dr("IDCtaContableComplementaria").ToString.ToEntero
CambiaTipoMoneda()
If Opcion IsNot Nothing AndAlso Opcion.Contiene("EGSSINFACT") Then
If dr("CveTipoCuenta").ToString.ToEntero = 1 Then
Dim ObjMovtos As New ClsMovimientos
If DdlCuenta.SelectedValue.ToEntero > 0 Then
ObjMovtos.GetCajaChicaDetalle(DdlCuenta.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
If ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha").Rows.Count > 0 Then
DDlCheques.DataSource = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha")
DDlCheques.DataBind()
DDlCheques.Items.Insert(0, New ListItem("-", "-1"))
DivCheques.Visible = True
End If
End If
ObjMovtos.Dispose()
Else
DivCheques.Visible = False
End If
End If
'PAGAR NC CON C.CH DEBE DESCONTAR EN EL CORTE
If Opcion IsNot Nothing AndAlso Opcion = "DevDinV" AndAlso dr("CveTipoCuenta").ToString.ToEntero = 1 Then
CargaCorteCaja()
End If
If dr("UsaTarjeta").ToString = "True" Then
CargaGridTarjetas()
Else
DivTarjeta.Visible = False
End If
If Not IDCtaContable > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
Alert("La Cuenta Bancaria no tiene asignada una cuenta contable", TipoMensaje.MsgAdvertencia)
End If
End If
If trIEDevolucion.Visible And RBL.SelectedValue <> "C" Then
CargaIEDevoluciones()
End If
End Sub
#End Region
#Region " CARGA CREDITOS - DETALLE "
Protected Sub DdlFinanciera_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFinanciera.SelectedIndexChanged
CargaCreditos(DdlFinanciera.SelectedValue.ToEntero)
End Sub
Private Sub CargaCreditos(CveProveedor As Integer)
If CveProveedor < 1 Then Exit Sub
Dim Cred As New ClsBancos
Dim dt As DataTable = Nothing
If Cred.GetCreditos(-1, -1, -1, CveProveedor, -1, UsuarioActual.CveEmpresa) Then
CveProveedor = Cred.CveProveedor
DdlCredito.DataSource = Cred.DtResultados.FiltraParametros(String.Format("CveProveedor = {0} AND EstatusNum in (1,2,101,102)", DdlFinanciera.SelectedValue), DistinctColumns:={"CveCredito", "ReferenciaCredito"}, Orderby:="ReferenciaCredito")
DdlCredito.DataBind()
DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
Cred.Dispose()
DdlCreditoDetalle.Items.Clear()
DdlCreditoDetalle.DataSource = Nothing
DdlCreditoDetalle.DataBind()
End Sub
Protected Sub DdlCredito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCredito.SelectedIndexChanged
CargaCreditosDetalle()
End Sub
Protected Sub DdlCreditoDetalle_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaCreditosDetalle(DdlCreditoDetalle.SelectedValue.ToEntero)
End Sub
Private Sub CargaCreditosDetalle(Optional CveCreditoDetalle As Integer = -1)
Dim Cred As New ClsBancos
Dim dt As DataTable = Nothing
Dim dt2 As DataTable = Nothing
If DdlCredito.SelectedValue.ToEntero > 0 AndAlso Cred.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
CveProveedor = Cred.CveProveedor
HdnCveTipoCredito.Value = Cred.CveTipoCredito.ToString
If Cred.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then
dt = Cred.DtResultados.FiltraParametros("Estatus IN (1,101,102)")
Dim Importe As Decimal = 0
If CveCreditoDetalle > 0 Then
Dim drt As DataRow = Cred.DtResultados.FiltroPrimero(String.Format("CveCreditoDetalle = {0}", CveCreditoDetalle))
If drt IsNot Nothing Then
'verifico si es credito está activo
If Not drt("Estatus").ToString.Contiene("1", "101", "102") Then
Alert("La Mensualidad no está vigente para pago", TipoMensaje.MsgError)
End If
Importe = dt.FiltroPrimeroValor("Mensualidad", String.Format("CveCreditoDetalle = {0}", CveCreditoDetalle)).ToDecimal
End If
End If
TxtImporte.Text = Importe.ToString
HdnImporteCredito.Value = Importe.ToString
RegistraScript(String.Format("$get('TxtImporte').value = '{0}';", Importe.FormatoNumero))
TxtImporte.Attributes.Remove("onkeyup")
TxtImporte.Attributes.Add("onkeyup", String.Format("ValidaCantidad({0},{1});", TxtImporte.ClientID, Importe))
End If
End If
Cred.Dispose()
DdlCreditoDetalle.Items.Clear()
If dt IsNot Nothing Then
DdlCreditoDetalle.DataSource = dt
End If
DdlCreditoDetalle.DataBind()
If CveCreditoDetalle = -1 Then
DdlCreditoDetalle.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlCreditoDetalle.SelectedValue = "-1"
Else
DdlCreditoDetalle.SelectedValueExist(CveCreditoDetalle.ToString)
Try
TxtObservaciones.Text = String.Format("{0} {1} {2}", DdlFinanciera.SelectedItem.Text, DdlCredito.SelectedItem.Text, DdlCreditoDetalle.SelectedItem.Text)
Catch ex As Exception
End Try
End If
UpDatos.Update()
End Sub
#End Region
#End Region
#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
Private Sub CargaCuenta(Optional pCveMoneda As Integer = -1)
DdlCuenta.Items.Clear()
Dim dt As DataTable
If UsuarioActual.Empresa.Funcionalidad(127) = "1" Then
dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
Else
dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveTipoCuenta <> 1") ' quito las cajas chicas
End If
If pCveMoneda > 0 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", pCveMoneda))
End If
'cuando es layout
If DdlTipoTransaccion.SelectedValue.ToEntero = 9 Then
dt = dt.FiltraParametros("UsaLayout = 1")
End If
DdlCuenta.DataSource = dt
DdlCuenta.DataBind()
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargaTipoTransaccion(Optional Tipo As String = "")
Dim dt As DataTable
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT", "EGSCREDITO") Then
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs' AND Estatus = 1")
LtlTitulo.Text = "Egreso Por Comprobar"
RBL.Items.Remove(RBL.Items.FindByValue("C"))
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "DEV" Then
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1 ")
LtlTitulo.Text = If(Request("Opcion").ToString = "INGPC", "Ingreso por comprobar", "Devolución")
LblPagueseA.Text = "Recibido de:"
RBL.SelectedValue = "C"
Anexo.Visible = True
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "INGPC" Then
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1")
LtlTitulo.Text = If(Request("Opcion").ToString = "INGPC", "Ingreso por comprobar", "Devolución")
LblPagueseA.Text = "Recibido de:"
RBL.SelectedValue = "C"
Anexo.Visible = True
RBL.Items.Remove(RBL.Items.FindByValue("P"))
RBL.Items.Remove(RBL.Items.FindByValue("FE"))
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1 ")
LtlTitulo.Text = "Anticipo de Cliente"
LblPagueseA.Text = "Recibido de:"
Anexo.Visible = True
RBL.Items.Remove(RBL.Items.FindByValue("P")) : RBL.Items.Remove(RBL.Items.FindByValue("FE")) : RBL.Items.Remove(RBL.Items.FindByValue("DD")) : RBL.Items.Remove(RBL.Items.FindByValue("AC")) : RBL.Items.Remove(RBL.Items.FindByValue("DP"))
ElseIf Opcion = "DevDinV" Then ' DEVOLUCION DINERO NC-VENTAS
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs' AND Estatus = 1 ")
LtlTitulo.Text = "Devolución dinero"
RBL.SelectedValue = "C"
RBL.Enabled = False
Else
dt = GlobalDTTipoTransacciones
End If
If Opcion = "DevDinC" AndAlso Request("P") IsNot Nothing AndAlso Request("P").Length > 0 Or Opcion = "DevDinC" AndAlso Masivonotas Then
DdlTipoTransaccion.DataSource = dt.FiltraParametros("Tipo = 'Ing' AND Estatus = 1 ")
Else
DdlTipoTransaccion.DataSource = dt
End If
If Tipo.Length > 0 Then
DdlTipoTransaccion.Items.Clear()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}' AND Estatus = 1 ")
End If
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
RBL_SelectedIndexChanged(RBL, Nothing)
End Sub
#End Region
#Region "VIATICOS"
Private Function TimbrarNomina12(CvePersonal As Integer) As String
Dim Retorno As String = ""
UsuarioActual.Empresa.CvePAC = 2
Dim sw As New Diagnostics.Stopwatch
sw.Start()
Select Case UsuarioActual.Empresa.CvePAC
Case 1
'Retorno = TimbrarBIInformNomina12(CveNomina, CvePersonal, CvePeriodo)
Case 2, 4
Dim cfdi As CFDITimbre = PreTimbrar(CvePersonal)
If cfdi Is Nothing Then
sw.Stop()
Return "No tiene asignado un folio de viaticos"
End If
If cfdi IsNot Nothing AndAlso cfdi.Mensaje = "" Then
Dim ObjTimbrado As New Timbrado
Dim ObjFactura As New Modelos.Factura
ObjFactura.TipoDocto = "Viaticos"
ObjFactura.Folio = cfdi.Comprobante.Folio.ToEntero
ObjFactura.Serie = cfdi.Comprobante.Serie
ObjFactura.Timbre = cfdi
If Not ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then
Retorno = ObjTimbrado.MensajeErrorCFDI
End If
'Retorno = TimbrarFacturaRealVirtual(cfdi, UsuarioActual)
If Retorno <> "" Then
Retorno = $"{Retorno} - {cfdi.Receptor.Nombre}"
Else
'Genero la addenda Ford
' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo)
End If
Else
Retorno = $"No se pudo generar el pretimbre: <br/> {cfdi.Mensaje}"
End If
End Select
sw.Stop()
GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC, "Nomina")
Return Retorno
End Function
Private Function PreTimbrar(CvePersonal As Integer) As CFDITimbre
Dim cfdi As New CFDITimbre
Dim ObjFolio As New ClsGralFolios
If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then
If ObjFolio.DtResultados.Rows.Count > 0 Then
Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString
Else
ObjFolio.Dispose()
Return Nothing
End If
End If
ObjFolio.Dispose()
Dim objPersonal As New ClsRH
objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa)
Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero
cfdi.Nomina = New CFDINomina
cfdi.Nomina.Version = "1.2"
cfdi.Nomina.TipoNomina = "E"
cfdi.Nomina.FechaPago = TxtFechaDocumento.Text.ToDate
cfdi.Nomina.FechaInicio = TxtFechaDocumento.Text
cfdi.Nomina.FechaFin = TxtFechaDocumento.Text
cfdi.Nomina.NumDiasPagados = 1
cfdi.Emisor.Nombre = UsuarioActual.Empresa.Empresa
cfdi.Emisor.RFC = UsuarioActual.Empresa.RFC
cfdi.Emisor.RegistroPatronal = objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString()
cfdi.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal
'aplica persona fisica debe de tener CURP
If cfdi.Emisor.RegimenFiscal.Contiene("605", "606", "608", "611", "612", "614", "616", "621", "622", "629", "630", "615") Then
cfdi.Emisor.CURP = UsuarioActual.Empresa.CURP
End If
cfdi.Receptor.UsoCFDI = "P01"
cfdi.Receptor.RFC = objPersonal.RFC
cfdi.Receptor.Nombre = objPersonal.NombreCompleto
Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos)
ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "003",
.Clave = "003",
.Concepto = "Viáticos (entregados al trabajador).",
.Importe = TxtImporte.Text.ToString.ToDecimal
}
)
If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos
cfdi.Comprobante.Version = "3.3"
cfdi.Comprobante.Serie = "VIA"
cfdi.Comprobante.Folio = Folio
cfdi.Comprobante.Fecha = Now
cfdi.Comprobante.Subtotal = TxtImporte.Text.ToDecimal
cfdi.Comprobante.Descuentos = 0
cfdi.Comprobante.Total = TxtImporte.Text.ToDecimal
cfdi.Comprobante.MotivoDescuento = ""
cfdi.Comprobante.Moneda = "MXN"
cfdi.Comprobante.TipoComprobante = "N"
cfdi.Comprobante.TipoDocto = "Egs"
cfdi.Comprobante.MetodoPago = "PUE"
cfdi.Comprobante.CondicionesdePago = ""
cfdi.Comprobante.FormadePago = "99"
cfdi.Comprobante.LugarExpedicion = UsuarioActual.Empresa.CP.ToString
cfdi.Comprobante.NumCuentaPago = ""
cfdi.Nomina.Receptor.CURP = objPersonal.CURP
cfdi.Nomina.Receptor.NSS = objPersonal.NumeroSS
cfdi.Nomina.Receptor.FechaInicioContrato = objPersonal.FechaInicioContrato.ToShortDateString
cfdi.Nomina.Receptor.Antiguedad = $"P{AntiguedadSemanas}W"
cfdi.Nomina.Receptor.TipoContrato = objPersonal.CodigoTipoContrato
cfdi.Nomina.Receptor.CodigoTipoJornada = objPersonal.ClaveTipoJornada
cfdi.Nomina.Receptor.CodigoRegimenContratacion = If(objPersonal.CveRegimenContratacion = "", "99", objPersonal.CveRegimenContratacion)
cfdi.Nomina.Receptor.CodigoEmpleado = objPersonal.Codigo
cfdi.Nomina.Receptor.Departamento = objPersonal.Departamento
cfdi.Nomina.Receptor.Puesto = objPersonal.Puesto
cfdi.Nomina.Receptor.CodigoRiesgoPuesto = If(objPersonal.CveSATRiesgoPuesto.ToString = "0", "99", objPersonal.CveSATRiesgoPuesto.ToString)
cfdi.Nomina.Receptor.TipoPeriodo = objPersonal.TipoPeriodoPago
cfdi.Nomina.Receptor.CodigoBanco = objPersonal.ClaveBanco
cfdi.Nomina.Receptor.NumeroCuenta = objPersonal.BancoNumCuenta
cfdi.Nomina.Receptor.SDI = objPersonal.SDI
cfdi.Nomina.Receptor.SBC = objPersonal.SDI
cfdi.Nomina.Receptor.Sindicalizado = ""
cfdi.Nomina.Receptor.CodigoEntidadFederativa = objPersonal.ClaveEstado
cfdi.Conceptos.Add(New CFDIConceptos With {.Cantidad = 1, .ClaveUnidad = "ACT", .ClaveProdServ = "84111505", .Descripcion = "Pago de nómina", .ValorUnitario = cfdi.Comprobante.Subtotal, .Importe = cfdi.Comprobante.Subtotal, .Descuento = cfdi.Nomina.TotalDeducciones.ToDecimal})
objPersonal.Dispose()
Return cfdi
End Function
'Private Function TimbrarBIInformNomina12(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As String
' If UsuarioActual.CveEmpresa = 8 Then
' UsuarioActual.Empresa.FacturaProduccion = True
' End If
' 'UsuarioActual.Empresa.FacturaProduccion = False
' Dim MsgError As String = String.Empty
' Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI
' CFDi.ObjCompNomina12 = New ClbNegBICFDv3_2.ClsNegComplementoNomina12()
' 'CFDi.ObjCompNomina = New ClbNegBICFDv3_2.ClsNegCompNomina
' Dim objPersonal As New ClsRH
' 'Dim objNomina As New ClsNominas
' objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa)
' 'objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa)
' Dim Total As Decimal = 0
' Dim SubTotal As Decimal = 0
' Dim Descuentos As Decimal = 0
' Dim RetISR As Decimal = 0
' Dim TotalExcento As Decimal = 0
' Dim TotalGravado As Decimal = 0
' Dim TotalPercepciones As Decimal = 0
' Dim TotalDeducciones As Decimal = 0
' Dim TotalOtrosPagos As Decimal = 0
' Dim Serie As String = ""
' Dim Folio As String = ""
' Dim NominaFolio As String = Serie & "-" & Folio
' Dim RFC As String = objPersonal.RFC.Trim
' Dim Nombre As String = objPersonal.NombreCompleto.Trim
' Dim Direccion As String = String.Format("{0} {1} {2}", objPersonal.Calle.Trim, objPersonal.NumExt.Trim, objPersonal.NumInt.Trim).Trim
' Dim Ciudad As String = objPersonal.Ciudad.Trim
' Dim Estado As String = objPersonal.Estado.Trim
' Dim CP As String = objPersonal.CP.Trim
' 'Dim TipoContrato As String = GlobalDTTiposContrato.FiltraParametros("CveTipoContrato = " + objPersonal.CveTipoContrato.ToString)(0)("TipoContrato").ToString
' 'Dim TipoPeriodo As String = GlobalDTTipoPeriodo.FiltraParametros("CveTipoPeriodo = " + objPersonal.CveTipoPeriodo.ToString)(0)("TipoPeriodo").ToString
' Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero
' Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi
' Dim FechaInicio, FechaFin, FechaPago As Date
' Dim DiasPagados As Integer = 0
' Dim Msg As String = String.Empty
' Dim DiasIncapacitados As Integer = 0
' Dim DrPeriodo As DataRow = Nothing
' Dim ObjFolio As New ClsGralFolios
' If ObjFolio.GetFolios("VIA", UsuarioActual.CveEmpresa) Then
' If ObjFolio.DtResultados.Rows.Count > 0 Then
' Folio = ObjFolio.DtResultados.Rows(0)("FActual").ToString
' End If
' End If
' 'If objNomina.GetPeriodos(-1, -1, -1, -1, CvePeriodo) Then
' ' If objNomina.DtResultados.Rows().Count > 0 Then
' ' DrPeriodo = objNomina.DtResultados.Rows(0)
' ' End If
' 'End If
' 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("")
' If DrPeriodo IsNot Nothing Then
' FechaInicio = DrPeriodo("FechaInicio").ToString.ToDate
' FechaFin = DrPeriodo("FechaFin").ToString.ToDate
' FechaPago = DrPeriodo("FechaPago").ToString.ToDate
' If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then
' Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero
' Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero
' DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero
' DiasPagados = Asistencias - Vacaciones
' If DiasPagados < 0 Then DiasPagados = 0
' End If
' End If
' Dim DtPercepciones As Data.DataTable = Nothing
' Dim DtDeducciones As Data.DataTable = Nothing
' Dim DtOtrosPagos As Data.DataTable = Nothing
' 'If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then
' ' If objNomina.DtResultados.Rows.Count > 0 Then
' ' DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ")
' ' DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ")
' ' TotalPercepciones = DtPercepciones.SUM("Importe")
' ' TotalDeducciones = DtDeducciones.SUM("Importe")
' ' Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal)
' ' End If
' 'End If
' 'Tipo Nomina O de Ordinaria o E de extraordinaria
' 'Dim FechaPago As Date = Now
' Dim TotalSueldos As Decimal = 0
' Dim TotalIndemnizacion As Decimal = 0
' Dim TotalJubilacion As Decimal = 0
' Msg = CFDi.ObjCompNomina12.Cargar("O", FechaPago, FechaInicio, FechaFin, DiasPagados, TotalPercepciones, TotalDeducciones, 0)
' If Msg = String.Empty Then
' If DtPercepciones IsNot Nothing Then
' If DtPercepciones.Rows.Count > 0 Then
' TotalSueldos = DtPercepciones.SUM("Importe", "SATCveConcepto = '001'")
' TotalIndemnizacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('022','023','025')") ' https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf
' TotalJubilacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('039','044')") 'https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf
' Msg = CFDi.ObjCompNomina12.CargarPercepciones(TotalSueldos, TotalIndemnizacion, TotalJubilacion, DtPercepciones.SUM("ImporteGravado").ToDecimal, DtPercepciones.SUM("ImporteExento").ToDecimal)
' End If
' For Each Row As DataRow In DtPercepciones.Rows
' If Row("Importe").ToString.ToDecimal > 0 Then
' If Row("CveSATConcepto").ToString = "" Then
' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString)
' Else
' Msg = CFDi.ObjCompNomina12.AgregarPercepcion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, Row("ImporteGravado").ToString.ToDecimal, Row("ImporteExento").ToString.ToDecimal)
' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal
' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal
' SubTotal = SubTotal + Row("Importe").ToString.ToDecimal
' End If
' If Msg <> String.Empty Then
' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Percepcion", New Exception)
' Exit For
' End If
' End If
' 'RMF, falta poner el numero de horas pagadas
' If Row("CveSATConcepto").ToString.ToEntero = 19 Then 'cuando son horas extras
' 'Obtengo el desglose de horas extras
' If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then
' Dim dr As DataRow = objNomina.DtResultados.FiltroPrimero("")
' If dr IsNot Nothing Then
' If dr("HorasDobles").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasDobles").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Dobles, dr("HorasDobles").ToString.ToEntero, Row("Importe").ToString.ToDecimal)
' If dr("HorasTriples").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasTriples").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Triples, dr("HorasTriples").ToString.ToEntero, Row("Importe").ToString.ToDecimal)
' End If
' End If
' End If
' Next
' If Msg = "" Then
' CFDi.ObjCompNomina12.ObjPercepciones.TotalExento = TotalExcento
' CFDi.ObjCompNomina12.ObjPercepciones.TotalGravado = TotalGravado
' End If
' End If
' 'cargo las incapacidades
' If DiasIncapacitados > 0 Then
' If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then
' CFDi.ObjCompNomina12.CargarIncapacidades()
' For Each dr As DataRow In objNomina.DtResultados.Rows
' CFDi.ObjCompNomina12.AgregarIncapacidad(dr("Dias").ToString.ToDecimal, dr("ClaveTipoIncapacidad").ToString.ToEntero, dr("Descuento").ToString.ToDecimal)
' Next
' End If
' End If
' TotalExcento = 0
' TotalGravado = 0
' If Msg = String.Empty Then
' If DtDeducciones IsNot Nothing Then
' If DtDeducciones.Rows.Count > 0 Then
' Total = CType((Total - DtDeducciones.SUM("Importe")), Decimal)
' CFDi.ObjCompNomina12.CargarDeducciones(CType(DtDeducciones.SUM("ImporteGravado"), Decimal), CType(DtDeducciones.SUM("ImporteExento"), Decimal))
' End If
' For Each Row As DataRow In DtDeducciones.Rows
' If Row("Importe").ToString.ToDecimal > 0 Then
' If Row("CveSATConcepto").ToString = "" Then
' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString)
' Else
' Msg = CFDi.ObjCompNomina12.AgregarDeduccion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0)
' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal
' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal
' If Row("CveSATConcepto").ToString.ToEntero = 3 Then
' RetISR = RetISR + Row("Importe").ToString.ToDecimal
' Else
' Descuentos = Descuentos + Row("Importe").ToString.ToDecimal
' End If
' End If
' If Msg <> String.Empty Then
' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Deduccion", New Exception)
' Exit For
' End If
' End If
' Next
' If Msg = "" Then
' If CFDi.ObjCompNomina12.ObjDeducciones IsNot Nothing Then
' CFDi.ObjCompNomina12.ObjDeducciones.TotalOtrasDeducciones = Descuentos
' CFDi.ObjCompNomina12.ObjDeducciones.TotalImpuestosRetenidos = RetISR
' End If
' End If
' End If
' If Msg = String.Empty Then
' If DtOtrosPagos IsNot Nothing Then
' If DtOtrosPagos.Rows.Count > 0 Then
' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal)
' CFDi.ObjCompNomina12.CargarOtrosPagos()
' End If
' For Each Row As DataRow In DtOtrosPagos.Rows
' If Row("Importe").ToString.ToDecimal > 0 Then
' If Row("CveSATConcepto").ToString = "" Then
' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString)
' Else
' Msg = CFDi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0)
' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0)
' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0)
' End If
' If Msg <> String.Empty Then
' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception)
' Exit For
' End If
' End If
' Next
' End If
' If Msg = String.Empty Then
' Dim x As Integer = 0
' Dim Moneda As String = "MXN"
' Dim LugarExp As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} ", SucCalle, SucNoExt, SucNoInt, SucColonia, SucLocalidad, SucMunicipio, SucEstado, SucPais, SucCP)
' Dim FechaFactura As DateTime = Now
' 'Nodo Comprobante
' Dim TipoComprobante As ClbNegBICFDv3_2.TipoDeComprobante = ClbNegBICFDv3_2.TipoDeComprobante.egreso
' Msg = CFDi.comprobantecfd(0, 0, Serie, Folio, FechaFactura, "PAGO EN UNA SOLA EXHIBICION", "CONTADO", SubTotal, Descuentos, "Deducciones nómina", "1", Moneda, Total, objPersonal.MetodoPagoSAT, ClbNegBICFDv3_2.TipoDeComprobante.egreso, LugarExp, "", "", "", New Date(1900, 1, 1), 0)
' If Msg = String.Empty Then
' 'Nodo emisor
' Msg = CFDi.ObjCompNomina12.CargarEmisor("", objPersonal.DtResultados.Rows(0)("RegistroPatronal").ToString(), UsuarioActual.Empresa.RFC)
' 'If Msg = String.Empty Then Msg = CFDi.EmisorRegimen(UsuarioActual.Empresa.CodigoRegimenFiscal)
' If Msg = String.Empty Then
' 'Nodo Entidad SNCF
' If 1 = 2 Then 'cuando es gobierno
' Msg = CFDi.ObjCompNomina12.CargarEntidadSNCF("", 0)
' End If
' If Msg = String.Empty Then
' 'Nodo Receptor
' Msg = CFDi.ObjCompNomina12.CargarReceptor(objPersonal.CURP, objPersonal.NumeroSS, objPersonal.FechaInicioContrato, AntiguedadSemanas, objPersonal.TipoContrato, "", objPersonal.ClaveTipoJornada, objPersonal.CveRegimenContratacion, objPersonal.Codigo.ToString,
' objPersonal.Departamento, objPersonal.Puesto, objPersonal.CveRiesgoPuesto, objPersonal.TipoPeriodo, objPersonal.ClaveBanco, objPersonal.BancoNumCuenta, Total, objPersonal.SDI.ToString.ToDecimal, objPersonal.ClaveEstado)
' If Msg = String.Empty Then
' 'Nodo SubContratacion
' If 1 = 2 Then Msg = CFDi.ObjCompNomina12.AgregarSubContratacion("", 0)
' If Msg = String.Empty Then
' CFDi.LstCompNomina12.Add(CFDi.ObjCompNomina12)
' Dim HasErrorConceptos As Boolean = False
' 'Dim Importe As Decimal = 0
' Msg = CFDi.ConceptosCfd(1, "ACT", "", "Pago de nómina", SubTotal, SubTotal)
' 'Timbrado
' 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx
' 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx
' Dim WS As String = String.Empty
' If UsuarioActual.Empresa.FacturaProduccion Then
' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx"
' Else
' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx"
' End If
' If Not System.IO.Directory.Exists(Ruta & "XML\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\")
' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\")
' 'Generar Timbre
' 'If UsuarioActual.Empresa.FacturaProduccion Then
' If 1 = 2 Then
' CFDi.Generar(String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoPfx),
' UsuarioActual.Empresa.ContraseñaKey,
' String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoCer),
' String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio),
' String.Format("{0}Certificados\", Ruta),
' UsuarioActual.Empresa.BIUsuario,
' UsuarioActual.Empresa.BIContraseña,
' WS,
' True)
' Else
' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\Demo\")
' 'RutaPruebas & "XML\Demo\" & NominaFolio & ".xml",
' CFDi.Generar(String.Format("{0}Certificados\aaa010101aaa__csd_01.pfx", RutaPruebas),
' "12345678a",
' String.Format("{0}Certificados\aaa010101aaa__csd_01.cer", RutaPruebas),
' String.Format("{0}XML\Nomina\Demo\{1}.xml", Ruta, NominaFolio),
' String.Format("{0}Certificados\", RutaPruebas),
' "prueba",
' "123",
' WS,
' True)
' End If
' If CFDi.MsgError <> String.Empty Then
' 'OnError("Ocurrió un error al generar el timbre: " & CFDi.MsgError, New Exception)
' Dim params As New ActualizaTimbre
' params.Estatus = False
' params.CveNomina = CveNomina
' params.CvePAC = 1
' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado)
' 'Hilo.Start(params)
' BtnAutorizar.Enabled = False
' MsgError = "Nombre: " & Nombre & ". Error: " & CFDi.MsgError
' Else
' 'Actualiza Estatus Timbrado
' Dim params As New ActualizaTimbre
' params.Estatus = True
' params.CveNomina = CveNomina
' params.CvePAC = 1
' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado)
' 'Hilo.Start(params)
' Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar()
' Dim FechaCertificacion As DateTime
' Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String
' FolioFiscal = CFDi.Timbrado.UUDI 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText
' NoSerieCertificado = CFDi.Timbrado.NoCertificadoSAT
' FechaCertificacion = CFDi.Timbrado.FechaTimbrado
' SelloCFDi = CFDi.Timbrado.SelloCFD
' SelloSAT = CFDi.Timbrado.SelloSAT
' NoSerieCertificadoContribuyente = CFDi.Timbrado.NoCertificado
' ViewState("FolioFiscal") = FolioFiscal
' 'Actualiza Estatus Factura
' CveNominaT = CveNomina
' Dim Rastro As String = String.Format("Nomina: CvePeriodo:{0}, CvePersonal:{1}, UUID: {2}, RFC:{3}", CvePeriodo, CvePersonal, FolioFiscal, objPersonal.RFC)
' Rastro.GuardaLog()
' If FolioFiscal <> "" Then
' 'If UsuarioActual.Empresa.FacturaProduccion Then
' ' Dim ObjNomina2 As New ClsNominas()
' ' ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, CveNomina, SubTotal, Descuentos, RetISR, Total, DiasPagados)
' ' ObjNomina2.Dispose()
' 'End If
' Rastro = "--Estatus" & Rastro
' Rastro.GuardaLog()
' 'Dim Hilo1 As New System.Threading.Thread(AddressOf ActualizaEstatus)
' 'Hilo1.Start(3)
' End If
' Dim RutaCBB As String = String.Empty
' If Not System.IO.Directory.Exists(Ruta & "CBB\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\")
' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\")
' If UsuarioActual.Empresa.FacturaProduccion Then
' RutaCBB = Ruta & "CBB\Nomina\" & NominaFolio & ".jpg"
' Else
' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\Demo\")
' RutaCBB = Ruta & "CBB\Nomina\Demo\" & NominaFolio & ".jpg"
' End If
' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFC, Total, FolioFiscal, RutaCBB)
' 'GeneraPDF(FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, TmpDT, SelloCFDi, SelloSAT, RutaCBB, VentaFolio, Ruta & "XML\" & VentaFolio & ".xml", False, CFDi.CadenaOriginal)
' 'GeneraPDF(CveNomina, CvePersonal, CvePeriodo, FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT, RutaCBB, Ruta & "Nomina\XML\" & NominaFolio & ".xml", False, CFDi.Timbrado.CadenaOriginal, FormatoReciboCFDi)
' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre)
' End If
' Else
' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception)
' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre)
' End If
' objPersonal.Dispose()
' objNomina.Dispose()
' Return MsgError
'End Function
#End Region
#Region " GUARDAR - ACTUALIZAR "
Private Function ValidaGuardar() As Boolean
Dim EsValido = True
Dim PagueseA = ""
If HdnCveCliente.Value.ToEntero > 0 Then
PagueseA = DdlCliente.SelectedText.ToString()
ElseIf HdnCveProveedor.Value.ToEntero > 0 Then
PagueseA = DdlProveedores.SelectedText.ToString()
ElseIf HdnCvePersonal.Value.ToEntero > 0 Then
PagueseA = DdlPersonal.SelectedItem.ToString
End If
If DdlEstatusIE.SelectedValue = "2" AndAlso TxtImporte.Text.ToDouble > 0 Then
Alert("Un movimiento Cancelado debe tener importe = 0", TipoMensaje.MsgAdvertencia)
EsValido = False
End If
If DdlEstatusIE.SelectedValue <> "2" AndAlso TxtImporte.Text.ToDouble <= 0 Then
Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia)
EsValido = False
End If
'cuando sea activo es requerido proveedor o personal
If DdlEstatusIE.SelectedValue = "1" AndAlso (CveProveedor <= 0 And CvePersonal <= 0) AndAlso HdnTipoTransaccion.Value = "Egs" And RBL.SelectedValue <> "C" Then
Alert("Debe de seleccionar un Proveedor o un Funcionario Empleado", TipoMensaje.MsgAdvertencia)
EsValido = False
End If
If DdlEstatusIE.SelectedValue = "1" AndAlso PagueseA = "" AndAlso Not Opcion = "EGSCREDITO" Then
Alert("Ingrese Beneficiario", TipoMensaje.MsgAdvertencia)
EsValido = False
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)
EsValido = False
End If
End If
Dep.Dispose()
If CveOCSolicitudAnticipo > 0 Then
Dim ObjOC As New ClsOC
If ObjOC.GetOCAnticipoSaldo(CveOCSolicitudAnticipo, UsuarioActual.CveEmpresa) Then
SaldoOCAnticipo = ObjOC.DtResultados(0)("Saldo").ToString.ToDecimal
Else
SaldoOCAnticipo = 0
End If
ObjOC.Dispose()
Dim ImporteComparacion As Decimal = TxtImporte.Text.ToDecimal
'
If ChkPagarPesos.Checked Then
ImporteComparacion = ImporteOriginalDolaras
End If
If ImporteComparacion > SaldoOCAnticipo Then
EsValido = False
Alert($"El importe del movimiento es mayor al saldo de la orden de compra importe movmiento {TxtImporte.Text.FormatoNumero } saldo orden de compra: {SaldoOCAnticipo.ToString.FormatoNumero}", TipoMensaje.MsgAdvertencia)
End If
End If
Return EsValido
End Function
Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
CambiaTipoMoneda()
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
If Not ValidaGuardar() Then
Exit Sub
End If
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL)
Dim ObjOC As New ClsOC(ObjIE.IniciaTransacSQL)
' Dim ObjContabilidad As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim MsgError As String = ""
Dim CveConceptoContable As Integer = 30
Dim CveConceptoCompra As Integer = 10
Dim CveCreditoDetalle As Integer = -1
Dim tCveTipoPoliza As Integer = 2
Dim CIF As Decimal = 0
Dim CvePlantillaPoliza As Integer = 3
Dim CvePrePoliza As Integer = 0
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim Msg As New StringBuilder
If CveIE = -1 Then
Dim CveCuentaDeposito As Integer = 0
If DdlCuentaDeposito.Items.Count > 0 Then
CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
End If
'OBTIENE COMPROBANTE!!
ComprobanteIE = ""
Dim Comprobante As String = ""
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
Dim filemove As String = ""
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
'*****-_- INICIA: CONFIGURACION REGISTRO -_-*****
If CvePersonal > 0 Then
If Opcion IsNot Nothing AndAlso Opcion.Contiene("EGSSINFACT") And DDlCheques.SelectedValue.ToEntero > 0 Then
CveConceptoCompra = 29 'Comprobación Personal
Else
CveConceptoCompra = 28 'Prestamo Personal
End If
CveConceptoContable = 30 'Banco
CvePlantillaPoliza = 8
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "DEV" Then
If CvePersonal > 0 Then
CveConceptoCompra = 29 'Comprobacion Personal
CveConceptoContable = 30 'Bancos
CvePlantillaPoliza = 9
ElseIf CveProveedor > 0 Then
CveConceptoCompra = 21 'Pago a Proveedor/CAncelacion Anticipos
CveConceptoContable = 30 'Bancos
CvePlantillaPoliza = 7
ElseIf CveCliente > 0 Then
CvePlantillaPoliza = 11
End If
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then
If CveCliente > 0 Then
CveConceptoCompra = 66 'Clientes
CveConceptoContable = 30 'Bancos
CvePlantillaPoliza = 12
End If
End If
If Opcion = "DevDinC" Then
CvePlantillaPoliza = 40
End If
'Cuando es Egreso sin factura, se registra una compra tipo anticipo
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSCREDITO" Then
CveConceptoCompra = 48 'Anticipo Acreedores
CveConceptoContable = 30 'Bancos
CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero
Dim Estatus As Integer = 2
If HdnCveTipoCredito.Value = "1" Then
Estatus = 103
'cuando es crediproveedores es, pago a documentos por pagar
CveConceptoCompra = 57
End If
ObjIE.UpdateCreditosDetalle(Estatus, CveCreditoDetalle)
If HdnImporteCredito.Value.ToDouble > 0 AndAlso TxtImporte.Text.ToDouble > HdnImporteCredito.Value.ToDouble Then
CIF = TxtImporte.Text.ToDecimal - HdnImporteCredito.Value.ToDecimal
Else
CIF = 0
End If
CvePlantillaPoliza = 92
End If
Dim AgregaPolizaSaldoInicial As Boolean = False
'Cuando es Egreso sin factura, se registra una compra tipo anticipo
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSSINFACT" Then
tCveTipoPoliza = 2
Select Case RBL.SelectedValue
Case "P" 'Proveedores
If CveProveedor > 0 Then
CveConceptoCompra = 10 'Anticipo a proveedor
CveConceptoContable = 30 'Pago a Proveedor
CvePlantillaPoliza = 3
End If
Case "DD" ' Deudores Diversos
If CveProveedor > 0 Then
CveConceptoCompra = 43 'Prestamo a deudor diverso
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
CvePlantillaPoliza = 6
End If
Case "AC" ' Acreedores Diversos
If CveProveedor > 0 Then
CveConceptoCompra = 48 'anticipo a acreedor diverso
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
CvePlantillaPoliza = 21
End If
Case "DP" ' Documentos por pagar
If CveProveedor > 0 Then
CveConceptoCompra = 50 'Anticipo doc por pagar
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
CvePlantillaPoliza = 22
End If
Case "FE"
AgregaPolizaSaldoInicial = True
End Select
End If
'Nuevo Formato Charlie
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "INGPC" Then
HdnProvPorIVA.Value = "0"
CvePlantillaPoliza = 6
tCveTipoPoliza = 1
Select Case RBL.SelectedValue
Case "DD" ' Deudores Diversos
If CveProveedor > 0 Then
CveConceptoCompra = 37 'Prestamo a deudor diverso
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
CvePlantillaPoliza = 45
End If
Case "C" ' Clientes
If CveCliente > 0 Then
CveConceptoCompra = 66 'Anticipo doc por pagar
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
End If
Case "AC" ' Acreedores Diversos
If CveCliente > 0 Then
CveConceptoCompra = 41
CveConceptoContable = 30 'Bancos
'limpio el iva
HdnProvPorIVA.Value = "0"
End If
End Select
End If
'*****-_- TERMINA: CONFIGURACION REGISTRO -_-*****
Dim FolioFijo As Integer = 0
Dim tCveMoneda As Integer = CveMoneda
Dim tImporteMonedaExtranjera As Decimal = TxtImporte.Text.ToDecimal
If tCveMoneda <> 1 Then tImporteMonedaExtranjera = (TxtImporte.Text.ToDecimal * GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString.ToDecimal).RoundSQL
Dim PagueseA = ""
If HdnCveCliente.Value.ToEntero > 0 Then
PagueseA = DdlCliente.SelectedText.ToString()
ElseIf HdnCveProveedor.Value.ToEntero > 0 Then
PagueseA = DdlProveedores.SelectedText.ToString()
ElseIf HdnCvePersonal.Value.ToEntero > 0 Then
PagueseA = DdlPersonal.SelectedItem.ToString
ElseIf DdlCreditoDetalle.SelectedValue.ToEntero > 0 Then
PagueseA = String.Format("{0} {1} {2}", DdlFinanciera.SelectedItem.Text, DdlCredito.SelectedItem.Text, DdlCreditoDetalle.SelectedItem.Text)
End If
If AgregaPolizaSaldoInicial Then
If AgregarSaldoInicial(TxtImporte.Text.ToDouble(), TxtFechaDocumento.Text.ToDateTime(), 1, ObjMov) <= 0 Then
MsgError = "No se pudo insertar la póliza de saldo inicial."
End If
End If
Dim UsaComplementariaBancos As Boolean = False
UsaComplementariaBancos = If(UsuarioActual.CveEmpresa.Contiene(13, 83), False, True)
If MsgError = "" Then
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, PagueseA, TxtImporte.Text.Trim.ToDouble, tCveMoneda,
TxtTipoCambio.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, ChkAplicaImpuestos.Checked, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
CveCuentaDeposito:=CveCuentaDeposito, CveEstatusIE:=DdlEstatusIE.SelectedValue.ToString.ToEntero, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1),
ConceptoCIE:=If(TxtConceptoCIE.Text.Trim.Length > 0, TxtConceptoCIE.Text, "-1"), CveCorte:=Me.CveCorte, CveOCAnticipo:=CveOCSolicitudAnticipo)
If CveIE > 0 Then
If DdlCuentaDeposito.SelectedValue.ToEntero > 0 And DdlTipoTransaccion.SelectedValue = "17" Then
If TxtReferenciaCIE.Text <> OriReferenciaCIE Or TxtConceptoCIE.Text <> OriConceptoCIE Then
Dim ObjGrales As New ClsGenerales(ObjIE.IniciaTransacSQL)
If Not ObjGrales.UpdateCuentasDepositosEstatusPagoElectronicoGrupos(DdlCuentaDeposito.SelectedValue.ToEntero, -1, -1, "-1", TxtReferenciaCIE.Text.Trim, TxtConceptoCIE.Text.Trim) Then
MsgError = "Error al actualziar Cuanta Referencia y Concepto Deposito."
End If
End If
End If
If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa <> 119 Then FolioFijo = ObjIE.Folio.ToEntero 'cheque
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE " + If(Request("Opcion") IsNot Nothing, Request("Opcion").ToString, "") + " " + RBL.SelectedValue, CvePlantillaPoliza, TxtImporte.Text.Trim.ToDouble, TxtImporte.Text.Trim.ToDouble, tCveMoneda, TxtFechaDocumento.Text.ToDate, PagueseA, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, Nothing, UsuarioActual.CveEmpresa), CveTipoPoliza:=tCveTipoPoliza)
'valida prepoliza
If CvePrePoliza > 0 Then
If Not ObjIE.UpdateIEPrePoliza(MinFecha, "", -1, CvePrePoliza, CveIE, -1) Then
MsgError = "Ocurrio un error al agregar la prepoliza al IE."
End If
Dim Conc As String = If(TxtObservaciones.Text = "", ObjIE.Folio, TxtObservaciones.Text)
Dim Ref As String = If(TxtObservaciones.Text = "", ObjIE.Folio, TxtObservaciones.Text)
If Comprobante <> "" Then
ComprobanteIE = $"{CveIE}.{Comprobante}"
End If
'GUARDA COMPROBANTE
If filemove <> "" Then
filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
End If
'GUARDA PREPOLIZAS DETALLE [PRIMERO SON LOS CASOS ESPECIALES, AL FINAL (ELSE) LOS CASOS NORMALES] --REEMPLAZA IFs
Select Case Opcion
Case "DEV"
Dim CveIEOtro As Integer = If(CveProveedor > 0 Or CvePersonal > 0, DdlIEDevolucion.SelectedValue.ToEntero, CveIE)
If CveCliente > 0 AndAlso Not DivIvaIxC.Visible AndAlso TxtIvaIxC.Text.ToDouble = 0 Then
'RMF- CASO DONDE HAY UNA DEVOLUCION Y TENGO QUE AFECTAR LAS FACTURAS QUE SE HABIAN MARCADO COMO PAGADAS TENGO QUE REGRESARLAS A PENDIENTES
Dim Mov As New ClsMovimientos
If Mov.GetMovimientosIE(2, DdlIEDevolucion.SelectedValue.ToEntero, -1, Now, Now, 1, 0, UsuarioActual.CveEmpresa) Then
Dim DtIE As DataTable = Mov.DtResultados
For Each dr As DataRow In DtIE.Rows
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, If(dr("TipoMovto").ToString.ToEntero = 1, False, True), If(dr("CveConceptoContable").ToString.ToEntero.Contiene(66), -TxtImporte.Text.ToDecimal, dr("Importe").ToString.ToDecimal), "", dr("CveConceptoContable").ToString.ToEntero, "", Now, IDCtaBeneficiario, -1, CveIE, CveCliente:=dr("CveCliente").ToString.ToEntero, CveVenta:=dr("CveVenta").ToString.ToEntero, ImporteMX:=If(dr("CveConceptoContable").ToString.ToEntero.Contiene(66), -TxtImporte.Text.ToDecimal, -dr("Importe").ToString.ToDecimal), ImporteME:=tImporteMonedaExtranjera) Then
MsgError = "no se pudo insertar el detalle de la póliza 2"
End If
Next
ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Ref, CveConceptoContable, Conc, Now, IDCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera)
End If
Mov.Dispose()
'Devolucion de INGxC Formato Charlie
ElseIf CveCliente > 0 AndAlso DivIvaIxC.Visible Then
Dim Mov As New ClsMovimientos
'INGxC
ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -(TxtImporte.Text.ToDecimal - TxtIvaIxC.Text.ToDecimal), Ref, 66, Conc, Now, IDCtaContable, -1, CveIE, CveIEDevolucion:=DdlIEDevolucion.SelectedValue.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=-(TxtImporte.Text.ToDecimal - TxtIvaIxC.Text.ToDecimal), ImporteME:=tImporteMonedaExtranjera)
If TxtIvaIxC.Text.ToDouble > 0 Then
Dim PorcentajeIVA = (TxtIvaIxC.Text.ToDecimal() / (TxtImporte.Text.ToDecimal() - TxtIvaIxC.Text.ToDecimal())).RoundSQL(2)
'Iva
ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -TxtIvaIxC.Text.ToDecimal, Ref, 61, Conc, Now, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE, CveIEDevolucion:=DdlIEDevolucion.SelectedValue.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=-TxtIvaIxC.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, PorcentajeImpuesto:=If(PorcentajeIVA.ToString().Contiene("0.08", "0.16"), PorcentajeIVA, 0))
End If
'Bancos
ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -TxtImporte.Text.ToDecimal, Ref, 30, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveIEDevolucion:=DdlIEDevolucion.SelectedValue.ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=-TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera)
Mov.Dispose()
Else
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDecimal, Ref, CveConceptoContable, Conc, Now, IDCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera) Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Ref, CveConceptoCompra, Conc, Now, IDCtaBeneficiario, -1, CveIE:=If(CveIEOtro < 0, CveIE, CveIEOtro), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=tImporteMonedaExtranjera, ImporteME:=tImporteMonedaExtranjera) Then
MsgError = "no se pudo insertar el detalle de la póliza 2"
End If
Else
MsgError = "no se pudo insertar el detalle de la póliza"
End If
End If
Case "INGPC"
Dim ConceptoContable As Integer
Dim TipoMovimiento As Boolean
Dim importeMovimiento As Decimal
Dim FechaMovimiento As Date = Now
Dim Concepto As String = ""
Dim Referencia As String = PagueseA
Dim importeMX As Decimal
Dim Multiplicador As Integer
Dim tCveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero
'OTROS INGRESOS/EGRESOS
Dim TCC As Decimal = 1
If TxtTipoCambio.Text.Trim.ToDecimal > 0 Then TCC = TxtTipoCambio.Text.Trim.ToDecimal
Dim ImporteOtros As Decimal = TxtOtrosIngresosEgresos.Text.ToDecimal * TCC
If ImporteOtros <> 0 Then
Dim TipoMovtoIE As Boolean = False
Dim CveConcIE As Integer = 78
If ImporteOtros > 0 Then
TipoMovtoIE = True : ImporteOtros = Math.Abs(ImporteOtros)
CveConcIE = 78
Else
TipoMovtoIE = False : ImporteOtros = Math.Abs(ImporteOtros)
CveConcIE = 211
End If
Dim OtConcepto As String = PagueseA & " $" & TxtOtrosIngresosEgresos.Text.ToDecimal.FormatoNumero
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoIE, ImporteOtros, PagueseA, CveConcIE, OtConcepto, Now, -1, -1, CveIE, CveCliente:=CveCliente, ImporteMX:=ImporteOtros, CveSubProyecto:=tCveSubProyecto, ImporteME:=0) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
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
Multiplicador = (Row("Multiplicador").ToString.ToEntero)
Concepto = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, PagueseA, "", ObjIE.Folio)
Select Case ConceptoContable
Case 10
If RBL.SelectedValue = "P" AndAlso CveProveedor > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 28
If RBL.SelectedValue = "FE" AndAlso CvePersonal > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 37
If RBL.SelectedValue = "DD" AndAlso CveProveedor > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 41
If RBL.SelectedValue = "AC" AndAlso CveProveedor > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 46
If TxtInteresMoratorio.Text.ToDecimal > 0 Then
importeMovimiento = TxtInteresMoratorio.Text.ToDecimal
importeMX = importeMovimiento
Else
importeMovimiento = 0
importeMX = 0
End If
Case 50
If RBL.SelectedValue = "DP" AndAlso CveProveedor > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 66
If RBL.SelectedValue = "C" AndAlso CveCliente > 0 Then
importeMovimiento = TxtImporte.Text.ToDecimal - TxtIvaIxC.Text.ToDecimal - TxtOtrosIngresosEgresos.Text.ToDecimal
importeMX = importeMovimiento
'Agregamos el IVA
If DivIvaIxC.Visible AndAlso TxtIvaIxC.Text.ToDecimal <> 0 Then
Dim CveConIVA As Integer = 61
If UsuarioActual.CveEmpresa = 70 Then CveConIVA = 299
Dim PorcentajeIVA = (TxtIvaIxC.Text.ToDecimal() / (TxtImporte.Text.ToDecimal() - TxtIvaIxC.Text.ToDecimal())).RoundSQL(2)
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtIvaIxC.Text.ToDecimal, Concepto, CveConIVA, Concepto, FechaMovimiento, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtIvaIxC.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, PorcentajeImpuesto:=PorcentajeIVA) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
If tCveMoneda > 1 Then
'Agregamos complementaria
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Concepto, 226, Concepto, FechaMovimiento, IDCtaBeneficiarioComplementaria, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=(importeMovimiento * TC - importeMovimiento).RoundSQL, ImporteME:=importeMovimiento, TipoCambio:=TC) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
End If
Case 30
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
If tCveMoneda > 1 AndAlso UsaComplementariaBancos Then
'Agregamos complementaria
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Concepto, 204, Concepto, FechaMovimiento, IDCtaContableComplementaria, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=(importeMovimiento * TC - importeMovimiento).RoundSQL, ImporteME:=importeMovimiento, TipoCambio:=TC) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
Else
If tCveMoneda > 1 Then
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
importeMX = (importeMovimiento * TC).RoundSQL
End If
End If
End Select
If importeMovimiento <> 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, If(ConceptoContable = 30, IDCtaContable, IDCtaBeneficiario), -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=importeMovimiento, ImporteME:=tImporteMonedaExtranjera, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
Next
End If
Case "DevDinV"
Dim IdCtaContableAplicar = -1
Dim ImporteAplicar = 0.0D
Dim ImporteAplicarMN = 0.0D
Dim ImporteAplicarME = 0.0D
Dim ReferenciaAplicar = ObjIE.Folio
Dim ConceptoAplicar = $"Devolución al cliente {PagueseA} {TxtImporte.Text} NC:{SerieFolioDevDin}"
ImporteAplicar = TxtImporte.Text.ToDecimal
ImporteAplicarME = ImporteAplicar
'CONSIDERA COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ImporteAplicar
Else
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
End If
'BANCOS
IdCtaContableAplicar = If(IDCtaContable > 0, IDCtaContable, 0)
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, ReferenciaAplicar, 30, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución"
Exit Select
End If
'BANCOS COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, ReferenciaAplicar, 204, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
'OTROS INGRESOS/EGRESOS
Dim Impo As Decimal = TxtOtrosIngresosEgresos.Text.ToDecimal
If TxtOtrosIngresosEgresos.Text.ToDecimal <> 0 Then
Dim TipoMovtoIE As Boolean = False
Dim CveConcIE As Integer = 78
If Impo > 0 Then
TipoMovtoIE = True
Impo = Math.Abs(Impo)
CveConcIE = 78
IdCtaContableAplicar = UsuarioActual.Empresa.IdCuentaOtrosIngresos
Else
TipoMovtoIE = False
Impo = Math.Abs(Impo)
CveConcIE = 211
IdCtaContableAplicar = UsuarioActual.Empresa.Funcionalidad(266).ToEntero
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoIE, Impo, ReferenciaAplicar, CveConcIE, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=Impo, ImporteME:=0) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
End If
'CANCELA NC
IdCtaContableAplicar = IDCtaBeneficiario
ImporteAplicar = ImporteAplicar + Impo
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -(ImporteAplicar), ReferenciaAplicar, 12, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=-(ImporteAplicarMN), ImporteME:=ImporteAplicarME) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
'IMPUESTOS
If ObjMov.GetPrePolizasDetalle(CvePrePolizaDevDin, UsuarioActual.CveEmpresa) Then
Dim PorcentajePagoDevDin = (TxtImporte.Text.ToDecimal / ImporteOriginalDevDin).RoundSQL(6)
Dim CveConceptoContableAplciar = -1
Dim TipoMovtoAplicar = False
For Each Dr As DataRow In ObjMov.DtResultados.FiltraParametros("CveConceptoContable IN (13,8,9,38)").Rows
Dim PorcentajeImpuesto As Decimal = Dr("PorcentajeImpuesto").ToString.ToDecimal()
CveConceptoContableAplciar = Dr("CveConceptoContable").ToString.ToEntero
TipoMovtoAplicar = Not CBool(Dr("TipoMovto").ToString)
ImporteAplicar = (Dr("Importe").ToString.ToDecimal * PorcentajePagoDevDin).RoundSQL()
ImporteAplicarMN = (Dr("ImporteMN").ToString.ToDecimal * PorcentajePagoDevDin).RoundSQL()
ImporteAplicarME = (Dr("ImporteME").ToString.ToDecimal * PorcentajePagoDevDin).RoundSQL()
IdCtaContableAplicar = Dr("IdCtaContable").ToString.ToEntero
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=PorcentajeImpuesto) Then
Select Case CveConceptoContableAplciar
Case 13
CveConceptoContableAplciar = 61
Case 8
CveConceptoContableAplciar = 62
Case 9
CveConceptoContableAplciar = 63
Case 38
CveConceptoContableAplciar = 39
End Select
TipoMovtoAplicar = Not TipoMovtoAplicar
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, ImporteAplicar, ReferenciaAplicar, CveConceptoContableAplciar, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveVenta:=CveVentaDevDin, CveCliente:=CveCliente, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, PorcentajeImpuesto:=PorcentajeImpuesto) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit Select
End If
Else
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
Exit Select
End If
Next
End If
Case "DevDinC"
'asdasdasd
'asdasdasdasd
Dim IdCtaContableAplicar = -1
Dim ImporteAplicar = 0.0D
Dim ImporteAplicarMN = 0.0D
Dim ImporteAplicarME = 0.0D
Dim ReferenciaAplicar = ObjIE.Folio
Dim CveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero
Dim ConceptoAplicar = $"Devolución de Proveedor {PagueseA} {TxtImporte.Text} NC:{SerieFolioDeCDin}"
ImporteAplicar = TxtImporte.Text.ToDecimal
ImporteAplicarME = ImporteAplicar
'CONSIDERA COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ImporteAplicar
Else
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
End If
Dim TCCompra As Decimal = 1
Dim TCDocumento As Decimal = 1
'BANCOS
IdCtaContableAplicar = If(IDCtaContable > 0, IDCtaContable, 0)
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAplicar, ReferenciaAplicar, 30, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, TipoCambio:=TCDocumento) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución"
Exit Select
End If
If Masivonotas Then
For Each GvRow As GridViewRow In GvA.Rows
If GvRow.RowType = DataControlRowType.DataRow AndAlso GvRow.FCCheckBox("Chk").Checked Then
Dim FechaCompraNota As Date = GvRow.DataKey("Fecha").ToDate
If tCveMoneda > 1 Then
TCCompra = GlobalTipoCambio(FechaCompraNota).ToDecimal
TCDocumento = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal
If TCCompra <= 0 Then
Alert("No se pudo obtener el tipo de cambio de la nota de crédito.", TipoMensaje.MsgAdvertencia)
End If
If TCDocumento <= 0 Then
Alert("No se pudo obtener el tipo de cambio del documentpo.", TipoMensaje.MsgAdvertencia)
End If
End If
ImporteAplicar = GvRow.DataKey("Saldo").ToDecimal
ImporteAplicarME = ImporteAplicar
'CONSIDERA COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ImporteAplicar
Else
ImporteAplicarMN = (ImporteAplicar * If(tCveMoneda = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
End If
If tCveMoneda > 1 Then
TCCompra = GlobalTipoCambio(GvRow.DataKey("Fecha").ToDate).ToDecimal
TCDocumento = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal
If TCCompra <= 0 Then
Alert("No se pudo obtener el tipo de cambio de la nota de crédito.", TipoMensaje.MsgAdvertencia)
End If
If TCDocumento <= 0 Then
Alert("No se pudo obtener el tipo de cambio del documentpo.", TipoMensaje.MsgAdvertencia)
End If
End If
ConceptoAplicar = $"Devolución de Proveedor {PagueseA} {ImporteAplicar} NC:{GvRow.DataKey("SerieFolio")}"
CveCompraDeCDin = GvRow.DataKey("CveCompra").ToEntero
''
'BANCOS COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, TCDocumento)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAplicar, ReferenciaAplicar, 204, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, TipoCambio:=TCDocumento) Then
MsgError = "Ocurrió un error al registrara el asiento de bancos complementaria de devolución"
End If
End If
''OTROS INGRESOS/EGRESOS
'If TxtOtrosIngresosEgresos.Text.ToDecimal <> 0 Then
' Dim Impo As Decimal = TxtOtrosIngresosEgresos.Text.ToDecimal
' Dim TipoMovtoIE As Boolean = False
' Dim CveConcIE As Integer = 78
' If Impo > 0 Then
' TipoMovtoIE = True
' Impo = Math.Abs(Impo)
' CveConcIE = 78
' IdCtaContableAplicar = UsuarioActual.Empresa.IdCuentaOtrosIngresos
' Else
' TipoMovtoIE = False
' Impo = Math.Abs(Impo)
' CveConcIE = 211
' IdCtaContableAplicar = UsuarioActual.Empresa.Funcionalidad(266).ToEntero
' End If
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoIE, Impo, ReferenciaAplicar, CveConcIE, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=Impo, ImporteME:=0, TipoCambio:=TCDocumento) Then
' MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
' Exit Select
' End If
'End If
'CANCELA NC
IdCtaContableAplicar = IDCtaBeneficiario
ImporteAplicar = ImporteAplicar '- TxtOtrosIngresosEgresos.Text.ToDecimal
ImporteAplicarMN = ImporteAplicar ' (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -(ImporteAplicar), ReferenciaAplicar, 18, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=(ImporteAplicarMN), ImporteME:=ImporteAplicarME, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
'NC COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, TCCompra)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -(ImporteAplicar), ReferenciaAplicar, 201, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-(ImporteAplicarMN), ImporteME:=-(ImporteAplicarME), TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
If TCCompra <> TCDocumento Then
Dim DiferenciaTC As Decimal = TCCompra - TCDocumento
Dim DiferenciaImportes As Decimal = Math.Abs((ImporteAplicar * TCCompra) - (ImporteAplicar * TCDocumento))
If DiferenciaTC < 0 Then
'64
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaImportes, ReferenciaAplicar, 64, ConceptoAplicar, Now, UsuarioActual.Empresa.IdCuentaGananciaCambiaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=DiferenciaImportes, ImporteME:=0, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de ganancia cambiaria"
Exit Select
End If
Else
'65
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, DiferenciaImportes, ReferenciaAplicar, 65, ConceptoAplicar, Now, UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=DiferenciaImportes, ImporteME:=0, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de perdidada cfambiaria"
Exit Select
End If
End If
End If
'IMPUESTOS
Dim PorcentajePagoDevDin = (ImporteAplicar / ImporteAplicar).RoundSQL(6)
Dim CveConceptoContableAplciar = -1
'Dim TipoMovtoAplicar = False
Dim ObjCompras As New ClsCompras()
If ObjCompras.GetCompras(CveCompraDeCDin, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
Dim dr As DataRow = ObjCompras.DtResultados.Rows(0)
If dr IsNot Nothing Then
Dim CveMonedaDev As Integer = dr("CveMoneda").ToString.ToEntero
Dim TotalCompraDev As Decimal = dr("Total").ToString.ToDecimal
Dim IVADev As Decimal = dr("IVA").ToString.ToDecimal
Dim IEPSDev As Decimal = dr("IEPS").ToString.ToDecimal
PorcentajeCompraDevDinC = ObjCompras.DtResultados.Rows(0)("PorcentajeIVA").ToString.ToDecimal
Dim DTCuentas As DataTable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeCompraDevDinC)
Dim IdCtaIVAXAcreditarDevDinC = DTCuentas.Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
Dim IdCtaIVAAcreditableDevDinC = DTCuentas.Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
Dim IVADevMN As Decimal = 0
Dim IEPSDevMN As Decimal = 0
Dim PorcentajeDevolucion As Decimal = ((ImporteAplicar * 100D / TotalCompraDev) / 100).RoundSQL(2)
IVADev = Math.Round(IVADev * PorcentajeDevolucion, 2)
IEPSDev = Math.Round(IEPSDev * PorcentajeDevolucion, 2)
Dim IdCtaIVADevolucionIMPUESTOS As Integer = -1
If tCveMoneda > 1 Then
IVADevMN = IVADev
IEPSDevMN = IEPSDev
Else
IVADevMN = (IVADev * If(CveMonedaDev = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL(2)
IEPSDevMN = (IEPSDev * If(CveMonedaDev = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL(2)
End If
Dim ErrorDevolucionImpuestos As Boolean = False
If IVADev > 0 Then
IdCtaIVADevolucionIMPUESTOS = IdCtaIVAXAcreditarDevDinC
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -IVADev, ReferenciaAplicar, 14, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, PorcentajeImpuesto:=PorcentajeCompraDevDinC) Then
IdCtaIVADevolucionIMPUESTOS = IdCtaIVAAcreditableDevDinC
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -IVADev, ReferenciaAplicar, 19, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, PorcentajeImpuesto:=PorcentajeCompraDevDinC) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
Else
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
End If
If IEPSDev > 0 Then
'Dim ObjContabilidad As New ClsContabilidad
If ObjMov.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then
Try
IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -IEPSDev, ReferenciaAplicar, 25, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev) Then
If ObjMov.GetRetCuenta(26, UsuarioActual.CveEmpresa) Then
Try
IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -IEPSDev, ReferenciaAplicar, 26, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
Catch ex As Exception
Alert("Se presento un error al obtener las cuentas de IEPS acreditable.")
ErrorDevolucionImpuestos = True
End Try
End If
Else
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
Catch ex As Exception
Alert("Se presento un error al obtener las cuentas de IEPS acreditable.")
ErrorDevolucionImpuestos = True
End Try
End If
End If
If ErrorDevolucionImpuestos Then
MsgError = MsgError & " Error en devolución compra."
End If
End If
End If
''
End If
Next
Else
If tCveMoneda > 1 Then
TCCompra = GlobalTipoCambio(FechaCompra).ToDecimal
TCDocumento = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal
If TCCompra <= 0 Then
Alert("No se pudo obtener el tipo de cambio de la nota de crédito.", TipoMensaje.MsgAdvertencia)
End If
If TCDocumento <= 0 Then
Alert("No se pudo obtener el tipo de cambio del documentpo.", TipoMensaje.MsgAdvertencia)
End If
End If
'BANCOS COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, TCDocumento)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAplicar, ReferenciaAplicar, 204, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicarME, TipoCambio:=TCDocumento) Then
MsgError = "Ocurrió un error al registrara el asiento de bancos complementaria de devolución"
End If
End If
'OTROS INGRESOS/EGRESOS
If TxtOtrosIngresosEgresos.Text.ToDecimal <> 0 Then
Dim Impo As Decimal = TxtOtrosIngresosEgresos.Text.ToDecimal
Dim TipoMovtoIE As Boolean = False
Dim CveConcIE As Integer = 78
If Impo > 0 Then
TipoMovtoIE = True
Impo = Math.Abs(Impo)
CveConcIE = 78
IdCtaContableAplicar = UsuarioActual.Empresa.IdCuentaOtrosIngresos
Else
TipoMovtoIE = False
Impo = Math.Abs(Impo)
CveConcIE = 211
IdCtaContableAplicar = UsuarioActual.Empresa.Funcionalidad(266).ToEntero
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoIE, Impo, ReferenciaAplicar, CveConcIE, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=Impo, ImporteME:=0, TipoCambio:=TCDocumento, CveSubProyecto:=CveSubProyecto) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
End If
'CANCELA NC
IdCtaContableAplicar = IDCtaBeneficiario
ImporteAplicar = ImporteAplicar - TxtOtrosIngresosEgresos.Text.ToDecimal
ImporteAplicarMN = ImporteAplicar ' (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -(ImporteAplicar), ReferenciaAplicar, 18, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=(ImporteAplicarMN), ImporteME:=ImporteAplicarME, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de pago de devolución"
Exit Select
End If
'NC COMPLEMENTARIA
If tCveMoneda > 1 Then
ImporteAplicarMN = ((ImporteAplicar * If(tCveMoneda = 1, 1, TCCompra)) - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -(ImporteAplicar), ReferenciaAplicar, 201, ConceptoAplicar, Now, IdCtaContableAplicar, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-(ImporteAplicarMN), ImporteME:=-(ImporteAplicarME), TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
If TCCompra <> TCDocumento Then
Dim DiferenciaTC As Decimal = TCCompra - TCDocumento
Dim DiferenciaImportes As Decimal = Math.Abs((ImporteAplicar * TCCompra) - (ImporteAplicar * TCDocumento))
If DiferenciaTC < 0 Then
'64
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, DiferenciaImportes, ReferenciaAplicar, 64, ConceptoAplicar, Now, UsuarioActual.Empresa.IdCuentaGananciaCambiaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=DiferenciaImportes, ImporteME:=0, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de ganancia cambiaria"
Exit Select
End If
Else
'65
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, DiferenciaImportes, ReferenciaAplicar, 65, ConceptoAplicar, Now, UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=DiferenciaImportes, ImporteME:=0, TipoCambio:=TCCompra) Then
MsgError = "Ocurrió un error al registrar el asiento de perdidada cfambiaria"
Exit Select
End If
End If
End If
'IMPUESTOS
Dim PorcentajePagoDevDin = (TxtImporte.Text.ToDecimal / ImporteOriginalDevDin).RoundSQL(6)
Dim CveConceptoContableAplciar = -1
'Dim TipoMovtoAplicar = False
Dim ObjCompras As New ClsCompras()
If ObjCompras.GetCompras(CveCompraDeCDin, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
Dim dr As DataRow = ObjCompras.DtResultados.Rows(0)
If dr IsNot Nothing Then
Dim CveMonedaDev As Integer = dr("CveMoneda").ToString.ToEntero
Dim TotalCompraDev As Decimal = dr("Total").ToString.ToDecimal
Dim IVADev As Decimal = dr("IVA").ToString.ToDecimal
Dim IEPSDev As Decimal = dr("IEPS").ToString.ToDecimal
PorcentajeCompraDevDinC = ObjCompras.DtResultados.Rows(0)("PorcentajeIVA").ToString.ToDecimal
Dim DTCuentas As DataTable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeCompraDevDinC)
Dim IdCtaIVAXAcreditarDevDinC As Integer
Dim IdCtaIVAAcreditableDevDinC As Integer
If DTCuentas IsNot Nothing AndAlso DTCuentas.Rows.Count > 0 Then
IdCtaIVAXAcreditarDevDinC = DTCuentas.Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero
IdCtaIVAAcreditableDevDinC = DTCuentas.Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero
Else
MsgError = "Sin Registros de porcentaje impuesto"
End If
Dim IVADevMN As Decimal = 0
Dim IEPSDevMN As Decimal = 0
Dim PorcentajeDevolucion As Decimal = ((TxtImporte.Text.ToDecimal * 100D / TotalCompraDev) / 100).RoundSQL(2)
IVADev = Math.Round(IVADev * PorcentajeDevolucion, 2)
IEPSDev = Math.Round(IEPSDev * PorcentajeDevolucion, 2)
Dim IdCtaIVADevolucionIMPUESTOS As Integer = -1
If tCveMoneda > 1 Then
IVADevMN = IVADev
IEPSDevMN = IEPSDev
Else
IVADevMN = (IVADev * If(CveMonedaDev = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL(2)
IEPSDevMN = (IEPSDev * If(CveMonedaDev = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL(2)
End If
Dim ErrorDevolucionImpuestos As Boolean = False
If IVADev > 0 Then
IdCtaIVADevolucionIMPUESTOS = IdCtaIVAXAcreditarDevDinC
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -IVADev, ReferenciaAplicar, 14, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, PorcentajeImpuesto:=PorcentajeCompraDevDinC) Then
IdCtaIVADevolucionIMPUESTOS = IdCtaIVAAcreditableDevDinC
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -IVADev, ReferenciaAplicar, 19, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, PorcentajeImpuesto:=PorcentajeCompraDevDinC) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
Else
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
End If
If IEPSDev > 0 Then
'Dim ObjContabilidad As New ClsContabilidad
If ObjMov.GetRetCuenta(25, UsuarioActual.CveEmpresa) Then
Try
IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, -IEPSDev, ReferenciaAplicar, 25, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev) Then
If ObjMov.GetRetCuenta(26, UsuarioActual.CveEmpresa) Then
Try
IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, -IEPSDev, ReferenciaAplicar, 26, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev) Then
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución "
ErrorDevolucionImpuestos = True
End If
Catch ex As Exception
Alert("Se presento un error al obtener las cuentas de IEPS acreditable.")
ErrorDevolucionImpuestos = True
End Try
End If
Else
MsgError = "Ocurrió un error al registrar el asiento de impuestos de devolución"
ErrorDevolucionImpuestos = True
End If
Catch ex As Exception
Alert("Se presento un error al obtener las cuentas de IEPS acreditable.")
ErrorDevolucionImpuestos = True
End Try
End If
End If
If ErrorDevolucionImpuestos Then
MsgError = MsgError & " Error en devolución compra."
End If
End If
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''
Case "EGSCREDITO"
Dim ConceptoContable As Integer
Dim TipoMovimiento As Boolean
Dim importeMovimiento As Decimal
Dim FechaMovimiento As Date = Now
Dim Concepto As String = ""
Dim Referencia As String = PagueseA
Dim importeMX As Decimal
Dim Multiplicador As Integer
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
Multiplicador = (Row("Multiplicador").ToString.ToEntero)
Concepto = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, PagueseA, "", ObjIE.Folio)
Select Case ConceptoContable
Case 30
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
If tCveMoneda > 1 Then
'Agregamos complementaria
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, Concepto, 204, Concepto, FechaMovimiento, IDCtaContableComplementaria, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=(importeMovimiento * TC - importeMovimiento).RoundSQL, ImporteME:=importeMovimiento, TipoCambio:=TC) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
Case 42
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
If tCveMoneda > 1 Then
importeMovimiento = TxtImporte.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal
importeMX = importeMovimiento
End If
Case 46
If TxtInteresMoratorio.Text.ToDecimal > 0 Then
importeMovimiento = TxtInteresMoratorio.Text.ToDecimal
importeMX = importeMovimiento
Else
importeMovimiento = 0
importeMX = 0
End If
Case 48
importeMovimiento = TxtImporte.Text.ToDecimal
importeMX = importeMovimiento
End Select
If importeMovimiento <> 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, If(ConceptoContable = 30, IDCtaContable, IDCtaBeneficiario), -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=importeMovimiento, ImporteME:=tImporteMonedaExtranjera, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
Next
End If
Case Else
Dim TipoMovimiento As Boolean = True
If Opcion.Contiene("ANTC") Then
TipoMovimiento = False
End If
If CveConceptoCompra = 10 AndAlso tCveMoneda > 1 AndAlso UsaComplementariaBancos Then
IDCtaBeneficiario = IdCtaAnticipoExtranjera
End If
Dim Importe30 As Decimal = TxtImporte.Text.ToDecimal
If Not UsaComplementariaBancos AndAlso tCveMoneda > 1 Then
Importe30 = TxtImporte.Text.ToDecimal + (TxtImporte.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal - TxtImporte.Text.ToDecimal).RoundSQL()
End If
'MOVIMIENTOS EGRESOS
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtImporte.Text.ToDecimal, Ref, CveConceptoContable, Conc, Now, IDCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=Importe30, ImporteME:=tImporteMonedaExtranjera, CveIEDevolucion:=DDlCheques.SelectedValue.ToEntero) Then
Dim IVA As Decimal = 0 ' TxtImporte.Text.ToDouble * HdnProvPorIVA.Value.ToDouble
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, TxtImporte.Text.ToDecimal - IVA - CIF, Ref, CveConceptoCompra, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=If(UsaComplementariaBancos, TxtImporte.Text.ToDecimal, tImporteMonedaExtranjera), ImporteME:=TxtImporte.Text.ToDecimal, CveIEDevolucion:=DdlIEAcreedor.SelectedValue.ToEntero) Then
If IVA > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, IVA, Ref, 19, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveIEDevolucion:=DDlCheques.SelectedValue.ToEntero) Then
MsgError = "Detalle"
End If
'intereses pagados
If CIF > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, CIF, Ref, 46, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=CIF, ImporteME:=tImporteMonedaExtranjera, CveIEDevolucion:=DDlCheques.SelectedValue.ToEntero) Then
MsgError = "Detalle"
End If
Else
MsgError = "no se pudo insertar el detalle de la póliza2"
End If
Else
MsgError = "no se pudo insertar el detalle de la póliza"
End If
'BANCOS COMPLEMENTARIA
If tCveMoneda > 1 And UsaComplementariaBancos Then
Dim ImporteAplicar As Decimal = TxtImporte.Text.ToDecimal
Dim ImporteAplicarMN = (ImporteAplicar * TxtTipoCambio.Text.ToDecimal - ImporteAplicar).RoundSQL()
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAplicar, Ref, 204, Conc, Now, IDCtaContableComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
If CveConceptoCompra = 10 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteAplicar, Ref, 266, Conc, Now, IdCtaAnticipoComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
If CveConceptoCompra = 66 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteAplicar, Ref, 226, Conc, Now, IdCtaAnticipoComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, TipoCambio:=TxtTipoCambio.Text.ToDecimal) Then
MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución"
End If
End If
End If
If Opcion.Contiene("EGSSINFACT") AndAlso CveSolicitudViatico > 0 AndAlso MsgError = "" Then
If Not ObjIE.UpdateSolicitudesViaticosIE(CveSolicitudViatico, CveIE) Then
MsgError = "Ocurrió un error al vincular el egreso con la solicitud de viatico."
End If
End If
End Select
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
Dim ConceptoRenglon, Referencia As String
Dim FolioPoliza As Integer
Dim Fecha As Date = TxtFechaDocumento.Text.ToDate
Dim TipoChq As String = ""
Dim Total As Double = TxtImporte.Text.ToDouble
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
Conta.IniciaTransacSQL()
If DdlTipoTransaccion.SelectedValue = "1" Then TipoChq = "CHQ"
ConceptoRenglon = String.Format("Anticipo {0}", PagueseA)
IDPoliza = Conta.AddPoliza(2, ConceptoRenglon, Total, Total, UsuarioActual.CveUsuario, Fecha, ObjIE.Folio, TipoChq)
If IDPoliza > 0 Then
FolioPoliza = Conta.Folio
Referencia = ObjIE.Folio
ConceptoRenglon = String.Format("Anticipo {0} {1}", PagueseA, TxtObservaciones.Text)
Total = TxtImporte.Text.ToDouble
If Not Conta.AddMovimiento(IDPoliza, IDCtaContable, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento"
If Not Conta.AddMovimiento(IDPoliza, IDCtaBeneficiario, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento"
Else
'MsgError = "No se insertó el encabezado"
End If
If MsgError = "" Then
Conta.Commit()
Conta.AjustaPoliza(IDPoliza)
'actualizar la conta del IE
ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
Else
Conta.RollBack()
IDPoliza = 0
End If
Conta.Dispose()
End If
'Notificación de Pago
If TxtNotificarA.Text.Trim <> "" And MsgError = "" Then
'NotificacionPago(CveIE, TxtNotificarA.Text.Trim)
EnviarCorreoNotificacion(CveIE, TxtNotificarA.Text.Trim, "", UsuarioActual, False)
End If
Else
MsgError = "No se pudo insertar la póliza"
End If
Else
MsgError = "No se insertó el encabezado (IE)"
End If
End If
Else
Msg.Append("El Documento se guardó correctamente.")
End If
'SOLICITUD DE ANTICIPO OC
If MsgError = "" Then
MsgError = GuardaSolicitudAnticipoOC(ObjOC)
End If
If MsgError = "" Then
'VIATICOS
If ChkAplicaViatico.Checked Then
Dim Retorno As String = TimbrarNomina12(CvePersonal)
If Retorno <> "" Then MsgError = $"{MsgError} {Retorno}" : Msg.Clear() : CveIE = -1
If Retorno <> "" Then
Alert(Retorno, TipoMensaje.MsgError)
End If
End If
End If
If MsgError = "" Then
If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
' MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"Bancos/IE | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
Else
MsgError = "No se pudo validar la prepoliza de cuadre."
End If
End If
'El movimiento 1 es el de Venta
'Conta ContPAQ
If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
Dim AutoConta As Boolean = True
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
If Not (IDCtaBeneficiario > 0 And IDCtaContable > 0) Then
AutoConta = False
If IDCtaContable < 1 Then
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de Bancos es invalida", TipoMensaje.MsgAdvertencia)
End If
If IDCtaBeneficiario < 1 Then
Alert("No se puede contabilizar la Prepoliza debido a que las cuenta del Beneficiario es invalida", TipoMensaje.MsgAdvertencia)
End If
End If
End If
If AutoConta Then
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
IDPoliza = ObjMov.ContaIdPoliza
Else
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
MsgError = "Error al contabilizar."
End If
End If
End If
If MsgError = "" Then
'IMPRIME CHEQUE
'GeneraChequePDF(CveIE, UsuarioActual.Empresa, IDPoliza)
If Msg.ToString = "" Then
Msg.Append("El Documento se guardo correctamente")
End If
Dim Archivo As System.IO.FileInfo = Nothing
'VERIFICA SI EXISTE EL FORMATO
If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(2, 8, 9) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta))
ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero))
If Not Archivo.Exists Then
Archivo = New System.IO.FileInfo(String.Format("{0}\Empresas\Grales\Formatos\CHQ.rdlc", ModExtensiones.DirectorioBaseEmpresas))
End If
ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(6) And UsuarioActual.CveEmpresa = 72 Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/ComprobanteEgreso.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero))
End If
If Archivo IsNot Nothing Then
If Archivo.Exists Then
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">{1}</a> ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem))
End If
End If
If IDPoliza > 0 Then
Msg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
End If
'AUTO DESCARGAR PDF PARA COMPU
If UsuarioActual.CveEmpresa.Contiene(72, 1, 2) And CveSolicitudViatico > 0 Then
If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1, 2, 6, 8, 9) Then
RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=IE&CVEIE={0}", CveIE))}'", String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem))
End If
End If
ObjIE.Commit()
Else
ObjIE.RollBack()
Alert(MsgError, TipoMensaje.MsgAdvertencia)
If Opcion = "INGPC" Then
CveIE = -1
End If
End If
If Msg.ToString <> "" Then
If CveOCSolicitudAnticipo > 0 Then
Alert("El Documento se guardo correctamente", TipoMensaje.MsgInformacion, "document.location.href=""../Inicio.aspx""")
Else
If ChkAplicaViatico.Checked Then
Dim SerieFolio = $"VIA-{Folio}"
Msg.Clear()
Msg.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=DesXmlVIA&SERIEFOLIO={0}&TIPO={1}", SerieFolio, "Viaticos")))
End If
Dim AccionJS = ""
If Opcion = "DevDinV" Then
AccionJS = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}"";"
AccionJS = String.Format("document.location.href=""{0}"";", HttpContext.Current.Request.Url.AbsolutePath)
Else
AccionJS = String.Format("document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery)
End If
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then
AccionJS = $"document.location.href=""/Bancos/Creditos.aspx?CveCredito={Request("CveCredito")}"";"
Alert(Msg.ToString, TipoMensaje.MsgInformacion, AccionJS)
Else
Alert(Msg.ToString, TipoMensaje.MsgInformacion, String.Format("document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery))
End If
End If
End If
Msg.Clear()
ObjIE.Dispose()
ObjMov.Dispose()
If ObjComp IsNot Nothing Then ObjComp.Dispose()
End Sub
#Region " NOTIFICACION PAGO "
'Private Sub NotificacionPago(CveIE As Integer, CorreoNotificarA As String)
' If Not DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(9, 17) Then
' Dim Param As New List(Of String)
' Param.Add(CorreoNotificarA) 'Para
' Param.Add("Notificaciones de pago") 'Asunto
' Param.Add(GeneraCorreo2(CveIE)) 'Body
' Param.Add(CveIE.ToString) 'CveIE
' Param.Add(If(ComprobanteIE <> "", String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ComprobanteIE), "")) 'Archivo Adjunto
' Dim Hilo As New Threading.Thread(AddressOf MandaCorreo)
' Hilo.Start(Param)
' End If
'End Sub
'Private Sub MandaCorreo(data As Object)
' Dim Parametros As List(Of String) = DirectCast(data, List(Of String))
' Dim Mail As New ClsSisMail()
' Dim Para As String = If(Parametros(0) IsNot Nothing, Parametros(0), "")
' Dim Asunto As String = If(Parametros(1) IsNot Nothing, Parametros(1), "")
' Dim Body As String = If(Parametros(2) IsNot Nothing, Parametros(2), "")
' Dim CveIE As Integer = If(Parametros(3) IsNot Nothing, Parametros(3).ToEntero, 0)
' Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail)
' If Parametros(4) IsNot Nothing AndAlso Parametros(4) <> "" Then
' ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = Parametros(4).ToString})
' 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 GeneraCorreo2(CveIE As Integer) As String
' Dim strBody As New StringBuilder
' Dim objIE As New ClsBancos
' If objIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then
' strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
' strBody.Append("<head> ")
' strBody.Append(" <style type=""text/css""> ")
' strBody.Append(" body ")
' strBody.Append(" { ")
' strBody.Append(" margin:0px; ")
' strBody.Append(" padding:0px 0px 0px 0px; ")
' strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
' strBody.Append(" font-size: 10px; ")
' strBody.Append(" background-color:#F0F0F0; ")
' strBody.Append(" } ")
' strBody.Append(" a.Texto ")
' strBody.Append(" { ")
' strBody.Append(" font-size:11px; ")
' strBody.Append(" background-color:#F7F6F3; ")
' strBody.Append(" text-decoration:none; ")
' strBody.Append(" font-weight:bold; ")
' strBody.Append(" } ")
' strBody.Append(" .Texto ")
' strBody.Append(" { ")
' strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
' strBody.Append(" } ")
' strBody.Append(" .TextoAlterno ")
' strBody.Append(" { ")
' strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
' strBody.Append(" vertical-align:middle; height:20px;")
' strBody.Append(" } ")
' strBody.Append(" .BarraIdentidad ")
' strBody.Append(" { ")
' strBody.Append(" color:#FFFFFF; ")
' strBody.Append(" background:#F0F0F0; ")
' strBody.Append(" font-weight:bold; ")
' strBody.Append(" font-size:19px; ")
' strBody.Append(" font-style:oblique; ")
' strBody.Append(" } ")
' strBody.Append(" .Titulos ")
' strBody.Append(" { ")
' strBody.Append(" background-color: Gray;")
' strBody.Append(" color:White; ")
' strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
' strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
' strBody.Append(" text-decoration:none; ")
' strBody.Append(" } ")
' strBody.Append(" .Verde {color: #00CC00;} ")
' strBody.Append(" .Negro {color: #000000;} ")
' strBody.Append(" .Rojo {color: #FF0000;} ")
' strBody.Append(" </style> ")
' strBody.Append("</head> ")
' strBody.Append("<body> ")
' strBody.AppendFormat("<div id='C_div' style='width: 600px'>")
' strBody.AppendFormat(" <fieldset>")
' strBody.AppendFormat(" <legend><b>{0}</b></legend>", UsuarioActual.Empresa.Empresa)
' strBody.AppendFormat(" <table class='TextoG' border='0' cellpadding='0' cellspacing='0' width='100%'>")
' strBody.AppendFormat(" <tr>")
' strBody.AppendFormat(" <td style='width:100px'>{0}</td>", UsuarioActual.Empresa.Direccion)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr>")
' strBody.AppendFormat(" <td>Col. {0}</td>", UsuarioActual.Empresa.Colonia)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr>")
' strBody.AppendFormat(" <td>{0}, {1}, C.P.{2}</td>", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr>")
' strBody.AppendFormat(" <td>RFC {0}</td>", UsuarioActual.Empresa.RFC)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" </table>")
' strBody.AppendFormat(" </fieldset>")
' strBody.AppendFormat("</div><br/><br/>")
' 'strBody.AppendFormat("<div style='width: 600px'>")
' 'strBody.AppendFormat(" <fieldset>")
' 'strBody.AppendFormat(" <legend><b> </b></legend>")
' 'strBody.AppendFormat(" <table class='TextoG' style='width:100%'>")
' 'If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque
' ' strBody.Append(" <tr style=""height: 22px""> ")
' ' strBody.Append(" <td>Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.</td> ")
' ' strBody.Append(" </tr> ")
' 'End If
' 'If objIE.CveTipoTransaccion = 2 Then ' cuando es transf
' ' strBody.Append(" <tr style=""height: 22px""> ")
' ' strBody.Append(" <td>Notificación de transferencia de pago realizada.</td> ")
' ' strBody.Append(" </tr> ")
' 'End If
' 'strBody.Append(" <tr style=""height: 22px""> ")
' 'strBody.AppendFormat(" <td>&nbsp;</td> ")
' 'strBody.Append(" </tr> ")
' 'strBody.Append(" </table> ")
' 'strBody.AppendFormat(" </fieldset>")
' 'strBody.Append(" </div> ")
' strBody.AppendFormat("<div style='width: 600px'>")
' strBody.AppendFormat(" <table style='width:100%'>")
' strBody.AppendFormat(" <tr>")
' strBody.AppendFormat(" <td style='vertical-align: top'>")
' strBody.AppendFormat(" <fieldset>")
' strBody.AppendFormat(" <legend>Beneficiario:<b>{0}</b> </legend>", objIE.PagueseA)
' strBody.AppendFormat(" <table width='100%'>")
' strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
' strBody.AppendFormat(" <th scope='col' style='width:150px;'></th>")
' strBody.AppendFormat(" <th scope='col' style='width:450px;'></th>")
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Movimiento:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.TipoTransaccion)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Banco:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.Banco)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Cuenta:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.NumCuenta)
' strBody.AppendFormat(" </tr>")
' If objIE.CuentaDepositado.ToString <> "" Then
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Cuenta Destino:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.CuentaDepositado)
' strBody.AppendFormat(" </tr>")
' End If
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Fecha:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.FechaDocumento.ToString("dd/MM/yyyy"))
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Importe:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>$ {0} {1}</td>", objIE.Importe.FormatoNumero, objIE.Moneda)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td>Observaciones:</td>")
' strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.Observaciones)
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" <tr class='Texto'>")
' strBody.AppendFormat(" <td colspan='2'>")
' strBody.AppendFormat(" <hr />")
' strBody.AppendFormat(" </td>")
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" </table>")
' strBody.AppendFormat(" </fieldset>")
' strBody.AppendFormat(" </td>")
' strBody.AppendFormat(" </tr>")
' strBody.AppendFormat(" </table>")
' strBody.AppendFormat("</div>")
' '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("<div style='width: 1000px'>")
' ' strBody.AppendFormat(" <table style='width:1000px'>")
' ' strBody.AppendFormat(" <tr>")
' ' strBody.AppendFormat(" <td style='vertical-align: top'>")
' ' strBody.AppendFormat(" <fieldset>")
' ' strBody.AppendFormat(" <legend><b>Documentos abonados o pagados <br/>{0}</b> </legend>", Textov33)
' ' strBody.AppendFormat(" <table width='1000px'>")
' ' strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
' ' strBody.AppendFormat(" <th scope='col' style='width: 15%'>Fecha</th>")
' ' strBody.AppendFormat(" <th scope='col' style='width: 25%'>Factura</th>")
' ' strBody.AppendFormat(" <th scope='col' style='width: 25%'>Importe ($)</th>")
' ' strBody.AppendFormat(" <th scope='col' style='width: 40%'>Folio Fiscal</th>")
' ' strBody.AppendFormat(" </tr>")
' ' For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows
' ' strBody.AppendFormat(" <tr class='Texto'>")
' ' strBody.AppendFormat(" <td>{0}</td>", dr("Fecha").ToString.ToDate.ToShortDateString())
' ' strBody.AppendFormat(" <td>{0}</td>", dr("SerieFolio").ToString)
' ' strBody.AppendFormat(" <td style='text-align: right'>$ {0}</td>", dr("Importe").ToString.FormatoNumero)
' ' strBody.AppendFormat(" <td>{0}</td>", dr("FolioFiscal"))
' ' strBody.AppendFormat(" </tr>")
' ' Next
' ' strBody.AppendFormat(" <tr class='Texto'>")
' ' strBody.AppendFormat(" <td colspan='4'>")
' ' strBody.AppendFormat(" <hr />")
' ' strBody.AppendFormat(" </td>")
' ' strBody.AppendFormat(" </tr>")
' ' strBody.AppendFormat(" </table>")
' ' strBody.AppendFormat(" </fieldset>")
' ' strBody.AppendFormat(" </td>")
' ' strBody.AppendFormat(" </tr>")
' ' strBody.AppendFormat(" </table>")
' ' strBody.AppendFormat("</div>")
' 'End If
' strBody.Append(" <div> Favor de no responder a este correo. </div> ")
' strBody.Append("</body></html>")
' End If
' objIE.Dispose()
' Return strBody.ToString
'End Function
#End Region
Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs) Handles BtnActualizar.Click
Dim IE As New ClsBancos
IE.IniciaTransacSQL()
Dim FechaAplicado As DateTime? = Nothing
Dim OcurrioError As Boolean = False
Dim CveCuentaDepositoUpdate As Integer = If(DdlCuentaDeposito.SelectedValue.ToEntero.ToEntero = 0, -1, DdlCuentaDeposito.SelectedValue.ToEntero.ToEntero)
If Not IE.UpdateBancos_IE(TxtFechaDocumento.Text.ToDate, FechaAplicado, CveIE, TxtFolio.Text, CveCuentaDeposito:=CveCuentaDepositoUpdate, CveCuenta:=DdlCuenta.SelectedValue.ToEntero,
Observaciones:=TxtObservaciones.Text, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveTipoTransaccion:=DdlTipoTransaccion.SelectedValue.ToEntero) Then
OcurrioError = True
End If
If OcurrioError Then
IE.RollBack()
Else
IE.Commit()
Alert("La Actualización del documento se realizó correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""IE.aspx?CveIE={CveIE}""")
End If
IE.Dispose()
End Sub
Protected Sub ImgUpdateCuentaDeposito_Click(sender As Object, e As ImageClickEventArgs)
Dim IE As New ClsBancos
If IE.UpdateBancos_IECuentaDeposito(DdlCuentaDeposito.SelectedValue.ToEntero, CveIE) Then
Alert("Se vinculó con exito la cuenta deposito", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un Error al vincular la cuenta deposito al IE", TipoMensaje.MsgError)
End If
IE.Dispose()
End Sub
#End Region
#Region " ELIMINAR/CANCELAR - MOVIMIENTO "
Protected Sub BtnCancelarIE_Click(sender As Object, e As EventArgs)
RegistraScript("$('#DivCancelarIE').modal('hide');")
Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
If ExistenComplementosVigentes AndAlso DdlMotivoCancelacion.SelectedValue.ToEntero() <= 0 Then
Alert("Debe seleccionar un motivo de cancelación", TipoMensaje.MsgError)
Exit Sub
End If
CancelarIE(CancelarComplemento:=ExistenComplementosVigentes)
End Sub
Private Sub CancelarIE(Optional CancelarComplemento As Boolean = False)
If Not IsDate(TxtFechaCancelacion.Text.ToDate) Then
Alert("El campo fecha cancelación es incorrecto. Por favor verifique y vuelva a intentar")
Exit Sub
End If
If ChkConciliado.Checked AndAlso TxtFechaCancelacion.Text.ToDate < TxtFechaAplicado.Text.ToDate.FirstDayOfMonth.AddMonths(1) Then
Alert("El documento conciliado, no se puede cancelar con la fecha especificada.", TipoMensaje.MsgError)
Exit Sub
End If
Dim ErrorCancelar = False
Dim MensajeError = ""
Dim IdPolizaNueva = -1
Dim FolioPolizaNueva = -1
Dim MensajeLog As String = ""
Dim Banc As New ClsBancos
Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL())
Dim ObjAC As ClsContPAQi = Nothing
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") Then
Try
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
Catch ex As Exception
OnError("Ocurrió un error al iniciar la contabilización", ex)
ErrorCancelar = True
End Try
End If
Try
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC)) Then
If ObjAC Is Nothing Then
ErrorCancelar = True
End If
If Not ErrorCancelar Then
Dim dt As DataTable
If ObjAC.GetPoliza(IDPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then
dt = ObjAC.DtResultados
' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS)
If dt.Rows(0)("FechaPol").ToString.ToDate < TxtFechaCancelacion.Text.ToDate.FirstDayOfMonth Then 'dt.Rows(0)("FechaPol").ToString.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or dt.Rows(0)("FechaPol").ToString.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then
IdPolizaNueva = ObjAC.AddPoliza(dt.Rows(0)("CodigoTipoPoliza").ToString.ToEntero, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaCancelacion.Text.ToDate)
If IdPolizaNueva > 0 Then
FolioPolizaNueva = ObjAC.Folio
'CREA POLIZA NEGATIVA
For Each dr As DataRow In dt.Rows
If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, "") Then
ErrorCancelar = True
MensajeError = "Error al crear poliza negativa"
Exit For
End If
Next
'AJUSTA POLIZA
If Not ErrorCancelar Then
If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then
ErrorCancelar = True
MensajeError = "Error al ajustar poliza negativa"
End If
End If
'CANCELA IE
If Not ErrorCancelar Then
If Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, FolioPolizaNueva, TxtFechaCancelacion.Text.ToDate, CveTipoTransaccionCancelacion:=DdlTipoTransaccionCancelacion.SelectedValue.ToEntero) <= 0 Then
ErrorCancelar = True
MensajeError = "Error al cancelar IE"
End If
End If
Else
ErrorCancelar = True
End If
Else
If ObjAC.RemovePoliza(IDPoliza) Then
If Not ObjConta.DesvincularPrePolizaContabilizada(IDPoliza, UsuarioActual.CveEmpresa) Then
ErrorCancelar = True
MensajeError = "Error al desvincular poliza."
End If
Else
ErrorCancelar = True
MensajeError = "Error al eliminar poliza."
End If
If Not ErrorCancelar Then
If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
ErrorCancelar = True
MensajeError = "Error al desbloquear prepoliza."
End If
End If
'CANCELA IE
If Not ErrorCancelar Then
If Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, FolioPolizaNueva, TxtFechaCancelacion.Text.ToDate, CveTipoTransaccionCancelacion:=DdlTipoTransaccionCancelacion.SelectedValue.ToEntero) <= 0 Then
ErrorCancelar = True
MensajeError = "Error al cancelar IE"
End If
End If
If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then
ErrorCancelar = True
MensajeError = "Error al contabilizar poliza"
End If
End If
Else
ErrorCancelar = True
MensajeError = "Error al obtener la poliza"
End If
End If
Else
' If TxtFechaDocumento.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFechaDocumento.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then
Dim GeneraCancelacionEnCero As Boolean = False
If TxtFechaCancelacion.Text.ToDate <= TxtFechaDocumento.Text.ToDate.LastDayOfMonth Then 'si es del mismo mes, se genra cancelacion en cero
GeneraCancelacionEnCero = True
End If
Dim TipoMovimiento As Integer = 1
Dim CveTipoTransaccionCancelacion As Integer = DdlTipoTransaccionCancelacion.SelectedValue.ToEntero
Dim CveCuentaDevolucion As Integer = DdlDevolucionCuenta.SelectedValue.ToEntero
If ChkGeneraCancelacion.Checked Then
GeneraCancelacionEnCero = False
TipoMovimiento = 2
If DdlTipoTransaccionCancelacion.SelectedValue.ToEntero = -1 Then
CveTipoTransaccionCancelacion = 16 'Validacion manual para solo enviar el correcto
End If
End If
MensajeLog += "GeneraCancelacionEnCero:" & GeneraCancelacionEnCero
Dim CvePrePolizaCancelacion As Integer = 0
If Not GeneraCancelacionEnCero Then
'CANCELA IE MES ANTERIOR
CvePrePolizaCancelacion = Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, FolioPolizaNueva, TxtFechaCancelacion.Text.ToDate, TipoMovimiento:=TipoMovimiento,
CveTipoTransaccionCancelacion:=CveTipoTransaccionCancelacion, CveCuentaDevolucion:=CveCuentaDevolucion)
If CvePrePolizaCancelacion <= 0 Then
ErrorCancelar = True
MensajeError = "Error al cancelar IE MES ANTERIOR"
Else
'DEBE GENERAR UNA NUEVA POLIZA
IDPoliza = -1
End If
Else
If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
ErrorCancelar = True
MensajeError = "Error al desbloquear prepoliza."
Else
'CANCELA IE MES ACTUAL
CvePrePolizaCancelacion = Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, FolioPolizaNueva, TxtFechaCancelacion.Text.ToDate,
CveTipoTransaccionCancelacion:=CveTipoTransaccionCancelacion, CveCuentaDevolucion:=CveCuentaDevolucion)
If CvePrePolizaCancelacion <= 0 Then
ErrorCancelar = True
MensajeError = "Error al cancelar IE MES ACTUAL"
End If
End If
End If
If Not ErrorCancelar AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaCancelacion, UsuarioActual.CveUsuario, UsuarioActual.Empresa, pIDPoliza:=If(IDPoliza > 0, IDPoliza, -1), ObjConta:=ObjAC) Then
ErrorCancelar = True
MensajeError = "Error al contabilizar poliza"
End If
End If
End If
If Not ErrorCancelar Then
If Banc.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then
If Banc.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"}).Rows.Count > 0 Then
If Not Banc.GetFoliosCancelados(UsuarioActual.CveEmpresa) Then
ErrorCancelar = True
MensajeError = "Error al cancelar complemento de pago"
Else
Dim FolioCancelado = $"{TxtFolio.Text}_C_{Banc.DtResultados(0)("Cantidad").ToString().ToEntero + 1}"
If Not Banc.UpdateFolioCancelado(CveIE.ToEntero, Folio:=FolioCancelado) Then
ErrorCancelar = True
MensajeError = "Error al actualizar complemento de pago"
End If
End If
End If
End If
End If
If Not ErrorCancelar Then
Dim ErrorCancelarComplemento As Boolean = True
If CancelarComplemento Then
Dim CveMotivoCancelacion As Integer = DdlMotivoCancelacion.SelectedValue.ToEntero
Dim CveSATMotivoCancelacion As Integer = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa, CveMotivoCancelacion:=CveMotivoCancelacion).FiltroPrimeroValor("CveSATMotivoCancelacion").ToEntero()
If CveMotivoCancelacion <= 0 Or CveSATMotivoCancelacion <= 0 Then
Alert("Debe de elegir un motivo de cancelación.", TipoMensaje.MsgAdvertencia)
ErrorCancelarComplemento = True
End If
If CveMotivoCancelacion > 0 AndAlso CveSATMotivoCancelacion > 0 Then
Dim DtComplementos As DataTable = Nothing
If CveIE > 0 AndAlso Banc.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then
DtComplementos = Banc.DtResultados.FiltraParametros(" Estatus IN(1,3) ")
End If
For Each RowComplemento As DataRow In DtComplementos.Rows
CveComplementoPagoCancelar = RowComplemento("CveComplementoPago").ToString().ToEntero()
FolioFiscalCancelar = RowComplemento("FolioFiscal").ToString()
'' Dim RFCEmisor As String = UsuarioActual.Empresa.RFC
RFCReceptorCancelar = RowComplemento("RFCReceptor").ToString()
CvePACCancelacion = RowComplemento("CvePAC").ToString().ToEntero()
Dim ObjCancelacion As New Timbrado
If EstatusSATCancelado(FolioFiscalCancelar, UsuarioActual.Empresa.RFC, RFCReceptorCancelar) Then
If Banc.UpdateComplementoPagoCancelado(CveComplementoPagoCancelar, 2, CvePACCancelacion, UsuarioActual.CveEmpresa, Date.Now, "", 1) Then
CargaComplementosPago()
RegistraScript("$('#ModalCancelarComplemetno').modal('hide');")
ErrorCancelarComplemento = False
Alert("El complemento se cancelo correctamente.")
Else
ErrorCancelarComplemento = True
End If
Else
Dim respCancelacion = ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion, CveSATMotivoCancelacion:=CveSATMotivoCancelacion)
If respCancelacion.Verificado Then
If Banc.UpdateComplementoPagoCancelado(CveComplementoPagoCancelar, 2, CvePACCancelacion, UsuarioActual.CveEmpresa, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse, CveSATMotivoCancelacion:=CveSATMotivoCancelacion) Then
CargaComplementosPago()
RegistraScript("$('#ModalCancelarComplemetno').modal('hide');")
ErrorCancelarComplemento = False
Alert("El complemento se cancelo correctamente.")
End If
Else
Alert("Se presento un error al cancelar el complemento.", TipoMensaje.MsgAdvertencia)
ErrorCancelarComplemento = True
End If
End If
Next
If DtComplementos IsNot Nothing Then
DtComplementos.Dispose()
DtComplementos = Nothing
End If
Else
ErrorCancelarComplemento = True
End If
Else
ErrorCancelarComplemento = False
End If
If Not ErrorCancelarComplemento AndAlso Not ErrorCancelar Then
If ObjAC IsNot Nothing Then ObjAC.Commit()
Banc.Commit()
Dim Msg As New StringBuilder
If CancelarComplemento Then
Msg.Append("El movimiento bancario y su complemento quedaron cancelados exitosamente.")
Else
Msg.Append("El movimiento bancario quedó cancelado exitosamente.")
End If
If IdPolizaNueva > 0 Then Msg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza de cancelación</a>", IdPolizaNueva)
Alert(Msg.ToString, TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""")
Else
If ObjAC IsNot Nothing Then ObjAC.RollBack()
Banc.RollBack()
Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
GuardaLog(MensajeError + " | CANCELAR IE")
End If
Else
If ObjAC IsNot Nothing Then ObjAC.RollBack()
Banc.RollBack()
Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
GuardaLog(MensajeError + " | CANCELAR IE")
End If
Catch ex As Exception
OnError("Ocurrio un error al cancelar", ex)
End Try
If ObjAC IsNot Nothing Then ObjAC.Dispose()
Banc.Dispose()
ObjConta.Dispose()
End Sub
'Protected Sub BtnDevueltoIE_Click(sender As Object, e As EventArgs)
' RegistraScript("$('#DivChqDevueltoIE').modal('hide');")
' ChequeDevuelto()
'End Sub
'Private Sub ChequeDevuelto()
' If Not IsDate(TxtFechaDevuelto.Text.ToDate) Then
' Alert("El campo fecha cancelación es incorrecto. Por favor verifique y vuelva a intentar")
' Exit Sub
' End If
' If ChkConciliado.Checked Then
' Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgError)
' Exit Sub
' End If
' Dim Banc As New ClsBancos
' Banc.IniciaTransacSQL()
' Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL)
' Dim ObjAC As ClsContPAQi = Nothing
' If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") Then
' ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
' ObjAC.IniciaTransacSQL()
' End If
' Dim ErrorCancelar = False
' Dim IdPolizaNueva = -1
' Dim FolioPolizaNueva = -1
' If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1")) Then
' If ObjAC Is Nothing Then
' ErrorCancelar = True
' End If
' If Not ErrorCancelar Then
' Dim dt As DataTable
' If ObjAC.GetPoliza(IDPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then
' dt = ObjAC.DtResultados
' ' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS)
' IdPolizaNueva = ObjAC.AddPoliza(1, String.Format("Cheque Devuelto: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaDevuelto.Text.ToDate)
' If IdPolizaNueva > 0 Then
' FolioPolizaNueva = ObjAC.Folio
' 'CREA POLIZA NEGATIVA
' For Each dr As DataRow In dt.Rows
' If Not ObjAC.AddMovimiento(IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaDevuelto.Text.ToDate, "") Then
' ErrorCancelar = True : Exit For
' End If
' Next
' 'AJUSTA POLIZA
' If Not ErrorCancelar Then
' If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then
' ErrorCancelar = True
' End If
' End If
' 'genera nuevo IE contrario
' If Not ErrorCancelar Then
' If Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, FolioPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2, 16) <= 0 Then
' ErrorCancelar = True
' End If
' End If
' Else
' ErrorCancelar = True
' End If
' End If
' End If
' Else
' 'siempre se hace una cancelación
' If Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, FolioPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2, 16) <= 0 Then
' ErrorCancelar = True
' End If
' If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
' If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
' IDPoliza = ObjConta.ContaIdPoliza
' Else
' ErrorCancelar = True
' Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia)
' End If
' End If
' End If
' If Not ErrorCancelar Then
' If ObjAC IsNot Nothing Then ObjAC.Commit()
' Banc.Commit()
' Dim Msg As New StringBuilder
' Msg.Append("El movimiento bancario quedó devuelto exitosamente.")
' If IdPolizaNueva > 0 Then Msg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza de cancelación</a>", IdPolizaNueva)
' Alert(Msg.ToString, TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""")
' Else
' If ObjAC IsNot Nothing Then ObjAC.RollBack()
' Banc.RollBack()
' Alert("El movimiento bancario no se pudo registrar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
' End If
' If ObjAC IsNot Nothing Then ObjAC.Dispose()
' Banc.Dispose()
'End Sub
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs) Handles LnkEliminar.Click
If CveIECancelado > 0 Then
Alert("El Movimiento no se puede eliminar porque tiene una cancelación relacionada, se tiene que eliminar primero la cancelación", TipoMensaje.MsgAdvertencia)
Else
RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion"))
End If
End Sub
#End Region
Private Sub CambiaTipoMoneda()
If CveMoneda > 1 Then
TrTipoCambio.Visible = True
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString
Else
TrTipoCambio.Visible = False
End If
UpTipoCambio.Update()
End Sub
<WebMethod()> <Script.Services.ScriptMethodAttribute()>
Public Shared Function wsImporteLetra(ByVal contextKey As System.String, ByVal tCveMoneda As Integer) As System.String
Dim Retorno As String = ""
If contextKey.ToDouble >= 0 Then
Retorno = String.Format("---{0}---", contextKey.ToDouble.Texto2Letras(tCveMoneda))
End If
Return Retorno
End Function
Protected Sub RBL_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBL.SelectedIndexChanged
ChkAplicaViatico.Visible = False
If RBL.SelectedValue = "FE" Then
If UsuarioActual.CveRol = 1 Then ChkAplicaViatico.Visible = True
DdlPersonal.Visible = True
DdlProveedores.Visible = False
DdlCliente.Visible = False
ElseIf RBL.SelectedValue = "P" Then
DdlPersonal.Visible = False
DdlProveedores.Visible = True
DdlCliente.Visible = False
ElseIf RBL.SelectedValue = "C" Then
DdlPersonal.Visible = False
DdlProveedores.Visible = False
DdlCliente.Visible = True
ElseIf RBL.SelectedValue = "AC" Then
DdlPersonal.Visible = False
DdlProveedores.Visible = True
DdlCliente.Visible = False
Else
End If
If RBL.SelectedValue = "C" AndAlso Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("DEV") Then
DdlTipoTransaccion.Items.Clear()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs'")
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
ElseIf RBL.SelectedValue = "P" AndAlso Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("DEV") Then
DdlTipoTransaccion.Items.Clear()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones()
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
ElseIf RBL.SelectedValue = "DD" AndAlso Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("DEV") Then
DdlTipoTransaccion.Items.Clear()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones()
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("DEV") Then
DdlTipoTransaccion.Items.Clear()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing'")
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
End If
'Apartado Nueva Modalidad de INGPC Charlie
If RBL.SelectedValue = "C" AndAlso Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("INGPC", "DEV") Then
DivIvaIxC.Visible = True
End If
UpDatos.Update()
End Sub
#Region " IMPRIMIR "
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
If CveIE > 0 Then GeneraChequePDF(CveIE, UsuarioActual.Empresa)
End Sub
#End Region
#Region "E V E N T O - B I T A C O R A"
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).Width = Unit.Pixel(200)
e.Row.Cells(1).Width = Unit.Pixel(200)
e.Row.Cells(2).Width = Unit.Pixel(100)
e.Row.Cells(3).Width = Unit.Pixel(500)
End If
If e.Row.DBCampo("Archivo").ToString <> "" Then
e.Row.FCLinkButton("LinkArchivo").Visible = True
e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString)
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
End If
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
End If
End Sub
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
Dim ObjEventoBitacora As New ClsOIEventos
Dim FileExtension As String = "" 'Anteriormente -1
Dim filesgral As List(Of Archivo) = Anexo2.getfiles().Archivos
Dim filemove As String = ""
For Each fileItem As Archivo In filesgral
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
filemove = fileItem.filename
Next
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format("{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
If filemove <> "" Then
filemove.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
End If
GvEB.DataSource = ObjEventoBitacora.DtResultados
TxtEventoDescripcion.Text = ""
Anexo2.Text = "[]"
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
End If
ObjEventoBitacora.Dispose()
GvEB.DataBind()
UPEventoBitacora.Update()
CargaEventoBitacora()
UPAddEventoBitacora.Update()
End Sub
Private Sub CargaEventoBitacora()
If CveIE <= 0 Then Exit Sub
Dim ObjEventoBitacora As New ClsOIEventos()
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
'GVEventoBitacora.DataSource = ObjEventoBitacora.DtResultados
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
Else
GvEB.DataSource = Nothing
End If
ObjEventoBitacora.Dispose()
GvEB.DataBind()
End Sub
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
If IO.File.Exists(filePath) Then
Dim Archivo As New System.IO.FileInfo(filePath)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/octet-stream"
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
HttpContext.Current.Response.TransmitFile(filePath)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
Archivo = Nothing
End If
End Sub
#End Region
#Region " C O N T A B I L I D A D DESASOCIAR POLIZA "
Protected Sub BtnContabilizar_Click(sender As Object, e As EventArgs)
Dim ObjMov As New ClsContabilidad
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
Alert(alertaContabilizacion & ObjMov.AlertaMensaje, ModExtensiones.TipoMensaje.MsgInformacion)
Else
Alert(String.Format("Ocurrio un error al contabilizar {0}", ObjMov.AlertaMensaje))
End If
ObjMov.Dispose()
End Sub
Protected Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs)
Dim ObjConta As New ClsContabilidad
Dim Movimientos = ObjConta.GetMovimientosPoliza(IDPoliza, UsuarioActual.CveEmpresa)
'Verifica que solo exista 1 compra asociada
If Movimientos = 1 Then
EliminaPoliza()
Else
RegistraScript("ConfirmEliminarPoliza();")
End If
ObjConta.Dispose()
End Sub
'Protected Sub BtnEliminarMov_Click(sender As Object, e As EventArgs) Handles BtnEliminarMov.Click
' Dim ObjBancos As New ClsBancos
' ObjBancos.IniciaTransacSQL()
' If ObjBancos.EliminarBancos_IEComprobacion(UsuarioActual.CveUsuario, CveIE) Then
' Alert("Los Movimientos Bancarios se eliminaron correctamente.", TipoMensaje.MsgInformacion)
' GvRH.Visible = False
' DivEliminar.Visible = False
' ObjBancos.Commit()
' Else
' ObjBancos.RollBack()
' End If
' ObjBancos.Dispose()
'End Sub
Protected Sub BtnEliminarPoliza_Click(sender As Object, e As EventArgs)
EliminaPoliza()
End Sub
Private Sub EliminaPoliza()
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL()
Dim ErrorCompra = False
'Elimina la poliza
If (UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IDPoliza > 0 Then
If Not ObjAC.RemovePoliza(IDPoliza) Then
ErrorCompra = True
End If
End If
'Desasocia la poliza
If Not ErrorCompra Then
If Not ObjConta.DesasociarPoliza(IDPoliza, UsuarioActual.CveEmpresa) Then
ErrorCompra = True
End If
End If
If Not ErrorCompra Then
If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
ErrorCompra = True
End If
End If
If Not ErrorCompra Then
Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion)
ObjAC.Commit()
ObjConta.Commit()
Else
Alert("Ocurrió un error al desvincular y/o eliminar la poliza. Por favor intente de nuevo ", TipoMensaje.MsgError)
ObjAC.RollBack()
ObjConta.RollBack()
End If
ObjAC.Dispose()
ObjConta.Dispose()
If Not ErrorCompra Then
CargaDatos()
End If
End If
End Sub
#End Region
#Region " CARGAR - COMPROBANTE "
Protected Sub BtnConfirmaComprobante_Click(sender As Object, e As EventArgs)
Dim DirectorioGuardar = String.Format("{0}IE", UsuarioActual.Empresa.Ruta)
Dim ArchivoTemporal = String.Format("{0}Temp\{1}", UsuarioActual.Empresa.Ruta, Session("FileUpload").ToString)
If Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(ArchivoTemporal) Then
Dim Extension As String = Path.GetExtension(ArchivoTemporal)
Dim ObjIE As New ClsBancos
ObjIE.IniciaTransacSQL()
Dim TieneError = False
If ObjIE.UpdateComprobanteIE(Extension.Replace("."c, ""), CveIE) Then
If Not Directory.Exists(DirectorioGuardar) Then Directory.CreateDirectory(DirectorioGuardar)
'Si ya existe el archivo lo eliminamos, para evitar error
If File.Exists(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension)) Then
File.Delete(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension))
End If
File.Move(ArchivoTemporal, String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension))
If Not File.Exists(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension)) Then
TieneError = True
End If
Else
TieneError = True
End If
If Not TieneError Then
ObjIE.Commit()
Alert("El Comprobante se guardo exitosamente.", TipoMensaje.MsgInformacion)
If HplComprobante.Visible = False Then
HplComprobante.Visible = True
HplComprobante.NavigateUrl = String.Format("/Empresas/{0}/IE/{1}{2}", UsuarioActual.CveEmpresa, CveIE, Extension)
UpDatos.Update()
End If
Else
ObjIE.RollBack()
Alert("Ocurrió un error al guardar el comprobante. Por favor vuelta a intentar.", TipoMensaje.MsgError)
End If
Session("FileUpload") = ""
ObjIE.Dispose()
End If
End Sub
Protected Sub BtnGuardarArchivo_Click(sender As Object, e As EventArgs) Handles BtnGuardarArchivo.Click
Dim ObjIE As New ClsBancos
Dim Comprobante As String = ""
Dim Filesgral As List(Of Archivo) = TxtCargarArchivo.getfiles().Archivos
If Filesgral.Count > 0 Then
Dim fileItem As Archivo = Filesgral(0)
Dim Path As String = HttpContext.Current.Request.ApplicationPath
Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
Path = String.Format("{0}IE", UsuarioActual.Empresa.Ruta)
If Not Directory.Exists(Path) Then
Directory.CreateDirectory(Path)
End If
Path += $"/{CveIE}.{Comprobante}"
If File.Exists(Path) Then
File.Delete(Path)
End If
My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path)
End If
TxtCargarArchivo.Text = ""
RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1")
If ObjIE.UpdateComprobanteIE(Comprobante.Replace("."c, ""), CveIE) Then
Alert("El Comprobante se guardo exitosamente.", TipoMensaje.MsgInformacion)
End If
ObjIE.Dispose()
End Sub
#End Region
#Region " DEVOLUCIONES "
Private Sub CargaIEDevoluciones()
Dim ObjMov As New ClsMovimientos
If HdnCveProveedor.Value.ToEntero > 0 Or HdnCvePersonal.Value.ToEntero > 0 Then
trIEDevolucion.Visible = True
If ObjMov.GetEgresosSinComprobar("-1", "-1", HdnCveProveedor.Value.ToEntero, HdnCvePersonal.Value.ToEntero, -1, -1, -1, CveMoneda, -1, UsuarioActual.CveEmpresa) Then
DtIEDevolucion = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ", "", {"CveIE", "IEDevolucion", "Saldo"})
Else
Alert("Ocurrió un error al cargar los Egresos del Proveedor seleccionado. Por favor vuelva a intetar.", TipoMensaje.MsgError)
End If
End If
ObjMov.Dispose()
'CARGAMOS LOS IE EN EL DLL
DdlIEDevolucion.Items.Clear()
DdlIEDevolucion.DataSource = DtIEDevolucion
DdlIEDevolucion.DataBind()
DdlIEDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1"))
UpIEDevolucion.Update()
End Sub
Private Sub CargaIEDevolucionesClientes()
Dim ObjMov As New ClsMovimientos
If HdnCveCliente.Value.ToEntero > 0 Then
trIEDevolucion.Visible = True
If ObjMov.GetMovimientosIE(1, HdnCveCliente.Value.ToEntero, DdlCuenta.SelectedValue.ToEntero, Now.AddMonths(-24), Now, CveMoneda, -1, UsuarioActual.CveEmpresa) Then
DtIEDevolucion = ObjMov.DtResultados.FiltraParametros("Saldo > 0 ")
Else
Alert("Ocurrió un error al cargar los Egresos del Proveedor seleccionado. Por favor vuelva a intetar.", TipoMensaje.MsgError)
End If
End If
ObjMov.Dispose()
'CARGAMOS LOS IE EN EL DLL
DdlIEDevolucion.Items.Clear()
DdlIEDevolucion.DataSource = DtIEDevolucion
DdlIEDevolucion.DataBind()
DdlIEDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1"))
UpIEDevolucion.Update()
End Sub
Private Sub DdlIEDevolucion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIEDevolucion.SelectedIndexChanged
If DtIEDevolucion.Rows.Count > 0 Then
TxtImporte.Text = DtIEDevolucion.FiltroPrimeroValor("Saldo", String.Format("CveIE = {0}", DdlIEDevolucion.SelectedValue.ToEntero)).FormatoNumero()
End If
UpDatos.Update()
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 "PAGO ACREEDORES"
Private Sub CargaIEIngresos()
Dim ObjMov As New ClsMovimientos
If HdnCveProveedor.Value.ToEntero > 0 Then
DivIEAcreedor.Visible = True
DdlIEDevolucion.Items.Clear()
If ObjMov.GetIngresosAcreedorXSaldar(HdnCveProveedor.Value.ToEntero, CveMoneda, UsuarioActual.CveEmpresa) Then
DdlIEAcreedor.DataSource = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ", "", {"CveIE", "IEAcreedor", "Saldo"})
DdlIEAcreedor.DataBind()
DdlIEAcreedor.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
End If
ObjMov.Dispose()
UpIEAcreedor.Update()
End Sub
#End Region
#Region "I M P R I M E P D F - N U E V O -"
Private Sub ImprimirIEPDF(CveTipoTransaccion As Integer)
Dim Archivo As System.IO.FileInfo = Nothing
'VERIFICA SI EXISTE EL FORMATO
If CveTipoTransaccion.Contiene(2, 8, 9, 10) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta))
ElseIf CveTipoTransaccion.Contiene(1) Then
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, CveCuenta))
End If
''PRUEBAS AD-TEAM
'LnkImprimir.Visible = False
'If UsuarioActual.CveUsuario = 100 Then
' LnkImprimir.Visible = True
'End If
If Archivo IsNot Nothing AndAlso Archivo.Exists Then
HLImprimir.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=IE&CVEIE={0}", CveIE)))
HLImprimir.Visible = True
Else
HLImprimir.Visible = False
End If
End Sub
#End Region
#Region " CUENTAS DEPOSITOS "
'Si la cuenta no esta activa, no la muestra.
Private Sub CargaCuentasDepositos()
DdlCuentaDeposito.Items.Clear()
'If DdlTipoTransaccion.SelectedValue.Contiene("2", "9") Then ' transferencias y layout
trCuentaDeposito.Visible = False
Dim dtc As DataTable = Nothing
If CveProveedor > 0 Then
dtc = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
ElseIf CveCliente > 0 Then
dtc = GlobalDTCuentasDepositosClientes(UsuarioActual.CveEmpresa, CveCliente:=CveCliente)
End If
' If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCliente:=CveCliente, CvePersonal:=CvePersonal) Then
If dtc IsNot Nothing Then
If DdlTipoTransaccion.SelectedValue = "9" And CveIE <= -1 Then
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
Else
Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
End If
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
ElseIf DdlTipoTransaccion.SelectedValue = "17" And CveIE <= -1 Then
If dtc.Rows.Count > 0 Then
DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus = 'True' ")
trCuentaDeposito.Visible = True
BtnGuardar.ToolTip = ""
Else
BtnGuardar.Enabled = False
Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
End If
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
UpGuardar.Update()
Else
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
If dtc.Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
End If
End If
Else
If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") And CveIE <= -1 Then
BtnGuardar.Enabled = False
Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia)
BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
Else
trCuentaDeposito.Visible = True
BtnGuardar.Enabled = True
End If
UpGuardar.Update()
End If
'If DdlTipoTransaccion.SelectedValue = "9" AndAlso DdlCuentaDeposito.Items.Count = 0 Then
' BtnIEGuardar.Enabled = False
'End If
'GVCuentasPago.DataBind()
DdlCuentaDeposito.DataBind()
'Else
' trCuentaDeposito.Visible = False
' DdlCuentaDeposito.Items.Clear()
'End If
UpCuentaDeposito.Update()
UpDatos.Update()
End Sub
Private Sub RecargaCuentasDepositos()
If CveProveedor > 0 Then
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
End If
'cuando es transferencia bancaria, debe de solicitar a que cuenta se va a depositar
CargaCuentasDepositos()
End If
If CveCliente > 0 Then
CargaCuentasDepositoClientes()
End If
End Sub
Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim Dep As New ClsGenerales
If DdlCuentaDeposito.SelectedValue.ToEntero > 0 Then
If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then
If Dep.DtResultados.Rows.Count > 0 Then
If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then
TrReferenciaCIE.Visible = True
TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString
TxtConceptoCIE.Text = Dep.DtResultados.Rows(0)("ConceptoCIE").ToString
OriReferenciaCIE = Dep.DtResultados.Rows(0)("Referencia").ToString
OriConceptoCIE = Dep.DtResultados.Rows(0)("ConceptoCIE").ToString
Else
TrReferenciaCIE.Visible = False
End If
If Boolean.Parse(Dep.DtResultados.Rows(0)("EstatusPagoElectronicoGrupos").ToString) AndAlso Dep.DtResultados.Rows(0)("CveSATBanco").ToString.ToEntero <= 0 Then
Alert("Es necesario establecer el banco de la cuenta deposito", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
Else
BtnGuardar.Enabled = True
End If
Else
TrReferenciaCIE.Visible = False
End If
Else
TrReferenciaCIE.Visible = False
End If
Else
TrReferenciaCIE.Visible = False
End If
Dep.Dispose()
UpCuentaDeposito.Update()
UpGuardar.Update()
End Sub
#End Region
#Region "Historial de Modificacion"
Private Sub CargaGvBitacora()
Dim ObjGral As New ClsGenerales()
If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, -1, CveIE, UsuarioActual.CveEmpresa) Then
GvBitacora.DataSource = ObjGral.DtResultados
GvBitacora.DataBind()
End If
ObjGral.Dispose()
UpDatos.Update()
End Sub
Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click
If Not TxtDescripcion.Text = "" Then
If ChkConciliado.Checked Then
Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgError)
Exit Sub
End If
Dim ObjAC As ClsContPAQi = Nothing
Dim Banc As New ClsBancos
Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL())
Dim ObjGral As New ClsGenerales(Banc.IniciaTransacSQL())
Dim DescripcionAus As String = TxtDescripcion.Text
If DdlTipoTransaccion.SelectedItem.Text <> "Seleccione Tipo Movimiento" Then DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Movimiento: {DdlTipoTransaccion.SelectedItem.Text}")
DescripcionAus = $"{DescripcionAus}, Fecha Documento: {TxtFechaDocumento.Text} , Observaciones: {TxtObservaciones.Text} . "
If DdlCuenta.SelectedItem.Text <> "Seleccione" Then DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Cuenta:{DdlCuenta.SelectedItem.Text}")
If TxtFolio.Text <> "" Then DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Número:{TxtFolio.Text}")
If TxtImporte.Text <> "" AndAlso TxtImporte.Text <> "0" Then DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Importe:{TxtImporte.Text}")
If DdlCliente.Visible Then
DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Páguese A:{DdlCliente.SelectedText}")
ElseIf DdlProveedores.Visible Then
DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Páguese A:{DdlProveedores.SelectedText}")
ElseIf DdlPersonal.Visible Then
DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Páguese A:{DdlPersonal.SelectedItem.Text}")
End If
DescripcionAus = String.Format("{0} {1}", DescripcionAus, $"Fecha:{TxtFechaDocumento.Text}")
If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, DescripcionAus, "Banco", TxtFolio.Text + " / " + Cuenta) Then
Borrar = True
End If
If Borrar = True Then
Dim ErrorCompra = False
Dim MsgEliminar As String = ""
'VERIFICA SI EL IES ESTA VINCULADO A UNA SOLICITUD VIATICO
If Banc.GetSolicitudesViaticos(-1, UsuarioActual.CveEmpresa, CveIE:=CveIE) AndAlso Banc.DtResultados.Rows.Count > 0 Then
If Not Banc.UpdateSolicitudesViaticosIE(Banc.DtResultados.FiltroPrimeroValor("CveSolicitudViatico").ToEntero(), -1) Then
ErrorCompra = True
MsgEliminar = "Documento con solicitud de viáticos solicitado"
End If
End If
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ((UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IDPoliza > 0) Then
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
If Not ObjAC.RemovePoliza(IDPoliza) Then
ErrorCompra = True
MsgEliminar = "- No se pudo eliminar la póliza"
End If
End If
If Not ErrorCompra Then
If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
ErrorCompra = True
MsgEliminar += "- No se pudo desbloquear la prepóliza"
End If
End If
If Not ErrorCompra Then
If Not Banc.EliminarBancos_IE(UsuarioActual.CveUsuario, CveIE) Then
ErrorCompra = True
MsgEliminar = "- No se pudo eliminar el movimiento bancario"
End If
End If
If Not ErrorCompra Then
If ObjAC IsNot Nothing Then ObjAC.Commit()
If Banc.ExisteConexion Then
Banc.Commit()
Alert($"El documento bancario quedó eliminado. {MsgEliminar}", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""")
End If
Else
Alert($"El documento no ha sido eliminado. {If(UsuarioActual.CveRol = 1, MsgEliminar, "")}", TipoMensaje.MsgAdvertencia)
If ObjAC IsNot Nothing Then ObjAC.RollBack()
If Banc.ExisteConexion Then
Banc.RollBack()
End If
End If
If ObjAC IsNot Nothing Then ObjAC.Dispose()
Banc.Dispose()
ObjConta.Dispose()
ObjGral.Dispose()
End If
Else
Alert("Tiene que decir el motivo de su eliminacion.", TipoMensaje.MsgInformacion)
End If
End Sub
#End Region
#Region " SOLICITUD DE ANTICIPO OC "
Private Sub InicializaSolicitudAnticipoOC()
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSSINFACT" Then
If Request("CveOC") IsNot Nothing AndAlso Request("CveOC").ToString.ToEntero > 0 Then
CveOCSolicitudAnticipo = Request("CveOC").ToString.ToEntero
TxtImporte.Enabled = False
End If
End If
If CveOCSolicitudAnticipo > 0 Then
Dim ObjOC As New ClsOC
If ObjOC.GetOCAnticipoSaldo(CveOCSolicitudAnticipo, UsuarioActual.CveEmpresa) Then
SaldoOCAnticipo = ObjOC.DtResultados(0)("Saldo").ToString.ToDecimal
Else
SaldoOCAnticipo = 0
End If
If ObjOC.GetSolicitudAnticipo(CveOCSolicitudAnticipo, UsuarioActual.CveEmpresa) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then
Dim DrOC = ObjOC.DtResultados.FiltroPrimero("")
If DrOC("TipoTermino").ToString.ToEntero.Contiene(0, 3) Then
TxtObservaciones.Text = DrOC("Descripcion").ToString
If DrOC("ImporteAnticipo").ToString.ToDecimal > SaldoOCAnticipo Then
'TxtImporte.Text = SaldoOCAnticipo.ToString().FormatoNumero
'TxtImporteLetra.Text = SaldoOCAnticipo.ToString().FormatoNumero.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero)
Alert($"El importe solcitado es superior al saldo de la compra, importe solicitado: {DrOC("ImporteAnticipo").ToString.FormatoNumero} saldo: {SaldoOCAnticipo.ToString().FormatoNumero }", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
Else
TxtImporte.Text = DrOC("ImporteAnticipo").ToString.FormatoNumero
TxtImporteLetra.Text = DrOC("ImporteAnticipo").ToString.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero)
ImporteOriginalDolaras = DrOC("ImporteAnticipo").ToString.ToDecimal
End If
CveMoneda = DrOC("CveMoneda").ToString.ToEntero
CargaCuenta(CveMoneda)
CveMonedaOriginal = CveMoneda
If CveMonedaOriginal > 1 Then
MostrarPagoEnPesos(True)
End If
UpCuentaDeposito.Update()
If DrOC("CveProveedor").ToString.ToEntero > 0 Then
HdnCveProveedor.Value = DrOC("CveProveedor").ToString
RBL.SelectedValue = "P"
RBL_SelectedIndexChanged(RBL, Nothing)
DdlProveedores.SelectedValue = HdnCveProveedor.Value
DdlProveedores_selectedindexchange(DdlProveedores, Nothing)
DdlProveedores.SelectedText = RazonSocial
' BuscaCargaProveedor()
End If
CveOCSolicitudAnticipo = DrOC("CveOC").ToString.ToEntero
Else
'If DrOC("CveIEAnticipo").ToString <> "" Then
' Alert($"La {DrOC("Tipo")} #{DrOC("Folio")} ya se le ha generado un anticipo.", TipoMensaje.MsgError)
'End If
If DrOC("TipoTermino").ToString = "3" Then ' cuando es tipo rechazado
Alert($"La {DrOC("Tipo")} #{DrOC("Folio")} ha sido cancelada.", TipoMensaje.MsgError)
CveOCSolicitudAnticipo = -1
BtnGuardar.Enabled = False
End If
End If
Else
Alert("Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ. Por favor actualice y vuelva a intentar.", TipoMensaje.MsgError)
End If
'If ObjOC.GetSolicitudAnticipo(CveOCSolicitudAnticipo, UsuarioActual.CveEmpresa) AndAlso ObjOC.DtResultados.Rows.Count > 0 Then
' Dim DrOC = ObjOC.DtResultados.FiltroPrimero("")
' If DrOC("TipoTermino").ToString.ToEntero.Contiene(0, 3) AndAlso DrOC("CveIEAnticipo").ToString = "" Then
' TxtObservaciones.Text = DrOC("Descripcion").ToString
' If DrOC("ImporteAnticipo").ToString.ToDecimal > SaldoOCAnticipo Then
' 'TxtImporte.Text = SaldoOCAnticipo.ToString().FormatoNumero
' 'TxtImporteLetra.Text = SaldoOCAnticipo.ToString().FormatoNumero.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero)
' Alert($"El importe solcitado es superior al saldo de la compra, importe solicitado: {DrOC("ImporteAnticipo").ToString.FormatoNumero} saldo: {SaldoOCAnticipo.ToString().FormatoNumero } se cambio", TipoMensaje.MsgAdvertencia)
' Else
' TxtImporte.Text = DrOC("ImporteAnticipo").ToString.FormatoNumero
' TxtImporteLetra.Text = DrOC("ImporteAnticipo").ToString.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero)
' End If
' DdlMoneda.SelectedValue = DrOC("CveMoneda").ToString
' CveMoneda = DrOC("CveMoneda").ToString.ToEntero
' CargaCuenta(DrOC("CveMoneda").ToString.ToEntero)
' UpCuentaDeposito.Update()
' If DrOC("CveProveedor").ToString.ToEntero > 0 Then
' HdnCveProveedor.Value = DrOC("CveProveedor").ToString
' RBL.SelectedValue = "P"
' RBL_SelectedIndexChanged(RBL, Nothing)
' DdlProveedores.SelectedValue = HdnCveProveedor.Value
' DdlProveedores_selectedindexchange(DdlProveedores, Nothing)
' DdlProveedores.SelectedText = RazonSocial
' ' BuscaCargaProveedor()
' End If
' CveOCSolicitudAnticipo = DrOC("CveOC").ToString.ToEntero
' Else
' If DrOC("CveIEAnticipo").ToString <> "" Then
' Alert($"La {DrOC("Tipo")} #{DrOC("Folio")} ya se le ha generado un anticipo.", TipoMensaje.MsgError)
' End If
' If DrOC("TipoTermino").ToString = "3" Then ' cuando es tipo rechazado
' Alert($"La {DrOC("Tipo")} #{DrOC("Folio")} ha sido cancelada.", TipoMensaje.MsgError)
' End If
' CveOCSolicitudAnticipo = -1
' BtnGuardar.Enabled = False
' End If
'Else
' Alert("Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ. Por favor actualice y vuelva a intentar.", TipoMensaje.MsgError)
'End If
ObjOC.Dispose()
End If
End Sub
Private Sub MostrarPagoEnPesos(Mostrar As Boolean)
LbTipoMoneda.Visible = Mostrar
LbTipoMoneda.Text = If(Mostrar, "Pago en doalres", "")
DVPAgoEnPesos.Visible = Mostrar
ChkPagarPesos.Visible = Mostrar
TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
End Sub
Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
If ChkPagarPesos.Checked Then
DivTC.Visible = True
DivTC2.Visible = True
' DivDolaresDolares.Visible = False
'CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
CargaCuenta(1)
'TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
'TxtTC.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
TxtImporteDolares.Text = TxtImporte.Text
'TxtImporteDolares.Text = TxtImporte.Text
'TxtImporte.Text = (TxtImporte.Text.ToDecimal * (TxtTC.Text.ToDecimal)).ToString("###,###,###.00")
CveMoneda = 1
Else
DivTC.Visible = False
DivTC2.Visible = False
CveMoneda = CveMonedaOriginal
'DivDolaresDolares.Visible = True
'CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
CargaCuenta(CveMonedaOriginal)
'TxtFechaDocumento.Attributes.Remove("onchange")
TxtImporte.Text = ImporteOriginalDolaras.ToString("###,###,###.00")
End If
CambiaTCPagoOC()
UpDatos.Update()
' RegistraScript("CambiaPesosDolares();")
End Sub
Public Sub CambiaTCPagoOC()
If ChkPagarPesos.Checked Then
TxtImporte.Text = (TxtImporteDolares.Text.ToDecimal * (TxtTC.Text.ToDecimal)).ToString("###,###,###.00")
Else
TxtImporte.Text = TxtImporteDolares.Text
End If
UpDatos.Update()
End Sub
Protected Sub LnkActualizaTCOC_Click(sender As Object, e As EventArgs)
CambiaTCPagoOC()
End Sub
Private Function GuardaSolicitudAnticipoOC(ByRef ObjOC As ClsOC) As String
Dim ObjOI As New ClsOIEventos
Dim CveEvento As Integer = 0
Dim CveEventoPrincipal As Integer = 0
If CveOCSolicitudAnticipo > 0 Then
If Not ObjOC.AddSolicitudAnticipoPago(CveOCSolicitudAnticipo, CveIE, UsuarioActual.CveEmpresa) Then
ObjOI.Dispose()
Return "Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ. Por favor actualice y vuelva a intentar."
End If
If ObjOI.GetEventos(-1, 6, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, CveOCSolicitudAnticipo, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
CveEvento = ObjOI.CveEvento
End If
If ObjOI.GetEventos(-1, 1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, Request("CveOC").ToString.ToEntero, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
CveEventoPrincipal = ObjOI.CveEvento
End If
If CveEvento = 0 Then
ObjOI.Dispose()
Return "Ocurrió un error al obtener el evento relacionado"
End If
If CveEventoPrincipal = 0 Then
ObjOI.Dispose()
Return "Ocurrió un error al obtener el evento relacionado ppal."
End If
If Not ObjOI.UpdateEstatusEvento(3, -1, CveEvento, UsuarioActual.CveUsuario) Then
ObjOI.Dispose()
Return "Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ. Por favor actualice y vuelva a intentar."
End If
If Request("CveOC").ToString.ToEntero > 0 Then
If Not ObjOI.UpdateEstatusEvento(3, -1, CveEventoPrincipal, UsuarioActual.CveUsuario) Then
ObjOI.Dispose()
Return "Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ. Por favor actualice y vuelva a intentar."
End If
End If
End If
ObjOI.Dispose()
Return ""
End Function
#End Region
#Region " COMPLEMENTOS PAGO "
Private Sub CargaComplementosPago()
Dim ObjBancos As New ClsBancos
DVGenerarComplementoModal.Visible = False
If Tipo = "Abono" Then
If ObjBancos.GetVincularPago(CveProveedor, CveCompra, 2, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, CveIE) Then
GvComplementoPagos.DataSource = ObjBancos.DtResultados
Else
GvComplementoPagos.DataSource = Nothing
End If
GvComplementoPagos.Columns(7).Visible = False
Else
If CveIE > 0 Then
If ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then
If ObjBancos.DtResultados.FiltraParametros(" Estatus IN (1,3) ").Rows.Count = 0 And Tipo.ToUpper = "CARGO" And CveCliente > 0 And CveEstatusIE <> 2 Then
DVGenerarComplementoModal.Visible = True
End If
If ObjBancos.DtResultados.FiltraParametros(" Estatus IN (1,3) ").Rows.Count = 1 And Tipo.ToUpper = "CARGO" And CveCliente > 0 And CveEstatusIE <> 2 Then
DivCancelarComplemento.Visible = True
End If
' GvComplementoPagos.DataSource = ObjBancos.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"})
GvComplementoPagos.DataSource = ObjBancos.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "FolioFiscal", "Folio", "SerieFolio", "FechaComplemento", "Importe", "RFCReceptor", "StrEstatus", "FechaCancelacion", "Tipo", "Estatus", "CveIE", "CvePAC", "MotivoCancelacion"})
'"CveComplementoPago","FolioFiscal","Folio","SerieFolio","FechaComplemento","Importe","RFCReceptor","StrEstatus","FechaCancelacion","Tipo,Estatus","CveIE","CvePAC"
End If
End If
GvComplementoPagos.Columns(7).Visible = True
End If
ObjBancos.Dispose()
GvComplementoPagos.DataBind()
UpComplementoPagos.Update()
UpEliminarCotizacion.Update() 'Esto se ocupa para mostrar DVmotivoCancelacion
'ObjBancos.Dispose()
'GvComplementoPagos.DataBind()
'UpComplementoPagos.Update()
End Sub
Protected Sub GvComplementoPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvComplementoPagos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataKey("Tipo") = "Ing" Then
e.Row.Cells(3).Text = String.Format("<a class="" texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank""><i class="" fa fa-file-code-o""></i></a>", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CVECOMPLEMENTOPAGO={1}&CVEIE={2}", e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("CveIE"))))
e.Row.Cells(4).Text = String.Format("<a class="" texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank""><i class="" fa fa-ad-pdf""></i></a>", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CVECOMPLEMENTOPAGO={1}&CVEIE={2}", e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("CveIE"))))
If e.Row.DataKey("Estatus").Contiene("1", "3") Then
e.Row.FCLinkButton("LnkCancelarComplemetno").Visible = True
e.Row.FCDropDownList("DdlMotivoCancelacion").Visible = True
e.Row.FCDropDownList("DdlMotivoCancelacion").DataSource = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa).FiltraParametros("CveSATMotivoCancelacion IN (2,3)")
e.Row.FCDropDownList("DdlMotivoCancelacion").DataBind()
e.Row.FCDropDownList("DdlMotivoCancelacion").Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
If e.Row.DataKey("Estatus").ToEntero = 1 Then
e.Row.FCLiteral("LtlMotivoCancelacion").Visible = True
End If
Else
e.Row.FCLinkButton("LnkCancelarComplemetno").Visible = False
e.Row.FCDropDownList("DdlMotivoCancelacion").Visible = False
If e.Row.DataKey("Estatus").ToEntero = 2 Then
e.Row.FCLiteral("LtlMotivoCancelacion").Visible = True
End If
End If
ElseIf e.Row.DataKey("Tipo") = "Egs" Then
e.Row.Cells(3).Text = String.Format("<a class=""texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank""><i class=""fa fa-file-code-o""></i></a>", Encripta(String.Format("OP=Fact&EXT=xml&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo(("RFCde").ToString.Replace("&", "%26%")))))
e.Row.Cells(4).Text = String.Format("<a class=""texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank""><i class=""fa fa-ad-pdf""></i></a>", Encripta(String.Format("OP=Fact&EXT=pdf&CveFactura={0}&RFC={1}", e.Row.DBCampo("CveFactura"), e.Row.DBCampo("RFCde").ToString.Replace("&", "%26%"))))
GvComplementoPagos.Columns(6).Visible = False
GvComplementoPagos.Columns(7).Visible = False
GvComplementoPagos.Columns(8).Visible = False
End If
End If
End Sub
Private Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) Handles LnkComplementoPago.Click
CargaComplementosPago()
RegistraScript("$('#ModalComplementoPagos').modal('show');")
End Sub
Private Function VerificaComplementos(Validos As Boolean) As Boolean
Dim ObjBancos As New ClsBancos
Dim Retorno As Boolean = False
Dim Filtro As String = ""
If Validos Then
Filtro = " Estatus IN(1,3) "
Else
Filtro = ""
End If
If CveIE > 0 AndAlso ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) AndAlso ObjBancos.DtResultados.FiltraParametros(Filtro).Rows.Count > 0 Then
Retorno = True
Else
Retorno = False
End If
ObjBancos.Dispose()
Return Retorno
End Function
'Protected Sub LnkCancelarComplemento_Click(sender As Object, e As EventArgs)
' If ChkConciliado.Checked Then
' Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgError)
' Exit Sub
' End If
' Confirmacion("¿Seguro que desea Cancelar el documento por Sustitución?", "", String.Format("document.location.href=""/Ventas/ClientesAbonar.aspx?CveIESustitucion={0}&CveCliente={1}&CveMoneda={2}""", CveIE, CveCliente, CveMoneda), "")
'End Sub
#End Region
#Region "SOLICITAR VIATICOS VIATICOS"
Protected Sub CargaDatosViaticos()
ViewState("CveSolicitudViatico") = Request("CveSolicitudViatico")
RBL.SelectedValue = "FE"
If Request("CvePersonal") IsNot Nothing AndAlso IsNumeric(Request("CvePersonal")) AndAlso Request("CvePersonal").ToEntero > 0 Then
ViewState("CvePersonal") = Request("CvePersonal")
PersonalIndexChange(CvePersonal)
Dim ObjBancos As New ClsBancos
If ObjBancos.GetSolicitudesViaticos(CveSolicitudViatico, UsuarioActual.CveEmpresa) AndAlso ObjBancos.DtResultados.Rows.Count > 0 Then
TxtImporte.Text = ObjBancos.DtResultados.FiltroPrimeroValor("Importe").ToString.FormatoNumero
TxtImporteLetra.Text = ObjBancos.DtResultados.FiltroPrimeroValor("Importe").ToString.ToDouble.Texto2Letras()
TxtObservaciones.Text = $"SOLICITUD DE VIÁTICOS - FOLIO {ObjBancos.DtResultados.FiltroPrimeroValor("Folio").ToString()}: {ObjBancos.DtResultados.FiltroPrimeroValor("Asunto").ToString()}."
End If
ObjBancos.Dispose()
End If
End Sub
#End Region
#Region " DEVOLVER DINERO ANT/NC "
Private Sub InicializaDevolverDinero()
If Opcion = "DevDinV" AndAlso Request("P") IsNot Nothing AndAlso Request("P").Length > 0 Then
Dim ParametrosTexto As String = Decripta(Request("P"))
If ParametrosTexto <> "" Then
CargaParametros(ParametrosTexto)
HdnCveCliente.Value = UrlParametros("CVECLIENTE").ToString
CveCliente = UrlParametros("CVECLIENTE").ToString.ToEntero
CveVentaDevDin = UrlParametros("CVEVENTA").ToString.ToEntero
SerieFolioDevDin = UrlParametros("SERIEFOLIO").ToString
CvePrePolizaDevDin = UrlParametros("CVEPREPOLIZA").ToString.ToEntero
ImporteOriginalDevDin = UrlParametros("ORIGINAL").ToString.ToDecimal.RoundSQL(6)
TxtImporte.Text = UrlParametros("SALDO").ToString.FormatoNumero()
TxtImporte.Attributes.Add("onkeyup", $"FormatoMoneda(this);ValidarCantidad(this,{UrlParametros("SALDO").ToString});")
TxtImporteLetra.Text = UrlParametros("SALDO").ToString.ToDouble.Texto2Letras(UrlParametros("CVEMONEDA").ToString.ToEntero)
CargaCliente(CveCliente)
'BuscarCliente()
CveMoneda = UrlParametros("CVEMONEDA").ToString.ToEntero
CargaCuenta(CveMoneda)
CambiaTipoMoneda()
UpCuentaDeposito.Update()
End If
End If
If Opcion = "DevDinC" AndAlso Request("P") IsNot Nothing AndAlso Request("P").Length > 0 Then
Dim ParametrosTexto As String = Decripta(Request("P"))
If ParametrosTexto <> "" Then
CargaParametros(ParametrosTexto)
HdnCveProveedor.Value = UrlParametros("CVEPROVEEDOR").ToString
CveProveedor = UrlParametros("CVEPROVEEDOR").ToString.ToEntero
CveCompraDeCDin = UrlParametros("CVECOMPRA").ToString.ToEntero
SerieFolioDeCDin = UrlParametros("SERIEFOLIO").ToString
CvePrePolizaDeCDin = UrlParametros("CVEPREPOLIZA").ToString.ToEntero
FechaCompra = UrlParametros("FECHACOMPRA").ToString.ToDate
ImporteOriginalDevDin = UrlParametros("ORIGINAL").ToString.ToDecimal.RoundSQL(6)
TxtImporte.Text = UrlParametros("SALDO").ToString.FormatoNumero()
TxtImporte.Attributes.Add("onkeyup", $"FormatoMoneda(this);ValidarCantidad(this,{UrlParametros("SALDO").ToString});")
TxtImporteLetra.Text = UrlParametros("SALDO").ToString.ToDouble.Texto2Letras(UrlParametros("CVEMONEDA").ToString.ToEntero)
CargaProveedor(CveProveedor, "-1")
'BuscarCliente()
CveMoneda = UrlParametros("CVEMONEDA").ToString.ToEntero
CargaCuenta(CveMoneda)
CambiaTipoMoneda()
UpCuentaDeposito.Update()
End If
End If
End Sub
#End Region
#Region "S A L D O - I N I C I A L"
Private Function AgregarSaldoInicial(SaldoInicial As Double, Fecha As DateTime, CveMoneda As Integer, ObjMov As ClsContabilidad) As Integer
Return ObjMov.AddPrePolizas("Bancos/IE", 13, SaldoInicial, SaldoInicial, CveMoneda, Fecha, "Saldo Inicial", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
End Function
#End Region
Protected Sub LnkChqDevuelto_Click(sender As Object, e As EventArgs)
If ChkConciliado.Checked Then
Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgError)
Exit Sub
End If
ChkGeneraCancelacion.Checked = True
ChkGeneraCancelacion.Visible = False
ActivaDevolucion()
DdlTipoTransaccionCancelacion.SelectedValue = "16"
DdlTipoTransaccionCancelacion.Enabled = False
BtnCancelarIE.Text = "Devuelto"
RegistraScript("ShowDivCancelarIE();")
End Sub
Protected Sub LnkCancelar_Click(sender As Object, e As EventArgs)
If ChkConciliado.Checked Then
'TxtFechaDesconciliado.Text = Now.ToShortDateString
'UpDesconciliar.Update()
'RegistraScript("$('#DModalDesconciliar').modal()")
Dim fechaCancelacion As String = TxtFechaAplicado.Text.ToDate.AddMonths(1).FirstDayOfMonth.ToShortDateString
RVTxtFechaCancelacion.MinimumValue = fechaCancelacion
CalendarioCancelacion.StartDate = fechaCancelacion.ToDate
UpEliminarCotizacion.Update()
End If
RegistraScript("ShowDivCancelarIE();")
End Sub
Protected Sub BtnDesconciliar_Click(sender As Object, e As EventArgs)
Dim ObjBancos As New ClsBancos
Dim ObjOI As New ClsOIEventos(ObjBancos.IniciaTransacSQL())
Dim ErrorTrans As Boolean = False
If ObjBancos.DesconciliarIE(CveIE, TxtFechaDesconciliado.Text.ToDate(), UsuarioActual.CveUsuario) Then
If Not ObjOI.AddEventoBitacora("El pago ha sido desconciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
ErrorTrans = True
End If
Else
ErrorTrans = True
End If
If Not ErrorTrans Then
ObjBancos.Commit()
Alert("Desconciliado correctamente")
RegistraScript("$('#DModalDesconciliar').modal('hide')")
Else
ObjBancos.RollBack()
End If
ObjBancos.Dispose()
ObjOI.Dispose()
End Sub
Private Sub LnkEmitirComplemento_Click(sender As Object, e As EventArgs) Handles LnkEmitirComplemento.Click
GeneraTimbre()
CargaComplementosPago()
End Sub
Private Sub GeneraTimbre()
Dim Str As New StringBuilder
Dim Banco As New ClsBancos
If Banco.GetComplementoPagosRep(-1, Now.AddYears(-2), Now, CveIE, -1, 1, UsuarioActual.CveEmpresa, -1) Then
If Not Banco.DtResultados.Rows.Count > 0 Then
Banco.Dispose()
Alert("No se generaron complementos de pago porque no hay facturas con método de pago PPD", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Banco.IniciaTransacSQL()
If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual) Then
If Banco.Mensaje = "" Then
Banco.Commit()
PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False, True)
Str.AppendFormat("Folio: <b>{0}</b> &nbsp;", Banco.ComplementoSerieFolio)
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">XML &nbsp;<i class=""fa fa-file""></i></i></a>&nbsp;&nbsp;", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">PDF &nbsp;<i class=""fa fa-ad-pdf""></i></i></i></a>&nbsp;", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}&CveIE={2}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago, CveIE)))
Str.AppendFormat("<a style='color:#337ab7' target='_blank' href='./IE.aspx?CveIE={0}'>{1}</a> &nbsp; {2}<br>", CveIE, Folio, DdlCliente.SelectedText.ToString())
MandaCorreo(Banco.ComplementoSerieFolio, CorreoCobranzaCliente)
End If
Else
Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", Folio, Banco.Mensaje)
Banco.RollBack()
End If
Banco.Dispose()
CargaDatos()
Alert(Str.ToString)
End Sub
Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
Try
Dim Msg As String = ""
If NombreArchivo <> "-1" Then '
Dim ObjMail As New ClsSisMail()
Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
Dim Asunto As String = "Entrega de comprobante de pago"
Dim ErrorAdjuntas As String = ""
If Not IO.File.Exists(RutaPDF) Then
ErrorAdjuntas = "No se pudo adjuntar el archivo PDF<br>"
End If
If Not IO.File.Exists(RutaXML) Then
ErrorAdjuntas = $"{ErrorAdjuntas} No se pudo adjuntar el XML."
End If
If ErrorAdjuntas.Length > 0 Then
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then
If ConAlerta Then
RegistraScript("$('#ModalDivMail').modal('hide');")
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
End If
Else
Msg = "No se pudo enviar el correo electrónico."
End If
Else
Msg = ErrorAdjuntas
End If
End If
If ConAlerta AndAlso Msg <> "" Then
Alert(Msg, TipoMensaje.MsgError)
End If
Catch ex As Exception
OnError("Ocurrió error al mandar MAIL", ex)
End Try
End Sub
Protected Sub LnkEliminaMovComprobacion_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
Dim TieneError = False
If GvRH.Rows(gvRow.RowIndex).DataKey("CveIE").ToEntero > 0 Then
Dim ObjBancos As New ClsBancos
ObjBancos.IniciaTransacSQL()
If Not ObjBancos.EliminarBancos_IEComprobacion(UsuarioActual.CveUsuario, GvRH.Rows(gvRow.RowIndex).DataKey("CveIE").ToEntero) Then
TieneError = True
Alert("Ocurrió un error al eliminar los Movimientos Bancarios. Por favor intente de nuevo", TipoMensaje.MsgError)
ObjBancos.RollBack()
Else
Alert("Los Movimientos Bancarios se eliminaron correctamente.", TipoMensaje.MsgInformacion)
ObjBancos.Commit()
End If
ObjBancos.Dispose()
End If
If Not TieneError Then
DtGvRH.Rows.RemoveAt(gvRow.RowIndex)
DtGvRH.AcceptChanges()
End If
CargaGvRH()
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("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
strBody.Append("<head> ")
strBody.Append(" <style type=""text/css""> ")
strBody.Append(" body ")
strBody.Append(" { ")
strBody.Append(" margin:0px; ")
strBody.Append(" padding:0px 0px 0px 0px; ")
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
strBody.Append(" font-size: 10px; ")
strBody.Append(" background-color:#F0F0F0; ")
strBody.Append(" } ")
strBody.Append(" a.Texto ")
strBody.Append(" { ")
strBody.Append(" font-size:11px; ")
strBody.Append(" background-color:#F7F6F3; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" } ")
strBody.Append(" .Texto ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .TextoAlterno ")
strBody.Append(" { ")
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
strBody.Append(" vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .BarraIdentidad ")
strBody.Append(" { ")
strBody.Append(" color:#FFFFFF; ")
strBody.Append(" background:#F0F0F0; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" font-size:19px; ")
strBody.Append(" font-style:oblique; ")
strBody.Append(" } ")
strBody.Append(" .Titulos ")
strBody.Append(" { ")
strBody.Append(" background-color: Gray;")
strBody.Append(" color:White; ")
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" } ")
strBody.Append(" .Verde {color: #00CC00;} ")
strBody.Append(" .Negro {color: #000000;} ")
strBody.Append(" .Rojo {color: #FF0000;} ")
strBody.Append(" </style> ")
strBody.Append("</head> ")
strBody.Append("<body> ")
strBody.AppendFormat("<div id='C_div' style='width: 600px'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend><b>{0}</b></legend>", UsuarioActual.Empresa.Empresa)
strBody.AppendFormat(" <table class='TextoG' border='0' cellpadding='0' cellspacing='0' width='100%'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td style='width:100px'>{0}</td>", UsuarioActual.Empresa.Direccion)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>Col. {0}</td>", UsuarioActual.Empresa.Colonia)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>{0}, {1}, C.P.{2}</td>", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>RFC {0}</td>", UsuarioActual.Empresa.RFC)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat("</div><br/><br/>")
strBody.AppendFormat("<div style='width: 600px'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend><b> </b></legend>")
strBody.AppendFormat(" <table class='TextoG' style='width:100%'>")
If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque
strBody.Append(" <tr style=""height: 22px""> ")
strBody.Append(" <td>Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.</td> ")
strBody.Append(" </tr> ")
End If
If objIE.CveTipoTransaccion = 2 Then ' cuando es transf
strBody.Append(" <tr style=""height: 22px""> ")
strBody.Append(" <td>Notificación de transferencia de pago realizada.</td> ")
strBody.Append(" </tr> ")
End If
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td>&nbsp;</td> ")
strBody.Append(" </tr> ")
strBody.Append(" </table> ")
strBody.AppendFormat(" </fieldset>")
strBody.Append(" </div> ")
strBody.AppendFormat("<div style='width: 600px'>")
strBody.AppendFormat(" <table style='width:100%'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td style='vertical-align: top'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend>Beneficiario:<b>{0}</b> </legend>", objIE.PagueseA)
strBody.AppendFormat(" <table width='100%'>")
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
strBody.AppendFormat(" <th scope='col' style='width:150px;'></th>")
strBody.AppendFormat(" <th scope='col' style='width:450px;'></th>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Movimiento:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.TipoTransaccion)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Banco:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.Banco)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Cuenta:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.NumCuenta)
strBody.AppendFormat(" </tr>")
If objIE.CuentaDepositado.ToString <> "" Then
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Cuenta Destino:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.CuentaDepositado)
strBody.AppendFormat(" </tr>")
End If
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Fecha:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.FechaDocumento.ToString("dd/MM/yyyy"))
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Importe:</td>")
strBody.AppendFormat(" <td style='text-align: left'>$ {0} {1}</td>", objIE.Importe.FormatoNumero, objIE.Moneda)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Observaciones:</td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objIE.Observaciones)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td colspan='2'>")
strBody.AppendFormat(" <hr />")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat("</div>")
'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("<div style='width: 1000px'>")
strBody.AppendFormat(" <table style='width:1000px'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td style='vertical-align: top'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend><b>Documentos abonados o pagados <br/>{0}</b> </legend>", Textov33)
strBody.AppendFormat(" <table width='1000px'>")
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
strBody.AppendFormat(" <th scope='col' style='width: 10%'>Fecha</th>")
strBody.AppendFormat(" <th scope='col' style='width: 20%'>Factura</th>")
strBody.AppendFormat(" <th scope='col' style='width: 20%'>Importe ($)</th>")
strBody.AppendFormat(" <th scope='col' style='width: 40%'>Folio Fiscal</th>")
strBody.AppendFormat(" <th scope='col' style='width: 15%'>NC Aplicadas</th>")
strBody.AppendFormat(" </tr>")
For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>{0}</td>", dr("Fecha").ToString.ToDate.ToShortDateString())
strBody.AppendFormat(" <td>{0}</td>", dr("SerieFolio").ToString)
strBody.AppendFormat(" <td style='text-align: right'>$ {0}</td>", dr("Importe").ToString.FormatoNumero)
strBody.AppendFormat(" <td>{0}</td>", dr("FolioFiscal"))
strBody.AppendFormat(" <td>{0}</td>", dr("ImporteNC").ToString.FormatoNumero)
strBody.AppendFormat(" </tr>")
Next
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td colspan='5'>")
strBody.AppendFormat(" <hr />")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat("</div>")
End If
strBody.Append(" <div> Favor de no responder a este correo. </div> ")
strBody.Append("</body></html>")
End If
objIE.Dispose()
Return strBody.ToString
End Function
Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click
EnviarCorreoNotificacion(CveIE, TxtParaMail.Text.Trim, TxtCC.Text.Trim, UsuarioActual, True)
''NotificacionPago(HdnCveIE.Value.ToEntero, Txt)
'Dim ObjMail As New ClsSisMail()
'Dim Body = GeneraCorreo(CveIE)
'Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail)
'Dim ObjIE As New ClsBancos()
'If ObjIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then
' If ObjIE.DtResultados.Rows.Count > 0 Then
' If ObjIE.Comprobante <> "" Then
' ComprobanteIE = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString)
' If IO.File.Exists(ComprobanteIE) Then
' ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = ComprobanteIE.ToString})
' End If
' End If
' End If
'End If
'ObjIE.Dispose()
'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Notificaciones de pago", Body, TxtCC.Text.Trim, Displayname:="Notificaciones de pago", Archivos:=ListaArchivos) Then
' 'ResultadoMail = 1
' TxtCC.Text = ""
' 'TxtAdicional.Text = ""
' RegistraScript("$('#ModalDivMail').modal('hide');")
' Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
'Else
' Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
'End If
End Sub
Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean)
Try
Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar))
Hilo.Start()
If MostarAlert Then
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
RegistraScript("$('#ModalDivMail').modal('hide');")
End If
Catch ex As Exception
If MostarAlert Then
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
End If
End Try
End Sub
Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario)
Try
Dim ObjBancos As New ClsBancos()
If ObjBancos.NotificacionPago(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) Then
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
Else
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
End If
ObjBancos.Dispose()
Catch ex As Exception
GuardaLog("Error al enviar notificación de pago IE --> " & ex.StackTrace.ToString)
End Try
End Sub
Private Sub LnkAjustarMovimiento_Click(sender As Object, e As EventArgs) Handles LnkAjustarMovimiento.Click
RegistraScript("$('#ModalAjustarMovimiento').modal('show');")
End Sub
Private Sub BtnAjustarMovimiento_Click(sender As Object, e As EventArgs) Handles BtnAjustarMovimiento.Click
Dim ObjBanco As New ClsBancos
ObjBanco.IniciaTransacSQL()
If ObjBanco.UpdateAjustarMovimiento(CveIE, TxtAjustarMovimiento.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
ObjBanco.Commit()
RegistraScript("$('#ModalAjustarMovimiento').modal('hide');", "ALTR")
Alert("El ajuste se realizo correctamente.", TipoMensaje.MsgInformacion, $" document.location.href = ""./IE.aspx?CveIE={CveIE}"";")
Else
ObjBanco.RollBack()
End If
ObjBanco.Dispose()
End Sub
Protected Sub LnkCancelaMovimiento_Click(sender As Object, e As EventArgs)
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
Dim ObjIE As New ClsBancos
If ObjIE.CancelarIEVenta(CveIE, gvRow.DataKey("CveVenta").ToString.ToEntero) Then
Alert("Movimiento cancelado correctamente")
CargaDatos()
End If
ObjIE.Dispose()
End Sub
Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveVenta").ToString.ToEntero > 0 AndAlso e.Row.DBCampo("CveCliente").ToString.ToEntero > 0 AndAlso e.Row.DBCampo("ImporteMN").ToString.ToDecimal > 0 AndAlso e.Row.DBCampo("CveConceptoContable").ToString.ToEntero = 2 Then
e.Row.FCLinkButton("LnkCancelaMovimiento").Visible = True
End If
End If
End Sub
Protected Sub LnkCancelarComplemetno_Click(sender As Object, e As EventArgs)
'If ChkConciliado.Checked Then
' Alert("El documento se encuentra conciliado, no se puede cancelar.", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow)
Dim CveMotivoCancelacion As Integer = GvRow.FCDropDownList("DdlMotivoCancelacion").SelectedValue.ToEntero
Dim CveSATMotivoCancelacion As Integer = GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa, CveMotivoCancelacion:=CveMotivoCancelacion).FiltroPrimeroValor("CveSATMotivoCancelacion").ToEntero()
If CveMotivoCancelacion <= 0 Or CveSATMotivoCancelacion <= 0 Then
Alert("Debe de elegir un motivo de cancelación.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
CveComplementoPagoCancelar = GvRow.DataKey("CveComplementoPago").ToEntero
FolioFiscalCancelar = GvRow.DataKey("FolioFiscal").ToString
'' Dim RFCEmisor As String = UsuarioActual.Empresa.RFC
RFCReceptorCancelar = GvRow.DataKey("RFCReceptor")
CvePACCancelacion = GvRow.DataKey("CvePAC").ToEntero
Dim ObjCancelacion As New Timbrado
Dim ObjBanco As New ClsBancos
If EstatusSATCancelado(FolioFiscalCancelar, UsuarioActual.Empresa.RFC, RFCReceptorCancelar) Then
If ObjBanco.UpdateComplementoPagoCancelado(CveComplementoPagoCancelar, 2, CvePACCancelacion, UsuarioActual.CveEmpresa, Date.Now, "", 1) Then
CargaComplementosPago()
Alert("El complemento se cancelo correctamente.")
End If
Else
Dim resp = ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion, CveSATMotivoCancelacion:=CveSATMotivoCancelacion)
If resp.Verificado Then
If ObjBanco.UpdateComplementoPagoCancelado(CveComplementoPagoCancelar, 2, CvePACCancelacion, UsuarioActual.CveEmpresa, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse, CveSATMotivoCancelacion:=CveSATMotivoCancelacion) Then
' Alert("El complemento se cancelo correctamente.")
'End If
Else
Alert("Se presento un error al cancelar el complemento.", TipoMensaje.MsgError)
End If
End If
End If
ObjBanco.Dispose()
CargaComplementosPago()
End Sub
Protected Sub BtnModalCancelarComplemento_Click(sender As Object, e As EventArgs)
If ChkConciliado.Checked Then
Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'TxtFechaCancelacion.Text = TxtFechaCancelarComplemento.Text
CancelarIE(True)
End Sub
Protected Sub LnkCancelarComplementoImporte_Click(sender As Object, e As EventArgs)
If ChkConciliado.Checked Then
Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim ObjBancos As New ClsBancos
Dim Respuesta As Boolean = False
Dim DTComplementos As New DataTable
If ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then
DTComplementos = ObjBancos.DtResultados.FiltraParametros(" Estatus IN (1,3) ")
End If
ObjBancos.Dispose()
If DTComplementos.Rows.Count = 1 Then
CveComplementoPagoCancelar = DTComplementos.Rows(0)("CveComplementoPago").ToString.ToEntero
FolioFiscalCancelar = DTComplementos.Rows(0)("FolioFiscal").ToString
RFCReceptorCancelar = DTComplementos.Rows(0)("RFCReceptor").ToString
CvePACCancelacion = DTComplementos.Rows(0)("CvePAC").ToString.ToEntero
RegistraScript("$('#ModalCancelarComplemetno').modal('show');")
'DivFechaCancelación.Visible = True
CargaComplementosPago()
'UpModalCancelarComplemetno.Update()
Else
If DTComplementos.Rows.Count = 0 Then
Alert("No hay complementos vigentes")
Else
Alert($"Existe mas de un complemento vigente, complementos vigentes: { DTComplementos.Rows.Count }")
End If
End If
End Sub
Protected Sub BtnEditar_Click(sender As Object, e As EventArgs)
BtnActualizar.Visible = True
BtnEditar.Visible = False
UpGuardar.Update()
ControlesEdicion()
End Sub
Private Sub ControlesEdicion()
Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
If PermisoComplementoVigente Then
If ExistenComplementosVigentes Then
TxtFolio.Enabled = True
TxtObservaciones.Enabled = True
Else
DdlTipoTransaccion.Enabled = True
LblCuenta.Visible = False
DdlCuenta.Enabled = True
DdlCuenta.Visible = True
TxtFolio.Enabled = True
TxtObservaciones.Enabled = True
End If
UpDatos.Update()
CargaCuentasDepositoClientes()
Else
TxtFolio.Enabled = True
TxtObservaciones.Enabled = True
UpDatos.Update()
End If
End Sub
Private Sub CargaCuentasDepositoClientes()
If DdlTipoTransaccion.SelectedValue = "9" And CveCliente > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Enabled = True
Dim Dep As New ClsGenerales
If Dep.GetCuentasDepositos(CveCliente:=CveCliente) Then
DdlCuentaDeposito.DataSource = Dep.DtResultados
If Dep.DtResultados.Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
End If
End If
Dep.Dispose()
DdlCuentaDeposito.DataBind()
UpCuentaDeposito.Update()
End If
End Sub
'Protected Sub LnkEstatusSAT_Click(sender As Object, e As EventArgs)
' Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow)
' Dim FolioFiscal As String = GvRow.DataKey("FolioFiscal").ToString
' Dim RFCReceptor As String = GvRow.DataKey("RFCReceptor")
' EstatusSATCancelado(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor)
' 'Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, "0", True)
' 'If Vigencia IsNot Nothing Then
' ' Alert($"Estatus SAT: { Vigencia.Estado }")
' 'End If
'End Sub
Function EstatusSATCancelado(FolioFiscal As String, RFCDe As String, RFCReceptor As String) As Boolean
Dim respuesta As Boolean = False
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, RFCDe, RFCReceptor, "0", True)
If Vigencia IsNot Nothing Then
If Vigencia.Estado.ToUpper = "CANCELADO" Then
respuesta = True
Else
respuesta = False
End If
Else
respuesta = False
End If
Return respuesta
End Function
Protected Sub ChkGeneraCancelacion_CheckedChanged(sender As Object, e As EventArgs)
ActivaDevolucion()
End Sub
Private Sub ActivaDevolucion()
Dim dttemp As DataTable
Dim TipoMovto As String
dttemp = GlobalDTTipoTransacciones.FiltraParametros($"CveTipoTransaccion ={DdlTipoTransaccion.SelectedValue}")
TipoMovto = dttemp(0)("Tipo").ToString
If TipoMovto = "Egs" Then
TipoMovto = "Ing"
Else
TipoMovto = "Egs"
End If
DdlTipoTransaccionCancelacion.Items.Clear()
DdlTipoTransaccionCancelacion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo ='{TipoMovto}' AND Estatus = 1")
DdlTipoTransaccionCancelacion.DataBind()
DdlTipoTransaccionCancelacion.Items.Insert(0, New ListItem("Seleccione una", "-1"))
DdlDevolucionCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlDevolucionCuenta.DataBind()
DdlDevolucionCuenta.Items.Insert(0, New ListItem("-", "-1"))
If ChkGeneraCancelacion.Checked Then
DVTipoTransacciónCancelar.Visible = True
DVTipoTransacciónCancelar2.Visible = True
Else
DVTipoTransacciónCancelar.Visible = False
DVTipoTransacciónCancelar2.Visible = False
End If
UpEliminarCotizacion.Update()
End Sub
Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init
RVTxtFechaDocumento.MaximumValue = DateTime.Now.ToShortDateString
Calendario.EndDate = DateTime.Now
End Sub
Private Sub CargaOCRelacionadas()
DVBancosOrdenCompra.Visible = False
If CveIE > 0 Then
Dim objBanco As New ClsBancos
If objBanco.GetBancosOrdenCompra(CveIE, UsuarioActual.CveEmpresa) Then
If objBanco.DtResultados.Rows.Count > 0 Then
HLFFolioOC.Text = objBanco.DtResultados.Rows(0)("FolioOC").ToString
HLFFolioOC.NavigateUrl = $"~/OC/OC.aspx?OC={objBanco.DtResultados.Rows(0)("CveOrdenCompra").ToString}"
DVBancosOrdenCompra.Visible = True
End If
End If
objBanco.Dispose()
End If
End Sub
End Class