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 End Function
#Region "F L U C T U A C I O N - C A M B I A R I A" #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 Dim Retorno = False
DataAdapter("PA_Conta_VentasTCValuacionUpdate") DataAdapter("PA_Conta_TipoCambioValuacionUpdate")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta .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("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
End With End With
Try Try
@@ -6615,6 +6618,7 @@ Public Class ClsContabilidad
Return Retorno Return Retorno
End Function End Function
#End Region #End Region
#Region "IDisposable Support" #Region "IDisposable Support"

View File

@@ -232,7 +232,7 @@
<i></i> <i></i>
</div> </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 ID="DdlSubProyectoCompras" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlSubProyectoCompras.ClientID.ToString()%>"> <label for="<%= DdlSubProyectoCompras.ClientID.ToString()%>">
@@ -241,26 +241,26 @@
<i></i> <i></i>
</div> </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" /> <asp:Button Text="Generar Proveedores" runat="server" ID="BtnGeneraCompras" OnClick="BtnGeneraCompras_Click" Style="margin-left: 30px;" class="btn btn-primary" ValidationGroup="GrpGuardarCompras" />
</div> <asp:HiddenField ID="HdnProveedorCvePrePoliza" runat="server" />
<div> <asp:HiddenField ID="HdnProveedorCvePrePoliza" runat="server" /> <asp:Button ID="BtnProveedoresRemove" runat="server" Text="Eliminar" OnClick="BtnProveedoresRemove_Click" class="btn btn-primary" /></div>
<asp:Button ID="BtnProveedoresRemove" runat="server" Text="Eliminar" OnClick="BtnProveedoresRemove_Click" /></div>
</div> </div>
<br /> <br />
<asp:GridView ID="GvCompras" Width="99%" runat="server" AutoGenerateColumns="False" <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" EmptyDataText="No se Encontraron compras pendientes de pagar." ToolTip="Listado de Compras"
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None"> CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns> <Columns>
<asp:HyperLinkField HeaderText="Proveedor" DataTextField="NombreComercial" Target="_blank" ItemStyle-HorizontalAlign="Left" DataNavigateUrlFormatString="/Compras/Proveedores.aspx?CveProveedor={0}" DataNavigateUrlFields="CveProveedor" /> <asp:HyperLinkField HeaderText="Proveedor" DataTextField="NombreComercial" Target="_blank" DataNavigateUrlFormatString="/Compras/Proveedores.aspx?CveProveedor={0}" DataNavigateUrlFields="CveProveedor" />
<asp:BoundField HeaderText="# Facturas" DataField="SerieFolio" ItemStyle-HorizontalAlign="Left" /> <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 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="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="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> </Columns>
</asp:GridView> </asp:GridView>
<%--<asp:Label ID="LblTotalCompras" runat="server" Text=""></asp:Label>--%> <%--<asp:Label ID="LblTotalCompras" runat="server" Text=""></asp:Label>--%>
@@ -339,7 +339,7 @@
<i></i> <i></i>
</div> </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 ID="DdlsubProyectoVentas" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlsubProyectoVentas.ClientID.ToString()%>"> <label for="<%= DdlsubProyectoVentas.ClientID.ToString()%>">
@@ -362,12 +362,13 @@
<asp:GridView ID="GvVentas" Width="99%" runat="server" AutoGenerateColumns="False" <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"> ToolTip="Listado de Cuentas Bancarias" CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns> <Columns>
<asp:HyperLinkField DataTextField="Nombre" HeaderText="Cliente" Target="_blank" ItemStyle-HorizontalAlign="Left" DataNavigateUrlFormatString="/Ventas/Clientes.aspx?CveCliente={0}" DataNavigateUrlFields="CveCliente" /> <asp:HyperLinkField DataTextField="Nombre" HeaderText="Cliente" Target="_blank" DataNavigateUrlFormatString="/Ventas/Clientes.aspx?CveCliente={0}" DataNavigateUrlFields="CveCliente" />
<asp:BoundField DataField="SerieFolio" HeaderText="SerieFolio" ItemStyle-HorizontalAlign="Left" /> <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="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="TipoCambio" HeaderText="TipoCambio" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="Saldo" HeaderText="Saldo" DataFormatString="{0:N2}" 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}" /> <asp:BoundField DataField="Diferencia" HeaderText="Diferencia TC" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N4}" />
@@ -393,7 +394,7 @@
<i></i> <i></i>
</div> </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 ID="DdlSubproyectoBancos" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlSubproyectoBancos.ClientID.ToString()%>"> <label for="<%= DdlSubproyectoBancos.ClientID.ToString()%>">
@@ -453,7 +454,7 @@
<i></i> <i></i>
</div> </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 ID="DdlSubProyectoDeudores" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlSubProyectoDeudores.ClientID.ToString()%>"> <label for="<%= DdlSubProyectoDeudores.ClientID.ToString()%>">
@@ -504,7 +505,7 @@
<i></i> <i></i>
</div> </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 ID="DdlSubProyectoAcreedores" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlSubProyectoAcreedores.ClientID.ToString()%>"> <label for="<%= DdlSubProyectoAcreedores.ClientID.ToString()%>">
@@ -513,9 +514,6 @@
<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> <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> <i></i>
</div> </div>
<div class="col-md-6" style="text-align: right!important"> <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" /> <asp:Button Text="Generar Acreedores" runat="server" ID="BtnGeneraAcreedores" OnClick="BtnGeneraAcreedores_Click" Style="margin-left: 30px;" class="btn btn-primary" ValidationGroup="GrpGuardarAcreedores" />
</div> </div>
@@ -524,7 +522,7 @@
<asp:GridView ID="GvAcreedores" Width="99%" runat="server" AutoGenerateColumns="False" <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" EmptyDataText="No se Encontraron compras pendientes de pagar." ToolTip="Listado de Compras"
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None"> CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns> <Columns>
@@ -553,7 +551,7 @@
<i></i> <i></i>
</div> </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 ID="DdlSubProyectoFiliales" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList> </asp:DropDownList>
<label for="<%= DdlSubProyectoFiliales.ClientID.ToString()%>"> <label for="<%= DdlSubProyectoFiliales.ClientID.ToString()%>">

View File

@@ -133,6 +133,8 @@ Partial Class Bancos_FluctuacionCambiaria
Dim Final As Double = GanaciaAux - PerdidaAux Dim Final As Double = GanaciaAux - PerdidaAux
HdnProveedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString 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") IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd")
@@ -320,37 +322,38 @@ Partial Class Bancos_FluctuacionCambiaria
ErrorRegistrar = True ErrorRegistrar = True
End If End If
'Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
'If CveBitacora <= 0 Then If CveBitacora <= 0 Then
' ErrorRegistrar = True ErrorRegistrar = True
'End If 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()
'saco las cuentas de pérdida y ganancia 'movimiento de complementaria
For Each gvr As GridViewRow In GvCompras.Rows 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
Total = gvr.DataKey("Fluctuacion").ToDecimal ErrorRegistrar = True
'si es pérdida o ganancia Exit For
End If
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then
'movimiento de complementaria ErrorRegistrar = True
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 Exit For
ErrorRegistrar = True End If
Exit For
End If
'If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then Next
' ErrorRegistrar = True
' Exit For
'End If
Next Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa)
'Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa) End If
If Not ErrorRegistrar Then If Not ErrorRegistrar Then
Conta.Commit() 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) 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 Else
Conta.RollBack() Conta.RollBack()
End If End If
@@ -409,7 +412,8 @@ Partial Class Bancos_FluctuacionCambiaria
ErrorRegistrar = True ErrorRegistrar = True
End If 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 ErrorRegistrar = True
End If End If
@@ -421,24 +425,30 @@ Partial Class Bancos_FluctuacionCambiaria
IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() 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 CveConconceptoCliente = 226
Else Else
CveConconceptoCliente = 203 CveConconceptoCliente = 203
End If End If
'If Not Conta.UpdateVentaTCValuacion(gvr.DataKey("CveVenta").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then
' ErrorRegistrar = True
' Exit For
'End If
'movimiento de complementaria '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 ErrorRegistrar = True
Exit For Exit For
End If 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 Next
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
ErrorRegistrar = True
End If
If Not ErrorRegistrar Then If Not ErrorRegistrar Then
Conta.Commit() 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) 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 Total As Decimal = 0
Dim Conta As New ClsContabilidad 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 CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
Dim idCta As Integer = 0 Dim idCta As Integer = 0
Dim CveCuenta As Integer = 0 Dim CveCuenta As Integer = 0
@@ -749,24 +759,40 @@ Partial Class Bancos_FluctuacionCambiaria
idCta = idCtaPerdida idCta = idCtaPerdida
TipoMovto = False 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 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 ErrorRegistrar = True
End If 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 'saco las cuentas de pérdida y ganancia
For Each gvr As GridViewRow In GvAcreedores.Rows For Each gvr As GridViewRow In GvAcreedores.Rows
Total = gvr.DataKey("Fluctuacion").ToDecimal 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 '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 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 ErrorRegistrar = True
Exit For Exit For
End If End If
'If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then
' ErrorRegistrar = True
' Exit For
'End If
Next Next
Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa)
If Not ErrorRegistrar Then If Not ErrorRegistrar Then
Conta.Commit() Conta.Commit()
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion) Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
@@ -774,160 +800,11 @@ Partial Class Bancos_FluctuacionCambiaria
Conta.RollBack() Conta.RollBack()
End If End If
Conta.Dispose() Conta.Dispose()
Banco.Dispose()
End Sub End Sub
#End Region #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" #Region "GRIDVIEWS"
Protected Sub GvCompras_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompras.RowDataBound 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) Protected Sub BtnProveedoresRemove_Click(sender As Object, e As EventArgs)
Dim Banco As New ClsBancos 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.") Alert("Flucturación eliminada.")
Else
Banco.RollBack()
End If End If
Banco.Dispose() Banco.Dispose()
End Sub End Sub
End Class End Class