From 9236dde53c92f00a5b92044f44014b5b8bafb93d Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 14 May 2021 23:53:05 +0200 Subject: [PATCH] Aggiunto resoconto fatturato e trattative annuali --- SHERPA.BBM.UI/Data/BBM_EFService.cs | 17 +++++++ SHERPA.BBM.UI/Pages/Index.razor | 8 ++-- SHERPA.BBM.UI/Pages/Index.razor.cs | 56 +++++++++++++++++++++++ SHERPA.BBM.UI/SHERPA.BBM.UI.csproj | 2 +- SHERPA.BBM/Controllers/BBMController.cs | 60 ++++++++++++++++++++++++- 5 files changed, 137 insertions(+), 6 deletions(-) diff --git a/SHERPA.BBM.UI/Data/BBM_EFService.cs b/SHERPA.BBM.UI/Data/BBM_EFService.cs index 08da762..a410a76 100644 --- a/SHERPA.BBM.UI/Data/BBM_EFService.cs +++ b/SHERPA.BBM.UI/Data/BBM_EFService.cs @@ -54,6 +54,23 @@ namespace SHERPA.BBM.UI.Data #region Public Methods + public Task SumTotTrattato(int anno) + { + return Task.FromResult(dbController.SumTotTrattato(anno)); + } + public Task SumTotOrdinato(int anno) + { + return Task.FromResult(dbController.SumTotOrdinato(anno)); + } + public Task SumTotImporto(int anno) + { + return Task.FromResult(dbController.SumTotImporto(anno)); + } + public Task SumTotIncasso(int anno) + { + return Task.FromResult(dbController.SumTotIncasso(anno)); + } + /// /// effettua reset del controller (nuova istanza) /// diff --git a/SHERPA.BBM.UI/Pages/Index.razor b/SHERPA.BBM.UI/Pages/Index.razor index c817f24..b467128 100644 --- a/SHERPA.BBM.UI/Pages/Index.razor +++ b/SHERPA.BBM.UI/Pages/Index.razor @@ -29,7 +29,7 @@
Trattative
- 000.00€ + @(getTrattato().Result.ToString("C2"))
@@ -37,7 +37,7 @@
Ordinato
- 000.00€ + @(getOrdinato().Result.ToString("C2"))
@@ -45,7 +45,7 @@
Fatturato
- 000.00€ + @(getImporto().Result.ToString("C2"))
@@ -53,7 +53,7 @@
Incassato
- 000.00€ + @(getIncasso().Result.ToString("C2"))
diff --git a/SHERPA.BBM.UI/Pages/Index.razor.cs b/SHERPA.BBM.UI/Pages/Index.razor.cs index 8f62294..4224abe 100644 --- a/SHERPA.BBM.UI/Pages/Index.razor.cs +++ b/SHERPA.BBM.UI/Pages/Index.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using SHERPA.BBM.UI.Data; +using System; using System.Threading.Tasks; namespace SHERPA.BBM.UI.Pages @@ -33,5 +34,60 @@ namespace SHERPA.BBM.UI.Pages } #endregion Protected Methods + + + [Inject] + private BBM_EFService BBMService { get; set; } + + private int Anno { get; set; } = DateTime.Today.Year; + + protected async Task getTrattato() + { + double valore = 0; + try + { + var currVal = await BBMService.SumTotTrattato(Anno); + valore = currVal != null ? currVal : 0; + } + catch + { } + return valore; + } + protected async Task getOrdinato() + { + double valore = 0; + try + { + var currVal = await BBMService.SumTotOrdinato(Anno); + valore = currVal != null ? currVal : 0; + } + catch + { } + return valore; + } + protected async Task getImporto() + { + decimal valore = 0; + try + { + var currVal = await BBMService.SumTotImporto(Anno); + valore = currVal != null ? currVal : 0; + } + catch + { } + return valore; + } + protected async Task getIncasso() + { + decimal valore = 0; + try + { + var currVal = await BBMService.SumTotIncasso(Anno); + valore = currVal != null ? currVal : 0; + } + catch + { } + return valore; + } } } \ No newline at end of file diff --git a/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj b/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj index 62eac91..1c54369 100644 --- a/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj +++ b/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj @@ -4,7 +4,7 @@ net5.0 60fcdaab-6c1e-4bec-9d88-f7727ef1c12c wwwroot\favicon.ico - 1.0.2105.2336 + 1.0.2105.2352 diff --git a/SHERPA.BBM/Controllers/BBMController.cs b/SHERPA.BBM/Controllers/BBMController.cs index e94d03b..137cc96 100644 --- a/SHERPA.BBM/Controllers/BBMController.cs +++ b/SHERPA.BBM/Controllers/BBMController.cs @@ -44,6 +44,64 @@ namespace SHERPA.BBM.Controllers #region Public Methods + /// + /// Importo complessivo fatture EMESSE x ANNO + /// + /// + /// + public decimal SumTotImporto(int anno = 0) + { + decimal answ = dbCtx + .DbSetFatt2Doc + .Where(x => (x.DataIns.Year == anno || anno == 0)) + .Select(x => x.Importo) + .Sum(); + return answ; + } + /// + /// Incasso complessivo fatture INCASSATE x ANNO + /// + /// + /// + public decimal SumTotIncasso(int anno = 0) + { + decimal answ = dbCtx + .DbSetFatt2Doc + .Where(x => (x.DataIns.Year == anno || anno == 0)) + .Select(x => x.Incassato) + .Sum(); + return answ; + } + + /// + /// Valore complessivo ORDINATO x ANNO + /// + /// + /// + public double SumTotOrdinato(int anno = 0) + { + double answ = dbCtx + .DbSetResources + .Where(x => ((x.Document.DataIns.Year == anno || anno == 0) && x.Document.DocType == BbmDocType.OrderConfirm)) + .Select(x => x.FinalPrice) + .Sum(); + return answ; + } + /// + /// Valore complessivo TRATTATO x ANNO + /// + /// + /// + public double SumTotTrattato(int anno = 0) + { + double answ = dbCtx + .DbSetResources + .Where(x => ((x.Document.DataIns.Year == anno || anno == 0) && x.Document.IsActive)) + .Select(x => x.FinalPrice) + .Sum(); + return answ; + } + /// /// Aggiunge un nuovo item Basket /// @@ -87,7 +145,7 @@ namespace SHERPA.BBM.Controllers { } return done; } - + public int BasketsCount() { int answ = dbCtx