From f7df6c7d0ce20b09e52b93fd88222d68852b3cdd Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 25 May 2022 20:46:04 -0700 Subject: [PATCH] =?UTF-8?q?--=20actualizaci=C3=B3n=20e=20reteciones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsCompras.vb | 43 +++++----- Compras/Compras.aspx.vb | 177 ++++------------------------------------ 2 files changed, 39 insertions(+), 181 deletions(-) diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb index 7a782d020..5750cf281 100644 --- a/App_Code/ClsCompras.vb +++ b/App_Code/ClsCompras.vb @@ -3302,30 +3302,31 @@ Public Class ClsCompras - Public Function GetComprasPrepolizasRetIvaRetISRActualiza(CveCompra As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer) As Boolean + 'Public Function GetComprasPrepolizasRetIvaRetISRActualiza(CveCompra As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer) As Boolean + ' Dim Retorno As Boolean = False + ' DataAdapter("PA_Comp_ComprasPrepolizasRetIvaRetISRActualizaGet") + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + ' .Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto + ' .Add("@CveRetISRConcepto", SqlDbType.Int).Value = CveRetISRConcepto + ' End With + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Ocurrió un error al Obtener los datos de retención de IVA y retención ISR.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + ' Return Retorno + 'End Function + + + Public Function UpdateComprasRetencionesUpdate(CveConceptoRetIVA As Integer, CveConceptoRetISR As Integer, CveCompra As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Comp_ComprasPrepolizasRetIvaRetISRActualizaGet") + DataAdapter("PA_Comp_ComprasRetencionesUpdate") With SqlAdapter.SelectCommand.Parameters + .Add("@CveConceptoRetIVA", SqlDbType.Int).Value = CveConceptoRetIVA + .Add("@CveConceptoRetISR", SqlDbType.Int).Value = CveConceptoRetISR .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@CveRetIVAConcepto", SqlDbType.Int).Value = CveRetIVAConcepto - .Add("@CveRetISRConcepto", SqlDbType.Int).Value = CveRetISRConcepto - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al Obtener los datos de retención de IVA y retención ISR.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - - Public Function UpdateComprasPrepolizasRetIvaRetISRActualiza(CvePrePolizaDetalle As Integer, CveConceptoContable As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Comp_ComprasPrepolizasRetIvaRetISRActualizaUpdate") - With SqlAdapter.SelectCommand.Parameters - .Add("@CvePrePolizaDetalle", SqlDbType.Int).Value = CvePrePolizaDetalle - .Add("@CveConceptoContable", SqlDbType.Int).Value = CveConceptoContable End With Try SqlAdapter.Fill(Data) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 2819d7784..00ffa0661 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -2616,8 +2616,6 @@ Partial Class Compras_Compras HFDiferenciaCompra.Value = TxtTotal.Text - - TotalGeneral = dr("Total").ToString.ToDouble CveMoneda = dr("CveMoneda").ToString.ToEntero DdlValidadaSAT.SelectedValue = "Si" @@ -5998,7 +5996,7 @@ Partial Class Compras_Compras importeMovimiento = TxtTotal.Text.ToDecimal 'TmpDT.SUM("Total", String.Format("ISNULL(TipoAF, 0) <> 2 And ISNULL(CveAlmacen, 0) = 0 And ISNULL(AplicaCostoIndirecto, 0) <> 1 And CveClasificacion = {0} And CveSubProyecto = {1} And ISNULL(CveTipoGasto, 0) = {2} Then", Row2("CveClasificacion").ToString.ToEntero, Row2("CveSubProyecto").ToString.ToEntero, Row2("CveTipoGasto").ToString.ToEntero)).ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador 'CLASIFICACION - If Row2("CveClasificacion").ToString.ToEntero > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso Row2("CveClasificacion").ToString.ToEntero > 0 Then If ObjConta.GetRetCuenta(6, Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero) Then If ObjConta.DtResultados.Rows.Count > 0 AndAlso ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaGasto").ToString.ToEntero @@ -6133,7 +6131,7 @@ Partial Class Compras_Compras ConceptoContable = 288 End If - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero End If @@ -6145,7 +6143,7 @@ Partial Class Compras_Compras IdCtaIva = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) Dim ttConceptoContable As Integer = 14 - If ObjConta.GetRetCuenta(ttConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ttConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaIva > 0 Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaIva = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero End If @@ -6171,7 +6169,7 @@ Partial Class Compras_Compras If chkImportacion.Checked Then ConceptoContable = 287 End If - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero End If @@ -6208,7 +6206,7 @@ Partial Class Compras_Compras If tipoCambioActual > 1 Then Concepto += $" TC{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" PorcentajeImpuesto = PorcentajeIVA IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0) - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIVAxAcreditar").ToString.ToEntero End If @@ -6221,7 +6219,7 @@ Partial Class Compras_Compras importeMovimiento = ImporteIEPSxAcreditar importeMN = Math.Round(importeMovimiento, 2) * tipoCambioActual * Multiplicador If tipoCambioActual > 1 Then Concepto += $" TC{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" - If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then If ObjConta.DtResultados.Rows.Count > 0 Then IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero End If @@ -10376,162 +10374,21 @@ Partial Class Compras_Compras End If + If Retorno AndAlso (CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero OrElse CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero) Then + Dim tCveConceptoIVA, tCveConceptoISR As Integer - If Retorno AndAlso (CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero Or CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero) Then - If ObjCompra.GetComprasPrepolizasRetIvaRetISRActualiza(CveCompra, CveRetIVAConceptoOriginal, CveRetISRConceptoOriginal) Then - - Dim DTPRePolizaDesbloquedo As DataTable = ObjCompra.DtResultados.FiltraParametros("", "", {"CvePrePoliza", "Bloqueado"}) - Dim DTPRePolizaDes As DataTable = ObjCompra.DtResultados - - If DTPRePolizaDesbloquedo IsNot Nothing Then - - For Each dr1 As DataRow In DTPRePolizaDesbloquedo.Rows - - If Boolean.Parse(dr1("Bloqueado").ToString) Then - - If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then - Retorno = False - End If - - End If - - - Next - - If Retorno Then - - For Each dr2 As DataRow In DTPRePolizaDes.Rows - - Dim CveConceptoContableOriginal As Integer = dr2("CveConceptoContable").ToString.ToEntero - Dim CveConceptoContableNuvo As Integer = -1 - - If dr2("Tipo").ToString = "IVA" Then - - Select Case DdlRetIVAConcepto.SelectedValue.ToEntero - Case 1 - - If CveConceptoContableOriginal.Contiene(184, 186, 249, 286) Then - CveConceptoContableNuvo = 15 - ElseIf CveConceptoContableOriginal.Contiene(183, 185, 248, 285) Then - CveConceptoContableNuvo = 22 - End If - - Exit Select - Case 2 - - If CveConceptoContableOriginal.Contiene(22, 186, 249, 286) Then - CveConceptoContableNuvo = 184 - ElseIf CveConceptoContableOriginal.Contiene(15, 185, 248, 285) Then - CveConceptoContableNuvo = 183 - End If - - Exit Select - Case 3 - - If CveConceptoContableOriginal.Contiene(22, 184, 249, 286) Then - CveConceptoContableNuvo = 186 - ElseIf CveConceptoContableOriginal.Contiene(15, 183, 248, 285) Then - CveConceptoContableNuvo = 187 - End If - - Exit Select - Case 4 - - If CveConceptoContableOriginal.Contiene(22, 184, 186, 286) Then - CveConceptoContableNuvo = 249 - ElseIf CveConceptoContableOriginal.Contiene(15, 183, 185, 285) Then - CveConceptoContableNuvo = 248 - End If - - Exit Select - Case 5 - - If CveConceptoContableOriginal.Contiene(22, 184, 186, 249) Then - CveConceptoContableNuvo = 286 - ElseIf CveConceptoContableOriginal.Contiene(15, 183, 185, 248) Then - CveConceptoContableNuvo = 285 - End If - - Exit Select - End Select - - - - End If - - If dr2("Tipo").ToString = "ISR" Then - Select Case DdlRetISRConcepto.SelectedValue.ToEntero - Case 1 - - If CveConceptoContableOriginal.Contiene(244, 328) Then - CveConceptoContableNuvo = 23 - ElseIf CveConceptoContableOriginal.Contiene(243, 327) Then - CveConceptoContableNuvo = 16 - End If - - Exit Select - Case 2 - - If CveConceptoContableOriginal.Contiene(23, 328) Then - CveConceptoContableNuvo = 244 - ElseIf CveConceptoContableOriginal.Contiene(16, 327) Then - CveConceptoContableNuvo = 243 - End If - - Exit Select - Case 3 - - If CveConceptoContableOriginal.Contiene(23, 244) Then - CveConceptoContableNuvo = 328 - ElseIf CveConceptoContableOriginal.Contiene(16, 243) Then - CveConceptoContableNuvo = 327 - End If - - Exit Select - End Select - End If - - - If Not (CveConceptoContableNuvo > 0 AndAlso ObjCompra.UpdateComprasPrepolizasRetIvaRetISRActualiza(dr2("CvePrePolizaDetalle").ToString.ToEntero, CveConceptoContableNuvo)) Then - Retorno = False - If CveConceptoContableNuvo <= 0 Then - Alert("Se presento un error al asiganar el nuevo concepto de retención", TipoMensaje.MsgAdvertencia) - End If - Exit For - End If - - - Next - - For Each dr1 As DataRow In DTPRePolizaDesbloquedo.Rows - - If Boolean.Parse(dr1("Bloqueado").ToString) Then - If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then - Retorno = False - End If - End If - - Next - - If Retorno Then - - If CveRetIVAConceptoOriginal > 0 Then - CveRetIVAConceptoOriginal = DdlRetIVAConcepto.SelectedValue.ToEntero - End If - - If CveRetISRConceptoOriginal > 0 Then - CveRetISRConceptoOriginal = DdlRetISRConcepto.SelectedValue.ToEntero - End If - - End If - End If - - Else - Retorno = False - End If + If CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero Then tCveConceptoIVA = DdlRetIVAConcepto.SelectedValue.ToEntero + If CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero Then tCveConceptoISR = DdlRetISRConcepto.SelectedValue.ToEntero + If ObjCompra.UpdateComprasRetencionesUpdate(tCveConceptoIVA, tCveConceptoISR, CveCompra) Then + If tCveConceptoIVA > 0 Then CveRetIVAConceptoOriginal = tCveConceptoIVA + If tCveConceptoISR > 0 Then CveRetISRConceptoOriginal = tCveConceptoISR + Else + Retorno = False + Alert("Se presento un error al asignar el nuevo concepto de retención", TipoMensaje.MsgAdvertencia) End If + End If