agregado procesos y bd clases

This commit is contained in:
2026-04-28 11:52:16 +02:00
parent 59a774c397
commit cd2e8b8530
251 changed files with 56881 additions and 49 deletions

View File

@@ -0,0 +1,92 @@
Imports System.Globalization
Imports DevExpress.CodeParser
Imports tsWPF
Partial Public Class liquidacionesagentes
Public Const Prod As String = "https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR"
Public Const TestValidate As String = "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR"
Public ReadOnly Property EnlaceQR As String
Get
Dim confsi = enumeraciones.LConfsi.Where(Function(x) x.Fecha1.HasValue AndAlso x.Fecha1.Value <= Fecha).OrderByDescending(Function(x) x.Fecha1).FirstOrDefault
If confsi IsNot Nothing Then
If confsi.ValorNumerico4 > 0 Then
Return Prod & "?nif=" & agentes.CIF & "&numserie=" & NumeroFactura & "&fecha=" & Fecha.ToString("dd-MM-yyyy") & "&importe=" & Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture)
Else
Dim nf = NumeroFacturaVF(confsi.ValorAlfabetico4)
Return TestValidate & "?nif=" & agentes.CIF & "&numserie=" & nf & "&fecha=" & Fecha.ToString("dd-MM-yyyy") & "&importe=" & Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture)
End If
Else
Dim nf = NumeroFacturaVF(confsi.ValorAlfabetico4)
Return TestValidate & "?nif=" & agentes.CIF & "&numserie=" & nf & "&fecha=" & Fecha.ToString("dd-MM-yyyy") & "&importe=" & Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture)
End If
End Get
End Property
Public ReadOnly Property QRVisible As Boolean
Get
Dim confsi = enumeraciones.LConfsi.Where(Function(x) x.Fecha1.HasValue AndAlso x.Fecha1.Value <= Fecha).OrderByDescending(Function(x) x.Fecha1).FirstOrDefault
If confsi IsNot Nothing Then
Return confsi.ValorNumerico4 > 0
Else
Return False
End If
End Get
End Property
Public ReadOnly Property DescripcionEstadoVerifactu As String
Get
Return EstadoVerifactu.ToString.Replace("_", " ")
End Get
End Property
Public Function NumeroFacturaVF(ByVal PrefijoPruebas As String) As String
If PrefijoPruebas IsNot Nothing Then
Return PrefijoPruebas + NumeroFactura
Else
Return NumeroFactura
End If
End Function
Public ReadOnly Property EstadoVerifactu As EstadoVerifactuEnum
Get
Dim bd As gestionasegasaEntities = Me.ObtieneContexto
Dim rvf = bd.registrosverifactu.Where(Function(x) x.idAplicacion = idLiquidacionAgente).OrderByDescending(Function(x) x.idRegistro).FirstOrDefault
If rvf IsNot Nothing Then
Return CType(rvf.Estado, EstadoVerifactuEnum)
Else
Return EstadoVerifactuEnum.SIN_REGISTROS
End If
End Get
End Property
Public Enum EstadoVerifactuEnum
PENDIENTE_RESPUESTA = 0
CORRECTO = 1
ACEPTADO_CON_ERRORES = 2
INCORRECTO = 3
COMPLETADO = 10
SIN_REGISTROS = 100
End Enum
Public Function ObtieneNumeroFactura()
Dim bd As bdGestionAsegasa.gestionasegasaEntities = Me.ObtieneContexto
Dim AnoAct = Today.Year
If Me.FechaFactura.Value.Year < 2026 Then
Dim UltimaLiquidacion = bd.liquidacionesagentes.Where(Function(x) x.FechaFactura.HasValue AndAlso x.FechaFactura.Value.Year = AnoAct).OrderByDescending(Function(x) x.NumeroFactura).FirstOrDefault
Dim UltimaFactura As Integer = 1
If UltimaLiquidacion IsNot Nothing Then UltimaFactura = Integer.Parse(UltimaLiquidacion.NumeroFactura.Split("-")(1)) + 1
Return Today.Year.ToString & "-" & UltimaFactura.ToString.PadLeft(5, "0")
Else
Dim UltimaLiquidacion = bd.liquidacionesagentes.Where(Function(x) x.FechaFactura.HasValue AndAlso x.FechaFactura.Value.Year = AnoAct AndAlso x.idSerieFactura = Me.idSerieFactura).OrderByDescending(Function(x) x.NumeroFactura).FirstOrDefault
Dim UltimaFactura As Integer = 1
If UltimaLiquidacion IsNot Nothing Then UltimaFactura = Integer.Parse(UltimaLiquidacion.NumeroFactura.Split("-")(1).Substring(2)) + 1
Dim sf = bd.seriesfacturas.First(Function(x) x.idSerieFactura = idSerieFactura).Serie
Return sf & "-" & Today.Year.ToString.Substring(2) & UltimaFactura.ToString.PadLeft(5, "0")
End If
End Function
Public ReadOnly Property TotalFacturaSinIRPF As Double
Get
Return Math.Round(BaseImponible + IVA, 2, MidpointRounding.AwayFromZero)
End Get
End Property
End Class