-- creación de pestaña de acreedores diversos

This commit is contained in:
2023-04-14 11:33:08 -07:00
parent 4f9bb9de80
commit 1a8dfae751
2 changed files with 171 additions and 35 deletions

View File

@@ -759,7 +759,59 @@
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel runat="server" ID="TabFilial" HeaderText="Filial">
<ajax:TabPanel runat="server" ID="TabAcreedoresDiversos" HeaderText="AcreedoresDiversos">
<ContentTemplate>
<br />
<div class="row">
<div class="col-md-5 form-group form-md-line-input input-iconright">
<asp:TextBox ID="TxtConceptoAcreedoresDiversos" ClientIDMode="Static" Style="text-transform: uppercase;" runat="server" MaxLength="100" CssClass="form-control " Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="help-block errorimput" ControlToValidate="TxtConceptoAcreedoresDiversos"
ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Concepto''</b> es necesario, por favor ingréselo." ValidationGroup="GrpGuardarAcreedoresDiversos"></asp:RequiredFieldValidator>
<label for="TxtConceptoAcreedoresDiversos">Concepto:</label>
<i></i>
</div>
<div class="col-md-2 form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlSubProyectoAcreedoresDiversos" ClientIDMode="Static" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" CssClass="form-control input-sm select2me js-referencia-programmatic marginFixRow" Width="90%">
</asp:DropDownList>
<label for="DdlSubProyectoAcreedoresDiversos">
<asp:Label runat="server" ID="LblSubProyectoAcreedoresDiversos"></asp:Label>
</label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="help-block errorimput" InitialValue="-1" ControlToValidate="DdlSubProyectoAcreedoresDiversos" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo es necesario, por favor ingréselo." ValidationGroup="GrpGuardarAcreedoresDiversos"></asp:RequiredFieldValidator>
<i></i>
</div>
<div class="col-md-6" style="text-align: right!important">
<asp:HiddenField ID="HdnAcreedoresDiversosCvePrePoliza" runat="server" />
<asp:HyperLink ID="HplAcreedoresDiversosPoliza" runat="server" Text="Ver Póliza" CssClass="Texto" Visible="false" />
<asp:Button ID="BtnAcreedoresDiversosRemove" runat="server" Text="Eliminar" Visible="false" OnClick="BtnAcreedoresDiversosRemove_Click" class="btn btn-primary" data-toggle="confirmation" data-popout="true" data-original-title="Está seguro de eliminar?" data-btn-ok-label="si" />
<asp:Button Text="Generar Acreedores Diversos" runat="server" ID="BtnGeneraAcreeedoresDiversos" OnClick="BtnGeneraAcreeedoresDiversos_Click" Style="margin-left: 30px;" class="btn btn-primary" ValidationGroup="GrpGuardarAcreedoresDiversos" />
</div>
</div>
<br />
<div style="float: right; margin-right: 50px;">
</div>
<asp:GridView ID="GvAcreedorDiversos" Width="99%" runat="server" AutoGenerateColumns="False"
DataKeyNames="TipoCambio,Fluctuacion,RazonSocial,CveProveedor"
EmptyDataText="No se Encontraron" ToolTip=""
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns>
<asp:BoundField HeaderText="Acreedor" DataField="RazonSocial" ItemStyle-Width="250" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Saldo" DataField="Saldo" ItemStyle-Width="100" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="T.C. último ajuste" DataField="TipoCambio" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Fluctuación" DataField="Fluctuacion" DataFormatString="{0:N2}" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
</Columns>
</asp:GridView>
<asp:Label ID="LblTotalAcreedoresDiversos" runat="server" Text=""></asp:Label>
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel runat="server" ID="TabFilial" HeaderText="Filial" Visible="false" >
<ContentTemplate>
<br />
@@ -806,17 +858,7 @@
<asp:BoundField HeaderText="Fluctuación" DataField="Fluctuacion" DataFormatString="{0:N2}" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
</Columns>
</asp:GridView>
<asp:GridView ID="GvAcreedorDiversos" Width="99%" runat="server" AutoGenerateColumns="False"
DataKeyNames="TipoCambio,Fluctuacion,RazonSocial,CveProveedor"
EmptyDataText="No se Encontraron" ToolTip=""
CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None">
<Columns>
<asp:BoundField HeaderText="Acreedor" DataField="RazonSocial" ItemStyle-Width="250" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Saldo" DataField="Saldo" ItemStyle-Width="100" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="T.C. último ajuste" DataField="TipoCambio" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Fluctuación" DataField="Fluctuacion" DataFormatString="{0:N2}" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Right" />
</Columns>
</asp:GridView>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</ContentTemplate>
</ajax:TabPanel>

View File

@@ -36,6 +36,8 @@ Partial Class Bancos_FluctuacionCambiaria
CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreeedoresAnt, Nothing, LblSubProyectoAcreedoresAnt, "")
CargarCentrosDeCosto(Nothing, DdlSubproyectoBancos, Nothing, LblSubProyectoBancos, "")
CargarCentrosDeCosto(Nothing, DdlSubProyectoFiliales, Nothing, LblSubProyectoFiliales, "")
CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreedoresDiversos, Nothing, LblSubProyectoAcreedoresDiversos, "")
CargarCentrosDeCosto(Nothing, DdlSubProyectoDeudores, Nothing, LblSubProyectoDeudores, "")
CargaUltimaFluctuacion()
@@ -66,6 +68,10 @@ Partial Class Bancos_FluctuacionCambiaria
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CargaDatos()
End Sub
Private Sub CargaDatos()
CargaTipoCambio()
If T.ActiveTabIndex = 0 Then CargaDatosProveedores()
If T.ActiveTabIndex = 1 Then CargaDatosProveedoresAnticipos()
@@ -380,8 +386,16 @@ Partial Class Bancos_FluctuacionCambiaria
Dim ObjBancos As New ClsBancos
LblTotalAcreedores.Text = "0.00"
If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 88, UsuarioActual.CveEmpresa) Then
GvAcreedorDiversos.DataSource = ObjBancos.DtResultados.FiltraParametros("Saldo > 0")
LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
HdnAcreedoresDiversosCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString
HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString
BtnAcreedoresDiversosRemove.Visible = HdnAcreedoresDiversosCvePrePoliza.Value.ToEntero > 0
BtnGeneraAcreeedoresDiversos.Visible = Not HdnAcreedoresDiversosCvePrePoliza.Value.ToEntero > 0
HplAcreedoresDiversosPoliza.Visible = HdnAcreedoresDiversosCvePrePoliza.Value.ToEntero > 0
HplAcreedoresDiversosPoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", ObjBancos.DtResultados.MAX("CvePrePoliza").ToString)
GvAcreedorDiversos.DataSource = ObjBancos.DtResultados
LblTotalAcreedoresDiversos.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero
Else
GvAcreedorDiversos.DataSource = Nothing
Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia)
@@ -1102,8 +1116,8 @@ Partial Class Bancos_FluctuacionCambiaria
Dim Total As Decimal = 0
Dim Conta As New ClsContabilidad
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa)
ObjContPaq.IniciaTransacSQL()
'Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa)
'ObjContPaq.IniciaTransacSQL()
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
Dim idCta As Integer = 0
Dim CveCuenta As Integer = 0
@@ -1157,9 +1171,6 @@ Partial Class Bancos_FluctuacionCambiaria
Banco.UpdateBancosTipoCambioValuacion(TCCierreFluctuacion, gvr.DataKey("CveIE").ToEntero, UsuarioActual.CveEmpresa)
End If
Next
If Not ErrorRegistrar Then
@@ -1168,28 +1179,96 @@ Partial Class Bancos_FluctuacionCambiaria
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
If AutoConta Then
If Conta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
If Conta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
Else
Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
End If
End If
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
' If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
'Fin autoconta
Conta.Commit()
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}' class='Texto'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
Else
Conta.RollBack()
ObjContPaq.RollBack()
'ObjContPaq.RollBack()
End If
Conta.Dispose()
Banco.Dispose()
ObjContPaq.Dispose()
'ObjContPaq.Dispose()
End Sub
#End Region
#Region "FLUCTUACION ACREEDORES DIVEROS"
Protected Sub BtnGeneraAcreeedoresDiversos_Click(sender As Object, e As EventArgs)
Dim Conta As New ClsContabilidad
Dim Banco As New ClsBancos(Conta.IniciaTransacSQL())
Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaAD", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedoresDiversos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
Dim CveConceptoContable As Integer
Dim TipoMovto As Boolean
Dim ErrorRegistrar As Boolean = False
Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias
Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal
Dim TotalAcumulado As Decimal = 0
Dim ConceptoFluctuacion As String = String.Format("Fluctuación Acreedores Diversos {0:d} ", FechaUltimoDiaMes)
For Each gvr As GridViewRow In GvAcreedorDiversos.Rows
TotalAcumulado += gvr.DataKey("Fluctuacion").ToDecimal
Next
'TotalAcumulado = GvAcreedorDiversos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) Convert.ToDecimal(GvAcreedorDiversos.DataKeys(gvr.RowIndex)("Fluctuacion")))
If TotalAcumulado < 0 Then
CveConceptoContable = 64 : TipoMovto = True
Else
CveConceptoContable = 65 : TipoMovto = False
End If
'saco las cuentas de pérdida y ganancia
For Each gvr As GridViewRow In GvAcreedorDiversos.Rows
If gvr.DataKey("Fluctuacion").ToDecimal <> 0 Then
'movimiento de complementaria
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, gvr.DataKey("Fluctuacion").ToDecimal, ConceptoFluctuacion, 351, ConceptoFluctuacion & gvr.DataKey("RazonSocial"), Now, 0, 0, TipoCambio:=TC, ImporteMX:=gvr.DataKey("Fluctuacion").ToDecimal, ImporteME:=gvr.DataKey("Fluctuacion").ToDecimal, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveSubProyecto:=DdlSubProyectoAcreedoresDiversos.SelectedValue.ToEntero) Then
ErrorRegistrar = True
Exit For
End If
End If
Next
If Not ErrorRegistrar Then
If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(TotalAcumulado), ConceptoFluctuacion, CveConceptoContable, ConceptoFluctuacion, Now, 0, 0, ImporteMX:=Math.Abs(TotalAcumulado), CveSubProyecto:=DdlSubProyectoAcreedoresDiversos.SelectedValue.ToEntero) Then
ErrorRegistrar = True
End If
End If
If Not ErrorRegistrar Then
If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 9, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
ErrorRegistrar = True
End If
Conta.Commit()
Alert(String.Format("La Fluctuación se ha generado <br/> <a href='/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}' class='Texto'>Ver Póliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
Else
Conta.RollBack()
'ObjContPaq.RollBack()
End If
Conta.Dispose()
Banco.Dispose()
'ObjContPaq.Dispose()
End Sub
#End Region
#Region "GRIDVIEWS"
@@ -1236,7 +1315,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorCvePrePoliza.Value.ToEntero, 1, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnProveedoresRemove.visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1251,7 +1330,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorAntCvePrePoliza.Value.ToEntero, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnProveedoresAntRemove.Visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1265,7 +1344,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteCvePrePoliza.Value.ToEntero, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnClientesRemove.Visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1279,7 +1358,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteAntCvePrePoliza.Value.ToEntero, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnClientesAntRemove.Visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1293,7 +1372,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorCvePrePoliza.Value.ToEntero, 5, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnAcreedoresRemove.Visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1307,7 +1386,7 @@ Partial Class Bancos_FluctuacionCambiaria
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorAntCvePrePoliza.Value.ToEntero, 6, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnAcreedoresAntRemove.Visible = False
Alert("Flucturación eliminada.")
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
@@ -1352,4 +1431,19 @@ Partial Class Bancos_FluctuacionCambiaria
End Sub
#End Region
Protected Sub BtnAcreedoresDiversosRemove_Click(sender As Object, e As EventArgs)
Dim Banco As New ClsBancos
Banco.IniciaTransacSQL()
If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedoresDiversosCvePrePoliza.Value.ToEntero, 9, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then
Banco.Commit()
BtnAcreedoresDiversosRemove.Visible = False
CargaDatos()
Alert("Fluctuación eliminada.")
Else
Banco.RollBack()
End If
Banco.Dispose()
End Sub
End Class