Fluctuacion

This commit is contained in:
2022-02-11 23:44:38 -07:00
parent 6efc986e3e
commit 22db099b4f
3 changed files with 107 additions and 224 deletions

View File

@@ -6576,14 +6576,17 @@ Public Class ClsContabilidad
End Function
#Region "F L U C T U A C I O N - C A M B I A R I A"
Public Function UpdateVentaTCValuacion(CveVenta As Integer, TCValuacion As Decimal) As Boolean
Public Function UpdateTCValuacion(CveVenta As Integer, CveCompra As Integer, CveIE As Integer, TCValuacion As Decimal, CveEmpresa As Integer) As Boolean
Dim Retorno = False
DataAdapter("PA_Conta_VentasTCValuacionUpdate")
DataAdapter("PA_Conta_TipoCambioValuacionUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
.Add("@CveIE", SqlDbType.Int).Value = CveIE
.Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
End With
Try
@@ -6615,6 +6618,7 @@ Public Class ClsContabilidad
Return Retorno
End Function
#End Region
#Region "IDisposable Support"

View File

@@ -232,7 +232,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubProyectoCompras" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlSubProyectoCompras.ClientID.ToString()%>">
@@ -241,26 +241,26 @@
<i></i>
</div>
<div class="col-md-6" style="text-align: right!important">
<div class="col-md-2" style="text-align: right!important">
<asp:Button Text="Generar Proveedores" runat="server" ID="BtnGeneraCompras" OnClick="BtnGeneraCompras_Click" Style="margin-left: 30px;" class="btn btn-primary" ValidationGroup="GrpGuardarCompras" />
</div>
<div> <asp:HiddenField ID="HdnProveedorCvePrePoliza" runat="server" />
<asp:Button ID="BtnProveedoresRemove" runat="server" Text="Eliminar" OnClick="BtnProveedoresRemove_Click" /></div>
<asp:HiddenField ID="HdnProveedorCvePrePoliza" runat="server" />
<asp:Button ID="BtnProveedoresRemove" runat="server" Text="Eliminar" OnClick="BtnProveedoresRemove_Click" class="btn btn-primary" /></div>
</div>
<br />
<asp:GridView ID="GvCompras" Width="99%" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveCompra,CveProveedor,TipoCambio, Fluctuacion,SerieFolio, CveConceptoContable,FluctuacionTotal,PerdidaGanancia,IdCtaContComplementaria"
DataKeyNames="CveCompra,CveProveedor,TipoCambio, Fluctuacion,SerieFolio, CveConceptoContable,FluctuacionTotal,PerdidaGanancia,IdCtaContComplementaria,CveIE"
EmptyDataText="No se Encontraron compras pendientes de pagar." ToolTip="Listado de Compras"
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns>
<asp:HyperLinkField HeaderText="Proveedor" DataTextField="NombreComercial" Target="_blank" ItemStyle-HorizontalAlign="Left" DataNavigateUrlFormatString="/Compras/Proveedores.aspx?CveProveedor={0}" DataNavigateUrlFields="CveProveedor" />
<asp:BoundField HeaderText="# Facturas" DataField="SerieFolio" ItemStyle-HorizontalAlign="Left" />
<asp:HyperLinkField HeaderText="Proveedor" DataTextField="NombreComercial" Target="_blank" DataNavigateUrlFormatString="/Compras/Proveedores.aspx?CveProveedor={0}" DataNavigateUrlFields="CveProveedor" />
<asp:HyperLinkField HeaderText="# Facturas" DataTextField="SerieFolio" Target="_blank" DataNavigateUrlFormatString="/Compras/Compras.aspx?CveCompra={0}" DataNavigateUrlFields="CveCompra"/>
<asp:BoundField DataField="TipoDocto" HeaderText="Tipo" />
<asp:BoundField DataField="TipoCambio" HeaderText="TipoCambio" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Saldo USD" DataField="Saldo" DataFormatString="{0:N2}" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Fluctuación Pesos" DataField="FluctuacionTotal" DataFormatString="{0:N2}" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Perdida o Ganancia" DataField="PerdidaGanancia" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Perdida o Ganancia" DataField="PerdidaGanancia" ItemStyle-Width="100" />
</Columns>
</asp:GridView>
<%--<asp:Label ID="LblTotalCompras" runat="server" Text=""></asp:Label>--%>
@@ -339,7 +339,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlsubProyectoVentas" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlsubProyectoVentas.ClientID.ToString()%>">
@@ -362,12 +362,13 @@
<asp:GridView ID="GvVentas" Width="99%" runat="server" AutoGenerateColumns="False"
DataKeyNames="TipoCambio,Fluctuacion,CveVenta,SerieFolio,CveIE,IdCtaContComplementaria" EmptyDataText="No se Encontraron Cuentas Bancarias."
DataKeyNames="TipoCambio,Fluctuacion,CveVenta,SerieFolio,CveIE,IdCtaContComplementaria,TipoDocto,CveIE" EmptyDataText="No se Encontraron Cuentas Bancarias."
ToolTip="Listado de Cuentas Bancarias" CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns>
<asp:HyperLinkField DataTextField="Nombre" HeaderText="Cliente" Target="_blank" ItemStyle-HorizontalAlign="Left" DataNavigateUrlFormatString="/Ventas/Clientes.aspx?CveCliente={0}" DataNavigateUrlFields="CveCliente" />
<asp:BoundField DataField="SerieFolio" HeaderText="SerieFolio" ItemStyle-HorizontalAlign="Left" />
<asp:HyperLinkField DataTextField="Nombre" HeaderText="Cliente" Target="_blank" DataNavigateUrlFormatString="/Ventas/Clientes.aspx?CveCliente={0}" DataNavigateUrlFields="CveCliente" />
<asp:HyperLinkField DataTextField="SerieFolio" HeaderText="SerieFolio" Target="_blank" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataNavigateUrlFields="CveVenta" />
<asp:BoundField DataField="Fecha" HeaderText="Fecha" DataFormatString="{0:d}" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="TipoDocto" HeaderText="Tipo" />
<asp:BoundField DataField="TipoCambio" HeaderText="TipoCambio" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="Saldo" HeaderText="Saldo" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="Diferencia" HeaderText="Diferencia TC" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N4}" />
@@ -393,7 +394,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubproyectoBancos" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlSubproyectoBancos.ClientID.ToString()%>">
@@ -453,7 +454,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubProyectoDeudores" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlSubProyectoDeudores.ClientID.ToString()%>">
@@ -504,7 +505,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubProyectoAcreedores" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlSubProyectoAcreedores.ClientID.ToString()%>">
@@ -512,10 +513,7 @@
</label>
<asp:RequiredFieldValidator ID="RFVDdlSubProyectoAcreedores" runat="server" CssClass="help-block errorimput" InitialValue="-1" ControlToValidate="DdlSubProyectoAcreedores" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo es necesario, por favor ingréselo." ValidationGroup="GrpGuardarAcreedores"></asp:RequiredFieldValidator>
<i></i>
</div>
</div>
<div class="col-md-6" style="text-align: right!important">
<asp:Button Text="Generar Acreedores" runat="server" ID="BtnGeneraAcreedores" OnClick="BtnGeneraAcreedores_Click" Style="margin-left: 30px;" class="btn btn-primary" ValidationGroup="GrpGuardarAcreedores" />
</div>
@@ -524,7 +522,7 @@
<asp:GridView ID="GvAcreedores" Width="99%" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveCompra,CveProveedor,Fluctuacion,SerieFolio"
DataKeyNames="CveCompra,CveProveedor,Fluctuacion,SerieFolio,IdCtaContComplementaria,CveIE"
EmptyDataText="No se Encontraron compras pendientes de pagar." ToolTip="Listado de Compras"
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns>
@@ -553,7 +551,7 @@
<i></i>
</div>
<div class="col-md-1 form-group form-md-line-input input-iconright">
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubProyectoFiliales" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="<%= DdlSubProyectoFiliales.ClientID.ToString()%>">

View File

@@ -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