From ac553c3147b3195f5db25a899d5900db0ea7c118 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 17 Oct 2024 16:22:41 -0700 Subject: [PATCH] =?UTF-8?q?--=20nuevo=20grid=20de=20validaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bancos/FluctuacionCambiaria.aspx | 14 +++ Bancos/FluctuacionCambiaria.aspx.vb | 173 +++++++++++++++++++++++----- 2 files changed, 155 insertions(+), 32 deletions(-) diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index 343bfe9ce..0fad5f963 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -913,6 +913,20 @@ + + + + + + + + + + + + + diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index 50b35f9f8..c59ab7d4b 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -28,6 +28,7 @@ Partial Class Bancos_FluctuacionCambiaria Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaFechas() + CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "") CargarCentrosDeCosto(Nothing, DdlSubProyectoComprasAnt, Nothing, LblSubProyectoComprasAnt, "") CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "") @@ -60,10 +61,10 @@ Partial Class Bancos_FluctuacionCambiaria DdlMes.Items.Add(New ListItem(mesStr, i.ToString())) Next - Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(NowADS()) + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(NowADS().AddMonths(-1)) If UltimaFluctuacion IsNot Nothing Then DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Month) - DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Year) + DdlAnio.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Year) End If End Sub @@ -85,6 +86,7 @@ Partial Class Bancos_FluctuacionCambiaria If T.ActiveTabIndex = 7 Then CargaDatosAcreedoresDiversos() 'CargaDatosFiliales() If T.ActiveTabIndex = 8 Then CargaDatosDeudores() UpTabs.Update() + UPPCompara.Update() End Sub Private Sub CargaTipoCambio() @@ -103,14 +105,16 @@ Partial Class Bancos_FluctuacionCambiaria If UltimaFluctuacion IsNot Nothing Then LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", UltimaFluctuacion.FechaFluctuacion.ToShortDateString) - 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual - If UltimaFluctuacion.FechaFluctuacion >= NowADS().AddMonths(-1).LastDayOfMonth Then - DdlMes.SelectedValueExist(NowADS().Month) - DdlAnio.SelectedValueExist(NowADS().Year) - Else - DdlMes.SelectedValueExist(NowADS().AddMonths(-1).Month) - DdlAnio.SelectedValueExist(NowADS().AddMonths(-1).Year) - End If + DdlMes.SelectedValueExist(NowADS().AddMonths(-1).Month) + DdlAnio.SelectedValueExist(NowADS().AddMonths(-1).Year) + ''si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual + 'If UltimaFluctuacion.FechaFluctuacion >= NowADS().AddMonths(-1).LastDayOfMonth Then + ' DdlMes.SelectedValueExist(NowADS().Month) + ' DdlAnio.SelectedValueExist(NowADS().Year) + 'Else + ' DdlMes.SelectedValueExist(NowADS().AddMonths(-1).Month) + ' DdlAnio.SelectedValueExist(NowADS().AddMonths(-1).Year) + 'End If End If CargaTipoCambio() @@ -145,14 +149,18 @@ Partial Class Bancos_FluctuacionCambiaria LblComprasPerdidaGanancia.Text = If(Final < 0, "Ganancia", "Pérdida") LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero - - End If + Dim tdt As DataTable = VerificacionFluctuacion(1, FechaUltimoDiaMes) + LtIndicador_ExistenciaPerdida.Text = tdt.SUMD("Diferencia").FormatoNumero + LtIndicador_ValorPesosGanancia.Text = "" + LtIndicador_CPPesosFinal.Text = "" + End If ObjBancos.Dispose() GvProveedores.DataBind() UpIndicadores.Visible = True If GvProveedores.Rows.Count > 0 Then GvProveedores.Rows(GvProveedores.Rows.Count - 1).CssClass = "SubTotales2" - End If + End If + End Sub Private Sub CargaDatosProveedoresAnticipos() @@ -183,10 +191,11 @@ Partial Class Bancos_FluctuacionCambiaria LblComprasPerdidaGanancia.Text = If(Final > 0, "Ganancia", "Pérdida") LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + VerificacionFluctuacion(2, FechaUltimoDiaMes) End If ObjBancos.Dispose() - GvProveedoresAnt.DataBind() + GvProveedoresAnt.DataBind() UpIndicadores.Visible = True End Sub @@ -223,6 +232,11 @@ Partial Class Bancos_FluctuacionCambiaria UpIndicadoresVentas.Visible = True + Dim tdt As DataTable = VerificacionFluctuacion(3, FechaUltimoDiaMes) + LtIndicador_PerdidasVentas.Text = tdt.SUMD("Diferencia").FormatoNumero + LtIndicador_GanaciaVentas.Text = "" + LtIndicador_FinalVentas.Text = "" + End If ObjBancos.Dispose() GvVentas.DataBind() @@ -257,7 +271,7 @@ Partial Class Bancos_FluctuacionCambiaria LblTotalVentasAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero UpIndicadoresVentas.Visible = True - + VerificacionFluctuacion(4, FechaUltimoDiaMes) End If ObjBancos.Dispose() GvClientesAnt.DataBind() @@ -278,6 +292,7 @@ Partial Class Bancos_FluctuacionCambiaria HplAcreedorLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString) GvAcreedores.DataSource = ObjBancos.DtResultados LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + VerificacionFluctuacion(5, FechaUltimoDiaMes) Else GvAcreedores.DataSource = Nothing Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) @@ -298,7 +313,8 @@ Partial Class Bancos_FluctuacionCambiaria HplAcreedorAntLiga.Visible = HdnAcreedorAntCvePrePoliza.Value.ToEntero > 0 HplAcreedorAntLiga.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString) GvAcreedoresAnt.DataSource = ObjBancos.DtResultados - LblTotalAcreedoresAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + LblTotalAcreedoresAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + VerificacionFluctuacion(6, FechaUltimoDiaMes) Else GvAcreedoresAnt.DataSource = Nothing Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) @@ -325,6 +341,7 @@ Partial Class Bancos_FluctuacionCambiaria GvCuentas.DataSource = DtTemp LblTotalBancos.Text = TotAcumulado.FormatoNumero + VerificacionFluctuacion(77, FechaUltimoDiaMes) Else GvCuentas.DataSource = Nothing Alert("Ocurrio un error al cargar las cuentas", TipoMensaje.MsgAdvertencia) @@ -339,6 +356,7 @@ Partial Class Bancos_FluctuacionCambiaria If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 9, UsuarioActual.CveEmpresa) Then GvDeudores.DataSource = ObjBancos.DtResultados LblTotalDeudores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + VerificacionFluctuacion(9, FechaUltimoDiaMes) Else GvDeudores.DataSource = Nothing Alert("Ocurrio un error al cargar los deudores", TipoMensaje.MsgAdvertencia) @@ -354,6 +372,7 @@ Partial Class Bancos_FluctuacionCambiaria If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 88, UsuarioActual.CveEmpresa) Then GvFiliales.DataSource = ObjBancos.DtResultados.FiltraParametros("Saldo > 0") LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + VerificacionFluctuacion(88, FechaUltimoDiaMes) Else GvFiliales.DataSource = Nothing Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) @@ -392,14 +411,12 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - Dim CveCuentaPerdida, CveCuentaGanancia As Integer + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CveCompra, CveProv As Integer Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 Dim ErrorRegistrar As Boolean = False - CveCuentaPerdida = 0 '55379 - CveCuentaGanancia = 0 ' 55382 + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias Total = LblTotal.ToDecimal @@ -425,6 +442,8 @@ Partial Class Bancos_FluctuacionCambiaria 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvProveedores.Rows Total = gvr.DataKey("Fluctuacion").ToDecimal + CveCompra = gvr.DataKey("CveCompra").ToEntero + CveProv = gvr.DataKey("CveProveedor").ToEntero 'movimiento de complementaria If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero) Then ErrorRegistrar = True @@ -441,6 +460,11 @@ Partial Class Bancos_FluctuacionCambiaria ErrorRegistrar = True End If + 'VERIFICACION DE IMPORTES Y AJUSTE + If Not ErrorRegistrar AndAlso AjusteFluctuacion(CvePrePoliza, 1, 201, FechaUltimoDiaMes, Conta, CveCompra:=CveCompra, CveProveedor:=CveProv) Then + ErrorRegistrar = True + End If + If Not ErrorRegistrar AndAlso Not Conta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then ErrorRegistrar = True End If @@ -569,24 +593,25 @@ Partial Class Bancos_FluctuacionCambiaria End If Dim CveConconceptoCliente As Integer = 203 - + Dim CveVenta, CveCliente As Integer 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvVentas.Rows Total = -gvr.DataKey("Fluctuacion").ToDecimal - - If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then + CveVenta = gvr.DataKey("CveVenta").ToEntero + CveCliente = gvr.DataKey("CveCliente").ToEntero + If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso CveVenta < 0) OrElse (CveVenta > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then CveConconceptoCliente = 226 Else CveConconceptoCliente = 203 End If 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, CveConconceptoCliente, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero, CveCliente:=gvr.DataKey("CveCliente").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, CveConconceptoCliente, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveVenta:=CveVenta, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero, CveCliente:=CveCliente) Then ErrorRegistrar = True Exit For End If - If Not Conta.UpdateTCValuacion(gvr.DataKey("CveVenta").ToEntero, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + If Not Conta.UpdateTCValuacion(CveVenta, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True Exit For End If @@ -595,6 +620,12 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar AndAlso Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True End If + + 'VERIFICACION DE IMPORTES Y AJUSTE + If Not ErrorRegistrar AndAlso AjusteFluctuacion(CvePrePoliza, 3, 203, FechaUltimoDiaMes, Conta, CveVenta:=CveVenta, CveCliente:=CveCliente) Then + ErrorRegistrar = True + End If + If Not ErrorRegistrar AndAlso Not Conta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then ErrorRegistrar = True End If @@ -611,6 +642,46 @@ Partial Class Bancos_FluctuacionCambiaria Conta.Dispose() End Sub + Private Function AjusteFluctuacion(CvePrePoliza As Integer, TipoFluctuacion As Integer, CveConcepto As Integer, FechaUltimoDaMes As Date, ByRef ObjConta As ClsContabilidad, Optional CveVenta As Integer = -1, Optional CveCliente As Integer = -1, Optional CveCompra As Integer = -1, Optional CveProveedor As Integer = -1) As Boolean + If UsuarioActual.CveEmpresa <> 119 Then Return True + Dim ErrorRegistrar As Boolean = False + Dim tdt As DataTable = VerificacionFluctuacion(TipoFluctuacion, FechaUltimoDiaMes) + 'ajustar las cuentas. + Dim AjusteTotal As Decimal = tdt.SUMD("Diferencia") + Dim tTipoMovto As Boolean = If(TipoFluctuacion.Contiene(2, 3, 6), False, True) 'LAS OPCIONES QUE SE CARGAN + If tdt IsNot Nothing Then + For Each dr As DataRow In tdt.FiltraParametros("Diferencia <> 0").Rows + Dim imp As Decimal = dr("Diferencia").ToString.ToDecimal * -1 + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tTipoMovto, imp, imp, CveConcepto, "Fluctuación", "Fluctuación", CveVenta:=CveVenta, TipoCambio:=2, ImporteME:=imp, CveCliente:=CveCliente, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveCuenta:=dr("CveCuentaComplementaria").ToString.ToEntero) Then + ErrorRegistrar = True + Exit For + End If + Next + 'ajustar el importe + If AjusteTotal <> 0 AndAlso ObjConta.GetPrePolizasDetalle(CvePrePoliza, UsuarioActual.CveEmpresa) Then + Dim dr As DataRow = ObjConta.DtResultados.FiltroPrimero("CveConceptoContable in (64,65)") + If dr IsNot Nothing Then + Dim tcvePrePDetalle As Integer = dr("CvePrePolizaDetalle").ToString.ToEntero + Dim tCveConcepto As Integer = dr("CveConceptoContable").ToString.ToEntero + 'If dr("CveConceptoContable").ToString = "65" Then + ' AjusteTotal = AjusteTotal + dr("Importe").ToString.ToDecimal + 'End If + tTipoMovto = dr("TipoMovto").ToString.ToBool + AjusteTotal = AjusteTotal + dr("Importe").ToString.ToDecimal + If AjusteTotal < 0 Then + AjusteTotal = Math.Abs(AjusteTotal) ' ' si hay cambio de fluctuacion de pérdida a ganancia, o viceversas + tTipoMovto = Not tTipoMovto + If tTipoMovto Then tCveConcepto = 64 Else tCveConcepto = 65 + End If + ObjConta.UpdatePrePolizasDetalle(dr("CvePrePolizaDetalle").ToString.ToEntero, dr("Concepto").ToString, -1, -1, tTipoMovto, + CveConceptoContable:=tCveConcepto, ImporteMN:=AjusteTotal, Importe:=AjusteTotal) + End If + End If + End If + + Return ErrorRegistrar + End Function + Protected Sub BtnClientesAnticipos_Click(sender As Object, e As EventArgs) Dim Total As Decimal = 0 Dim TipoMovto As Boolean = False @@ -648,24 +719,25 @@ Partial Class Bancos_FluctuacionCambiaria End If Dim CveConconceptoCliente As Integer = 203 - + Dim CveVenta, CveCliente As Integer 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvClientesAnt.Rows Total = gvr.DataKey("Fluctuacion").ToDecimal - - If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then + CveVenta = gvr.DataKey("CveVenta").ToEntero + CveCliente = -1 + If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso CveVenta < 0) OrElse (CveVenta > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then CveConconceptoCliente = 226 Else CveConconceptoCliente = 203 End If 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, CveConconceptoCliente, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, CveConconceptoCliente, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveVenta:=CveVenta, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If - If Not Conta.UpdateTCValuacion(gvr.DataKey("CveVenta").ToEntero, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + If Not Conta.UpdateTCValuacion(CveVenta, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True Exit For End If @@ -674,6 +746,12 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar AndAlso Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True End If + + 'VERIFICACION DE IMPORTES Y AJUSTE + If Not ErrorRegistrar AndAlso AjusteFluctuacion(CvePrePoliza, 4, 226, FechaUltimoDiaMes, Conta, CveVenta:=CveVenta, CveCliente:=CveCliente) Then + ErrorRegistrar = True + End If + If Not ErrorRegistrar AndAlso Not Conta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then ErrorRegistrar = True End If @@ -708,6 +786,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 Dim ErrorRegistrar As Boolean = False + Dim CveCompra, CveProv As Integer Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias Total = LblTotalAcreedores.Text.ToDecimal @@ -733,6 +812,8 @@ Partial Class Bancos_FluctuacionCambiaria 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvAcreedores.Rows Total = gvr.DataKey("Fluctuacion").ToDecimal + CveCompra = gvr.DataKey("CveCompra").ToEntero + CveProv = gvr.DataKey("CveProveedor").ToEntero 'movimiento de complementaria If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Total, 307, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero) Then ErrorRegistrar = True @@ -748,6 +829,12 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar AndAlso Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True End If + + 'VERIFICACION DE IMPORTES Y AJUSTE + If Not ErrorRegistrar AndAlso AjusteFluctuacion(CvePrePoliza, 5, 307, FechaUltimoDiaMes, Conta, CveCompra:=CveCompra, CveProveedor:=CVEPROV) Then + ErrorRegistrar = True + End If + If Not ErrorRegistrar AndAlso Not Conta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then ErrorRegistrar = True End If @@ -774,6 +861,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 Dim ErrorRegistrar As Boolean = False + Dim CveCompra, CveProv As Integer Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias Total = LblTotalAcreedoresAnt.Text.ToDecimal @@ -799,7 +887,8 @@ Partial Class Bancos_FluctuacionCambiaria 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvAcreedoresAnt.Rows Total = gvr.DataKey("Fluctuacion").ToDecimal - + CveCompra = gvr.DataKey("CveCompra").ToEntero + CveProv = gvr.DataKey("CveProveedor").ToEntero 'movimiento de complementaria If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Total, 347, gvr.DataKey("SerieFolio"), gvr.DataKey("SerieFolio"), CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True @@ -815,6 +904,10 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar AndAlso Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 6, CveBitacora, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True End If + 'VERIFICACION DE IMPORTES Y AJUSTE + If Not ErrorRegistrar AndAlso AjusteFluctuacion(CvePrePoliza, 6, 347, FechaUltimoDiaMes, Conta, CveCompra:=CveCompra, CveProveedor:=CveProv) Then + ErrorRegistrar = True + End If If Not ErrorRegistrar AndAlso Not Conta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then ErrorRegistrar = True End If @@ -1296,4 +1389,20 @@ Partial Class Bancos_FluctuacionCambiaria End If Banco.Dispose() End Sub + + +#Region "VERIFICACION " + Private Function VerificacionFluctuacion(Opcion As Integer, Fecha As Date) As DataTable + Dim tdt As DataTable = Nothing + Dim Conta As New ClsContabilidad + If Conta.GetAjusteFluctuacion(Opcion, Fecha, UsuarioActual.CveEmpresa) Then + tdt = Conta.DtResultados + GvComparativo.DataSource = tdt + End If + Conta.Dispose() + GvComparativo.DataBind() + Return tdt + End Function +#End Region + End Class