Fluctuacion
This commit is contained in:
@@ -132,8 +132,10 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
|
||||
Dim Final As Double = GanaciaAux - PerdidaAux
|
||||
HdnProveedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
|
||||
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
||||
|
||||
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
|
||||
BtnProveedoresRemove.Visible = HdnProveedorCvePrePoliza.Value.ToEntero > 0
|
||||
BtnGeneraCompras.Visible = Not HdnProveedorCvePrePoliza.Value.ToEntero > 0
|
||||
|
||||
IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
|
||||
|
||||
LtIndicador_ExistenciaPerdida.Text = PerdidaAux.ToString.FormatoNumero
|
||||
@@ -320,37 +322,38 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
'Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
'If CveBitacora <= 0 Then
|
||||
' ErrorRegistrar = True
|
||||
'End If
|
||||
|
||||
|
||||
'saco las cuentas de pérdida y ganancia
|
||||
For Each gvr As GridViewRow In GvCompras.Rows
|
||||
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
||||
'si es pérdida o ganancia
|
||||
|
||||
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
||||
'movimiento de complementaria
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total) Then
|
||||
ErrorRegistrar = True
|
||||
Exit For
|
||||
End If
|
||||
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
If CveBitacora <= 0 Then
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
If Not ErrorRegistrar Then
|
||||
'saco las cuentas de pérdida y ganancia
|
||||
For Each gvr As GridViewRow In GvCompras.Rows
|
||||
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
||||
'si es pérdida o ganancia
|
||||
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString.ToEntero()
|
||||
|
||||
'movimiento de complementaria
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
||||
ErrorRegistrar = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
|
||||
ErrorRegistrar = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa)
|
||||
|
||||
End If
|
||||
|
||||
'If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then
|
||||
' ErrorRegistrar = True
|
||||
' Exit For
|
||||
'End If
|
||||
|
||||
Next
|
||||
|
||||
'Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa)
|
||||
|
||||
If Not ErrorRegistrar Then
|
||||
Conta.Commit()
|
||||
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
||||
|
||||
Else
|
||||
Conta.RollBack()
|
||||
End If
|
||||
@@ -409,7 +412,8 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 3, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
If CveBitacora <= 0 Then
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
@@ -421,24 +425,30 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
|
||||
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
||||
|
||||
If gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0 Then
|
||||
If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then
|
||||
CveConconceptoCliente = 226
|
||||
Else
|
||||
CveConconceptoCliente = 203
|
||||
End If
|
||||
|
||||
'If Not Conta.UpdateVentaTCValuacion(gvr.DataKey("CveVenta").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then
|
||||
' ErrorRegistrar = True
|
||||
' Exit For
|
||||
'End If
|
||||
|
||||
'movimiento de complementaria
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, 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
|
||||
ErrorRegistrar = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
|
||||
If Not ErrorRegistrar Then
|
||||
Conta.Commit()
|
||||
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
|
||||
@@ -718,7 +728,7 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
|
||||
Dim Total As Decimal = 0
|
||||
Dim Conta As New ClsContabilidad
|
||||
Conta.IniciaTransacSQL()
|
||||
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
|
||||
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
Dim idCta As Integer = 0
|
||||
Dim CveCuenta As Integer = 0
|
||||
@@ -748,24 +758,40 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
CveCuenta = CveCuentaPerdida
|
||||
idCta = idCtaPerdida
|
||||
TipoMovto = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal()
|
||||
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
|
||||
'saco las cuentas de pérdida y ganancia
|
||||
End If
|
||||
|
||||
Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
If CveBitacora <= 0 Then
|
||||
ErrorRegistrar = True
|
||||
End If
|
||||
|
||||
'saco las cuentas de pérdida y ganancia
|
||||
For Each gvr As GridViewRow In GvAcreedores.Rows
|
||||
Total = gvr.DataKey("Fluctuacion").ToDecimal
|
||||
'si es pérdida o ganancia
|
||||
|
||||
'si es pérdida o ganancia
|
||||
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero()
|
||||
|
||||
'movimiento de complementaria
|
||||
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria) Then
|
||||
ErrorRegistrar = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
'If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then
|
||||
' ErrorRegistrar = True
|
||||
' Exit For
|
||||
'End If
|
||||
|
||||
Next
|
||||
|
||||
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
If Not ErrorRegistrar Then
|
||||
Conta.Commit()
|
||||
@@ -774,160 +800,11 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
Conta.RollBack()
|
||||
End If
|
||||
Conta.Dispose()
|
||||
Banco.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "FLUCTUACION GENERAL"
|
||||
|
||||
' Protected Sub BtnGenerar_Click(sender As Object, e As EventArgs)
|
||||
' Dim AcumuladoGananciaCompras = 0.0, AcumuladoPerdidaCompras = 0.0, AcumuladoGananciaBancos = 0.0, AcumuladoPerdidaBancos = 0.0
|
||||
' Dim IDPoliza = -1
|
||||
|
||||
' 'Valida datos de Compras
|
||||
' For Each gvr As GridViewRow In GvCompras.Rows
|
||||
' If gvr.DataKey("SinTipoCambio").ToString.ToEntero > 0 AndAlso Not gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' Alert("No se puede Generar la Fluctuación ya que faltan datos en Compras")
|
||||
' 'Exit Sub
|
||||
' Else
|
||||
' If gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' If gvr.DataKey("Fluctuacion").ToString.ToDouble > 0 Then
|
||||
' AcumuladoGananciaCompras += gvr.DataKey("Fluctuacion").ToString.ToDouble
|
||||
' Else
|
||||
' AcumuladoPerdidaCompras += gvr.DataKey("Fluctuacion").ToString.ToDouble * -1
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' 'Valida datos de Bancos
|
||||
' For Each gvr As GridViewRow In GvCuentas.Rows
|
||||
' If Not gvr.DataKey("TipoCambio").ToString.ToEntero > 0 AndAlso Not gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' Alert("No se puede Generar la Fluctuación ya que faltan datos en Cuentas Bancarias")
|
||||
' 'Exit Sub
|
||||
' Else
|
||||
' If gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' If gvr.DataKey("Fluctuacion").ToString.ToDouble > 0 Then
|
||||
' AcumuladoGananciaBancos += gvr.DataKey("Fluctuacion").ToString.ToDouble
|
||||
' Else
|
||||
' AcumuladoPerdidaBancos += gvr.DataKey("Fluctuacion").ToString.ToDouble * -1
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
' ObjConta.IniciaTransacSQL()
|
||||
' Dim ObjBancos As New ClsBancos
|
||||
' ObjBancos.IniciaTransacSQL()
|
||||
' Dim ErrorGenerar = False
|
||||
' Dim Fecha As Date = TxtFecha.Text.ToDate
|
||||
|
||||
' IDPoliza = ObjConta.AddPoliza(3, "Fluctuación Cambiaria", (AcumuladoGananciaCompras + AcumuladoPerdidaCompras) * 2, (AcumuladoGananciaCompras + AcumuladoPerdidaCompras) * 2, UsuarioActual.CveUsuario, Fecha)
|
||||
|
||||
' If IDPoliza > 0 Then
|
||||
|
||||
' 'COMIENZA: AGREGA CUENTAS BANCARIAS
|
||||
' If AcumuladoGananciaBancos > 0 Or AcumuladoPerdidaBancos > 0 Then
|
||||
' 'Agrega movimientos
|
||||
' Dim Fluc As Double
|
||||
' For Each gvr As GridViewRow In GvCuentas.Rows
|
||||
' Fluc = gvr.DataKey("Fluctuacion").ToString.ToDouble
|
||||
' If Math.Abs(Fluc) > 0 AndAlso gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, gvr.DataKey("IdCtaAfectable").ToString.ToEntero, Not Fluc > 0, Math.Abs(Fluc), "", String.Format("{0} Cambiaria de Cuentas Bancarias", If(Fluc > 0, "Ganancia", "Perdida")), 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' Exit For
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' 'Agrega acumulados
|
||||
' If Not ErrorGenerar AndAlso AcumuladoGananciaBancos > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, 2195, AcumuladoGananciaBancos > 0, AcumuladoGananciaBancos, "", "Acumulado Ganancia Cambiaria de Cuentas Bancarias", 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' End If
|
||||
' If Not ErrorGenerar AndAlso AcumuladoPerdidaBancos > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, 4695, AcumuladoPerdidaBancos > 0, AcumuladoPerdidaBancos, "", "Acumulado Pérdida Cambiaria de Cuentas Bancarias", 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' End If
|
||||
' Else
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' 'TERMINA: AGREGA CUENTAS BANCARIAS
|
||||
|
||||
|
||||
' 'COMIENZA: AGREGA COMPRAS
|
||||
' If AcumuladoGananciaCompras > 0 Or AcumuladoPerdidaCompras > 0 Then
|
||||
' 'Agrega movimientos
|
||||
' Dim Fluc As Double
|
||||
' For Each gvr As GridViewRow In GvCompras.Rows
|
||||
' Fluc = gvr.DataKey("Fluctuacion").ToString.ToDouble
|
||||
' If Math.Abs(Fluc) > 0 AndAlso gvr.DataKey("IdCtaAfectable").ToString.ToEntero > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, gvr.DataKey("IdCtaAfectable").ToString.ToEntero, Not Fluc > 0, Math.Abs(Fluc), "", String.Format("{0} Cambiaria de Compras", If(Fluc > 0, "Ganancia", "Pérdida")), 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' Exit For
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' 'Agrega acumulados
|
||||
' If Not ErrorGenerar AndAlso AcumuladoGananciaCompras > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, UsuarioActual.Empresa.IdCuentaGananciaCambiaria, Not AcumuladoGananciaCompras > 0, AcumuladoGananciaCompras, "", "Acumulado Ganancia Cambiaria de Compras", 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' End If
|
||||
' If Not ErrorGenerar AndAlso AcumuladoPerdidaCompras > 0 Then
|
||||
' If Not ObjConta.AddMovimiento(IDPoliza, UsuarioActual.Empresa.IdCuentaPerdidaCambiaria, Not AcumuladoPerdidaCompras > 0, AcumuladoPerdidaCompras, "", "Acumulado Pérdida Cambiaria de Compras", 0, Fecha, "") Then
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' End If
|
||||
' Else
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' 'TERMINA: AGREGA COMPRAS
|
||||
|
||||
|
||||
' Else
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
|
||||
|
||||
' 'Agrega en Bitacoras
|
||||
' If Not ErrorGenerar Then
|
||||
' If ObjBancos.AddFluctuacionesBitacora(IDPoliza, Fecha, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
' If Not ObjBancos.AddFluctuacionesBitacora(IDPoliza, Fecha, 2, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' Else
|
||||
' ErrorGenerar = True
|
||||
' End If
|
||||
' End If
|
||||
|
||||
|
||||
' If Not ErrorGenerar Then
|
||||
|
||||
' ObjConta.AjustaPoliza(IDPoliza)
|
||||
|
||||
' ObjConta.Commit()
|
||||
' ObjBancos.Commit()
|
||||
' Alert(String.Format("Fluctuación realizada con exito.<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza))
|
||||
' Else
|
||||
' ObjConta.RollBack()
|
||||
' ObjBancos.RollBack()
|
||||
' Alert("Ocurrio un error al generar la poliza", TipoMensaje.MsgAdvertencia)
|
||||
' End If
|
||||
|
||||
' ObjConta.Dispose()
|
||||
' ObjBancos.Dispose()
|
||||
' End Sub
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "GRIDVIEWS"
|
||||
|
||||
Protected Sub GvCompras_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompras.RowDataBound
|
||||
@@ -996,11 +873,15 @@ Partial Class Bancos_FluctuacionCambiaria
|
||||
|
||||
Protected Sub BtnProveedoresRemove_Click(sender As Object, e As EventArgs)
|
||||
Dim Banco As New ClsBancos
|
||||
If Not Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorCvePrePoliza.Value.ToEntero, 1, 1, UsuarioActual.CveEmpresa) Then
|
||||
Banco.IniciaTransacSQL()
|
||||
|
||||
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorCvePrePoliza.Value.ToEntero, 1, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
Banco.Commit()
|
||||
Alert("Flucturación eliminada.")
|
||||
Else
|
||||
Banco.RollBack()
|
||||
End If
|
||||
Banco.Dispose()
|
||||
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user