-- generación de anticipos timbrado, mejora

This commit is contained in:
2025-01-21 09:17:31 -07:00
parent 4a3cd1b787
commit 877476625d
2 changed files with 132 additions and 6 deletions

View File

@@ -205,10 +205,14 @@
</div>
<div class="row" id="divAnticipo" runat="server" visible="false">
<div class="col-md-2">Anticipo:</div>
<div class="col-md-3">
<div class="col-md-2">
<asp:TextBox ID="TxtAnticipo" runat="server" Width="100px" ClientIDMode="Static" />
</div>
<div class="col-md-2" runat="server" id="Div3" visible="false"></div>
<div class="col-md-1" runat="server" id="DivAntSubProyectoTexto" visible="false">Sucursal:</div>
<div class="col-md-2" runat="server" id="DivAntSubProyecto" visible="false">
<asp:DropDownList runat="server" ID="DdlSubProyectos" CssClass="form-control input-sm select2me" DataValueField="CveSubProyecto" DataTextField="SubProyecto" Class="table-group-action-input form-control input-inline input-small input-sm">
</asp:DropDownList>
</div>
<div class="col-md-3" runat="server" id="Div4" visible="false">
</div>
</div>
@@ -831,7 +835,7 @@
var chkPesosBancos = $get("ChkPagarPesos");
var chkDolaresBancos = $get("ChkPagarDolares");
debugger;
if (t.checked) {
txt.value = FormatoNumero(importe, 2);
@@ -853,6 +857,13 @@
}
}
function FnRecalcula(pagoMultiple,monedaPago)
{
var Suma = SumaValores(pagoMultiple, monedaPago);
$get('TxtImporte').value = FormatoNumero(Suma, 2);
$('#LtlTotalMXN').text(FormatoNumero(Suma, 2))
}
function SumaValores(pagoMultiple, monedaPago) {
var Importe = 0;

View File

@@ -4,6 +4,7 @@
Imports System.Data
Imports ADSTimbrado
Imports Extensiones
Imports Org.BouncyCastle.Ocsp
Partial Class Ventas_ClientesAbonar
Inherits ClsPaginas
@@ -343,6 +344,13 @@ Partial Class Ventas_ClientesAbonar
DtPrestamos = CargaPrestamos(1)
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then 'GDIaz
divAnticipo.Visible = True
TxtAnticipo.Attributes.Add("onKeyUp", "FnRecalcula(0,1);")
DivAntSubProyecto.Visible = True
DivAntSubProyectoTexto.visible = True
CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, Nothing, AplicaTodos:="")
End If
CargaDatos(tCveMoneda)
Else
Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
@@ -758,7 +766,8 @@ Partial Class Ventas_ClientesAbonar
Dim MsgError As String = ""
Dim NCGeneradas As New List(Of RespuestaNotaCredrito)
Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura)
Dim ObjFacturaAnt As Modelos.Factura = Nothing
Dim RespAnt As Modelos.Factura.MMensajeFactura = Nothing
Dim ImporteSeleccionado As Decimal = 0
'02-05-2018 MANDAMOS CANCELAR EL COMPLEMENTO A SUSTITUIR
@@ -1176,12 +1185,79 @@ Partial Class Ventas_ClientesAbonar
End If
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso MsgError = "" Then '' si es empresa GDiaz
'generar un anticipo y registrarle el pago.
Dim tCveMoneda As Integer = 1
Dim tCveFormaPago As Integer = GlobalDTTipoTransacciones().FiltroPrimeroValor("CveFormaPago", $"CveTipoTransaccion={DdlTipoTransaccion.SelectedValue}").ToEntero
Dim tCvePS As Integer
Dim tCveUM As Integer = 0
Dim tCveSub As Integer = DdlSubProyectos.SelectedValue.ToEntero
ObjFacturaAnt = Modelos.Factura.CrearVentaNueva(UsuarioActual, tCveSub, CveCliente, tCveMoneda, "Ant")
ObjFacturaAnt.CveMoneda = tCveMoneda
ObjFacturaAnt.CveFormaPago = tCveFormaPago
ObjFacturaAnt.CveMetodoPago = 1
ObjFacturaAnt.ClaveMetodoPagoSAT = "PUE"
ObjFacturaAnt.ClaveFormaPagoSAT = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {ObjFacturaAnt.CveFormaPago}")
ObjFacturaAnt.ClaveUsoCFDISAT = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {ObjFacturaAnt.CveUsoCFDI}")
Dim drPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CodigoSATPS:="84111506").FiltroPrimero("PSCodigo LIKE '%ANTICIPO%' OR PSCodigo LIKE '%anticipo%' OR PSCodigo LIKE '%Anticipo%'")
Dim tPorIVA As Decimal = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=tCveSub).FiltroPrimeroValor("IVA").ToDecimal
Dim tPU As Decimal = (TxtAnticipo.Text.ToDecimal / (1 + tPorIVA)).RoundSQL(6)
If drPS IsNot Nothing Then
tCvePS = drPS("CvePS").ToString.ToEntero
tCveUM = drPS("CveUnidadMedida").ToString.ToEntero
End If
ObjFacturaAnt.AgregarPS(tCvePS, 1, tPU, 0, "", CveUM:=tCveUM, CveSubProyecto:=tCveSub, PorcentajeIVA:=tPorIVA)
ObjFacturaAnt.CalculaTotales()
RespAnt = ObjFacturaAnt.EmitirFactura(False, Transac:=ObjMov.IniciaTransacSQL(), Modulo:="Ventas/ClientesAbonarAnt", MostrarURL:=True)
RespAnt.Factura = ObjFacturaAnt
If RespAnt IsNot Nothing AndAlso RespAnt.Factura IsNot Nothing Then
Dim VentaActual As New Venta(UsuarioActual)
VentaActual.CveVenta = RespAnt.Factura.CveVenta
VentaActual.Fecha = RespAnt.Factura.Fecha
VentaActual.CveCliente = CveCliente
VentaActual.CveMoneda = tCveMoneda
VentaActual.TipoDocto = "Ant"
VentaActual.SerieFolio = RespAnt.Factura.SerieFolio
VentaActual.ClienteNombre = NombreComercial
VentaActual.TC = 1
VentaActual.Total = TxtAnticipo.Text.ToDecimal
VentaActual.IVA = (tPorIVA * tPU).RoundSQL(2)
VentaActual.PorcentajeIVA = tPorIVA
VentaActual.CveSubProyecto = tCveSub
'Importe de pago
Dim Pago As New VentaPago
Pago.TipoPago = "XXX"
Pago.Fecha = TxtFechaDocumento.Text.ToDate
Pago.CveIE = CveIE
Pago.CveMonedaPago = tCveMoneda
Pago.ImportePago = TxtAnticipo.Text.ToDecimal
Pago.ImportePagoVenta = TxtAnticipo.Text.ToDecimal
Pago.Referencia = TxtFolio.Text
Pago.TipoPago = "XXX"
'If RblTipoPago.SelectedValue = "3" Then
' Pago.TipoPago = "I"
' Pago.FechaDocumentoRelacionado = FechaIngreso
' Pago.CveClientePago = CveCliente
'End If
'MsgError = RespAnt.Mensajes.ToString
If MsgError = "" AndAlso AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
If MsgError = "" AndAlso Not ObjMov.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=3) Then
MsgError = ObjMov.MensajePolizaDescuadre & " La diferencia es de: " & ObjMov.ValorDiferencia
'If ObjMov.ValorPolizaDescuadre > 0 Then
' MsgError = ObjMov.MensajePolizaDescuadre & " La diferencia es de: " & ObjMov.ValorDiferencia
'End If
End If
Else
MsgError = "No se pudo insertar la póliza"
End If
@@ -1326,6 +1402,25 @@ Partial Class Ventas_ClientesAbonar
End If
Next
If ObjFacturaAnt IsNot Nothing Then
Dim MsgTimbrado As String = ""
Try
ObjFacturaAnt.PreparaTimbre()
MsgTimbrado = TimbrarFactura(ObjFacturaAnt, True)
StrMsg.AppendFormat("<br/><br/>Anticipo generado correctamente.<br/> Folio: <a href='/Ventas/Ventas.aspx?CveVenta={0}' target='_blank' class='Texto'>{1}</a><br/>", ObjFacturaAnt.CveVenta, ObjFacturaAnt.SerieFolio)
If Not String.IsNullOrEmpty(MsgTimbrado) Then
Dim StrEr As String = $"<div id = 'DivTipoCambioAdvertencia' class='alert alert-danger' style='padding: 5px; margin-bottom: 5px; padding-right: 25px;'><strong style = 'font-size: 20px; margin-right: 25px;' > Comprobante no emitido : </strong><br/> {MsgTimbrado}<br/>Por favor inténtelo de nuevo a través del botón 'Emitir' en ventas.</div>"
StrMsg.AppendFormat("<br/>{0}<br/>", StrEr)
End If
Catch ex As Exception
GuardaLogAD(ex.ToString())
StrMsg.AppendFormat("<br/>{0}<br/>", MsgTimbrado)
End Try
End If
If ChkComplementoPago.Checked Then
Dim TextoComplementoPago As String = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
StrMsg.AppendFormat("<br/><br/>{0}", TextoComplementoPago)
@@ -1352,6 +1447,26 @@ Partial Class Ventas_ClientesAbonar
End Sub
Private Function TimbrarFactura(ByRef ObjFactura As Modelos.Factura, ByRef SeTimbro As Boolean) As String
Dim MsgErrorTimbrado As String = ""
Dim ObjTimbrado As New Timbrado
Try
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
Catch ex As Exception
OnError("Ocurrió un error al generar el timbrado", ex)
End Try
If Not String.IsNullOrEmpty(MsgErrorTimbrado) Then
GuardaLogAD(MsgErrorTimbrado, Archivo:="LogTimbrado")
End If
Return MsgErrorTimbrado
End Function
Private Function RegistraAmortizacionAnticipo(ByRef ObjMov As ClsContabilidad, CvePrePoliza As Integer, CveIE As Integer, Importe As Decimal, tipoCambioPago As Decimal, CveVenta As Integer, ReferenciaVenta As String, ReferenciaPago As String) As String
Dim MsgError As String = ""
If CveMonedaPago = 2 Then