Skip to content

Commit

Permalink
Big int dl_event_tms
Browse files Browse the repository at this point in the history
Related work items: #534
  • Loading branch information
mg-dgsspa committed Jan 7, 2025
1 parent fd1a680 commit 44de7fd
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public sealed class KPIPagamentiMatriceDto
public string? KpiOutcome { get; set; }

[HeaderPagoPA(caption: "dl_event_tms", Order = 11)]
public DateTime? DlEventTms { get; set; }
public long? DlEventTms { get; set; }

[HeaderPagoPA(caption: "dl_ingestion_tms", Order = 11)]
public long? DlIngestionTms { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@ namespace PortaleFatture.BE.Infrastructure.Common.pagoPA.KPIPagamenti.Dto;

public sealed class KPIPagamentiScontoDto
{
public string? RecipientName { get; set; }
public string? RecipientName { get; set; }

[HeaderPagoPA(caption: "psp_name", Order = 0)]
public string? PSPName { get; set; }

[HeaderPagoPA(caption: "psp_id", Order = 1)]
public string? PspId { get; set; }

public string? PspId { get; set; }

[HeaderPagoPA(caption: "recipient_id", Order = 10)]
public string? RecipientId { get; set; }

[HeaderPagoPA(caption: "year_quarter", Order = 2)]
public string? YearQuarter { get; set; }

[HeaderPagoPA(caption: "trx_total", Order = 3)]
public long TrxTotal { get; set; }
public long? TrxTotal { get; set; }

[HeaderPagoPA(caption: "value_total", Order = 4)]
public decimal ValueTotal { get; set; }
public decimal? ValueTotal { get; set; }

[HeaderPagoPA(caption: "KpiOk", Order = 5)]
public int KpiOk { get; set; }
public int? KpiOk { get; set; }

[HeaderPagoPA(caption: "PercSconto", Order = 5)]
public decimal PercSconto { get; set; }
public decimal? PercSconto { get; set; }

[HeaderPagoPA(caption: "value_discount", Order = 6)]
public decimal ValueDiscount { get; set; }
public decimal? ValueDiscount { get; set; }

[JsonIgnore]
[HeaderPagoPA(caption: "LinkReport", Order = 7)]
Expand All @@ -43,4 +44,13 @@ public sealed class KPIPagamentiScontoDto

[HeaderPagoPA(caption: "FlagMQ", Order = 9)]
public bool? FlagMQ { get; set; }

[HeaderPagoPA(caption: "value_total_recipient_id", Order = 11)]
public decimal? RecipientValueTotal { get; set; } = null;

[HeaderPagoPA(caption: "trx_total_recipient_id", Order = 12)]
public long? RecipientTrxTotal { get; set; } = null;

[HeaderPagoPA(caption: "value_discount_recipient_id", Order = 13)]
public decimal? RecipientValueDiscount { get; set; } = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public sealed class KPIPagamentiScontoExcelDto
public string? YearQuarter { get; set; }

[HeaderPagoPA(caption: "Totale ", Order = 7)]
public decimal Totale { get; set; }
public decimal? Totale { get; set; }

[HeaderPagoPA(caption: "TotaleSconto", Order = 10)]
public decimal TotaleSconto { get; set; }
public decimal? TotaleSconto { get; set; }

[HeaderPagoPA(caption: "Link", Order = 11)]
public string? Link { get; set; }
Expand All @@ -33,7 +33,7 @@ public sealed class KPIPagamentiScontoExcelDto
public string? PspId { get; set; }

[HeaderPagoPA(caption: "trx_total", Order = 6)]
public long TrxTotal { get; set; }
public long? TrxTotal { get; set; }

[HeaderPagoPA(caption: "KpiOk", Order = 8)]
public int? KpiOk { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static IEnumerable<GridKPIPagamentiScontoReportDto> Map(this IEnumerable<

actualValue.Name = ff.RecipientName;
actualValue.RecipientId = ff.RecipientId;
actualValue.Totale += ff.ValueTotal;
actualValue.TotaleSconto+= ff.ValueDiscount;
actualValue.Totale += ff.ValueTotal == null ? 0 : ff.ValueTotal.Value;
actualValue.TotaleSconto+= ff.ValueDiscount == null ? 0 : ff.ValueDiscount.Value;
actualValue.YearQuarter = ff.YearQuarter;
actualValue.Link = ff.LinkReport;
actualValue.KpiList = ff.KpiList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Data;
using System.Text.RegularExpressions;
using DocumentFormat.OpenXml.Office2010.CustomUI;
using Microsoft.IdentityModel.Logging;
using PortaleFatture.BE.Api.Modules.pagoPA.FinancialReports.Dto;
using PortaleFatture.BE.Api.Modules.pagoPA.FinancialReports.Request;
using PortaleFatture.BE.Core.Auth;
Expand All @@ -12,6 +10,7 @@
using PortaleFatture.BE.Infrastructure.Common.pagoPA.Documenti.Common;
using PortaleFatture.BE.Infrastructure.Common.pagoPA.FinancialReports.Dto;
using PortaleFatture.BE.Infrastructure.Common.pagoPA.FinancialReports.Queries;
using PortaleFatture.BE.Infrastructure.Common.pagoPA.KPIPagamenti.Dto;
using PortaleFatture.BE.Infrastructure.Gateway.Storage.pagoPA;

namespace PortaleFatture.BE.Api.Modules.pagoPA.FinancialReports.Extensions;
Expand Down Expand Up @@ -227,7 +226,7 @@ public static FinancialReportQuartersQuery Map(this FinancialReportsQuartersRequ
Quantità = item.Quantita,
Sconti = null,
Totale = group.Sum(i => i.Importo),
ContractId = item.ContractId
ContractId = item.ContractId
};

if (item != group.First())
Expand All @@ -248,14 +247,14 @@ public static FinancialReportQuartersQuery Map(this FinancialReportsQuartersRequ
foreach (var check in totalChecks)
{
var item = check;
var sconto = sconti != null ? sconti.Where(x => x.YearQuarter == yearQuarter && x.RecipientId == check.ContractId).Select(x=> x.ValueDiscount) : [];
var sconto = sconti != null ? sconti.Where(x => x.YearQuarter == yearQuarter && x.RecipientId == check.ContractId).Select(x => x.ValueDiscount) : [];
if (check.Totale != null)
{
item.Sconti = sconto.FirstOrDefault();
item.TotaleScontato = check.Totale - item.Sconti;
}
}
}
}

totalChecks.Add(new CheckFinance
{
Numero = "Totale Risultato",
Expand All @@ -267,13 +266,39 @@ public static FinancialReportQuartersQuery Map(this FinancialReportsQuartersRequ
dataSet.Tables.Add(totalChecks!.FillTable(tableName!));

//kpi-pagamenti
var scontoLista = scontiList != null? scontiList.Where(x => x.YearQuarter == yearQuarter) : [];
if(!scontoLista.IsNullNotAny())
var scontoLista = scontiList != null ? scontiList.Where(x => x.YearQuarter == yearQuarter).ToList() : [];
if (!scontoLista.IsNullNotAny())
{
tableName = yearQuarter!.TableName(2);
tableNames.Add(tableName!);
dataSet.Tables.Add(scontoLista!.FillTable(tableName!));
}
tableNames.Add(tableName!);

var aggregatedData = scontoLista
.GroupBy(item => new { item.YearQuarter, item.RecipientId, item.FlagMQ })
.Select(group => new KPIPagamentiScontoDto
{
YearQuarter = group.Key.YearQuarter,
RecipientId = group.Key.RecipientId,
RecipientTrxTotal = group.Sum(item => item.TrxTotal),
RecipientValueTotal = group.Sum(item => item.ValueTotal),
RecipientValueDiscount = group.Sum(item => item.ValueDiscount),
FlagMQ = group.Key.FlagMQ,
PercSconto = null,
KpiOk = null,
TrxTotal = null,

})
.ToList();

scontoLista.AddRange(aggregatedData);

var orderedList = scontoLista
.OrderBy(x => x.RecipientId)
.ThenBy(x => x.PSPName == null ? 1 : 0)
.ThenBy(x => x.PSPName)
.ToList();

dataSet.Tables.Add(orderedList!.FillTable(tableName!));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static IEnumerable<KPIPagamentiScontoExcelDto> Map(this IEnumerable<GridK
KpiList = sc.KpiList,
PercSconto = null,
KpiOk = null,
TrxTotal = sc!.Posizioni!.Sum(x=>x.TrxTotal),
TrxTotal = sc!.Posizioni!.Sum(x=>x.TrxTotal==null?0: x.TrxTotal.Value),
FlagMQ = sc!.FlagMQ,
});
foreach (var pos in sc!.Posizioni!)
Expand Down

0 comments on commit 44de7fd

Please sign in to comment.