This commit is contained in:
2024-10-23 20:02:39 -07:00
3 changed files with 279 additions and 182 deletions

View File

@@ -381,6 +381,7 @@ Namespace Modelos
Public Class MAnticipoRelacionado Public Class MAnticipoRelacionado
Public Property CveVenta As Integer Public Property CveVenta As Integer
Public Property FolioFiscal As String Public Property FolioFiscal As String
Public Property Tipo As String
End Class End Class
<Serializable> <Serializable>
Public Class MVentaDetalleCotizacion Public Class MVentaDetalleCotizacion
@@ -1119,7 +1120,7 @@ Namespace Modelos
'MENSAJE PRINCIPAL 'MENSAJE PRINCIPAL
If MostrarURL Then If MostrarURL Then
MensajeAlert.AppendFormat("<br/>La {0}: <a class=""Texto"" target=""_blank"" href=""/Ventas/Ventas.aspx?CveVenta={2}""><b></b>{1}</a> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio, Me.CveVenta) MensajeAlert.AppendFormat("<br/>La {0}: <a class=""Texto"" target=""_blank"" href=""/Ventas/Ventas.aspx?CveVenta={2}""><b></b>{1}</a> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", If(Me.TipoDocumento = "Egresos", "Nota de crédito", Me.TipoDocumento)), Me.SerieFolio, Me.CveVenta)
Else Else
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio)) MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
End If End If

View File

@@ -393,7 +393,11 @@
<div class="row"> <div class="row">
<div class="note note-success"> <div class="note note-success">
<div class="row"> <div class="row">
<div class="col-md-1"><b>Nombre:</b></div> <div class="col-md-2">
<asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money' style='font-size: 18px !important; color: #3c763d !important;'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" />
&nbsp;
<b>Nombre:</b>
</div>
<div class="col-md-4">&nbsp;<label><asp:Literal ID="LtlNombre" runat="server"></asp:Literal></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div> <div class="col-md-4">&nbsp;<label><asp:Literal ID="LtlNombre" runat="server"></asp:Literal></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="col-md-1"><b>Folio:</b></div> <div class="col-md-1"><b>Folio:</b></div>
@@ -411,10 +415,6 @@
<div class="col-md-1" style="text-align: right;"> <div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="LnkLiberar" runat="server" CssClass="btn btn-xs btn-success" Text="Liberar" OnClick="LnkLiberar_Click" /> <asp:LinkButton ID="LnkLiberar" runat="server" CssClass="btn btn-xs btn-success" Text="Liberar" OnClick="LnkLiberar_Click" />
</div> </div>
<div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" />
</div>
</div> </div>
</div> </div>

View File

@@ -512,7 +512,7 @@ Partial Class Ventas_PVCobranza
Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing
Dim respNC As Modelos.Factura.MMensajeFactura = Nothing Dim respNC As Modelos.Factura.MMensajeFactura = Nothing
Dim RegistrarPago As Boolean = True
Try Try
'FACTURAR LA REMISION PARA HACER EL PAGO 'FACTURAR LA REMISION PARA HACER EL PAGO
If UsuarioActual.CveEmpresa.Contiene(189, 197) AndAlso VentaActual.TipoDocto = "Rem" Then If UsuarioActual.CveEmpresa.Contiene(189, 197) AndAlso VentaActual.TipoDocto = "Rem" Then
@@ -563,6 +563,7 @@ Partial Class Ventas_PVCobranza
End If End If
If MsgError = "" Then If MsgError = "" Then
If SaldoPendiente > 0 Then
CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
If CvePrePoliza > 0 Then If CvePrePoliza > 0 Then
@@ -631,6 +632,10 @@ Partial Class Ventas_PVCobranza
Else Else
MsgError = "Error al registrar prepólizas" MsgError = "Error al registrar prepólizas"
End If End If
Else
'SI NO TIENE SALDO PENDIENTE NO GENERAR POLIZA PARA EL PAGO
RegistrarPago = False
End If
End If End If
Catch ex As Exception Catch ex As Exception
MsgError = "Error al registrar el pago" MsgError = "Error al registrar el pago"
@@ -640,15 +645,25 @@ Partial Class Ventas_PVCobranza
If MsgError = "" Then If MsgError = "" Then
ObjVentas2.Commit() ObjVentas2.Commit()
Dim msBuild As New StringBuilder() Dim msBuild As New StringBuilder()
Dim MsgTimbrado As String = ""
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO 'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
'If respFactura IsNot Nothing Then If respFactura IsNot Nothing Then
' If Not respFactura.Factura.TimbrarFactura() Then 'VERIFICA SI SE GENERO NC
' msBuild.Append("La factura no se pudo timbrar<br/> ") If respNC IsNot Nothing Then
' End If AjustarTimbre(respFactura.Factura, respNC.Factura)
'End If MsgTimbrado = TimbrarFactura(respFactura.Factura, respNC.Factura)
Else
AjustarTimbre(respFactura.Factura, Nothing)
MsgTimbrado = TimbrarFactura(respFactura.Factura, Nothing)
End If
End If
If respFactura IsNot Nothing Then If respFactura IsNot Nothing Then
If RegistrarPago Then
msBuild.Append($"Pago Registrado correctamente.") msBuild.Append($"Pago Registrado correctamente.")
End If
For Each m In respFactura.Mensajes For Each m In respFactura.Mensajes
msBuild.AppendFormat("<br/> {0}", m) msBuild.AppendFormat("<br/> {0}", m)
Next Next
@@ -663,6 +678,10 @@ Partial Class Ventas_PVCobranza
msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>") msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>")
End If End If
If Not String.IsNullOrEmpty(MsgTimbrado) Then
msBuild.AppendFormat("<br/> {0}", MsgTimbrado)
End If
Alert(msBuild.ToString(), TipoMensaje.MsgInformacion) Alert(msBuild.ToString(), TipoMensaje.MsgInformacion)
Else Else
ObjVentas2.RollBack() ObjVentas2.RollBack()
@@ -996,6 +1015,79 @@ Partial Class Ventas_PVCobranza
Return Retorno Return Retorno
End Function End Function
Private Sub AjustarTimbre(ByRef ObjFactura As Modelos.Factura, ByRef ObjNC As Modelos.Factura)
ObjFactura.Timbre.CFDIRelacionados.UUID.Clear()
If HdnTipoAmortizacion.Value = "2" Then
Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant")
For Each Ant As Modelos.MAnticipoRelacionado In Anticipos
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
'AJUSTAR NC
If ObjNC IsNot Nothing Then
ObjNC.Timbre.CFDIRelacionados.UUID.Clear()
ObjNC.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjNC.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
End If
End If
'DEVOLUCIONES DE OTRA VENTA, APLICADAS EN UNA NUEVA
If HdnTipoAmortizacion.Value = "4" Then
Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC")
For Each Ant As Modelos.MAnticipoRelacionado In DevolucionesNC
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
'TEMPORAL- DEBE SER TIPO RELACION "01 - Nota de crédito de los documentos relacionados"
Dim CveTipoRelacion As Integer = 1
ObjFactura.CveTipoRelacion = CveTipoRelacion
Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {CveTipoRelacion}")
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
End If
End Sub
Private Function TimbrarFactura(ByRef ObjFactura As Modelos.Factura, ByRef ObjNC As Modelos.Factura) As String
Dim MsgErrorTimbrado As String = ""
Dim SeTimbro As Boolean = False
Dim ObjTimbrado As New Timbrado
Try
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
If SeTimbro AndAlso ObjNC IsNot Nothing Then
If ObjNC.Timbre IsNot Nothing Then
ObjNC.Timbre.CFDIRelacionados.UUID.Clear()
ObjNC.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
Dim ObjTimbradoNC As New Timbrado
Dim TimbroNC As Boolean = ObjTimbradoNC.TimbrarFactura(UsuarioActual, ObjNC)
If Not TimbroNC Then
MsgErrorTimbrado = ObjTimbradoNC.MensajeErrorCFDI
End If
ObjTimbradoNC = Nothing
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al generar el timbrado", ex)
End Try
Return MsgErrorTimbrado
End Function
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String
Dim Retorno As String = "" Dim Retorno As String = ""
Dim CveIEPago As Integer = 0 Dim CveIEPago As Integer = 0
@@ -1751,7 +1843,11 @@ Partial Class Ventas_PVCobranza
Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal() Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal()
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal")}) ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal"), .Tipo = gvr.DataKey("Tipo")})
End If
If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal"), .Tipo = gvr.DataKey("Tipo")})
End If End If
End If End If
End If End If