--FIX cobranza

This commit is contained in:
2025-02-05 17:56:41 -07:00
parent 4edc27d2db
commit 1b53da98c4

View File

@@ -716,7 +716,7 @@ Partial Class Ventas_PVCobranza
End If
'GENERAR NC PARA AMORTIZACION
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
If ListaAnticiposAplicados IsNot Nothing AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.DataKey("Tipo") = "Ant" AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
@@ -1091,34 +1091,37 @@ Partial Class Ventas_PVCobranza
Private Sub AjustarTimbreFactura(ByRef ObjFactura As Modelos.Factura)
ObjFactura.Timbre.CFDIRelacionados.UUID.Clear()
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant")
If Anticipos IsNot Nothing AndAlso Anticipos.Count() > 0 Then
For Each Ant As Modelos.MAnticipoRelacionado In Anticipos
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
If ListaAnticiposAplicados IsNot Nothing Then
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant")
If Anticipos IsNot Nothing AndAlso Anticipos.Count() > 0 Then
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"
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
End If
End If
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC")
If DevolucionesNC IsNot Nothing AndAlso DevolucionesNC.Count() > 0 Then
For Each NC As Modelos.MAnticipoRelacionado In DevolucionesNC
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(NC.FolioFiscal)
Next
Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {ObjFactura.CveTipoRelacion}")
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
End If
End If
End If
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC")
If DevolucionesNC IsNot Nothing AndAlso DevolucionesNC.Count() > 0 Then
For Each NC As Modelos.MAnticipoRelacionado In DevolucionesNC
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(NC.FolioFiscal)
Next
Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {ObjFactura.CveTipoRelacion}")
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
End If
End If
End Sub
@@ -1347,14 +1350,16 @@ Partial Class Ventas_PVCobranza
ObjFactura.PedidoContrato = PedidoContrato
ObjFactura.OrdenCompra = OrdenCompra
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
ObjFactura.CveTipoRelacion = 7
End If
If ListaAnticiposAplicados IsNot Nothing Then
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
ObjFactura.CveTipoRelacion = 7
End If
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
ObjFactura.CveTipoRelacion = 1
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
ObjFactura.CveTipoRelacion = 1
End If
End If
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)