From afcaec9e7be375f4b73d0b454e4b7d523af5ebc7 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Sat, 24 Aug 2019 14:15:00 -0500 Subject: [PATCH 01/13] =?UTF-8?q?agregando=20validaci=C3=B3n=20al=20IE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bancos/IE.aspx.vb | 10520 ++++++++++++++++++++++---------------------- 1 file changed, 5267 insertions(+), 5253 deletions(-) diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index e83e9f36d..907e60fe4 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -1,413 +1,413 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports Extensiones -Imports System.Web.Services -Imports System.IO -Imports Microsoft.Reporting.WebForms - -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 - Return ViewState("SerieFolioDeCDin").ToString - 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 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 CveCuentaConta As Integer - Get - Return ViewState("CveCuentaConta").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaConta") = value - End Set - End Property - Private Property CveCuentaBeneficiario As Integer - Get - Return ViewState("CveCuentaBeneficiario").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBeneficiario") = 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 CveOCSolicitudAnticipo As Integer - Get - Return ViewState("CveOCSolicitudAnticipo").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveOCSolicitudAnticipo") = 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 +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones +Imports System.Web.Services +Imports System.IO +Imports Microsoft.Reporting.WebForms + +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 + Return ViewState("SerieFolioDeCDin").ToString + 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 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 CveCuentaConta As Integer + Get + Return ViewState("CveCuentaConta").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaConta") = value + End Set + End Property + Private Property CveCuentaBeneficiario As Integer + Get + Return ViewState("CveCuentaBeneficiario").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBeneficiario") = 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 CveOCSolicitudAnticipo As Integer + Get + Return ViewState("CveOCSolicitudAnticipo").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveOCSolicitudAnticipo") = 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 @@ -423,272 +423,284 @@ Partial Class Bancos_IE 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 + + +#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 "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 - - - - -#End Region - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - - Folio = "" - IDCtaBeneficiario = 0 - IDCtaBeneficiarioComplementaria = 0 - IDCtaContable = 0 - IdCtaAnticipoComplementaria = 0 - IdCtaAnticipoExtranjera = 0 - CveCuentaBeneficiario = 0 - CveCuentaConta = 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") - - Session("FileUpload") = "" - TRCveIE.Visible = False - - CargaTipoTransaccion() - CargaMoneda() - 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").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" - - 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 - DdlMoneda.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 +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + + Folio = "" + IDCtaBeneficiario = 0 + IDCtaBeneficiarioComplementaria = 0 + IDCtaContable = 0 + IdCtaAnticipoComplementaria = 0 + IdCtaAnticipoExtranjera = 0 + CveCuentaBeneficiario = 0 + CveCuentaConta = 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") + + Session("FileUpload") = "" + TRCveIE.Visible = False + + CargaTipoTransaccion() + CargaMoneda() + 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").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" + + 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 + DdlMoneda.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;" - - Else - 'Configuración de Modalidad Insert - ImgAddObs.Visible = False - CveIE = -1 - TxtFechaDocumento.Text = Now.ToShortDateString - ImgUpdateCuentaDeposito.Visible = False - End If - - InicializaSolicitudAnticipoOC() - If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT") AndAlso UsuarioActual.CveEmpresa = 119 Then - RBL.Items.Add(New ListItem("Acreedores Diversos", "AC")) - End If - - '08/05/2018 - Se deshabilita opcion Eliminar IE si tiene un complemento de pago relacionado - If CveIE = -1 Or (CveIE > 0 AndAlso VerificaComplementos(False)) Then - LnkEliminar.Visible = False - If CveIE > 0 Then - LnkCancelar.Visible = False - - If UsuarioActual.TienePermisoProceso(85) Then - LnkCancelarComplemento.Visible = True - LnkCancelarComplementoImporte.Visible = True - End If - 'LnkEliminarComplemento.NavigateUrl = String.Format("/Ventas/ClientesAbonar.aspx?CveIESustitucion={0}&CveCliente={1}", CveIE, CveCliente) - End If - Else - LnkEliminar.Visible = True - LnkCancelarComplemento.Visible = False - LnkCancelarComplementoImporte.Visible = False - End If - - If TabCancelacion.Visible Then - LnkCancelar.Visible = False - LnkCancelarComplemento.Visible = False - LnkEliminar.Visible = False - LnkCancelarComplementoImporte.Visible = False - End If - - UppEliminarIE.Update() - - InicializaActualizarTC() - - '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 - + 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;" + + Else + 'Configuración de Modalidad Insert + ImgAddObs.Visible = False + CveIE = -1 + TxtFechaDocumento.Text = Now.ToShortDateString + ImgUpdateCuentaDeposito.Visible = False + End If + + InicializaSolicitudAnticipoOC() + If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT") AndAlso UsuarioActual.CveEmpresa = 119 Then + RBL.Items.Add(New ListItem("Acreedores Diversos", "AC")) + End If + + '08/05/2018 - Se deshabilita opcion Eliminar IE si tiene un complemento de pago relacionado + If CveIE = -1 Or (CveIE > 0 AndAlso VerificaComplementos(False)) Then + LnkEliminar.Visible = False + If CveIE > 0 Then + LnkCancelar.Visible = False + + If UsuarioActual.TienePermisoProceso(85) Then + LnkCancelarComplemento.Visible = True + LnkCancelarComplementoImporte.Visible = True + End If + 'LnkEliminarComplemento.NavigateUrl = String.Format("/Ventas/ClientesAbonar.aspx?CveIESustitucion={0}&CveCliente={1}", CveIE, CveCliente) + End If + Else + LnkEliminar.Visible = True + LnkCancelarComplemento.Visible = False + LnkCancelarComplementoImporte.Visible = False + End If + + If TabCancelacion.Visible Then + LnkCancelar.Visible = False + LnkCancelarComplemento.Visible = False + LnkEliminar.Visible = False + LnkCancelarComplementoImporte.Visible = False + End If + + UppEliminarIE.Update() + + InicializaActualizarTC() + + '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 @@ -698,398 +710,401 @@ Partial Class Bancos_IE UppEliminarIE.Update() - End If - - End If + 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 - - 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 - - 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 - - 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 - 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) - DdlMoneda.SelectedValue = ObjIE.CveMoneda.ToString - 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, 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 +#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 + + 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 + + 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 + + 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 + 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) + DdlMoneda.SelectedValue = ObjIE.CveMoneda.ToString + 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, 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 - + 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 + 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 - + 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 - - IDPoliza = ObjIE.IDPoliza - IDCtaContable = ObjIE.IdCtaContable - CveCuentaConta = ObjIE.CveCuentaConta - - - 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 - Else - BtnContabilizar.Visible = True - BtnDescontabilizar.Visible = False - HplIrPoliza.Visible = False - - EstaContabilizado = False - End If - UPPDesContabilizar.Update() - - 'ImgImprimir.Visible = True - LblRegistroFecha.Text = ObjIE.FechaIng.ToShortDateString - LblRegistroUsuario.Text = ObjIE.Usuario - + 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 + + IDPoliza = ObjIE.IDPoliza + IDCtaContable = ObjIE.IdCtaContable + CveCuentaConta = ObjIE.CveCuentaConta + + + 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 + Else + BtnContabilizar.Visible = True + BtnDescontabilizar.Visible = False + HplIrPoliza.Visible = False + + EstaContabilizado = False + End If + UPPDesContabilizar.Update() + + 'ImgImprimir.Visible = True + LblRegistroFecha.Text = ObjIE.FechaIng.ToShortDateString + LblRegistroUsuario.Text = ObjIE.Usuario + CveEstatusIE = ObjIE.CveEstatusIE - Select Case ObjIE.CveEstatusIE - Case 1 - If Not ObjIE.FueConciliado Then - 'If UsuarioActual.TienePermisoProceso(85) Then ImgCancelarMovimiento.Visible = True - If UsuarioActual.TienePermisoProceso(85) Then LnkCancelar.Visible = True - - 'ELIMINAR IE SIN VALIDACIONES - If UsuarioActual.TienePermisoProceso(80) 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 Then - LnkEliminar.Visible = True - End If - End If - - ''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) 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 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("/Empresas/{0}/IE/{1}", UsuarioActual.CveEmpresa, 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 - HplListaProveedores.NavigateUrl = String.Format("/Bancos/Reportes.aspx?Opcion=ImprimeMov&CveIE={0}", ObjIE.CveIE) - End If - If CveIEDeposito2 > 0 Then - divDepositado.Visible = True - HplDepositado.NavigateUrl = $"/Bancos/IE.aspx?CveIE={CveIEDeposito2}" - End If - - - 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 Dep As New ClsGenerales - If Dep.GetCuentasDepositos(CveProveedor:=ObjIE.CveProveedor) 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")) - 'ElseIf Dep.DtResultados.Rows.Count = 1 Then - ' TrCuentaDepositado.Visible = True - ' LitTextoDepositado.Text = "Cuenta Depósito" - ' LitDepositado.Text = Dep.DtResultados.Rows(0)("CuentaDeposito").ToString - 'End If - End If - End If - Dep.Dispose() - 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 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 - 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 - 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 - 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 - + Select Case ObjIE.CveEstatusIE + Case 1 + If Not ObjIE.FueConciliado Then + 'If UsuarioActual.TienePermisoProceso(85) Then ImgCancelarMovimiento.Visible = True + If UsuarioActual.TienePermisoProceso(85) Then LnkCancelar.Visible = True + + 'ELIMINAR IE SIN VALIDACIONES + If UsuarioActual.TienePermisoProceso(80) 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 Then + LnkEliminar.Visible = True + End If + End If + + ''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) 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 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("/Empresas/{0}/IE/{1}", UsuarioActual.CveEmpresa, 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 + HplListaProveedores.NavigateUrl = String.Format("/Bancos/Reportes.aspx?Opcion=ImprimeMov&CveIE={0}", ObjIE.CveIE) + End If + If CveIEDeposito2 > 0 Then + divDepositado.Visible = True + HplDepositado.NavigateUrl = $"/Bancos/IE.aspx?CveIE={CveIEDeposito2}" + End If + + + 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 Dep As New ClsGenerales + If Dep.GetCuentasDepositos(CveProveedor:=ObjIE.CveProveedor) 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")) + 'ElseIf Dep.DtResultados.Rows.Count = 1 Then + ' TrCuentaDepositado.Visible = True + ' LitTextoDepositado.Text = "Cuenta Depósito" + ' LitDepositado.Text = Dep.DtResultados.Rows(0)("CuentaDeposito").ToString + 'End If + End If + End If + Dep.Dispose() + 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 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 + 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 + 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 + 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) + Alert("El Documento solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) BtnGuardar.Enabled = False - End If - - + End If + + If Not ChkConciliado.Checked Then If (Not VerificaComplementos(True)) And UsuarioActual.TienePermisoProceso(99) And ObjIE.CveEstatusIE <> 2 Then BtnEditar.Visible = True + PermisoComplementoVigente = True + Else + BtnEditar.Visible = True End If UpGuardar.Update() @@ -1097,2413 +1112,2413 @@ Partial Class Bancos_IE End If - End If - - 'If CveIE > 0 Then - ' DdlProveedores.Visible = False - ' LblBeneficiario.Visible = True - ' LblBeneficiario.Text = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {CveProveedor}")(0)("RazonSocial").ToString - 'End If - - - - - RecargaGlobalCuentasBancarias() - ObjIE.Dispose() - ObjIE2.Dispose() - UPPP.Update() - End Sub - Private Sub CargaGvRH() - GvRH.DataSource = DtGvRH - GvRH.DataBind() - UpGvRH.Update() - 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 - 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 - - End If - - Select Case RBL.SelectedValue - Case "P" - IDCtaBeneficiario = ObjProveedor.IdCtaContAnticipos : CveCuentaBeneficiario = ObjProveedor.CveCuentaAnticipos - IdCtaAnticipoExtranjera = ObjProveedor.IdCtaContAnticiposExtranjera : IdCtaAnticipoComplementaria = ObjProveedor.IdCtaContAnticiposComplementaria - If EsDevolucion Then - IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores : CveCuentaBeneficiario = ObjProveedor.CveCuentaProveedores - End If - Case "DD" : IDCtaBeneficiario = ObjProveedor.IdCtaContDeudor : CveCuentaBeneficiario = ObjProveedor.CveCuentaDeudor - Case "AC" : IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor : CveCuentaBeneficiario = ObjProveedor.CveCuentaAcreedor - Case "DP" : IDCtaBeneficiario = ObjProveedor.IdCtaContDocsXPagar : CveCuentaBeneficiario = ObjProveedor.CveCuentaDocsXPagar - Case Else - IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores - CveCuentaBeneficiario = ObjProveedor.CveCuentaProveedores - End Select - - - If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then - - IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor - CveCuentaBeneficiario = ObjProveedor.CveCuentaAcreedor - - If Not IDCtaBeneficiario > 0 Then - Alert("No se pudo cargar IDCtaBeneficiario", TipoMensaje.MsgAdvertencia) - End If - - End If - - - If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - If IDCtaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidad Then - Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - ElseIf CveCuentaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidadSIG Then - Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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 - -#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 - CveCuentaBeneficiario = ObjCliente.CveCuentaAnticipos - 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 - End If - - If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then - Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then - Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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 - CveCuentaBeneficiario = ObjPersonal.CveCuentaPersonal - - If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then - Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then - Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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. - - If HdnTipoTransaccion.Value = "Egs" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Or Opcion = "DevDinC" 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 - - If Opcion = "DevDinC" Then - TxtFolio.Enabled = False - End If - Else - TxtFolio.Text = "" - End If - - Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue)) - If dr IsNot Nothing Then - - - DdlMoneda.SelectedValue = dr("CveMoneda").ToString - IDCtaContable = dr("IdCtaContable").ToString.ToEntero - IDCtaContableComplementaria = dr("IDCtaContableComplementaria").ToString.ToEntero - CveCuentaConta = dr("IdCtaContableSIG").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 - - If dr("UsaTarjeta").ToString = "True" Then - CargaGridTarjetas() - Else - DivTarjeta.Visible = False - End If - - If Not IDCtaContable > 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then - Alert("La Cuenta Bancaria no tiene asignada una cuenta contable", TipoMensaje.MsgAdvertencia) - End If - - If Not CveCuentaConta > 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then - Alert("La Cuenta Bancaria no tiene asignada una cuenta contable en SIG", 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) - Else - dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).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() - Dim dt As DataTable - If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT", "EGSCREDITO") Then - dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs'") - 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'") - 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'") - 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'") - 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'") - 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 Then - DdlTipoTransaccion.DataSource = dt.FiltraParametros("Tipo = 'Ing' ") - Else - DdlTipoTransaccion.DataSource = dt - End If - - - DdlTipoTransaccion.DataBind() - DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) - RBL_SelectedIndexChanged(RBL, Nothing) - - End Sub - - Private Sub CargaMoneda() - DdlMoneda.DataSource = GlobalDTMonedas - DdlMoneda.DataBind() - 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:
{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 = UsuarioActual.Empresa.RegistroPatronal - 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.ToDouble - } - ) - 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("", UsuarioActual.Empresa.RegistroPatronal, 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() - - Return EsValido - End Function - - Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click - - If Not ValidaGuardar() Then - Exit Sub - End If - - 'PARA QUE TOME EL TIPO DE CAMBIO DEL DIA - TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString - UpTipoCambio.Update() - - - 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 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:

" - 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 - End If - End If - - If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then - If CveCliente > 0 Then - CveConceptoCompra = 3 'Clientes - CveConceptoContable = 30 'Bancos - CvePlantillaPoliza = 12 - End If - 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 - 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 = 42 'Prestamo 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 - 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 = DdlMoneda.SelectedValue.ToEntero - Dim tImporteMonedaExtranjera As Decimal = 0 - If tCveMoneda <> 1 Then tImporteMonedaExtranjera = TxtImporte.Text.ToDecimal * GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString.ToDecimal - 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(), DdlMoneda.SelectedValue.ToEntero(), ObjMov) <= 0 Then - MsgError = "No se pudo insertar la póliza de saldo inicial." - End If - End If - - 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, DdlMoneda.SelectedValue.ToEntero, - 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)) - - If CveIE > 0 Then - - If DdlTipoTransaccion.SelectedValue = "1" 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:=ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)) - - '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("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta)) - 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, CveCuenta:=CveCuentaBeneficiario) 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, CveCuenta:=CveCuentaConta) - - 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, CveCuenta:=CveCuentaConta) - - If TxtIvaIxC.Text.ToDouble > 0 Then - '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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) - 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, CveCuenta:=CveCuentaBeneficiario) - 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, CveCuenta:=CveCuentaConta) 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario) 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 - - 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 - importeMX = importeMovimiento - - 'Agregamos el IVA - If DivIvaIxC.Visible AndAlso TxtIvaIxC.Text.ToDecimal <> 0 Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtIvaIxC.Text.ToDecimal, Concepto, 61, Concepto, FechaMovimiento, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtIvaIxC.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then - MsgError = "Ocurrió un error al registrar el asiento del ingreso." - End If - End If - If tCveMoneda > 1 AndAlso UsuarioActual.CveEmpresa = 119 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, CveCuenta:=0) 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 UsuarioActual.CveEmpresa = 119 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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then - MsgError = "Ocurrió un error al registrar el asiento del ingreso." - 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, CveCuenta:=If(ConceptoContable = 30, CveCuentaConta, CveCuentaBeneficiario)) 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - ImporteAplicarMN = ImporteAplicar - Else - ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta) Then - MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución" - Exit Select - End If - - 'BANCOS COMPLEMENTARIA - If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta) Then - MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución" - End If - End If - - 'CANCELA NC - IdCtaContableAplicar = IDCtaBeneficiario - ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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) 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 - 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) 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) 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 ConceptoAplicar = $"Devolución de Proveedor {PagueseA} {TxtImporte.Text} NC:{SerieFolioDeCDin}" - - ImporteAplicar = TxtImporte.Text.ToDecimal - ImporteAplicarME = ImporteAplicar - - - 'CONSIDERA COMPLEMENTARIA - If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - ImporteAplicarMN = ImporteAplicar - Else - ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL() - End If - - Dim TCCompra As Decimal = 1 - Dim TCDocumento As Decimal = 1 - - If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) 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 TCCompra <= 0 Then - Alert("No se pudo obtener el tipo de cambio del documentpo.", TipoMensaje.MsgAdvertencia) - End If - - End If - - - - '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, CveCuenta:=CveCuentaConta, TipoCambio:=TCDocumento) Then - MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución" - Exit Select - End If - - - 'BANCOS COMPLEMENTARIA - If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta, TipoCambio:=TCDocumento) Then - MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución" - End If - End If - - 'CANCELA NC - IdCtaContableAplicar = IDCtaBeneficiario - 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - - ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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), CveCuenta:=CveCuentaConta, 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, CveCuenta:=CveCuentaConta, 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, CveCuenta:=CveCuentaConta, 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 CveCuentaIVAxAcreditarDevDinC = 0 - Dim CveCuentaIVAAcreditableDevDinC = 0 - 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 = ((TxtImporte.Text.ToDecimal * 100D / TotalCompraDev) / 100).RoundSQL(2) - - IVADev = Math.Round(IVADev * PorcentajeDevolucion, 2) - IEPSDev = Math.Round(IEPSDev * PorcentajeDevolucion, 2) - - Dim CveCuentaDevolucionIMPUESTOS As Integer = -1 - Dim IdCtaIVADevolucionIMPUESTOS As Integer = -1 - - - If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) 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 - - CveCuentaDevolucionIMPUESTOS = CveCuentaIVAxAcreditarDevDinC - IdCtaIVADevolucionIMPUESTOS = IdCtaIVAXAcreditarDevDinC - - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAplicar, -IVADev, ReferenciaAplicar, 14, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) Then - - CveCuentaDevolucionIMPUESTOS = CveCuentaIVAAcreditableDevDinC - IdCtaIVADevolucionIMPUESTOS = IdCtaIVAAcreditableDevDinC - - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IVADev, ReferenciaAplicar, 19, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) 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 - CveCuentaDevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero - IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero - - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IEPSDev, ReferenciaAplicar, 25, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) Then - - If ObjMov.GetRetCuenta(26, UsuarioActual.CveEmpresa) Then - Try - CveCuentaDevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero - IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero - - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IEPSDev, ReferenciaAplicar, 26, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) 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 - - - - 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 AndAlso UsuarioActual.CveEmpresa = 119 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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then - MsgError = "Ocurrió un error al registrar el asiento del ingreso." - End If - End If - Case 42 - - importeMovimiento = TxtImporte.Text.ToDecimal - importeMX = importeMovimiento - - - - 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, CveCuenta:=If(ConceptoContable = 30, CveCuentaConta, CveCuentaBeneficiario)) 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - IDCtaBeneficiario = IdCtaAnticipoExtranjera - CveCuentaConta = 0 - 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaConta, 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario, 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, CveCuenta:=CveCuentaBeneficiario, 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, CveCuenta:=CveCuentaBeneficiario, 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then - Dim ImporteAplicar As Decimal = TxtImporte.Text.ToDecimal - Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal - Dim ImporteAplicarMN = (ImporteAplicar * TCPago - ImporteAplicar).RoundSQL() - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAplicar, Ref, 204, Conc, Now, IDCtaContableComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=CveCuentaConta, TipoCambio:=TCPago) 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, CveCuenta:=0, TipoCambio:=TCPago) 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 - - 'El movimiento 1 es el de Venta - 'Conta SIG - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidadSIG Then - If CveCuentaBeneficiario > 0 And CveCuentaConta > 0 Then - If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then - IDPoliza = ObjMov.ContaIdPoliza - Else - Alert("Ocurrio un error al contabilizar en SIG, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) - End If - Else - If CveCuentaConta < 1 Then - Alert("No se puede contabilizar la Prepoliza en SIG debido a que la cuenta de Bancos es invalida", TipoMensaje.MsgAdvertencia) - End If - If CveCuentaBeneficiario < 1 Then - Alert("No se puede contabilizar la Prepoliza en SIG debido a que las cuenta del Beneficiario es invalida", TipoMensaje.MsgAdvertencia) - End If - End If - End If - - 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then - If IDCtaBeneficiario > 0 And IDCtaContable > 0 Then - If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then - IDPoliza = ObjMov.ContaIdPoliza - 'Alert(alertaContabilizacion & ObjMov.AlertaMensaje, ModExtensiones.TipoMensaje.MsgInformacion) - Else - Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) - End If - Else - 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 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 <> "" Then - NotificacionPago(CveIE, TxtNotificarA.Text.Trim) - End If - - Else - MsgError = "No se pudo insertar la póliza" - End If - - Else - MsgError = "No se insertó el encabezado" - 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 - - 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", AppDomain.CurrentDomain.BaseDirectory)) - 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("

{1} ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem)) - End If - End If - - If IDPoliza > 0 Then - Msg.AppendFormat("

Ver Póliza", 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() - 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("", 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 - - RecargaGlobalCuentasBancarias() - 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) - 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 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(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) - strBody.AppendFormat(" ") - strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("


") - - 'strBody.AppendFormat("
") - 'strBody.AppendFormat("
") - 'strBody.AppendFormat(" ") - 'strBody.AppendFormat(" ") - - 'If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque - ' strBody.Append(" ") - ' strBody.Append(" ") - ' strBody.Append(" ") - 'End If - - 'If objIE.CveTipoTransaccion = 2 Then ' cuando es transf - ' strBody.Append(" ") - ' strBody.Append(" ") - ' strBody.Append(" ") - 'End If - - 'strBody.Append(" ") - 'strBody.AppendFormat(" ") - 'strBody.Append(" ") - 'strBody.Append("
Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.
Notificación de transferencia de pago realizada.
 
") - 'strBody.AppendFormat("
") - 'strBody.Append("
") - - - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" Beneficiario:{0} ", objIE.PagueseA) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.TipoTransaccion) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Banco) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.NumCuenta) - strBody.AppendFormat(" ") - If objIE.CuentaDepositado.ToString <> "" Then - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.CuentaDepositado) - strBody.AppendFormat(" ") - End If - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.FechaDocumento.ToString("dd/MM/yyyy")) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Observaciones) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
Movimiento:{0}
Banco:{0}
Cuenta:{0}
Cuenta Destino:{0}
Fecha:{0}
Importe:$ {0} {1}
Observaciones:{0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - - - 'MOVIMIENTOS CHEQUE - 'If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then - ' Dim Textov33 As String = "" - ' If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then - ' Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" - ' End If - - ' strBody.AppendFormat("
") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat(" Documentos abonados o pagados
{0}
", Textov33) - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - - - ' For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ", dr("Fecha").ToString.ToDate.ToShortDateString()) - ' strBody.AppendFormat(" ", dr("SerieFolio").ToString) - ' strBody.AppendFormat(" ", dr("Importe").ToString.FormatoNumero) - ' strBody.AppendFormat(" ", dr("FolioFiscal")) - ' strBody.AppendFormat(" ") - ' Next - - - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat(" ") - ' strBody.AppendFormat("
FechaFacturaImporte ($)Folio Fiscal
{0}{0}$ {0}{0}
") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat("
") - ' strBody.AppendFormat("
") - 'End If - - strBody.Append("
Favor de no responder a este correo.
") - - strBody.Append("") - End If - - objIE.Dispose() - Return strBody.ToString + End If + + 'If CveIE > 0 Then + ' DdlProveedores.Visible = False + ' LblBeneficiario.Visible = True + ' LblBeneficiario.Text = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {CveProveedor}")(0)("RazonSocial").ToString + 'End If + + + + + RecargaGlobalCuentasBancarias() + ObjIE.Dispose() + ObjIE2.Dispose() + UPPP.Update() + End Sub + Private Sub CargaGvRH() + GvRH.DataSource = DtGvRH + GvRH.DataBind() + UpGvRH.Update() + 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 + 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 + + End If + + Select Case RBL.SelectedValue + Case "P" + IDCtaBeneficiario = ObjProveedor.IdCtaContAnticipos : CveCuentaBeneficiario = ObjProveedor.CveCuentaAnticipos + IdCtaAnticipoExtranjera = ObjProveedor.IdCtaContAnticiposExtranjera : IdCtaAnticipoComplementaria = ObjProveedor.IdCtaContAnticiposComplementaria + If EsDevolucion Then + IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores : CveCuentaBeneficiario = ObjProveedor.CveCuentaProveedores + End If + Case "DD" : IDCtaBeneficiario = ObjProveedor.IdCtaContDeudor : CveCuentaBeneficiario = ObjProveedor.CveCuentaDeudor + Case "AC" : IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor : CveCuentaBeneficiario = ObjProveedor.CveCuentaAcreedor + Case "DP" : IDCtaBeneficiario = ObjProveedor.IdCtaContDocsXPagar : CveCuentaBeneficiario = ObjProveedor.CveCuentaDocsXPagar + Case Else + IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores + CveCuentaBeneficiario = ObjProveedor.CveCuentaProveedores + End Select + + + If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then + + IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor + CveCuentaBeneficiario = ObjProveedor.CveCuentaAcreedor + + If Not IDCtaBeneficiario > 0 Then + Alert("No se pudo cargar IDCtaBeneficiario", TipoMensaje.MsgAdvertencia) + End If + + End If + + + If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + If IDCtaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidad Then + Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + ElseIf CveCuentaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidadSIG Then + Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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 + +#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 + CveCuentaBeneficiario = ObjCliente.CveCuentaAnticipos + 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 + End If + + If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then + Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then + Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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 + CveCuentaBeneficiario = ObjPersonal.CveCuentaPersonal + + If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then + Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then + Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. 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. + + If HdnTipoTransaccion.Value = "Egs" AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Or Opcion = "DevDinC" 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 + + If Opcion = "DevDinC" Then + TxtFolio.Enabled = False + End If + Else + TxtFolio.Text = "" + End If + + Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue)) + If dr IsNot Nothing Then + + + DdlMoneda.SelectedValue = dr("CveMoneda").ToString + IDCtaContable = dr("IdCtaContable").ToString.ToEntero + IDCtaContableComplementaria = dr("IDCtaContableComplementaria").ToString.ToEntero + CveCuentaConta = dr("IdCtaContableSIG").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 + + If dr("UsaTarjeta").ToString = "True" Then + CargaGridTarjetas() + Else + DivTarjeta.Visible = False + End If + + If Not IDCtaContable > 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then + Alert("La Cuenta Bancaria no tiene asignada una cuenta contable", TipoMensaje.MsgAdvertencia) + End If + + If Not CveCuentaConta > 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then + Alert("La Cuenta Bancaria no tiene asignada una cuenta contable en SIG", 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) + Else + dt = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).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() + Dim dt As DataTable + If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT", "EGSCREDITO") Then + dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs'") + 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'") + 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'") + 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'") + 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'") + 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 Then + DdlTipoTransaccion.DataSource = dt.FiltraParametros("Tipo = 'Ing' ") + Else + DdlTipoTransaccion.DataSource = dt + End If + + + DdlTipoTransaccion.DataBind() + DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) + RBL_SelectedIndexChanged(RBL, Nothing) + + End Sub + + Private Sub CargaMoneda() + DdlMoneda.DataSource = GlobalDTMonedas + DdlMoneda.DataBind() + 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:
{cfdi.Mensaje}" + End If + End Select + sw.Stop() + GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC, "Nomina") + + Return Retorno + End Function -#End Region + 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 = UsuarioActual.Empresa.RegistroPatronal + 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.ToDouble + } + ) + 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("", UsuarioActual.Empresa.RegistroPatronal, 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() + + Return EsValido + End Function + + Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click + + If Not ValidaGuardar() Then + Exit Sub + End If + + 'PARA QUE TOME EL TIPO DE CAMBIO DEL DIA + TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString + UpTipoCambio.Update() + + + 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 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:

" + 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 + End If + End If + + If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then + If CveCliente > 0 Then + CveConceptoCompra = 3 'Clientes + CveConceptoContable = 30 'Bancos + CvePlantillaPoliza = 12 + End If + 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 + 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 = 42 'Prestamo 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 + 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 = DdlMoneda.SelectedValue.ToEntero + Dim tImporteMonedaExtranjera As Decimal = 0 + If tCveMoneda <> 1 Then tImporteMonedaExtranjera = TxtImporte.Text.ToDecimal * GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString.ToDecimal + 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(), DdlMoneda.SelectedValue.ToEntero(), ObjMov) <= 0 Then + MsgError = "No se pudo insertar la póliza de saldo inicial." + End If + End If + + 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, DdlMoneda.SelectedValue.ToEntero, + 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)) + + If CveIE > 0 Then + + If DdlTipoTransaccion.SelectedValue = "1" 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:=ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)) + + '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("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta)) + 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, CveCuenta:=CveCuentaBeneficiario) 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, CveCuenta:=CveCuentaConta) + + 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, CveCuenta:=CveCuentaConta) + + If TxtIvaIxC.Text.ToDouble > 0 Then + '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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) + 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, CveCuenta:=CveCuentaBeneficiario) + 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, CveCuenta:=CveCuentaConta) 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario) 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 + + 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 + importeMX = importeMovimiento + + 'Agregamos el IVA + If DivIvaIxC.Visible AndAlso TxtIvaIxC.Text.ToDecimal <> 0 Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtIvaIxC.Text.ToDecimal, Concepto, 61, Concepto, FechaMovimiento, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE:=CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtIvaIxC.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then + MsgError = "Ocurrió un error al registrar el asiento del ingreso." + End If + End If + If tCveMoneda > 1 AndAlso UsuarioActual.CveEmpresa = 119 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, CveCuenta:=0) 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 UsuarioActual.CveEmpresa = 119 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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then + MsgError = "Ocurrió un error al registrar el asiento del ingreso." + 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, CveCuenta:=If(ConceptoContable = 30, CveCuentaConta, CveCuentaBeneficiario)) 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + ImporteAplicarMN = ImporteAplicar + Else + ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta) Then + MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución" + Exit Select + End If + + 'BANCOS COMPLEMENTARIA + If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta) Then + MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución" + End If + End If + + 'CANCELA NC + IdCtaContableAplicar = IDCtaBeneficiario + ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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) 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 + 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) 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) 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 ConceptoAplicar = $"Devolución de Proveedor {PagueseA} {TxtImporte.Text} NC:{SerieFolioDeCDin}" + + ImporteAplicar = TxtImporte.Text.ToDecimal + ImporteAplicarME = ImporteAplicar + + + 'CONSIDERA COMPLEMENTARIA + If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + ImporteAplicarMN = ImporteAplicar + Else + ImporteAplicarMN = (ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.ToDecimal)).RoundSQL() + End If + + Dim TCCompra As Decimal = 1 + Dim TCDocumento As Decimal = 1 + + If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) 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 TCCompra <= 0 Then + Alert("No se pudo obtener el tipo de cambio del documentpo.", TipoMensaje.MsgAdvertencia) + End If + + End If + + + + '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, CveCuenta:=CveCuentaConta, TipoCambio:=TCDocumento) Then + MsgError = "Ocurrió un error al registrar el asiento de bancos de devolución" + Exit Select + End If + + + 'BANCOS COMPLEMENTARIA + If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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, CveCuenta:=CveCuentaConta, TipoCambio:=TCDocumento) Then + MsgError = "Ocurrió un error al registrar el asiento de bancos complementaria de devolución" + End If + End If + + 'CANCELA NC + IdCtaContableAplicar = IDCtaBeneficiario + 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + + ImporteAplicarMN = ((ImporteAplicar * If(DdlMoneda.SelectedValue.ToEntero = 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), CveCuenta:=CveCuentaConta, 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, CveCuenta:=CveCuentaConta, 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, CveCuenta:=CveCuentaConta, 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 CveCuentaIVAxAcreditarDevDinC = 0 + Dim CveCuentaIVAAcreditableDevDinC = 0 + 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 = ((TxtImporte.Text.ToDecimal * 100D / TotalCompraDev) / 100).RoundSQL(2) + + IVADev = Math.Round(IVADev * PorcentajeDevolucion, 2) + IEPSDev = Math.Round(IEPSDev * PorcentajeDevolucion, 2) + + Dim CveCuentaDevolucionIMPUESTOS As Integer = -1 + Dim IdCtaIVADevolucionIMPUESTOS As Integer = -1 + + + If DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) 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 + + CveCuentaDevolucionIMPUESTOS = CveCuentaIVAxAcreditarDevDinC + IdCtaIVADevolucionIMPUESTOS = IdCtaIVAXAcreditarDevDinC + + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAplicar, -IVADev, ReferenciaAplicar, 14, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) Then + + CveCuentaDevolucionIMPUESTOS = CveCuentaIVAAcreditableDevDinC + IdCtaIVADevolucionIMPUESTOS = IdCtaIVAAcreditableDevDinC + + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IVADev, ReferenciaAplicar, 19, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IVADevMN, ImporteME:=-IVADev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) 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 + CveCuentaDevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditarSIG").ToString.ToEntero + IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero + + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IEPSDev, ReferenciaAplicar, 25, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) Then + + If ObjMov.GetRetCuenta(26, UsuarioActual.CveEmpresa) Then + Try + CveCuentaDevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditableSIG").ToString.ToEntero + IdCtaIVADevolucionIMPUESTOS = ObjMov.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero + + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAplicar, -IEPSDev, ReferenciaAplicar, 26, ConceptoAplicar, Now, IdCtaIVADevolucionIMPUESTOS, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=-IEPSDevMN, ImporteME:=-IEPSDev, CveCuenta:=CveCuentaDevolucionIMPUESTOS) 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 + + + + 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 AndAlso UsuarioActual.CveEmpresa = 119 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, CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar) Then + MsgError = "Ocurrió un error al registrar el asiento del ingreso." + End If + End If + Case 42 + + importeMovimiento = TxtImporte.Text.ToDecimal + importeMX = importeMovimiento + + + + 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, CveCuenta:=If(ConceptoContable = 30, CveCuentaConta, CveCuentaBeneficiario)) 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + IDCtaBeneficiario = IdCtaAnticipoExtranjera + CveCuentaConta = 0 + 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaConta, 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:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario, 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, CveCuenta:=CveCuentaBeneficiario, 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, CveCuenta:=CveCuentaBeneficiario, 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 DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + Dim ImporteAplicar As Decimal = TxtImporte.Text.ToDecimal + Dim TCPago As Decimal = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToDecimal + Dim ImporteAplicarMN = (ImporteAplicar * TCPago - ImporteAplicar).RoundSQL() + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteAplicar, Ref, 204, Conc, Now, IDCtaContableComplementaria, -1, CveIE, CveCompra:=CveCompraDeCDin, CveProveedor:=CveProveedor, ImporteMX:=ImporteAplicarMN, ImporteME:=ImporteAplicar, CveCuenta:=CveCuentaConta, TipoCambio:=TCPago) 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, CveCuenta:=0, TipoCambio:=TCPago) 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 + + 'El movimiento 1 es el de Venta + 'Conta SIG + If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidadSIG Then + If CveCuentaBeneficiario > 0 And CveCuentaConta > 0 Then + If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + IDPoliza = ObjMov.ContaIdPoliza + Else + Alert("Ocurrio un error al contabilizar en SIG, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) + End If + Else + If CveCuentaConta < 1 Then + Alert("No se puede contabilizar la Prepoliza en SIG debido a que la cuenta de Bancos es invalida", TipoMensaje.MsgAdvertencia) + End If + If CveCuentaBeneficiario < 1 Then + Alert("No se puede contabilizar la Prepoliza en SIG debido a que las cuenta del Beneficiario es invalida", TipoMensaje.MsgAdvertencia) + End If + End If + End If + + 'Conta ContPAQ + If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then + If IDCtaBeneficiario > 0 And IDCtaContable > 0 Then + If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + IDPoliza = ObjMov.ContaIdPoliza + 'Alert(alertaContabilizacion & ObjMov.AlertaMensaje, ModExtensiones.TipoMensaje.MsgInformacion) + Else + Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) + End If + Else + 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 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 <> "" Then + NotificacionPago(CveIE, TxtNotificarA.Text.Trim) + End If + + Else + MsgError = "No se pudo insertar la póliza" + End If + + Else + MsgError = "No se insertó el encabezado" + 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 + + 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", AppDomain.CurrentDomain.BaseDirectory)) + 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("

{1} ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem)) + End If + End If + + If IDPoliza > 0 Then + Msg.AppendFormat("

Ver Póliza", 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() + 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("", 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 + + RecargaGlobalCuentasBancarias() + 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) + 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 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(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) + strBody.AppendFormat(" ") + strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("


") + + 'strBody.AppendFormat("
") + 'strBody.AppendFormat("
") + 'strBody.AppendFormat(" ") + 'strBody.AppendFormat(" ") + + 'If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque + ' strBody.Append(" ") + ' strBody.Append(" ") + ' strBody.Append(" ") + 'End If + + 'If objIE.CveTipoTransaccion = 2 Then ' cuando es transf + ' strBody.Append(" ") + ' strBody.Append(" ") + ' strBody.Append(" ") + 'End If + + 'strBody.Append(" ") + 'strBody.AppendFormat(" ") + 'strBody.Append(" ") + 'strBody.Append("
Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.
Notificación de transferencia de pago realizada.
 
") + 'strBody.AppendFormat("
") + 'strBody.Append("
") + + + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" Beneficiario:{0} ", objIE.PagueseA) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.TipoTransaccion) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Banco) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.NumCuenta) + strBody.AppendFormat(" ") + If objIE.CuentaDepositado.ToString <> "" Then + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.CuentaDepositado) + strBody.AppendFormat(" ") + End If + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.FechaDocumento.ToString("dd/MM/yyyy")) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Observaciones) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
Movimiento:{0}
Banco:{0}
Cuenta:{0}
Cuenta Destino:{0}
Fecha:{0}
Importe:$ {0} {1}
Observaciones:{0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + + + 'MOVIMIENTOS CHEQUE + 'If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then + ' Dim Textov33 As String = "" + ' If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then + ' Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" + ' End If + + ' strBody.AppendFormat("
") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat(" Documentos abonados o pagados
{0}
", Textov33) + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + + + ' For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ", dr("Fecha").ToString.ToDate.ToShortDateString()) + ' strBody.AppendFormat(" ", dr("SerieFolio").ToString) + ' strBody.AppendFormat(" ", dr("Importe").ToString.FormatoNumero) + ' strBody.AppendFormat(" ", dr("FolioFiscal")) + ' strBody.AppendFormat(" ") + ' Next + + + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat(" ") + ' strBody.AppendFormat("
FechaFacturaImporte ($)Folio Fiscal
{0}{0}$ {0}{0}
") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat("
") + ' strBody.AppendFormat("
") + 'End If + + strBody.Append("
Favor de no responder a este correo.
") + + strBody.Append("") + End If + + objIE.Dispose() + Return strBody.ToString + End Function + + + + +#End Region ''[IPP] IFs REEMPLAZADOS - MIRAS DE ELIMINAR 2018/08/15 'If Not Opcion.Contiene("DEV", "INGPC", "DevDinV") AndAlso MsgError = "" Then @@ -3692,16 +3707,16 @@ Partial Class Bancos_IE Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs) Handles BtnActualizar.Click - Dim IE As New ClsBancos - IE.IniciaTransacSQL() + 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) Then - OcurrioError = True + If Not IE.UpdateBancos_IE(TxtFechaDocumento.Text.ToDate, FechaAplicado, CveIE, TxtFolio.Text, CveCuentaDeposito:=CveCuentaDepositoUpdate, CveCuenta:=DdlCuenta.SelectedValue.ToEntero, + Observaciones:=TxtObservaciones.Text, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + OcurrioError = True End If If OcurrioError Then @@ -3711,1832 +3726,1832 @@ Partial Class Bancos_IE 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');") - - CancelarIE() - 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 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 ObjAC As ClsContPAQi = Nothing - If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then - ObjAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - End If - - - Dim ErrorCancelar = False - Dim MensajeError = "" - Dim IdPolizaNueva = -1 - Dim FolioPolizaNueva = -1 - - If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) 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 Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then - ErrorCancelar = True - MensajeError = "Error al cancelar IE" - End If - End If - - Else - ErrorCancelar = True - End If - - Else - - 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS - For Each dr As DataRow In dt.Rows - If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then - ErrorCancelar = True - MensajeError = "Error al actualizar Movimientos con importe 0" - Exit For - End If - Next - - 'AJUSTA POLIZA - If Not ErrorCancelar Then - If Not ObjAC.AjustaPoliza(IDPoliza) Then - ErrorCancelar = True - MensajeError = "Error al ajustar poliza negativa" - End If - End If - - 'CANCELA IE - If Not ErrorCancelar Then - If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then - ErrorCancelar = True - MensajeError = "Error al cancelar IE" - End If - End If - - End If - - End If - End If - - Else - - ' If TxtFechaDocumento.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFechaDocumento.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then - If TxtFechaDocumento.Text.ToDate < TxtFechaCancelacion.Text.ToDate.FirstDayOfMonth Then - 'CANCELA IE MES ANTERIOR - If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then - ErrorCancelar = True - MensajeError = "Error al cancelar IE MES ANTERIOR" - End If - Else - 'CANCELA IE MES ACTUAL - If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then - ErrorCancelar = True - MensajeError = "Error al cancelar IE MES ACTUAL" - 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 ObjCancelacion As New Timbrado - 'Dim ObjBanco As New ClsBancos - If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then - - If Banc.UpdateComplementoPago(CveComplementoPagoCancelar, "-1", -1, UsuarioActual.CveEmpresa, 2, CvePACCancelacion, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse) 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.") - End If - Else - ErrorCancelarComplemento = False - End If - - - If Not ErrorCancelarComplemento 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("

Ver Póliza de cancelación", 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 - - If ObjAC IsNot Nothing Then ObjAC.Dispose() - Banc.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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad 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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) 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 Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2) Then - ErrorCancelar = True - End If - End If - - Else - ErrorCancelar = True - End If - - - End If - End If - - Else - - 'siempre se hace una cancelación - If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2) 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("

Ver Póliza de cancelación", 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 - RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion")) - End Sub -#End Region - - - Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlMoneda.SelectedIndexChanged - CambiaTipoMoneda() - End Sub - - Private Sub CambiaTipoMoneda() - If DdlMoneda.SelectedValue.ToEntero > 1 Then - TrTipoCambio.Visible = True - TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString - Else - TrTipoCambio.Visible = False - End If - UpTipoCambio.Update() - End Sub - - - 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("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) - 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() - - 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:

" - - - 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() - 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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) 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 - + 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');") + + CancelarIE() + 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 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 ObjAC As ClsContPAQi = Nothing + If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then + ObjAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + End If + + + Dim ErrorCancelar = False + Dim MensajeError = "" + Dim IdPolizaNueva = -1 + Dim FolioPolizaNueva = -1 + + If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) 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 Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then + ErrorCancelar = True + MensajeError = "Error al cancelar IE" + End If + End If + + Else + ErrorCancelar = True + End If + + Else + + 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS + For Each dr As DataRow In dt.Rows + If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then + ErrorCancelar = True + MensajeError = "Error al actualizar Movimientos con importe 0" + Exit For + End If + Next + + 'AJUSTA POLIZA + If Not ErrorCancelar Then + If Not ObjAC.AjustaPoliza(IDPoliza) Then + ErrorCancelar = True + MensajeError = "Error al ajustar poliza negativa" + End If + End If + + 'CANCELA IE + If Not ErrorCancelar Then + If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then + ErrorCancelar = True + MensajeError = "Error al cancelar IE" + End If + End If + + End If + + End If + End If + + Else + + ' If TxtFechaDocumento.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFechaDocumento.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then + If TxtFechaDocumento.Text.ToDate < TxtFechaCancelacion.Text.ToDate.FirstDayOfMonth Then + 'CANCELA IE MES ANTERIOR + If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then + ErrorCancelar = True + MensajeError = "Error al cancelar IE MES ANTERIOR" + End If + Else + 'CANCELA IE MES ACTUAL + If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva, TxtFechaCancelacion.Text.ToDate) Then + ErrorCancelar = True + MensajeError = "Error al cancelar IE MES ACTUAL" + 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 ObjCancelacion As New Timbrado + 'Dim ObjBanco As New ClsBancos + If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then + + If Banc.UpdateComplementoPago(CveComplementoPagoCancelar, "-1", -1, UsuarioActual.CveEmpresa, 2, CvePACCancelacion, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse) 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.") + End If + Else + ErrorCancelarComplemento = False + End If + + + If Not ErrorCancelarComplemento 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("

Ver Póliza de cancelación", 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 + + If ObjAC IsNot Nothing Then ObjAC.Dispose() + Banc.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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad 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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) 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 Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2) Then + ErrorCancelar = True + End If + End If + + Else + ErrorCancelar = True + End If + + + End If + End If + + Else + + 'siempre se hace una cancelación + If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva, TxtFechaDevuelto.Text.ToDate, 2) 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("

Ver Póliza de cancelación", 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 + RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion")) + End Sub +#End Region + + + Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlMoneda.SelectedIndexChanged + CambiaTipoMoneda() + End Sub + + Private Sub CambiaTipoMoneda() + If DdlMoneda.SelectedValue.ToEntero > 1 Then + TrTipoCambio.Visible = True + TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.Trim.ToDate).ToString + Else + TrTipoCambio.Visible = False + End If + UpTipoCambio.Update() + End Sub + + + 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("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) + 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() + + 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:

" + + + 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() + 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.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) 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 Sub -#End Region - -#Region " CARGAR - COMPROBANTE " - Protected Sub BtnConfirmaComprobante_Click(sender As Object, e As EventArgs) - Dim DirectorioGuardar = String.Format("{0}Empresas\{1}\IE", Request.PhysicalApplicationPath, UsuarioActual.CveEmpresa) - Dim ArchivoTemporal = String.Format("{0}Empresas\{1}\Temp\{2}", Request.PhysicalApplicationPath, UsuarioActual.CveEmpresa, 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 = HttpContext.Current.Request.MapPath(Path) - Path += String.Format("Empresas/{0}/IE", UsuarioActual.CveEmpresa) - 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, DdlMoneda.SelectedValue.ToEntero, -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, DdlMoneda.SelectedValue.ToEntero, -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, DdlMoneda.SelectedValue.ToEntero, 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 Dep As New ClsGenerales - If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCliente:=CveCliente, CvePersonal:=CvePersonal) Then - - If DdlTipoTransaccion.SelectedValue = "9" Then - - DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") - - If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - Else - Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) - End If - - Else - DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'") - If Dep.DtResultados.Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - End If - End If - - - ''ANTIGUO - 'GVCuentasPago.DataSource = Dep.DtResultados - 'If Dep.DtResultados.Rows.Count > 1 Then - ' trCuentaDeposito.Visible = True - ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - - ' 'Si tiene seleccionado Tipo Mov: Layout y no tiene cuenta deposito - 'ElseIf DdlTipoTransaccion.SelectedValue = "9" AndAlso Not Dep.DtResultados.Rows.Count > 0 Then - ' trCuentaDeposito.Visible = True - ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - - ' BtnIEGuardar.Enabled = False - ' UpGuardar.Update() - ' Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) - 'End If - - End If - Dep.Dispose() - - '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 - RecargaGlobalCuentasBancarias() - UpCuentaDeposito.Update() - UpDatos.Update() - End Sub + 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 Sub +#End Region + +#Region " CARGAR - COMPROBANTE " + Protected Sub BtnConfirmaComprobante_Click(sender As Object, e As EventArgs) + Dim DirectorioGuardar = String.Format("{0}Empresas\{1}\IE", Request.PhysicalApplicationPath, UsuarioActual.CveEmpresa) + Dim ArchivoTemporal = String.Format("{0}Empresas\{1}\Temp\{2}", Request.PhysicalApplicationPath, UsuarioActual.CveEmpresa, 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 = HttpContext.Current.Request.MapPath(Path) + Path += String.Format("Empresas/{0}/IE", UsuarioActual.CveEmpresa) + 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, DdlMoneda.SelectedValue.ToEntero, -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, DdlMoneda.SelectedValue.ToEntero, -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, DdlMoneda.SelectedValue.ToEntero, 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 Dep As New ClsGenerales + If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCliente:=CveCliente, CvePersonal:=CvePersonal) Then + + If DdlTipoTransaccion.SelectedValue = "9" Then + + DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + + If Dep.DtResultados.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) + End If + + Else + DdlCuentaDeposito.DataSource = Dep.DtResultados.FiltraParametros("Estatus ='True'") + If Dep.DtResultados.Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + End If + + + ''ANTIGUO + 'GVCuentasPago.DataSource = Dep.DtResultados + 'If Dep.DtResultados.Rows.Count > 1 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + + ' 'Si tiene seleccionado Tipo Mov: Layout y no tiene cuenta deposito + 'ElseIf DdlTipoTransaccion.SelectedValue = "9" AndAlso Not Dep.DtResultados.Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + + ' BtnIEGuardar.Enabled = False + ' UpGuardar.Update() + ' Alert("El proveedor no tiene ninguna cuenta deposito registrada ante el sistema BBVA BANCOMER", TipoMensaje.MsgAdvertencia) + 'End If + + End If + Dep.Dispose() + + '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 + RecargaGlobalCuentasBancarias() + 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 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 - - 'Recaga CuentasBancarias de Proveedor - Private Sub RecargaGlobalCuentasBancarias(Optional ByVal CveCuenta As Integer = -1) - If CveProveedor > 0 Then - Dim ObjCuentasBancos As New ClsGenerales - - If ObjCuentasBancos.GetCuentasDepositos() Then - GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados - End If - ObjCuentasBancos.Dispose() - End If - End Sub - Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim Dep As New ClsGenerales - If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then - If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then - TrReferenciaCIE.Visible = True - TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString - Else - TrReferenciaCIE.Visible = False - End If - End If - Dep.Dispose() - UpCuentaDeposito.Update() - End Sub -#End Region - -#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 ObjGral As New ClsGenerales - If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Banco", TxtFolio.Text + " / " + Cuenta) Then - Borrar = True - End If - ObjGral.Dispose() - If Borrar = True Then - Dim ObjAC As ClsContPAQi = Nothing + End If + + End Sub + + 'Recaga CuentasBancarias de Proveedor + Private Sub RecargaGlobalCuentasBancarias(Optional ByVal CveCuenta As Integer = -1) + If CveProveedor > 0 Then + Dim ObjCuentasBancos As New ClsGenerales + + If ObjCuentasBancos.GetCuentasDepositos() Then + GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados + End If + ObjCuentasBancos.Dispose() + End If + End Sub + Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim Dep As New ClsGenerales + If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero) AndAlso Dep.DtResultados.Rows.Count = 1 Then + If Dep.DtResultados.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then + TrReferenciaCIE.Visible = True + TxtReferenciaCIE.Text = Dep.DtResultados.Rows(0)("Referencia").ToString + Else + TrReferenciaCIE.Visible = False + End If + End If + Dep.Dispose() + UpCuentaDeposito.Update() + End Sub +#End Region + +#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 ObjGral As New ClsGenerales + If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Banco", TxtFolio.Text + " / " + Cuenta) Then + Borrar = True + End If + ObjGral.Dispose() + If Borrar = True Then + Dim ObjAC As ClsContPAQi = Nothing Dim Banc As New ClsBancos - Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL()) - - Dim ErrorCompra = False - - '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 - End If - End If - - If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then - ObjAC = New ClsContPAQi(UsuarioActual.Empresa) - ObjAC.IniciaTransacSQL() - If Not ObjAC.RemovePoliza(IDPoliza) Then - ErrorCompra = True - End If - End If - + Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL()) + + Dim ErrorCompra = False + + '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 + End If + End If + + If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then + ObjAC = New ClsContPAQi(UsuarioActual.Empresa) + ObjAC.IniciaTransacSQL() + If Not ObjAC.RemovePoliza(IDPoliza) 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 - If Not Banc.EliminarBancos_IE(UsuarioActual.CveUsuario, CveIE) Then - ErrorCompra = True - End If - End If - - If Not ErrorCompra Then - Alert("El documento bancario quedó eliminado.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""") - If ObjAC IsNot Nothing Then ObjAC.Commit() - Banc.Commit() - Else - Alert("El documento no ha sido eliminado.", TipoMensaje.MsgAdvertencia) - If ObjAC IsNot Nothing Then ObjAC.RollBack() - Banc.RollBack() - End If - - If ObjAC IsNot Nothing Then ObjAC.Dispose() - Banc.Dispose() - ObjConta.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 - End If - End If - - If CveOCSolicitudAnticipo > 0 Then - - Dim ObjOC As New ClsOC - 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 - TxtImporte.Text = DrOC("ImporteAnticipo").ToString.FormatoNumero - TxtImporteLetra.Text = DrOC("ImporteAnticipo").ToString.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero) - 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 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 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 + End If -#Region " COMPLEMENTOS PAGO " + + If Not ErrorCompra Then + If Not Banc.EliminarBancos_IE(UsuarioActual.CveUsuario, CveIE) Then + ErrorCompra = True + End If + End If + + If Not ErrorCompra Then + Alert("El documento bancario quedó eliminado.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""") + If ObjAC IsNot Nothing Then ObjAC.Commit() + Banc.Commit() + Else + Alert("El documento no ha sido eliminado.", TipoMensaje.MsgAdvertencia) + If ObjAC IsNot Nothing Then ObjAC.RollBack() + Banc.RollBack() + End If + + If ObjAC IsNot Nothing Then ObjAC.Dispose() + Banc.Dispose() + ObjConta.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 + End If + End If + + If CveOCSolicitudAnticipo > 0 Then + + Dim ObjOC As New ClsOC + 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 + TxtImporte.Text = DrOC("ImporteAnticipo").ToString.FormatoNumero + TxtImporteLetra.Text = DrOC("ImporteAnticipo").ToString.ToDouble.Texto2Letras(DrOC("CveMoneda").ToString.ToEntero) + 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 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 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 - - If UsuarioActual.CveRol = 1 Then - GvComplementoPagos.Columns(7).Visible = True + Dim ObjBancos As New ClsBancos + + If UsuarioActual.CveRol = 1 Then + GvComplementoPagos.Columns(7).Visible = True End If - DVGenerarComplementoModal.Visible = False - - If ObjBancos.GetVincularPago(CveProveedor, CveCompra, 2, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, CveIE) Then - + DVGenerarComplementoModal.Visible = False + + If ObjBancos.GetVincularPago(CveProveedor, CveCompra, 2, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, CveIE) Then + GvComplementoPagos.DataSource = ObjBancos.DtResultados If ObjBancos.DtResultados.FiltraParametros(" Estatus IN (1,3) ").Rows.Count = 0 And Tipo.ToUpper = "CARGO" And CveCliente > 0 And UsuarioActual.CveRol = 1 And CveEstatusIE <> 2 Then DVGenerarComplementoModal.Visible = True - End If + End If Else - GvComplementoPagos.DataSource = Nothing - End If - - ObjBancos.Dispose() - GvComplementoPagos.DataBind() - UpComplementoPagos.Update() - - 'If ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then - ' GvComplementoPagos.DataSource = ObjBancos.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"}) - 'End If - - '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 - e.Row.Cells(3).Text = String.Format("", 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("", 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 + GvComplementoPagos.DataSource = Nothing + End If + + ObjBancos.Dispose() + GvComplementoPagos.DataBind() + UpComplementoPagos.Update() + + 'If ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) Then + ' GvComplementoPagos.DataSource = ObjBancos.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "SerieFolio", "Fecha", "CveIE"}) + 'End If + + '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 + e.Row.Cells(3).Text = String.Format("", 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("", 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 - Else + Else e.Row.FCLinkButton("LnkCancelarComplemetno").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 - - - Protected Sub imgRegenerar_Click(sender As Object, e As EventArgs) - Dim gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow) - Dim FolioFiscalPadre As String = gvr.DataKey("FolioFiscal") - - If FolioFiscalPadre <> "" Then - Dim Str As New StringBuilder - Dim ObjBanco As New ClsBancos - ObjBanco.IniciaTransacSQL() - - If ObjBanco.GeneraTimbrePago(CveIE, -1, UsuarioActual, -1, FolioFiscalPadre, EsRegeneracion:=True) Then - ObjBanco.Commit() - Str.AppendFormat("Folio: {0}  ", ObjBanco.ComplementoSerieFolio) - Str.AppendFormat("XML    ", Encripta(String.Format("OP=Pag&EXT=xml&CveIE={0}&SerieFolio={1}", gvr.DataKey("CveIE").ToEntero, ObjBanco.ComplementoSerieFolio.Replace("&", "%26%")))) - Str.AppendFormat("PDF   ", Encripta(String.Format("OP=Pag&EXT=pdf&CveIE={0}&SerieFolio={1}", gvr.DataKey("CveIE").ToEntero, ObjBanco.ComplementoSerieFolio.Replace("&", "%26%")))) - 'Str.Append($"{gvr.DataKey("Folio")}   {gvr.DataKey("NombreCliente")}
") - PDFReciboDePagos(-1, gvr.DataKey("CveIE").ToEntero, ObjBanco.CveComplementoPago, False) - Alert(Str.ToString, TipoMensaje.MsgInformacion) - CargaComplementosPago() - Else - Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", gvr.DataKey("Folio"), ObjBanco.Mensaje) - Alert(Str.ToString, TipoMensaje.MsgError) - ObjBanco.RollBack() - End If - - ObjBanco.Dispose() - Else - Alert("El complemento no tiene Folio Fiscal", TipoMensaje.MsgError) - End If - - End Sub - - - - - - Private Function VerificaComplementos(Validos As Boolean) As Boolean - Dim ObjBancos As New ClsBancos - Dim Retorno As Boolean = False - Dim Filtro As String = "" - - + 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 + + + Protected Sub imgRegenerar_Click(sender As Object, e As EventArgs) + Dim gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow) + Dim FolioFiscalPadre As String = gvr.DataKey("FolioFiscal") + + If FolioFiscalPadre <> "" Then + Dim Str As New StringBuilder + Dim ObjBanco As New ClsBancos + ObjBanco.IniciaTransacSQL() + + If ObjBanco.GeneraTimbrePago(CveIE, -1, UsuarioActual, -1, FolioFiscalPadre, EsRegeneracion:=True) Then + ObjBanco.Commit() + Str.AppendFormat("Folio: {0}  ", ObjBanco.ComplementoSerieFolio) + Str.AppendFormat("XML    ", Encripta(String.Format("OP=Pag&EXT=xml&CveIE={0}&SerieFolio={1}", gvr.DataKey("CveIE").ToEntero, ObjBanco.ComplementoSerieFolio.Replace("&", "%26%")))) + Str.AppendFormat("PDF   ", Encripta(String.Format("OP=Pag&EXT=pdf&CveIE={0}&SerieFolio={1}", gvr.DataKey("CveIE").ToEntero, ObjBanco.ComplementoSerieFolio.Replace("&", "%26%")))) + 'Str.Append($"{gvr.DataKey("Folio")}   {gvr.DataKey("NombreCliente")}
") + PDFReciboDePagos(-1, gvr.DataKey("CveIE").ToEntero, ObjBanco.CveComplementoPago, False) + Alert(Str.ToString, TipoMensaje.MsgInformacion) + CargaComplementosPago() + Else + Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", gvr.DataKey("Folio"), ObjBanco.Mensaje) + Alert(Str.ToString, TipoMensaje.MsgError) + ObjBanco.RollBack() + End If + + ObjBanco.Dispose() + Else + Alert("El complemento no tiene Folio Fiscal", TipoMensaje.MsgError) + End If + + 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 ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) And 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 If + + If ObjBancos.GetComplementoPagos(-1, CveIE, -1, UsuarioActual.CveEmpresa) And 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 +#End Region + +#Region " ACTUALIZAR TIPO CAMBIO PREPOLIZA " + Private Sub InicializaActualizarTC() + If CveIE > 0 And DdlMoneda.SelectedValue.ToEntero = 2 And CvePrePoliza > 0 Then + TxtActualizarTC_TCActual.Text = TxtTipoCambio.Text + TxtActualizarTC_TCActualizar.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) + HLModalActualizarTC.Visible = True + End If + End Sub + Protected Sub BtnActualizarTC_Click(sender As Object, e As EventArgs) + Dim ObjContabilidad As New ClsContabilidad + Dim ObjBancos As New ClsBancos(ObjContabilidad.IniciaTransacSQL()) + Dim ObjEventos As New ClsOIEventos(ObjContabilidad.IniciaTransacSQL()) + Dim TieneError = False + Dim MensajeError = "" + + If ObjEventos.AddEventoBitacora($"Se actualizó el Tipo de Cambio de la compra. TC anterior: {TxtActualizarTC_TCActual.Text.FormatoNumero(4)} | TC actual: {TxtActualizarTC_TCActualizar.Text.FormatoNumero(4)}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then + If ObjBancos.UpdateBancos_IETipoCambio(TxtActualizarTC_TCActualizar.Text.ToDouble, CveIE, CvePrePoliza, UsuarioActual.CveEmpresa) Then + If Not ObjContabilidad.ReconstruirPP_PagoCompraVenta(CveIE) Then + TieneError = True + MensajeError = "Ocurrió un error al actualizar el asiento contable" + End If + Else + TieneError = True + MensajeError = "Ocurrió un error al actualizar el Tipo de Cambio al documento" + End If + Else + TieneError = True + MensajeError = "Ocurrió un error al guardar el historal al actualizar el Tipo de Cambio al documento" + End If + + If Not TieneError Then + ObjContabilidad.Commit() + Alert("Se actualizó correctamente el tipo de cambio del documento.", TipoMensaje.MsgInformacion) + RegistraScript("$('#ModalActualizarTC').modal('hide');") + Else + ObjContabilidad.RollBack() + Alert(MensajeError, TipoMensaje.MsgError) + End If + + ObjContabilidad.Dispose() + 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() + + DdlMoneda.SelectedValue = UrlParametros("CVEMONEDA").ToString + CveMoneda = DdlMoneda.SelectedValue.ToEntero + CargaCuenta(DdlMoneda.SelectedValue.ToEntero) + 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() + + DdlMoneda.SelectedValue = UrlParametros("CVEMONEDA").ToString + CveMoneda = DdlMoneda.SelectedValue.ToEntero + CargaCuenta(DdlMoneda.SelectedValue.ToEntero) + 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 + RegistraScript("ShowDivDevueltoIE();") + End Sub + + Protected Sub LnkCancelar_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 + RegistraScript("ShowDivCancelarIE();") + 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 + Banco.IniciaTransacSQL() + + + If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual) Then + If Banco.Mensaje = "" Then + Banco.Commit() + PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False) + Str.AppendFormat("Folio: {0}  ", Banco.ComplementoSerieFolio) + Str.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) + Str.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) + Str.AppendFormat("{1}   {2}
", CveIE, 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" + + If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then + + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) + + If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then + + If ConAlerta Then + RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + End If + + Else + Msg = "No se pudo enviar el correo electrónico." + End If + + Else + Msg = "No se pudo adjuntar el correo electrónico." + End If + + End If + + If ConAlerta AndAlso Msg <> "" Then + Alert(Msg, TipoMensaje.MsgError) + End If + + + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + + End Try + End 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(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) + strBody.AppendFormat(" ") + strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("


") + + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + + If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + End If + + If objIE.CveTipoTransaccion = 2 Then ' cuando es transf + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + End If + + strBody.Append(" ") + strBody.AppendFormat(" ") + strBody.Append(" ") + strBody.Append("
Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.
Notificación de transferencia de pago realizada.
 
") + strBody.AppendFormat("
") + strBody.Append("
") + + + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" Beneficiario:{0} ", objIE.PagueseA) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.TipoTransaccion) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Banco) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.NumCuenta) + strBody.AppendFormat(" ") + If objIE.CuentaDepositado.ToString <> "" Then + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.CuentaDepositado) + strBody.AppendFormat(" ") + End If + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.FechaDocumento.ToString("dd/MM/yyyy")) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", objIE.Observaciones) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
Movimiento:{0}
Banco:{0}
Cuenta:{0}
Cuenta Destino:{0}
Fecha:{0}
Importe:$ {0} {1}
Observaciones:{0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + + + 'MOVIMIENTOS CHEQUE + If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then + Dim Textov33 As String = "" + If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then + Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" + End If + + strBody.AppendFormat("
") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat(" Documentos abonados o pagados
{0}
", Textov33) + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + + + For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows + strBody.AppendFormat(" ") + strBody.AppendFormat(" ", dr("Fecha").ToString.ToDate.ToShortDateString()) + strBody.AppendFormat(" ", dr("SerieFolio").ToString) + strBody.AppendFormat(" ", dr("Importe").ToString.FormatoNumero) + strBody.AppendFormat(" ", dr("FolioFiscal")) + strBody.AppendFormat(" ", dr("ImporteNC").ToString.FormatoNumero) + strBody.AppendFormat(" ") + Next + + + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat(" ") + strBody.AppendFormat("
FechaFacturaImporte ($)Folio FiscalNC Aplicadas
{0}{0}$ {0}{0}{0}
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + strBody.AppendFormat("
") + End If + + strBody.Append("
Favor de no responder a este correo.
") + + strBody.Append("") + End If + + objIE.Dispose() + Return strBody.ToString + End Function + + Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click + '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 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 + + If ObjBanco.UpdateAjustarMovimiento(CveIE, TxtAjustarMovimiento.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + RegistraScript("$('#ModalAjustarMovimiento').modal('hide');", "ALTR") + Alert("El ajuste se realizo correctamente.", TipoMensaje.MsgInformacion, $" document.location.href = ""./IE.aspx?CveIE={CveIE}"";") + 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 AndAlso e.Row.DBCampo("Saldo").ToString.ToDecimal = 0 Then + e.Row.FCLinkButton("LnkCancelaMovimiento").Visible = True + End If + End If + End Sub + + + Protected Sub LnkCancelarComplemetno_Click(sender As Object, e As EventArgs) -#Region " ACTUALIZAR TIPO CAMBIO PREPOLIZA " - Private Sub InicializaActualizarTC() - If CveIE > 0 And DdlMoneda.SelectedValue.ToEntero = 2 And CvePrePoliza > 0 Then - TxtActualizarTC_TCActual.Text = TxtTipoCambio.Text - TxtActualizarTC_TCActualizar.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) - HLModalActualizarTC.Visible = True - End If - End Sub - Protected Sub BtnActualizarTC_Click(sender As Object, e As EventArgs) - Dim ObjContabilidad As New ClsContabilidad - Dim ObjBancos As New ClsBancos(ObjContabilidad.IniciaTransacSQL()) - Dim ObjEventos As New ClsOIEventos(ObjContabilidad.IniciaTransacSQL()) - Dim TieneError = False - Dim MensajeError = "" - - If ObjEventos.AddEventoBitacora($"Se actualizó el Tipo de Cambio de la compra. TC anterior: {TxtActualizarTC_TCActual.Text.FormatoNumero(4)} | TC actual: {TxtActualizarTC_TCActualizar.Text.FormatoNumero(4)}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then - If ObjBancos.UpdateBancos_IETipoCambio(TxtActualizarTC_TCActualizar.Text.ToDouble, CveIE, CvePrePoliza, UsuarioActual.CveEmpresa) Then - If Not ObjContabilidad.ReconstruirPP_PagoCompraVenta(CveIE) Then - TieneError = True - MensajeError = "Ocurrió un error al actualizar el asiento contable" - End If - Else - TieneError = True - MensajeError = "Ocurrió un error al actualizar el Tipo de Cambio al documento" - End If - Else - TieneError = True - MensajeError = "Ocurrió un error al guardar el historal al actualizar el Tipo de Cambio al documento" - End If - - If Not TieneError Then - ObjContabilidad.Commit() - Alert("Se actualizó correctamente el tipo de cambio del documento.", TipoMensaje.MsgInformacion) - RegistraScript("$('#ModalActualizarTC').modal('hide');") - Else - ObjContabilidad.RollBack() - Alert(MensajeError, TipoMensaje.MsgError) - End If - - ObjContabilidad.Dispose() - 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() - - DdlMoneda.SelectedValue = UrlParametros("CVEMONEDA").ToString - CveMoneda = DdlMoneda.SelectedValue.ToEntero - CargaCuenta(DdlMoneda.SelectedValue.ToEntero) - 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() - - DdlMoneda.SelectedValue = UrlParametros("CVEMONEDA").ToString - CveMoneda = DdlMoneda.SelectedValue.ToEntero - CargaCuenta(DdlMoneda.SelectedValue.ToEntero) - 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 - RegistraScript("ShowDivDevueltoIE();") - End Sub - - Protected Sub LnkCancelar_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 - RegistraScript("ShowDivCancelarIE();") - 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 - Banco.IniciaTransacSQL() - - - If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual) Then - If Banco.Mensaje = "" Then - Banco.Commit() - PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False) - Str.AppendFormat("Folio: {0}  ", Banco.ComplementoSerieFolio) - Str.AppendFormat("XML    ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) - Str.AppendFormat("PDF   ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago))) - Str.AppendFormat("{1}   {2}
", CveIE, 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" - - If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then - - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) - - If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then - - If ConAlerta Then - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - End If - - Else - Msg = "No se pudo enviar el correo electrónico." - End If - - Else - Msg = "No se pudo adjuntar el correo electrónico." - End If - - End If - - If ConAlerta AndAlso Msg <> "" Then - Alert(Msg, TipoMensaje.MsgError) - End If - - - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - - End Try - End 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(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" {0}", UsuarioActual.Empresa.Empresa) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Direccion) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Colonia) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", UsuarioActual.Empresa.RFC) - strBody.AppendFormat(" ") - strBody.AppendFormat("
{0}
Col. {0}
{0}, {1}, C.P.{2}
RFC {0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("


") - - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - - If objIE.CveTipoTransaccion = 1 Then ' cuando es cheque - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - End If - - If objIE.CveTipoTransaccion = 2 Then ' cuando es transf - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - End If - - strBody.Append(" ") - strBody.AppendFormat(" ") - strBody.Append(" ") - strBody.Append("
Favor de pasar a nuestras oficinas por el cheque con la siguientes instrucciones.
Notificación de transferencia de pago realizada.
 
") - strBody.AppendFormat("
") - strBody.Append("
") - - - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" Beneficiario:{0} ", objIE.PagueseA) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.TipoTransaccion) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Banco) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.NumCuenta) - strBody.AppendFormat(" ") - If objIE.CuentaDepositado.ToString <> "" Then - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.CuentaDepositado) - strBody.AppendFormat(" ") - End If - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.FechaDocumento.ToString("dd/MM/yyyy")) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Importe.FormatoNumero, objIE.Moneda) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", objIE.Observaciones) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
Movimiento:{0}
Banco:{0}
Cuenta:{0}
Cuenta Destino:{0}
Fecha:{0}
Importe:$ {0} {1}
Observaciones:{0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - - - 'MOVIMIENTOS CHEQUE - If objIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then - Dim Textov33 As String = "" - If UsuarioActual.Empresa.Funcionalidad(520) = "1" Then - Textov33 = "Favor de emitir complemento de pago de los siguientes documentos" - End If - - strBody.AppendFormat("
") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat(" Documentos abonados o pagados
{0}
", Textov33) - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - - - For Each dr As DataRow In objIE.DtResultados.FiltraParametros("CveConceptoContable IN (17) AND CveCompra > 0").Rows - strBody.AppendFormat(" ") - strBody.AppendFormat(" ", dr("Fecha").ToString.ToDate.ToShortDateString()) - strBody.AppendFormat(" ", dr("SerieFolio").ToString) - strBody.AppendFormat(" ", dr("Importe").ToString.FormatoNumero) - strBody.AppendFormat(" ", dr("FolioFiscal")) - strBody.AppendFormat(" ", dr("ImporteNC").ToString.FormatoNumero) - strBody.AppendFormat(" ") - Next - - - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat(" ") - strBody.AppendFormat("
FechaFacturaImporte ($)Folio FiscalNC Aplicadas
{0}{0}$ {0}{0}{0}
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - strBody.AppendFormat("
") - End If - - strBody.Append("
Favor de no responder a este correo.
") - - strBody.Append("") - End If - - objIE.Dispose() - Return strBody.ToString - End Function - - Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click - '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 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 - - If ObjBanco.UpdateAjustarMovimiento(CveIE, TxtAjustarMovimiento.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - RegistraScript("$('#ModalAjustarMovimiento').modal('hide');", "ALTR") - Alert("El ajuste se realizo correctamente.", TipoMensaje.MsgInformacion, $" document.location.href = ""./IE.aspx?CveIE={CveIE}"";") - 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 AndAlso e.Row.DBCampo("Saldo").ToString.ToDecimal = 0 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 seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgAdvertencia) Exit Sub - End If - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow) - - - 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 ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then - - If ObjBanco.UpdateComplementoPago(CveComplementoPagoCancelar, "-1", -1, UsuarioActual.CveEmpresa, 2, CvePACCancelacion, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse) Then - CargaComplementosPago() - - ' RegistraScript("$('#ModalCancelarComplemetno').modal('hide');") - Alert("El complemento se cancelo correctamente.") - End If - - Else - Alert("Se presento un error al cancelar el complemento.") - End If - - ObjBanco.Dispose() - - - '' INICIO Version 2 - '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 - - 'RegistraScript("$('#ModalCancelarComplemetno').modal('show');") - - 'RdlCancelarComplemento.SelectedValue = "1" - 'DivFechaCancelación.Visible = False - 'UpModalCancelarComplemetno.Update() - '' FIN Version 2 - - End Sub - + End If + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow) + + + 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 ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptorCancelar, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then + + If ObjBanco.UpdateComplementoPago(CveComplementoPagoCancelar, "-1", -1, UsuarioActual.CveEmpresa, 2, CvePACCancelacion, FechaCancelacion:=ObjCancelacion.CancelacionFecha, SelloCancelacion:=ObjCancelacion.CancelacionAcuse) Then + CargaComplementosPago() + + ' RegistraScript("$('#ModalCancelarComplemetno').modal('hide');") + Alert("El complemento se cancelo correctamente.") + End If + + Else + Alert("Se presento un error al cancelar el complemento.") + End If + + ObjBanco.Dispose() + + + '' INICIO Version 2 + '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 + + 'RegistraScript("$('#ModalCancelarComplemetno').modal('show');") + + 'RdlCancelarComplemento.SelectedValue = "1" + 'DivFechaCancelación.Visible = False + 'UpModalCancelarComplemetno.Update() + '' FIN Version 2 + + End Sub + Protected Sub BtnModalCancelarComplemento_Click(sender As Object, e As EventArgs) @@ -5558,14 +5573,14 @@ Partial Class Bancos_IE End If - Dim ObjBancos As New ClsBancos - Dim Respuesta As Boolean = False - Dim DTComplementos As New DataTable - + 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 - + End If + ObjBancos.Dispose() If DTComplementos.Rows.Count = 1 Then @@ -5598,14 +5613,14 @@ Partial Class Bancos_IE BtnEditar.Visible = False UpGuardar.Update() - ControlesEdicion(True) + ControlesEdicion() End Sub - Private Sub ControlesEdicion(mostrar As Boolean) + Private Sub ControlesEdicion() - If mostrar Then + If PermisoComplementoVigente Then DdlTipoTransaccion.Enabled = True LblCuenta.Visible = False @@ -5617,12 +5632,11 @@ Partial Class Bancos_IE CargaCuentasDepositoClientes() + Else + TxtFolio.Enabled = True + TxtObservaciones.Enabled = True - - - - - + UpDatos.Update() End If End Sub From d14c788dc78b087377e136ebca7edad726f12db7 Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Sat, 24 Aug 2019 12:43:34 -0700 Subject: [PATCH 02/13] =?UTF-8?q?cambio=20en=20ventas,=20TC=20no=20editabl?= =?UTF-8?q?e=20-=20popupaxiliar.=20=20generar=20p=C3=B3liza=20cancelada=20?= =?UTF-8?q?apartir=20de=20otra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsContabilidad.vb | 7 +- Contabilidad/PopUpAuxiliar.aspx.vb | 756 +++++++++++++++-------------- Ventas/Ventas.aspx | 2 +- Ventas/Ventas.aspx.vb | 8 +- 4 files changed, 397 insertions(+), 376 deletions(-) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 4ab57dfa8..2b556565a 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -228,9 +228,9 @@ Public Class ClsContabilidad - Public Function AddPrePolizasNegativa(CvePrePoliza As Integer, CveUsuario As Integer, Concepto As String, CveEmpresa As Integer, Fecha As Date) As Boolean + Public Function AddPrePolizasNegativa(CvePrePoliza As Integer, CveUsuario As Integer, Concepto As String, CveEmpresa As Integer, Fecha As Date) As Integer - Dim Retorno As Boolean = False + Dim Retorno As Integer = -1 DataAdapter("PA_Conta_PrePolizasNegativaAdd") @@ -240,11 +240,12 @@ Public Class ClsContabilidad .Add("@Concepto", SqlDbType.VarChar).Value = Concepto .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CvePrePolizaNueva", SqlDbType.Int).Direction = ParameterDirection.Output End With Try SqlAdapter.Fill(Data) - Retorno = True + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePrePolizaNueva").Value.ToString.ToEntero Catch ex As Exception OnError("Ocurrió un error al Guardar", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try diff --git a/Contabilidad/PopUpAuxiliar.aspx.vb b/Contabilidad/PopUpAuxiliar.aspx.vb index e283fc11f..115d1b7b7 100644 --- a/Contabilidad/PopUpAuxiliar.aspx.vb +++ b/Contabilidad/PopUpAuxiliar.aspx.vb @@ -1,371 +1,371 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports Microsoft.Reporting.WebForms -Imports System.Data - -Partial Class PopUpAuxiliar - Inherits ClsPaginas - - Private Property Tipo As String - Get - Return ViewState("Tipo").ToString - End Get - Set(value As String) - ViewState("Tipo") = value - End Set - End Property - - Private Property CveCliente As Integer - Get - Return ViewState("CveCliente").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCliente") = value - End Set - End Property - - Private Property CveVenta As Integer - Get - Return ViewState("CveVenta").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveVenta") = value - End Set - End Property - - Private Property CveProveedor As Integer - Get - Return ViewState("CveProveedor").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveProveedor") = value - End Set - End Property - - Private Property CveCompra As Integer - Get - Return ViewState("CveCompra").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCompra") = value - End Set - End Property - Private Property DTDatos As DataTable - Get - Return CType(ViewState("DTDatos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTDatos") = value - End Set - End Property - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - CType(Me.Master, BaseMasterPage).EsPopup = True - CType(Me.Master, BaseMasterPage).PopupWidth = 915 - RegistraScript("$get('tdContenido').style.height='1000'") - - Tipo = Request("Tipo") - CveCliente = 0 - CveProveedor = 0 - CargaDatos() - - End If - End Sub - - Private Sub CargaDatos() - GVAuxiliar.Columns(10).Visible = UsuarioActual.TienePermisoProceso(94) +Option Explicit On +Option Strict On + +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports System.Data + +Partial Class PopUpAuxiliar + Inherits ClsPaginas + + Private Property Tipo As String + Get + Return ViewState("Tipo").ToString + End Get + Set(value As String) + ViewState("Tipo") = value + End Set + End Property + + Private Property CveCliente As Integer + Get + Return ViewState("CveCliente").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCliente") = value + End Set + End Property + + Private Property CveVenta As Integer + Get + Return ViewState("CveVenta").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveVenta") = value + End Set + End Property + + Private Property CveProveedor As Integer + Get + Return ViewState("CveProveedor").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveProveedor") = value + End Set + End Property + + Private Property CveCompra As Integer + Get + Return ViewState("CveCompra").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCompra") = value + End Set + End Property + Private Property DTDatos As DataTable + Get + Return CType(ViewState("DTDatos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTDatos") = value + End Set + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + CType(Me.Master, BaseMasterPage).EsPopup = True + CType(Me.Master, BaseMasterPage).PopupWidth = 915 + RegistraScript("$get('tdContenido').style.height='1000'") + + Tipo = Request("Tipo") + CveCliente = 0 + CveProveedor = 0 + CargaDatos() + + End If + End Sub + + Private Sub CargaDatos() + GVAuxiliar.Columns(10).Visible = UsuarioActual.TienePermisoProceso(94) 'GVAuxiliar.Columns(11).Visible = UsuarioActual.TienePermisoProceso(94) - GVAuxiliar.Columns(12).Visible = UsuarioActual.TienePermisoProceso(94) - - Select Case Tipo - Case "CxCClientes" - CveCliente = Request("CveCliente").ToEntero - CveVenta = Request("CveVenta").ToEntero - CargaAuxiliarClienteCxC(CveCliente, CveVenta) - LtlTipo1.Text = "Cuentas por Cobrar" - LtlTipo2.Text = "Folio de la Venta" - LtlTipo3.Text = "Fecha de la Venta" - Case "AnticiposClientes" - CveCliente = Request("CveCliente").ToEntero - CveVenta = Request("CveVenta").ToEntero - CargaAuxiliarClienteAnticipos(CveCliente, CveVenta) - LtlTipo1.Text = "Anticipo de Clientes" - LtlTipo2.Text = "Folio de la Venta" - LtlTipo3.Text = "Fecha de la Venta" - Case "CxPProveedor" - CveProveedor = Request("CveProveedor").ToEntero - CveCompra = Request("CveCompra").ToEntero - CargaAuxiliarProveedor(CveProveedor, CveCompra) - LtlTipo1.Text = "Cuentas por Pagar" - LtlTipo2.Text = "Folio de la Compra" - LtlTipo3.Text = "Fecha de la Compra" - End Select - - - UpDatos.Update() - End Sub - - Private Sub CargaAuxiliarClienteCxC(CveCliente As Integer, CveVenta As Integer) - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxCClienteAuxiliar(CveCliente, CveVenta) Then - DTDatos = ObjMovtos.DtResultados - GVAuxiliar.DataSource = ObjMovtos.DtResultados - If ObjMovtos.DtResultados.Rows.Count > 0 Then - LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() - LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString - LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) - LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) - End If - Else - GVAuxiliar.DataSource = Nothing - End If - ObjMovtos.Dispose() - GVAuxiliar.DataBind() - End Sub - - Private Sub CargaAuxiliarClienteAnticipos(CveCliente As Integer, CveVenta As Integer) - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetAnticiposClienteAuxiliar(CveCliente, CveVenta) Then - DTDatos = ObjMovtos.DtResultados - GVAuxiliar.DataSource = ObjMovtos.DtResultados - If ObjMovtos.DtResultados.Rows.Count > 0 Then - LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() - LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString - 'LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) - 'LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) - End If - Else - GVAuxiliar.DataSource = Nothing - End If - ObjMovtos.Dispose() - GVAuxiliar.DataBind() - End Sub - - Private Sub CargaAuxiliarProveedor(CveProveedor As Integer, CveCompra As Integer) - Dim ObjMovtos As New ClsContabilidad() - If ObjMovtos.GetProveedorAuxiliar(CveProveedor, CveCompra) Then - DTDatos = ObjMovtos.DtResultados - GVAuxiliar.DataSource = ObjMovtos.DtResultados - If ObjMovtos.DtResultados.Rows.Count > 0 Then - LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() - LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString - LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) - LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) - End If - Else - GVAuxiliar.DataSource = Nothing - End If - ObjMovtos.Dispose() - GVAuxiliar.DataBind() - End Sub - + GVAuxiliar.Columns(12).Visible = UsuarioActual.TienePermisoProceso(94) + + Select Case Tipo + Case "CxCClientes" + CveCliente = Request("CveCliente").ToEntero + CveVenta = Request("CveVenta").ToEntero + CargaAuxiliarClienteCxC(CveCliente, CveVenta) + LtlTipo1.Text = "Cuentas por Cobrar" + LtlTipo2.Text = "Folio de la Venta" + LtlTipo3.Text = "Fecha de la Venta" + Case "AnticiposClientes" + CveCliente = Request("CveCliente").ToEntero + CveVenta = Request("CveVenta").ToEntero + CargaAuxiliarClienteAnticipos(CveCliente, CveVenta) + LtlTipo1.Text = "Anticipo de Clientes" + LtlTipo2.Text = "Folio de la Venta" + LtlTipo3.Text = "Fecha de la Venta" + Case "CxPProveedor" + CveProveedor = Request("CveProveedor").ToEntero + CveCompra = Request("CveCompra").ToEntero + CargaAuxiliarProveedor(CveProveedor, CveCompra) + LtlTipo1.Text = "Cuentas por Pagar" + LtlTipo2.Text = "Folio de la Compra" + LtlTipo3.Text = "Fecha de la Compra" + End Select + + + UpDatos.Update() + End Sub + + Private Sub CargaAuxiliarClienteCxC(CveCliente As Integer, CveVenta As Integer) + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetCxCClienteAuxiliar(CveCliente, CveVenta) Then + DTDatos = ObjMovtos.DtResultados + GVAuxiliar.DataSource = ObjMovtos.DtResultados + If ObjMovtos.DtResultados.Rows.Count > 0 Then + LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() + LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString + LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) + LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) + End If + Else + GVAuxiliar.DataSource = Nothing + End If + ObjMovtos.Dispose() + GVAuxiliar.DataBind() + End Sub + + Private Sub CargaAuxiliarClienteAnticipos(CveCliente As Integer, CveVenta As Integer) + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetAnticiposClienteAuxiliar(CveCliente, CveVenta) Then + DTDatos = ObjMovtos.DtResultados + GVAuxiliar.DataSource = ObjMovtos.DtResultados + If ObjMovtos.DtResultados.Rows.Count > 0 Then + LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() + LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString + 'LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) + 'LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) + End If + Else + GVAuxiliar.DataSource = Nothing + End If + ObjMovtos.Dispose() + GVAuxiliar.DataBind() + End Sub + + Private Sub CargaAuxiliarProveedor(CveProveedor As Integer, CveCompra As Integer) + Dim ObjMovtos As New ClsContabilidad() + If ObjMovtos.GetProveedorAuxiliar(CveProveedor, CveCompra) Then + DTDatos = ObjMovtos.DtResultados + GVAuxiliar.DataSource = ObjMovtos.DtResultados + If ObjMovtos.DtResultados.Rows.Count > 0 Then + LtlFechaVenta.Text = ObjMovtos.DtResultados.Rows(1)("FechaVenta").ToString.ToDate.ToShortDateString() + LtlFolio.Text = ObjMovtos.DtResultados.Rows(1)("Folio").ToString + LtlImporte.Text = ObjMovtos.DtResultados.Rows(1)("Total").ToString.FormatoNumero(2) + LtlSaldo.Text = ObjMovtos.DtResultados.Rows(1)("Saldo").ToString.FormatoNumero(2) + End If + Else + GVAuxiliar.DataSource = Nothing + End If + ObjMovtos.Dispose() + GVAuxiliar.DataBind() + End Sub + Protected Sub GVAuxiliar_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAuxiliar.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.BackColor = Drawing.Color.LightGray - e.Row.FCLiteral("LtlFechaMovto").Text = "Totales: " - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(0).ColumnSpan = 2 - e.Row.Cells(1).Visible = False - e.Row.Cells(4).ColumnSpan = 3 - e.Row.Cells(5).Visible = False - e.Row.Cells(6).Visible = False - e.Row.Cells(7).Visible = False - e.Row.Cells(8).Visible = False - e.Row.Cells(12).Visible = False - ElseIf e.Row.RowIndex = 1 Then - e.Row.Cells(0).Width = Unit.Pixel(95) - e.Row.Cells(1).Width = Unit.Pixel(180) - e.Row.Cells(2).Width = Unit.Pixel(80) - e.Row.Cells(3).Width = Unit.Pixel(80) - e.Row.Cells(4).Width = Unit.Pixel(83) - e.Row.Cells(5).Width = Unit.Pixel(93) - e.Row.Cells(6).Width = Unit.Pixel(85) - e.Row.Cells(7).Width = Unit.Pixel(95) - e.Row.Cells(8).Width = Unit.Pixel(70) - End If - - e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left - - If e.Row.FCLiteral("LtlContabilizado").Text = "Si" Then - Dim Liga As String = String.Format("", e.Row.DBCampo("IdPoliza")) - e.Row.FCLiteral("LtlPoliza").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("Poliza")) - End If - - If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(2) AndAlso e.Row.DBCampo("CvePersonal").ToEntero > 0 Then - Dim Liga As String = String.Format("", e.Row.DBCampo("CvePersonal")) - e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) - End If - - If e.Row.DBCampo("TipoReferencia").ToEntero = 1 Then - e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Bancos/IE.aspx?CveIE={e.Row.DBCampo("CveReferencia").ToEntero}" - 'If e.Row.DBCampo("CveReferencia").ToEntero > 0 Then - ' e.Row.Cells(10).Text = "" - 'End If - ElseIf e.Row.DBCampo("TipoReferencia").ToEntero = 2 Then - Select Case Tipo - Case "CxCClientes" - e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveReferencia").ToEntero}" - Case "CxPProveedor" - e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Compras/Compras.aspx?CveCompra={e.Row.DBCampo("CveReferencia").ToEntero}" - End Select - End If - - 'If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(272) AndAlso e.Row.DBCampo("CveCompraAmortizacion").ToEntero > 0 Then - ' Dim Liga As String = String.Format("", e.Row.DBCampo("CveCompraAmortizacion")) - ' e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) - 'End If - - If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(275) AndAlso e.Row.DBCampo("CveVenta").ToEntero > 0 Then - e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveVenta").ToEntero}" - 'Dim Liga As String = String.Format("", e.Row.DBCampo("CveVenta")) - 'e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) - - End If - - End If - End Sub - - Protected Sub GvDatos_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GVAuxiliar.RowDeleting - - Dim ObjContPaq As ClsContPAQi = Nothing - Dim Conta As New ClsContabilidad() - Conta.IniciaTransacSQL() - - Dim ClavePrePoliza = GVAuxiliar.Rows(e.RowIndex).DataKey("CvePrePolizaOriginal").ToEntero - Dim IdPoliza = GVAuxiliar.Rows(e.RowIndex).DataKey("IdPoliza").ToEntero - - Dim TieneError = False - - If Not TieneError Then - If Not Conta.UpdatePrePolizasDetalleBloquear(ClavePrePoliza, False) Then - TieneError = True - End If - End If - - If Not Conta.RemovePrePolizas(ClavePrePoliza, UsuarioActual.CveEmpresa) Then - TieneError = True - End If - - If Conta.ValidacionPrePolizaCuadre(ClavePrePoliza, -1) Then - If Conta.ValorPolizaDescuadre > 0 Then - TieneError = True - End If - End If - - If Not TieneError Then - If IdPoliza > 0 Then - If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then - ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) - ObjContPaq.IniciaTransacSQL() - - If Not ObjContPaq.RemovePoliza(IdPoliza) Then - TieneError = True - End If - - End If - End If - End If - - If Not TieneError Then - Alert("Movimiento Eliminado", TipoMensaje.MsgInformacion, "window.opener.location.reload(); window.close();") - If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() - Conta.Commit() - Else - If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() - Conta.RollBack() - End If - If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() - Conta.Dispose() - CargaDatos() - End Sub - - Private Sub GVAuxiliar_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GVAuxiliar.RowUpdating - Dim CvePrePoliza As Integer - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - Dim CvePlantillaPoliza As Integer = 0 - Dim Importe As Decimal - Dim MsgError As String = "" - - If GVAuxiliar.Rows(e.RowIndex).DataKey("Cargo").ToDecimal > GVAuxiliar.Rows(e.RowIndex).DataKey("Abono").ToDecimal Then - Importe = GVAuxiliar.Rows(e.RowIndex).DataKey("Cargo").ToDecimal - Else - Importe = GVAuxiliar.Rows(e.RowIndex).DataKey("Abono").ToDecimal - End If - - If CveCliente > 0 Then CvePlantillaPoliza = 11 - If CveProveedor > 0 Then CvePlantillaPoliza = 2 - - CvePrePoliza = ObjConta.AddPrePolizas("Contabilidad/PopUpAuxiliar", CvePlantillaPoliza, Importe, Importe, 1, Now, "Cancelacion de Pago", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - If CvePlantillaPoliza = 2 Then - If Not ObjConta.CancelarPagoCompraConAnticipo(CvePrePoliza, CveCompra, GVAuxiliar.Rows(e.RowIndex).DataKey("CveReferencia").ToEntero) Then - MsgError = "Ocurrió un error al cancelar el pago de la compra" - End If - End If - - If CvePlantillaPoliza = 11 Then - If Not ObjConta.CancelarPagoVentaConAnticipo(CvePrePoliza, CveVenta, GVAuxiliar.Rows(e.RowIndex).DataKey("CveReferencia").ToEntero) Then - MsgError = "Ocurrió un error al cancelar el pago de la venta" - End If - End If - - If MsgError = "" Then - ObjConta.Commit() - Alert("El movimiento se canceló exitosamente.") - Else - ObjConta.RollBack() - Alert(MsgError, TipoMensaje.MsgError) - End If - - - ObjConta.Dispose() - End Sub - Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosExcel.Click - GenerarPDF("Excel") - End Sub - Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosPDF.Click - GenerarPDF() - End Sub - Private Sub GenerarPDF(Optional Formato As String = "PDF") - Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) - Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) - - If DTDatos IsNot Nothing And DTDatos.Rows.Count > 0 Then - - Dim params As New List(Of ReportParameter) - - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("Tipo", LtlTipo1.Text)) - params.Add(New ReportParameter("Folio", LtlFolio.Text)) - params.Add(New ReportParameter("Fecha", LtlFechaVenta.Text)) - params.Add(New ReportParameter("Importe", LtlImporte.Text)) - params.Add(New ReportParameter("Saldo", LtlSaldo.Text)) - - If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) - Else - params.Add(New ReportParameter("LogoPath", "")) - End If - - ImprimirPDF("Empresas\Grales\Formatos\RepAuxiliarContable.rdlc", DTDatos, params, "RepAuxiliarContable_" & LtlFolio.Text, Formato:=Formato) - - Else - Alert("No se encontró información suficiente.", TipoMensaje.MsgAdvertencia) - End If - + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + e.Row.BackColor = Drawing.Color.LightGray + e.Row.FCLiteral("LtlFechaMovto").Text = "Totales: " + e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(0).ColumnSpan = 2 + e.Row.Cells(1).Visible = False + e.Row.Cells(4).ColumnSpan = 3 + e.Row.Cells(5).Visible = False + e.Row.Cells(6).Visible = False + e.Row.Cells(7).Visible = False + e.Row.Cells(8).Visible = False + e.Row.Cells(12).Visible = False + ElseIf e.Row.RowIndex = 1 Then + e.Row.Cells(0).Width = Unit.Pixel(95) + e.Row.Cells(1).Width = Unit.Pixel(180) + e.Row.Cells(2).Width = Unit.Pixel(80) + e.Row.Cells(3).Width = Unit.Pixel(80) + e.Row.Cells(4).Width = Unit.Pixel(83) + e.Row.Cells(5).Width = Unit.Pixel(93) + e.Row.Cells(6).Width = Unit.Pixel(85) + e.Row.Cells(7).Width = Unit.Pixel(95) + e.Row.Cells(8).Width = Unit.Pixel(70) + End If + + e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left + + If e.Row.FCLiteral("LtlContabilizado").Text = "Si" Then + Dim Liga As String = String.Format("", e.Row.DBCampo("IdPoliza")) + e.Row.FCLiteral("LtlPoliza").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("Poliza")) + End If + + If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(2) AndAlso e.Row.DBCampo("CvePersonal").ToEntero > 0 Then + Dim Liga As String = String.Format("", e.Row.DBCampo("CvePersonal")) + e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) + End If + + If e.Row.DBCampo("TipoReferencia").ToEntero = 1 Then + e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Bancos/IE.aspx?CveIE={e.Row.DBCampo("CveReferencia").ToEntero}" + 'If e.Row.DBCampo("CveReferencia").ToEntero > 0 Then + ' e.Row.Cells(10).Text = "" + 'End If + ElseIf e.Row.DBCampo("TipoReferencia").ToEntero = 2 Then + Select Case Tipo + Case "CxCClientes" + e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveReferencia").ToEntero}" + Case "CxPProveedor" + e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Compras/Compras.aspx?CveCompra={e.Row.DBCampo("CveReferencia").ToEntero}" + End Select + End If + + 'If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(272) AndAlso e.Row.DBCampo("CveCompraAmortizacion").ToEntero > 0 Then + ' Dim Liga As String = String.Format("", e.Row.DBCampo("CveCompraAmortizacion")) + ' e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) + 'End If + + If e.Row.DBCampo("CveConceptoContable").ToEntero.Contiene(275) AndAlso e.Row.DBCampo("CveVenta").ToEntero > 0 Then + e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveVenta").ToEntero}" + 'Dim Liga As String = String.Format("", e.Row.DBCampo("CveVenta")) + 'e.Row.FCLiteral("LtlConcepto").Text = String.Format("{0}{1}", Liga, e.Row.DBCampo("ConceptoContable")) + + End If + + End If + End Sub + + Protected Sub GvDatos_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GVAuxiliar.RowDeleting + + Dim ObjContPaq As ClsContPAQi = Nothing + Dim Conta As New ClsContabilidad() + Conta.IniciaTransacSQL() + + Dim ClavePrePoliza = GVAuxiliar.Rows(e.RowIndex).DataKey("CvePrePolizaOriginal").ToEntero + Dim IdPoliza = GVAuxiliar.Rows(e.RowIndex).DataKey("IdPoliza").ToEntero + + Dim TieneError = False + + If Not TieneError Then + If Not Conta.UpdatePrePolizasDetalleBloquear(ClavePrePoliza, False) Then + TieneError = True + End If + End If + + If Not Conta.RemovePrePolizas(ClavePrePoliza, UsuarioActual.CveEmpresa) Then + TieneError = True + End If + + If Conta.ValidacionPrePolizaCuadre(ClavePrePoliza, -1) Then + If Conta.ValorPolizaDescuadre > 0 Then + TieneError = True + End If + End If + + If Not TieneError Then + If IdPoliza > 0 Then + If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then + ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) + ObjContPaq.IniciaTransacSQL() + + If Not ObjContPaq.RemovePoliza(IdPoliza) Then + TieneError = True + End If + + End If + End If + End If + + If Not TieneError Then + Alert("Movimiento Eliminado", TipoMensaje.MsgInformacion, "window.opener.location.reload(); window.close();") + If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() + Conta.Commit() + Else + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + Conta.RollBack() + End If + If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() + Conta.Dispose() + CargaDatos() + End Sub + + Private Sub GVAuxiliar_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GVAuxiliar.RowUpdating + Dim CvePrePoliza As Integer + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + Dim CvePlantillaPoliza As Integer = 0 + Dim Importe As Decimal + Dim MsgError As String = "" + + If GVAuxiliar.Rows(e.RowIndex).DataKey("Cargo").ToDecimal > GVAuxiliar.Rows(e.RowIndex).DataKey("Abono").ToDecimal Then + Importe = GVAuxiliar.Rows(e.RowIndex).DataKey("Cargo").ToDecimal + Else + Importe = GVAuxiliar.Rows(e.RowIndex).DataKey("Abono").ToDecimal + End If + + If CveCliente > 0 Then CvePlantillaPoliza = 11 + If CveProveedor > 0 Then CvePlantillaPoliza = 2 + + CvePrePoliza = ObjConta.AddPrePolizas("Contabilidad/PopUpAuxiliar", CvePlantillaPoliza, Importe, Importe, 1, Now, "Cancelacion de Pago", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If CvePlantillaPoliza = 2 Then + If Not ObjConta.CancelarPagoCompraConAnticipo(CvePrePoliza, CveCompra, GVAuxiliar.Rows(e.RowIndex).DataKey("CveReferencia").ToEntero) Then + MsgError = "Ocurrió un error al cancelar el pago de la compra" + End If + End If + + If CvePlantillaPoliza = 11 Then + If Not ObjConta.CancelarPagoVentaConAnticipo(CvePrePoliza, CveVenta, GVAuxiliar.Rows(e.RowIndex).DataKey("CveReferencia").ToEntero) Then + MsgError = "Ocurrió un error al cancelar el pago de la venta" + End If + End If + + If MsgError = "" Then + ObjConta.Commit() + Alert("El movimiento se canceló exitosamente.") + Else + ObjConta.RollBack() + Alert(MsgError, TipoMensaje.MsgError) + End If + + + ObjConta.Dispose() + End Sub + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosExcel.Click + GenerarPDF("Excel") + End Sub + Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosPDF.Click + GenerarPDF() + End Sub + Private Sub GenerarPDF(Optional Formato As String = "PDF") + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + + If DTDatos IsNot Nothing And DTDatos.Rows.Count > 0 Then + + Dim params As New List(Of ReportParameter) + + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("Tipo", LtlTipo1.Text)) + params.Add(New ReportParameter("Folio", LtlFolio.Text)) + params.Add(New ReportParameter("Fecha", LtlFechaVenta.Text)) + params.Add(New ReportParameter("Importe", LtlImporte.Text)) + params.Add(New ReportParameter("Saldo", LtlSaldo.Text)) + + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + + ImprimirPDF("Empresas\Grales\Formatos\RepAuxiliarContable.rdlc", DTDatos, params, "RepAuxiliarContable_" & LtlFolio.Text, Formato:=Formato) + + Else + Alert("No se encontró información suficiente.", TipoMensaje.MsgAdvertencia) + End If + End Sub Property CvePrePolizaNegativa As Integer @@ -390,23 +390,37 @@ Partial Class PopUpAuxiliar Dim TieneError As Boolean = False ObjContabilidad.IniciaTransacSQL() - If ObjContabilidad.AddPrePolizasNegativa(CvePrePoliza, UsuarioActual.CveUsuario, TxtConceptoCancelacion.Text, UsuarioActual.CveEmpresa, TxtFechaCancelacion.Text.ToDate) Then - Alert("Se agrego polzia negativa correctamente.") - Else + Dim CvePrePolizaNueva As Integer = ObjContabilidad.AddPrePolizasNegativa(CvePrePoliza, UsuarioActual.CveUsuario, TxtConceptoCancelacion.Text, UsuarioActual.CveEmpresa, TxtFechaCancelacion.Text.ToDate) + + If Not CvePrePolizaNueva > 0 Then + + TieneError = True End If - If TieneError Then - ObjContabilidad.RollBack() - Else + If Not TieneError Then + ObjContabilidad.Commit() + Dim Str As New StringBuilder + Str.Append("Se agrego la póliza de cancelación correctamente.
") RegistraScript(" $('#DivCancelar').modal('hide'); ") - CargaDatos() + If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + If ObjContabilidad.ContabilizarPrePoliza(CvePrePolizaNueva, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + Str.AppendFormat("Ver Poliza", ObjContabilidad.ContaIdPoliza) + + End If + End If + Alert(Str.ToString) + Else + ObjContabilidad.RollBack() + End If - ObjContabilidad.Dispose() + ObjContabilidad.Dispose() + CargaDatos() + End Sub @@ -424,4 +438,4 @@ Partial Class PopUpAuxiliar -End Class +End Class diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 83040ea12..f4a3c6cc4 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1419,7 +1419,7 @@ T.C.: - + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index f4a9a4008..6566789d8 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -20758,13 +20758,19 @@ Partial Class Ventas CalculaTotalesVenta(True) + 'condicióon, en la que se verifica que el importe total de aplicación de la nota de crédito sea igual al del total de la nota de crédito, ej. saldo de la factura 1000.01 y la nota de crédito se generó po 1000.00 If Not AplicaNCMasiva Then Dim TT As Decimal = TxtNCImporte.Text.ToDecimal If TT > TxtTotal.Text.ToDecimal Then TT = TxtTotal.Text.ToDecimal CargaNCDT(CveVenta, TT) - End If + End If + 'verifica el tipo de cambio que se actualice + If DdlMoneda.SelectedValue <> "1" Then + TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString + End If + LblTCValuacion.Visible = False UpPS.Update() LBNotaCredito.Visible = False From c7254767152a8be12587a79da5b8d334f293c350 Mon Sep 17 00:00:00 2001 From: Raul Pimienta Date: Sat, 24 Aug 2019 13:14:31 -0700 Subject: [PATCH 03/13] Registro de prepolizas detalle en 0 cuando se toca almacen en Compras --- Compras/Compras.aspx.vb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 69fe82bf1..268ef5444 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -4225,6 +4225,12 @@ Partial Class Compras_Compras Else CveConceptoContableAlmacen = 225 End If + + 'Condiciones para los casos de facturas que son en 0 pero que se utiliza el almacen + ElseIf OCVinculada AndAlso Not (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero + ElseIf (CveImportacion > 0 Or CveFlete > 0) AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then + CveConceptoContableAlmacen = CveConceptoContableAlmacen End If End If @@ -6228,15 +6234,13 @@ Partial Class Compras_Compras If ContienePSNeteoBonif Then importeMovimiento = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 ").ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador - If importeMovimiento <> 0 Then - Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then - ErrorPrepoliza = True - End If - Else + Dim IdCtaContableDescCompra As Integer = UsuarioActual.Empresa.Funcionalidad(405).ToEntero + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -importeMovimiento, Referencia, 259, Concepto, FechaMovimiento, IdCtaContableDescCompra, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=-importeMN, ImporteME:=If(tipoCambioActual = 1, 0, -importeMovimiento), CveCuenta:=CveCuenta, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then ErrorPrepoliza = True End If + Else + ErrorPrepoliza = True End If End If From c37e5cb0d965c5e729cc5a8a6c3d4de8ffff96f4 Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Mon, 26 Aug 2019 09:49:58 -0700 Subject: [PATCH 04/13] Filtro de "Corte A" en Formatos de RepCxC y Detalle --- CxC/RepCxC.aspx.vb | 4 ++-- CxC/RepCxCDetalle.aspx.vb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CxC/RepCxC.aspx.vb b/CxC/RepCxC.aspx.vb index 73cac2e84..34a9b77b2 100644 --- a/CxC/RepCxC.aspx.vb +++ b/CxC/RepCxC.aspx.vb @@ -694,7 +694,7 @@ Partial Class RepCxC Dim Registro = If(DdlUsuario.SelectedValue = "-1", "", $" Registró: {DdlUsuario.SelectedItem.Text}") Dim Responsable = If(DdlResponsable.SelectedValue = "-1", "", $" Responsable: {DdlResponsable.SelectedItem.Text}") Dim EstatusCob = If(DdlCobranzaEstatus.SelectedValue = "-1", "", $" Estatus Cobranza: {DdlCobranzaEstatus.SelectedItem.Text}") - 'Dim CorteA As String = If(txtCorteA.Text = "31/12/2018", "", $" Corte A: {txtCorteA.Text}") + Dim CorteA As String = If(txtCorteA.Text = "31/12/2019", "", $" Corte A: {txtCorteA.Text}") Dim EstatusCli = If(DdlEstatusCliente.SelectedValue = "-1", "", $" Clientes: {DdlEstatusCliente.SelectedItem.Text}") Dim ClasificacionCli = If(DdlClienteClasificacion.SelectedValue = "-1", "", $" Clasificación Cliente: {DdlClienteClasificacion.SelectedItem.Text}") @@ -725,7 +725,7 @@ Partial Class RepCxC params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) params.Add(New ReportParameter("Grupo", DdlGrupo.SelectedItem.Text)) - params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{EstatusCli}{ClasificacionCli}")) + params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{EstatusCli}{ClasificacionCli}{CorteA}")) params.Add(New ReportParameter("TituloReporte", TituloReporte)) params.Add(New ReportParameter("CantColumnas", CantidadColumnas.ToString)) diff --git a/CxC/RepCxCDetalle.aspx.vb b/CxC/RepCxCDetalle.aspx.vb index 86922f5fa..d32b14256 100644 --- a/CxC/RepCxCDetalle.aspx.vb +++ b/CxC/RepCxCDetalle.aspx.vb @@ -833,7 +833,7 @@ Partial Class RepCxCDetalle Dim Registro = If(DdlUsuario.SelectedValue = "-1", "", $" Registró: {DdlUsuario.SelectedItem.Text}") Dim Responsable = If(DdlResponsable.SelectedValue = "-1", "", $" Responsable: {DdlResponsable.SelectedItem.Text}") Dim EstatusCob = If(DdlCobranzaEstatusFiltro.SelectedValue = "-1", "", $" Estatus Cobranza: {DdlCobranzaEstatusFiltro.SelectedItem.Text}") - 'Dim CorteA As String = If(txtCorteA.Text = "31/12/2018", "", $" Corte A: {txtCorteA.Text}") + Dim CorteA As String = If(txtCorteA.Text = "31/12/2019", "", $" Corte A: {txtCorteA.Text}") Dim ClasificacionCli = If(DdlClienteClasificacion.SelectedValue = "-1", "", $" Clasificación Cliente: {DdlClienteClasificacion.SelectedItem.Text}") Dim TituloReporte As String = "REPORTE DE CUENTAS POR COBRAR DEL CLIENTE CON DETALLE" @@ -850,7 +850,7 @@ Partial Class RepCxCDetalle params.Add(New ReportParameter("FechaFin", FechaF)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) - params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{ClasificacionCli}")) + params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{ClasificacionCli}{CorteA}")) params.Add(New ReportParameter("TituloReporte", TituloReporte)) If Imagen.Exists Then From f89a7b7c9da3ab1536acc0f2192e18a444f4d2cb Mon Sep 17 00:00:00 2001 From: Raul Pimienta Date: Mon, 26 Aug 2019 11:05:43 -0700 Subject: [PATCH 05/13] Cambios en el reporte de compras - almacen AutoConta solo con funcionalidad 200, se quito el UsaContabilidad --- App_Code/Modelos.vb | 2 +- Bancos/Devoluciones.aspx.cs | 2 +- Bancos/IE.aspx.vb | 4 ++-- Bancos/PagoAcreedor.aspx.cs | 4 ++-- Bancos/PagoDeudor.aspx.cs | 4 ++-- Bancos/PopIECompras.aspx.vb | 2 +- Bancos/PopIEVentas.aspx.vb | 2 +- Bancos/PrestamoPersonal.aspx.cs | 4 ++-- Bancos/ProveedoresAbonar.aspx.vb | 2 +- Bancos/Transferencias.aspx.vb | 2 +- Compras/Compras.aspx.vb | 4 ++-- Compras/ReembolsosComprobaciones.aspx.vb | 2 +- Compras/RepNotasCredito.aspx.vb | 2 +- Compras/RepRembolsoComprobaciones.aspx.vb | 2 +- Inventarios/RepAlmacenCompras.aspx | 7 +++++-- Inventarios/RepAlmacenCompras.aspx.vb | 7 +++++-- Ventas/ClientesAbonar.aspx.vb | 2 +- Ventas/Ventas.aspx.vb | 2 +- 18 files changed, 31 insertions(+), 25 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 58a1b50f4..2f8659c84 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -2746,7 +2746,7 @@ Namespace Modelos End If 'ContPAQ El movimiento 1 es el de Venta - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And UsuarioActual.Empresa.UsaContabilidad = True And Not ErrorPrepoliza Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso Not ErrorPrepoliza Then If idCuentaContabilizacion > 0 Then If ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=objContPaqi) Then Else diff --git a/Bancos/Devoluciones.aspx.cs b/Bancos/Devoluciones.aspx.cs index 6d93ef6e8..451c90e33 100644 --- a/Bancos/Devoluciones.aspx.cs +++ b/Bancos/Devoluciones.aspx.cs @@ -467,7 +467,7 @@ public partial class Bancos_Devoluciones : ClsPaginas } //CONTABILIZA - if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("")) { if (IDCtaContableDevolucion > 0 && IDCtaContableBancos > 0) { diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index fe5ce8ef2..8f1ef4435 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -3049,7 +3049,7 @@ Partial Class Bancos_IE 'El movimiento 1 es el de Venta 'Conta SIG - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidadSIG Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If CveCuentaBeneficiario > 0 And CveCuentaConta > 0 Then If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IDPoliza = ObjMov.ContaIdPoliza @@ -3067,7 +3067,7 @@ Partial Class Bancos_IE End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If IDCtaBeneficiario > 0 And IDCtaContable > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IDPoliza = ObjMov.ContaIdPoliza diff --git a/Bancos/PagoAcreedor.aspx.cs b/Bancos/PagoAcreedor.aspx.cs index ee352f560..874e91841 100644 --- a/Bancos/PagoAcreedor.aspx.cs +++ b/Bancos/PagoAcreedor.aspx.cs @@ -527,7 +527,7 @@ public partial class Bancos_PagoAcreedor : ClsPaginas } //CONTABILIZA - if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("")) { if (IDCtaContableAcreedor > 0 && IDCtaContableBancos > 0) { @@ -801,7 +801,7 @@ public partial class Bancos_PagoAcreedor : ClsPaginas } //CONTABILIZA - if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") ) { if (IDCtaContableAcreedor > 0 && IDCtaContableBancos > 0) { diff --git a/Bancos/PagoDeudor.aspx.cs b/Bancos/PagoDeudor.aspx.cs index 73435bc66..661fd2abd 100644 --- a/Bancos/PagoDeudor.aspx.cs +++ b/Bancos/PagoDeudor.aspx.cs @@ -447,7 +447,7 @@ public partial class Bancos_PagoDeudor : ClsPaginas bool AutoConta = UsuarioActual.Empresa.Funcionalidad(200).Equals("1"); if (UsuarioActual.CveEmpresa == 119) AutoConta = false; - if (AutoConta && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (AutoConta && MsgError.Equals("")) { //JJMQ:20190103: Cambio la siguiente linea porque esta validando siempre una complementaria aunque el movto sea dlls //if (IDCtaContableDeudorPrestamo > 0 && IDCtaContableBancosPrestamo > 0 && IDCtaContableBancosComplementariaPrestamo > 0 && IDCtaContableDeudorCompPrestamo > 0) @@ -838,7 +838,7 @@ public partial class Bancos_PagoDeudor : ClsPaginas bool AutoConta = UsuarioActual.Empresa.Funcionalidad(200).Equals("1"); if (UsuarioActual.CveEmpresa == 119) AutoConta = false; - if (AutoConta && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (AutoConta && MsgError.Equals("")) { if (IDCtaContableDeudor > 0 && IDCtaContableBancos > 0) { diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 683e35fd7..77d0c3498 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -3090,7 +3090,7 @@ Partial Class Bancos_PopIECompras End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If idCuentaContabilizacion > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IdPoliza = ObjMov.ContaIdPoliza diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 9715941cf..c19aea954 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -3390,7 +3390,7 @@ Partial Class Bancos_PopIEVentas End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then If idCuentaContabilizacion > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then diff --git a/Bancos/PrestamoPersonal.aspx.cs b/Bancos/PrestamoPersonal.aspx.cs index 75491b8fa..60cd167ef 100644 --- a/Bancos/PrestamoPersonal.aspx.cs +++ b/Bancos/PrestamoPersonal.aspx.cs @@ -366,7 +366,7 @@ public partial class Bancos_PrestamoPersonal : ClsPaginas } //CONTABILIZA - if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") ) { if (IDCtaContablePrestamo > 0 && IDCtaContableBancos > 0) { @@ -626,7 +626,7 @@ public partial class Bancos_PrestamoPersonal : ClsPaginas } //CONTABILIZA - if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") && UsuarioActual.Empresa.UsaContabilidad) + if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals("") ) { if (IDCtaContablePrestamo > 0 && IDCtaContableBancosPrestamo > 0) { diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 37a12c668..1f8d4b125 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -1823,7 +1823,7 @@ Partial Class Bancos_ProveedoresAbonar End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If idCuentaContabilizacion > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjConta) Then ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) diff --git a/Bancos/Transferencias.aspx.vb b/Bancos/Transferencias.aspx.vb index bbb322d80..7ccdbb882 100644 --- a/Bancos/Transferencias.aspx.vb +++ b/Bancos/Transferencias.aspx.vb @@ -412,7 +412,7 @@ Partial Class Bancos_Transferencias End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then If (IdCtaContableOrigen > 0 AndAlso IdCtaContableDestino > 0) OrElse (IdCtaContableDestino > 0 AndAlso Opcion = 1) Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, Fecha:=TxtFechaDocumento.Text) Then diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 268ef5444..ee9dc3df8 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -7009,7 +7009,7 @@ Partial Class Compras_Compras End If 'Conta ContPAQ - If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If ObjContaAC IsNot Nothing AndAlso Not ErrorPrepoliza AndAlso Not ErrorPrepolizaDescuadre AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then If idCuentaContabilizacion > 0 Then If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then ' Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion) @@ -8575,7 +8575,7 @@ Partial Class Compras_Compras End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And ErrorMovtosCxP = 0 And UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso ErrorMovtosCxP = 0 Then If idCuentaContabilizacion > 0 Then If ObjConta.ContabilizarPrePoliza(CvePrePolizaNueva, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then alertaContabilizacion.AppendFormat("{1}<\a>
", ObjConta.ContaIdPoliza, ObjConta.ContaFolio) diff --git a/Compras/ReembolsosComprobaciones.aspx.vb b/Compras/ReembolsosComprobaciones.aspx.vb index a419f00fb..5f9f37585 100644 --- a/Compras/ReembolsosComprobaciones.aspx.vb +++ b/Compras/ReembolsosComprobaciones.aspx.vb @@ -1295,7 +1295,7 @@ Partial Class Compras_ReembolsosComprobaciones End If 'Conta ContPAQ AUTOMATICA - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError.Trim = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError.Trim = "" Then If CvePrePolizaIERegistrado > 0 Then If IdCtaPersonal > 0 Or DdlCajaChica.Visible Then If IdCtaProveedor > 0 Then diff --git a/Compras/RepNotasCredito.aspx.vb b/Compras/RepNotasCredito.aspx.vb index 5605a94e5..c04fd2c3e 100644 --- a/Compras/RepNotasCredito.aspx.vb +++ b/Compras/RepNotasCredito.aspx.vb @@ -200,7 +200,7 @@ Partial Class Compras_RepNotasCredito End If End If - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then If MensajeAlert.ToString = "" Then MensajeAlert.AppendFormat("Los siguientes movimientos fueron saldados correctamente:
") diff --git a/Compras/RepRembolsoComprobaciones.aspx.vb b/Compras/RepRembolsoComprobaciones.aspx.vb index 86983e786..50fd8aed0 100644 --- a/Compras/RepRembolsoComprobaciones.aspx.vb +++ b/Compras/RepRembolsoComprobaciones.aspx.vb @@ -198,7 +198,7 @@ Partial Class Compras_RepRembolsoComprobaciones Msg.AppendFormat("Se unificaron todas las compras con éxito") End If - If UsuarioActual.Empresa.UsaContabilidad AndAlso Not TieneError Then + If UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" AndAlso Not TieneError Then If ObjAC Is Nothing Then TieneError = True End If diff --git a/Inventarios/RepAlmacenCompras.aspx b/Inventarios/RepAlmacenCompras.aspx index 9c4f2ba8b..cf906aac8 100644 --- a/Inventarios/RepAlmacenCompras.aspx +++ b/Inventarios/RepAlmacenCompras.aspx @@ -95,15 +95,18 @@ - + - + + + + diff --git a/Inventarios/RepAlmacenCompras.aspx.vb b/Inventarios/RepAlmacenCompras.aspx.vb index c52884fa1..8cf23b1a7 100644 --- a/Inventarios/RepAlmacenCompras.aspx.vb +++ b/Inventarios/RepAlmacenCompras.aspx.vb @@ -43,12 +43,15 @@ Partial Class Inventarios_RepAlmacenCompras #Region " CARGA VALORES INICIALES " Private Sub CargaPermisos() Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201) - GvDatos.Columns(6).Visible = TienePermisoImportes + GvDatos.Columns(3).Visible = TienePermisoImportes GvDatos.Columns(7).Visible = TienePermisoImportes GvDatos.Columns(8).Visible = TienePermisoImportes + GvDatos.Columns(9).Visible = TienePermisoImportes + GvDatos.Columns(10).Visible = TienePermisoImportes + GvDatos.Columns(11).Visible = TienePermisoImportes If TienePermisoImportes Then - CabeceraAlmacen.Width = "35%" + CabeceraAlmacen.Width = "36%" CabeceraCompra.Width = "65%" Else CabeceraAlmacen.Width = "45%" diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 01435d4c2..79ce2c26b 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -1538,7 +1538,7 @@ Partial Class Ventas_ClientesAbonar End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If idCuentaContabilizacion > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IDPoliza = ObjMov.ContaIdPoliza diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 6566789d8..eb95bd40a 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6572,7 +6572,7 @@ Partial Class Ventas AutoConta = False End If - If AutoConta And UsuarioActual.Empresa.UsaContabilidad = True Then + If AutoConta Then If idCuentaContabilizacion > 0 Then If ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then From 5e3b8c184347d9a89258d11e13443c579a4667e5 Mon Sep 17 00:00:00 2001 From: Raul Pimienta Date: Mon, 26 Aug 2019 11:09:31 -0700 Subject: [PATCH 06/13] AutoContabilidad en IE --- Bancos/IE.aspx.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 69d028c4a..108ab78d3 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -3064,7 +3064,7 @@ Partial Class Bancos_IE 'El movimiento 1 es el de Venta 'Conta SIG - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidadSIG Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then If CveCuentaBeneficiario > 0 And CveCuentaConta > 0 Then If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IDPoliza = ObjMov.ContaIdPoliza @@ -3082,7 +3082,7 @@ Partial Class Bancos_IE End If 'Conta ContPAQ - If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" And UsuarioActual.Empresa.UsaContabilidad Then + If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then If IDCtaBeneficiario > 0 And IDCtaContable > 0 Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then IDPoliza = ObjMov.ContaIdPoliza From f6dc07e7f17df2fdcec2069b1b7dadef25aa62c4 Mon Sep 17 00:00:00 2001 From: janeth arvizu Date: Mon, 26 Aug 2019 11:22:11 -0700 Subject: [PATCH 07/13] =?UTF-8?q?Correcci=C3=B3n=20en=20datos=20de=20Pagar?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Empresas/144/Formatos/Factura.rdlc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Empresas/144/Formatos/Factura.rdlc b/Empresas/144/Formatos/Factura.rdlc index a8f6d9968..6f7296e9b 100644 --- a/Empresas/144/Formatos/Factura.rdlc +++ b/Empresas/144/Formatos/Factura.rdlc @@ -1209,7 +1209,7 @@ - ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a Soluciones en Telemedición JAR SA de CV o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a + ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a PAOLA CASTILLO VALENZUELA o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a @@ -468,7 +468,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -490,7 +490,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") dd/MM/yyyy - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -504,7 +504,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -525,7 +525,7 @@ @@ -537,7 +537,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -555,11 +555,11 @@ - =Fields!Nombre.Value + =IIf(Fields!Nombre.Value = "", IIf(Fields!Gpo.Value = "", Fields!Moneda.Value, Fields!Gpo.Value), Fields!Nombre.Value) @@ -571,13 +571,14 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt 2pt + true @@ -592,7 +593,7 @@ @@ -606,7 +607,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -629,7 +630,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") f2 - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -641,7 +642,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -664,7 +665,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") #,0.00;- #,0.00;'-' - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -678,7 +679,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -701,7 +702,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") #,0.00;- #,0.00;'-' - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -715,7 +716,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -737,7 +738,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") #,0.00;-#,0.00;'-' - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -751,7 +752,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -773,7 +774,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") #,0.00;- #,0.00;'-' - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -787,7 +788,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -810,7 +811,7 @@ 8pt =iif(Fields!CveVenta.Value = "", "Bold", "Normal") #,0.00;-#,0.00;'-' - =iif(Fields!CveVenta.Value= "", "White", "Black") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","White","#67809F"), "Black") @@ -824,7 +825,7 @@ - =iif(Fields!CveVenta.Value = "", "#67809F", "Transparent") + =iif(Fields!CveVenta.Value = "",IIf(Fields!Gpo.Value = "","#67809F","#cccccc"), "Transparent") 2pt 2pt 2pt @@ -896,14 +897,16 @@ - Textbox1 0.18521cm - 2.8349cm + 3.37444cm 0.6cm - 12.60299cm + 21.20747cm @@ -949,9 +952,9 @@ Textbox2 1.10271cm - 8.17404cm + 9.22743cm 0.52945cm - 10.36447cm + 10.12635cm 1 - 0.58209cm + 1.04773cm true true @@ -1140,9 +1143,9 @@ Textbox10 0.0829cm - 9.84544cm + 10.83183cm 0.38981cm - 2.92333cm + 2.91804cm 3 + + + + + + Textbox11 + 0.0829cm + 13.56466cm + 0.38981cm + 6.47703cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + IMPRESO EN SIG, Rep. Productos Servicios @@ -1272,6 +1309,14 @@ Nombre System.String + + Gpo + System.String + + + Moneda + System.String + Codigo System.String @@ -1331,6 +1376,7 @@ ReportParameter1 + es-MX Cm 40c94aad-a12a-44fb-ab0d-ea36a9656792 \ No newline at end of file diff --git a/Ventas/RepProductosServiciosDetalle.aspx.vb b/Ventas/RepProductosServiciosDetalle.aspx.vb index c6af54b8b..47ff0cc89 100644 --- a/Ventas/RepProductosServiciosDetalle.aspx.vb +++ b/Ventas/RepProductosServiciosDetalle.aspx.vb @@ -661,6 +661,7 @@ Partial Class Ventas_RepProductosServiciosDetalle params.Add(New ReportParameter("LogoPath", "")) End If + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToString("dd/MM/yyyy"))) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) ImprimirPDF("Empresas/Grales/Formatos/RepProductosServiciosDetalle.rdlc", TmpDT, params, "ReportePS") From 2035c0a18e9e2c752ff1ade03c01be5335d5eae0 Mon Sep 17 00:00:00 2001 From: Raul Pimienta Date: Tue, 27 Aug 2019 11:33:57 -0700 Subject: [PATCH 13/13] Soporte Compras Nota de credito para remision --- Compras/Compras.aspx.vb | 21 ++++++++------ Planeacion/CatFolios.aspx.vb | 1 + Ventas/PopUpBuscarFolio.aspx | 1 + Ventas/Ventas.aspx.vb | 53 ++++++++++++++++++++++++++++++------ 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index ee9dc3df8..78272dc76 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -9741,18 +9741,21 @@ Partial Class Compras_Compras ReceptorRFC = ValorXML(node, "RFC") End If - node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - If ValorXML(node, "TipoRelacion").ToString.Contiene("04", "07") Then - Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) - For Each documento As XmlNode In nodeDocumentosRelacionados - If documento.Attributes("UUID").Value <> "" Then - ListaDocumentos.Add(documento.Attributes("UUID").Value) - End If - Next + If UsuarioActual.CveEmpresa.Contiene(119) Then + node = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + If ValorXML(node, "TipoRelacion").ToString.Contiene("04", "07") Then + Dim nodeDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionado", Prefijo), namespaces) + For Each documento As XmlNode In nodeDocumentosRelacionados + If documento.Attributes("UUID").Value <> "" Then + ListaDocumentos.Add(documento.Attributes("UUID").Value) + End If + Next + End If End If End If + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Comprobante/{0}:Impuestos/{0}:Retenciones/{0}:Retencion", Prefijo), namespaces) diff --git a/Planeacion/CatFolios.aspx.vb b/Planeacion/CatFolios.aspx.vb index 70eaeb189..1c8f92399 100644 --- a/Planeacion/CatFolios.aspx.vb +++ b/Planeacion/CatFolios.aspx.vb @@ -70,6 +70,7 @@ Partial Class CatFolios DdlTipoDocto.Items.Insert(31, New ListItem("Proveedor", "Pro")) DdlTipoDocto.Items.Insert(32, New ListItem("Acreedor", "Acr")) DdlTipoDocto.Items.Insert(33, New ListItem("Productos/Servicios", "PS")) + DdlTipoDocto.Items.Insert(34, New ListItem("NC de Remisión", "RNC")) ElseIf UsuarioActual.Empresa.CvePlataforma = 2 Then DdlTipoDocto.Items.Insert(1, New ListItem("Facturas", "Ing")) DdlTipoDocto.Items.Insert(2, New ListItem("Notas de Crédito", "Egs")) diff --git a/Ventas/PopUpBuscarFolio.aspx b/Ventas/PopUpBuscarFolio.aspx index 79cf3b927..e05a1490b 100644 --- a/Ventas/PopUpBuscarFolio.aspx +++ b/Ventas/PopUpBuscarFolio.aspx @@ -46,6 +46,7 @@ + Estatus Factura: diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index eb95bd40a..a20b8a60a 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1727,6 +1727,10 @@ Partial Class Ventas DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("Pedido", "Pd2")) + If UsuarioActual.Empresa.Funcionalidad(344).ToString = "1" Then + DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("NC de Remisión", "RNC")) + End If + If UsuarioActual.Empresa.Funcionalidad(528) = "1" Then 'FUNCIONALIDAD. DE REGISTRO DE CUENTA PREDIAL. GvPS.Columns(ColumnaPredial).Visible = True thPredial1.Visible = True @@ -6568,7 +6572,7 @@ Partial Class Ventas 'ContPAQ El movimiento 1 es el de Venta Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "Cot", "Ped", "Pd2", "PA", "NC") Then + If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "NC") Then AutoConta = False End If @@ -6623,7 +6627,7 @@ Partial Class Ventas Dim EstatusSMS = 0 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO - If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "Cot", "Ped", "DPe", "PA", "Pd2")) Then + If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then Dim DebeTimbrar As Boolean = True If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then @@ -9104,7 +9108,7 @@ Partial Class Ventas CvePlantilaPoliza = 4 ElseIf ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then CvePlantilaPoliza = 7 - ElseIf ObjFactura.TipoDocto = "Rem" Then + ElseIf ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then CvePlantilaPoliza = 4 End If @@ -9173,7 +9177,7 @@ Partial Class Ventas Select Case ConceptoContable Case 1 'Cliente - If Not ObjFactura.TipoDocto.Contiene("Egs", "Rem") Then + If Not ObjFactura.TipoDocto.Contiene("Egs", "Rem", "RNC") Then importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador FechaMovimiento = ObjFactura.FechaPago @@ -9247,6 +9251,37 @@ Partial Class Ventas ViewState("SeGuardoPrePoliza") = True End If + Case 277 'Remisión del cliente + + If ObjFactura.TipoDocto = "RNC" Then + importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador + importeMX = importeMovimiento * tipoCambio * Multiplicador + FechaMovimiento = ObjFactura.FechaPago + CveSubProyectoContabilizar = CveSubProyectoVenta + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + If tipoCambio = 1 Then + IdCtaContable = ObjFactura.Cliente.IdCtaContClientes + CveCuenta = ObjFactura.Cliente.CveCuentaClientes + Else + IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera + CveCuenta = ObjFactura.Cliente.CveCuentaMonedaExtranjera + End If + IdCtaContableCliente = IdCtaContable + CveCuentaCliente = CveCuenta + + If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + End If + Else + ErrorPrepoliza = True + End If + + importeMovimiento = 0 + ViewState("SeGuardoPrePoliza") = True + End If + Case 12 'Nota de Credito If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then importeMovimiento = ObjFactura.Total * ValorMultiplicador @@ -9712,7 +9747,7 @@ Partial Class Ventas importeMovimiento = 0 Case 4 'Venta Clasificacion - If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev") Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC", "Ant", "Egs", "Dev") Then Dim ConceptoContableAplicar = 4 Dim CveVentaAplicar = ObjFactura.CveVenta @@ -9890,7 +9925,7 @@ Partial Class Ventas importeMovimiento = 0 Case 103 'Descuento - If Not ObjFactura.TipoDocto.Contiene("Rem") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "-1" Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "-1" Then importeMovimiento = ObjFactura.Descuento * ValorMultiplicador importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador @@ -9937,7 +9972,7 @@ Partial Class Ventas End If Case 8 'Ret IVA por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem") Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then importeMovimiento = ObjFactura.RetIVA * ValorMultiplicador importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador FechaMovimiento = ObjFactura.FechaPago @@ -9968,7 +10003,7 @@ Partial Class Ventas End If Case 9 'Ret ISR por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem") Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then importeMovimiento = ObjFactura.RetISR * ValorMultiplicador importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador FechaMovimiento = ObjFactura.FechaPago @@ -9998,7 +10033,7 @@ Partial Class Ventas End If End If Case 13 'Iva por Trasladar - If Not ObjFactura.TipoDocto.Contiene("Rem") Then + If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then importeMovimiento = ObjFactura.IVA * ValorMultiplicador importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2) FechaMovimiento = ObjFactura.FechaPago