agregado procesos y bd clases
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -28,5 +28,111 @@ namespace bdAsegasa.db
|
||||
return NumeroFactura;
|
||||
}
|
||||
}
|
||||
public const string Prod = "https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
public const string TestValidate = "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR";
|
||||
|
||||
public string EnlaceQR
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
|
||||
if (confsi != null)
|
||||
{
|
||||
if (confsi.ValorNumerico4 > 0)
|
||||
{
|
||||
return Prod + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + NumeroFactura + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(confsi.ValorAlfabetico4);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string nf = NumeroFacturaVF(null);
|
||||
return TestValidate + "?nif=" + this.idAgenteNavigation?.CIF + "&numserie=" + nf + "&fecha=" + this.Fecha.ToString("dd-MM-yyyy") + "&importe=" + Math.Round(TotalFacturaSinIRPF, 2, MidpointRounding.AwayFromZero).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool QRVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime fechaCmp = this.Fecha != DateOnly.MinValue ? new DateTime(this.Fecha.Year, this.Fecha.Month, this.Fecha.Day) : DateTime.Now;
|
||||
var confsi = enumeraciones.LConfsi?.Where(x => x.Fecha1.HasValue && x.Fecha1.Value <= fechaCmp).OrderByDescending(x => x.Fecha1).FirstOrDefault();
|
||||
if (confsi != null)
|
||||
{
|
||||
return confsi.ValorNumerico4 > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DescripcionEstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
return EstadoVerifactu.ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
public EstadoVerifactuEnum EstadoVerifactu
|
||||
{
|
||||
get
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
var rvf = bd.registrosverifactu.Where(x => x.idAplicacion == idLiquidacionAgente).OrderByDescending(x => x.idRegistro).FirstOrDefault();
|
||||
if (rvf != null)
|
||||
{
|
||||
return (EstadoVerifactuEnum)(rvf.Estado);
|
||||
}
|
||||
else
|
||||
{
|
||||
return EstadoVerifactuEnum.SIN_REGISTROS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EstadoVerifactuEnum
|
||||
{
|
||||
PENDIENTE_RESPUESTA = 0,
|
||||
CORRECTO = 1,
|
||||
ACEPTADO_CON_ERRORES = 2,
|
||||
INCORRECTO = 3,
|
||||
COMPLETADO = 10,
|
||||
SIN_REGISTROS = 100
|
||||
}
|
||||
|
||||
public string ObtieneNumeroFactura()
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
int AnoAct = DateTime.Today.Year;
|
||||
if (this.FechaFactura.HasValue && this.FechaFactura.Value.Year < 2026)
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1]) + 1;
|
||||
return DateTime.Today.Year.ToString() + "-" + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
var UltimaLiquidacion = bd.liquidacionesagentes.Where(x => x.FechaFactura.HasValue && x.FechaFactura.Value.Year == AnoAct && x.idSerieFactura == this.idSerieFactura).OrderByDescending(x => x.NumeroFactura).FirstOrDefault();
|
||||
int UltimaFactura = 1;
|
||||
if (UltimaLiquidacion != null && !string.IsNullOrEmpty(UltimaLiquidacion.NumeroFactura) && UltimaLiquidacion.NumeroFactura.Contains("-"))
|
||||
UltimaFactura = int.Parse(UltimaLiquidacion.NumeroFactura.Split('-')[1].Substring(2)) + 1;
|
||||
var sf = bd.seriesfacturas.First(x => x.idSerieFactura == idSerieFactura).Serie;
|
||||
return sf + "-" + DateTime.Today.Year.ToString().Substring(2) + UltimaFactura.ToString().PadLeft(5, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user