Correciones Solicitudes SAT

This commit is contained in:
rakcsle
2024-06-20 16:50:54 -07:00
parent b4d5ec380e
commit dc0cda7142
12 changed files with 1464 additions and 1113 deletions

View File

@@ -10,15 +10,7 @@
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
<%-- <li>
<asp:LinkButton ID="LnkPdf" OnClick="LnkPdf_Click" runat="server"> <i class="fa fa-ad-pdf"></i> Generar PDF</asp:LinkButton>
</li>
<li>
<asp:LinkButton ID="LnkExcel" OnClick="LnkExcel_Click" runat="server"><i class="fa fa-ad-excel"></i> Exporta Excel</asp:LinkButton>
</li>
<li>
<asp:HyperLink NavigateUrl="javascript:;" data-toggle="modal" data-target="#DivTipoCambio" ID="ImgTipoCambio" runat="server"> <i class="fa fa-money"></i> Ver Dlls en pesos</asp:HyperLink>
</li>--%>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
@@ -110,10 +102,12 @@
</div>
</div>
<div class="col-md-1" style="text-align: left">Centro Costo:</div>
<div class="col-md-1" style="text-align: left">
<div class="col-md-1" style="text-align: left" runat="server" visible="false" id="DvSubProyectoSaldar1">Centro Costo:</div>
<div class="col-md-1" style="text-align: left" runat="server" visible="false" id="DvSubProyectoSaldar2">
<asp:DropDownList ID="DdlSubProyectoSaldar" runat="server" DataTextField="SubProyecto" DataValueField="CveSubProyecto" AppendDataBoundItems="true" Class="table-group-action-input form-control input-inline input-sm select2me" Width="100%">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RfvDdlSubProyectoSaldar" runat="server" ControlToValidate="DdlSubProyectoSaldar" InitialValue="-1" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Centro Costo''</b> es necesario, por favor ingréselo." ValidationGroup="VgGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VceRfvDdlSubProyectoSaldar" runat="server" HighlightCssClass="vco" TargetControlID="RfvDdlSubProyectoSaldar"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-1" style="text-align: left">Concepto:</div>
@@ -123,9 +117,25 @@
<ajax:ValidatorCalloutExtender ID="VcoConcepto" runat="server" HighlightCssClass="vco" TargetControlID="RfvConcepto"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-1">
<label class="col-md-1" runat="server" visible="false" id="DVDdlDeduccion1" >Cta Deducción:</label>
<div class="col-md-1" style="text-align: left" runat="server" visible="false" id="DVDdlDeduccion2">
<asp:DropDownList ID="DdlTipoDeduccion" runat="server" Width="100%" CssClass="form-control select2me" >
<asp:ListItem Text="Gasto No Deducible" Value="255" Selected="True"></asp:ListItem>
<asp:ListItem Text="Incobrable No Deducible" Value="179"></asp:ListItem>
<asp:ListItem Text="Incobrable Deducible" Value="263"></asp:ListItem>
<asp:ListItem Text="Reservas" Value="252"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RfvDdlTipoDeduccion" runat="server" ControlToValidate="DdlTipoDeduccion" InitialValue="-1" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cta Deducción''</b> es necesario, por favor ingréselo." ValidationGroup="VgGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VceRfvDdlTipoDeduccion" runat="server" HighlightCssClass="vco" TargetControlID="RfvDdlTipoDeduccion"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-1">
<asp:Button ID="BtnSaldar" OnClick="BtnSaldar_Click" runat="server" Text="Saldar" CssClass="btn btn-primary" ValidationGroup="VgGuardar" />
</div>
</div>
@@ -137,7 +147,7 @@
<ajax:TabContainer runat="server" ID="Tabs">
<ajax:TabPanel ID="TabIXC" runat="server" HeaderText="IXC" ClientIDMode="Static">
<ajax:TabPanel ID="TabIXC" runat="server" HeaderText="IXC" ClientIDMode="Static" OnClientClick="" >
<ContentTemplate>
@@ -254,11 +264,10 @@
DataKeyNames="TipoDocto,CveVenta,CveCliente,SerieFolio,Original,SubTotal,IVA,IEPS,RetIVA,RetISR,Num3,CveSubProyecto,CveMoneda,Saldo,TipoCambio, RFC,UUID,Fecha,PorcentajeIVA,DescuentoProntoPago,CveTipoRetencion,Descuento,ClaveMetodoPagoSAT"
CssClass="table table-striped table-advance table-hover Widthall" Style="text-align: center;" GridLines="None" HeaderStyle-CssClass="ADtr">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input type="checkbox" id="ChkAll" onclick="CheckAll();" />
<%--<input type="checkbox" id="ChkAll" onclick="CheckAll();" />--%>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="Chk" CssClass="chkgv" runat="server"></asp:CheckBox>
@@ -281,6 +290,15 @@
<asp:Literal ID="LtlTipoDocto" runat="server" Text='<%# Eval("TipoDocto") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Left">
<HeaderTemplate>
Cliente
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="Ltl" runat="server" Text='<%# Eval("Nombre") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
@@ -386,7 +404,17 @@
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="display:none">
<asp:Button runat="server" ID="BtnonClickTabs" OnClick="BtnonClickTabs_Click" ClientIDMode="Static" />
</div>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
function onClickTabs() {
$('#BtnonClickTabs').click();
}
</script>
</asp:Content>

View File

@@ -78,34 +78,47 @@ Partial Public Class General_SaldosMenores
InicializaDatos()
End If
End Sub
Protected Sub BtnonClickTabs_Click(sender As Object, e As EventArgs)
Consultar()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
Consultar()
End Sub
Private Sub Consultar()
DvSaldar.Visible = False
DtDatosIXC = New DataTable
DtDatosNCEXC = New DataTable
DtDatosVentas = New DataTable
DvSubProyectoSaldar1.Visible = False
DvSubProyectoSaldar2.Visible = False
DVDdlDeduccion1.Visible = False
DVDdlDeduccion2.Visible = False
If Tabs.ActiveTab Is TabIXC Then
CargaDatosIXC()
If DtDatosIXC.Rows.Count > 0 Then
DvSaldar.Visible = True
DvSubProyectoSaldar1.Visible = True
DvSubProyectoSaldar2.Visible = True
End If
End If
If Tabs.ActiveTab Is TabVentas Then
CargaDatosVentas()
If DtDatosVentas.Rows.Count > 0 Then
DvSaldar.Visible = True
DVDdlDeduccion1.Visible = True
DVDdlDeduccion2.Visible = True
End If
End If
Upsaldar.Update()
End Sub
Protected Sub BtnSaldar_Click(sender As Object, e As EventArgs)
@@ -182,6 +195,7 @@ Partial Public Class General_SaldosMenores
If MsgError = "" Then
ObjConta.Commit()
' DvSaldar.Visible = False
Dim Msg As String = "Los movimientos se saldaron correctamente."
Msg &= $"<br/><br/><a Class='Texto' target='_blank' href='/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={CvePrePoliza}'>Ver Póliza</a>&nbsp;&nbsp; "
Alert(Msg)
@@ -197,6 +211,159 @@ Partial Public Class General_SaldosMenores
If Tabs.ActiveTab Is TabVentas Then
Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL()
Dim CvePrePoliza As Integer = 0
Dim MsgError As String = ""
'Dim ObjIE As New ClsBancos
Dim FechaUltimaFluctuacion As Date = MinFecha
Dim TipoCambioFluctuacion As Decimal = 1
Dim tFecha As Date = TxtFecha.Text.ToDate
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion <= tFecha Then
FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion
End If
End If
CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFecha.Text.ToDate, TxtFecha.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
For Each gr As GridViewRow In GvCxC.Rows
If gr.FCCheckBox("Chk").Checked Then
Dim PorcentajePago As Decimal = gr.DataKey("Saldo").ToDecimal / gr.DataKey("Original").ToDecimal
Dim Saldo As Decimal = gr.DataKey("Saldo").ToDecimal
Dim RETIVA As Decimal = gr.DataKey("RetIVA").ToDecimal
Dim SubTotal As Decimal = PorcentajePago * (gr.DataKey("SubTotal").ToDecimal.RoundSQL - gr.DataKey("Descuento").ToDecimal.RoundSQL).RoundSQL
Dim IVA As Decimal = PorcentajePago * gr.DataKey("IVA").ToDecimal.RoundSQL
Dim IEPS As Decimal = PorcentajePago * gr.DataKey("IEPS").ToDecimal.RoundSQL
Dim TCVenta As Decimal = gr.DataKey("TipoCambio").ToDecimal
Dim FechaVenta As Date = gr.DataKey("Fecha").ToDate
Dim tCveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero
Dim TCPago As Decimal = GlobalTipoCambio(TxtFecha.Text.ToDate).FormatoNumero(4).ToDecimal
Dim CveConceptoDeduccion As Integer = DdlTipoDeduccion.SelectedValue.ToEntero
Dim CveMoneda As Integer = gr.DataKey("CveMoneda").ToEntero
'si la fecha del documento es anterior a su ultima fluctuación. toma el Tc de la fluctuacion
If tCveMoneda = 2 Then
If FechaVenta < FechaUltimaFluctuacion Then
TCVenta = TipoCambioFluctuacion
End If
End If
'condicionante
Dim ClienteMovto As Boolean = True
Dim SubtotalMovto As Boolean = False
Dim CveConceptoCliente As Integer = 2
Dim ImpuestosMovto As Boolean = False
Dim CveSubProyecto As Integer = gr.DataKey("CveSubProyecto").ToEntero
Dim ConceptoPartida As String = TxtConcepto.Text.Trim & " " & gr.DataKey("SerieFolio").ToString
'TxtConcepto.Text
'If CveConceptoDeduccion = 255 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(266).ToEntero
'If CveConceptoDeduccion = 179 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(559).ToEntero
'If CveConceptoDeduccion = 263 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(537).ToEntero
'If CveConceptoDeduccion = 252 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.Funcionalidad(581).ToEntero
If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) Then
ClienteMovto = False : Saldo = Saldo * -1
ImpuestosMovto = True : IVA = IVA * -1
RETIVA = ((SubTotal * RETIVA / gr.DataKey("SubTotal").ToDecimal.RoundSQL) * -1).RoundSQL(2)
CveConceptoCliente = 1
End If
Dim UsaComplementaria As Boolean = True
'If UsuarioActual.CveEmpresa = 119 Then
' UsaComplementaria = True
'End If
If MsgError = "" Then
Dim ConPreP As ConceptosTipoSaldo = ClsPaginas.ObtenerCveConceptoPrePoliza(6, tCveMoneda, True, 1)
'normal
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, Saldo, Saldo, ConPreP.CveConcepto, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If UsaComplementaria AndAlso tCveMoneda = 2 Then
'complementaria
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, 0, If(CveMoneda = 1, Saldo, (Saldo * TCVenta) - Saldo).RoundSQL, ConPreP.CveConceptoComplementario, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, ImporteME:=Saldo, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
'fluctuación.
If tCveMoneda = 2 Then
Dim ImporteFluctuacion As Decimal = 0
ImporteFluctuacion = Saldo * (TCPago - TCVenta)
If CveSubProyecto <= 0 Then
MsgError = $"No se pudo obtener el sub proyecto de la venta {gr.DataKey("SerieFolio").ToString}"
End If
If TCPago > TCVenta Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 64, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
Else
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Math.Abs(ImporteFluctuacion), Math.Abs(ImporteFluctuacion), 65, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, TipoCambio:=TCVenta, TipoCambioPago:=TCPago, CveSubProyecto:=CveSubProyecto) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
End If
'cuando hay pago en dólares, se ajusta el concepto de subtotal,
SubTotal = (Saldo * TCVenta) + ImporteFluctuacion - (IVA * TCVenta) - (IEPS * TCVenta)
End If
If (IVA > 0 Or UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) And IVA < 0) AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IVA, If(CveMoneda = 1, IVA, IVA * TCVenta), 13, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, PorcentajeImpuesto:=gr.DataKey("PorcentajeIVA").ToDecimal, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If (RETIVA > 0 Or UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) And RETIVA < 0) AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ClienteMovto, RETIVA, If(CveMoneda = 1, RETIVA, RETIVA * TCVenta), 8, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, ImpuestosMovto, IEPS, If(CveMoneda = 1, IEPS, IEPS * TCVenta), 38, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
'al gasto,Subtotal
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, SubtotalMovto, SubTotal, SubTotal, CveConceptoDeduccion, gr.DataKey("SerieFolio").ToString, ConceptoPartida, CveCliente:=gr.DataKey("CveCliente").ToEntero, CveVenta:=gr.DataKey("CveVenta").ToEntero, CveSubProyecto:=CveSubProyecto, CveCuenta:=-1, TipoCambio:=TCVenta, TipoCambioPago:=TCPago) Then
MsgError = "Ocurrio un error al saldar el movimiento"
End If
If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=5) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
MsgError = ObjConta.MensajePolizaDescuadre + " " + ObjConta.ValorDiferencia
GuardaLogAD($"Ventas/ClientesAbonar | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
Exit For
End If
End If
End If
End If
Next
If MsgError = "" Then
'ObjConta.RollBack()
ObjConta.Commit()
'DvSaldar.Visible = False
CargaDatosVentas()
'RegistraScript("$('#ModalSaldarCuentaIncobrable').modal('hide')")
Alert(String.Format("Los movimientos se saldaron correctamente. <br/> <a href='/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}' class='Texto'>Ver PrePóliza</a>", CvePrePoliza), TipoMensaje.MsgInformacion)
'BtnSaldarCuentasIncobrables.Visible = False
Else
ObjConta.RollBack()
Alert(MsgError, TipoMensaje.MsgError)
End If
ObjConta.Dispose()
End If
@@ -438,8 +605,8 @@ Partial Public Class General_SaldosMenores
Dim FechaCorte As Date = NowADS().AddYears(1).ToShortDateString.ToString.ToDate
Dim SumDescuentoProntoPago As Double = 0.0
If Mov.GetCxCClienteDetalle(-1, FechaI, FechaF, -1, -1, UsuarioActual.CveEmpresa, -1, FechaCorte:=FechaCorte) Then
DtDatosVentas = Mov.DtResultados.FiltraParametros($"Saldo > {TxtSaldoMayorA.Text.ToDecimal} AND Saldo < {TxtSaldoMenorA.Text.ToDecimal} ", "Fecha,SerieFolio").AsEnumerable().Take(51).CopyToDataTable()
If Mov.GetCxCClienteDetalle(-1, FechaI, FechaF, -1, -1, UsuarioActual.CveEmpresa, -1, FechaCorte:=FechaCorte, Opcion:=2, SaldoMayorA:=TxtSaldoMayorA.Text.ToDecimal, SaldoMenorA:=TxtSaldoMenorA.Text.ToDecimal) Then
DtDatosVentas = Mov.DtResultados
'Dim TmpCxCAux As DataTable
'TmpCxCAux = Mov.DtResultados.FiltraParametros($"Saldo > {TxtSaldoMayorA.Text.ToDecimal} AND Saldo < {TxtSaldoMenorA.Text.ToDecimal} ", "Fecha,SerieFolio").AsEnumerable().Take(51).CopyToDataTable()
@@ -467,9 +634,17 @@ Partial Public Class General_SaldosMenores
Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCxC.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataKey("CveVenta").ToEntero <= 0 Then
e.Row.BackColor = Drawing.Color.LightGray
e.Row.FCCheckBox("Chk").Visible = False
End If
End If
End Sub
#End Region
End Class