From 638baf02c845ff255c10051a412fecc18ee7323a Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Sun, 23 Jun 2024 19:56:05 +0330 Subject: [PATCH] ... --- Back/Services/servUser.cs | 65 ++++++++++++++++-------- Shared/DTOs/DashBoardDTO.cs | 1 + TaxPayerFull/Layout/SaleChart.razor | 10 +--- TaxPayerFull/Pages/UserPanel/Panel.razor | 9 ++-- 4 files changed, 53 insertions(+), 32 deletions(-) diff --git a/Back/Services/servUser.cs b/Back/Services/servUser.cs index ad7c9d4..67c6987 100644 --- a/Back/Services/servUser.cs +++ b/Back/Services/servUser.cs @@ -4,6 +4,7 @@ using Back.Data.Infrastructure.Repository; using Back.Data.Models; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; +using Org.BouncyCastle.Crypto.Tls; using Shared.DTOs; using System.ComponentModel.Design; using System.Data.SqlTypes; @@ -298,10 +299,9 @@ namespace Back.Services List dt = new List(); for (int i = -7; i < 1; i++) dt.Add(DateTime.Now.AddDays(i).ConvertMiladiToShamsi()); - + request.MostInvoicedProduct = await _invoiceitemRepo.Get(w => w.invoice.CompanyID == user.RolUsers.First().CompanyID && !w.invoice.IsDeleted - && (w.invoice.invoiceType == InvoiceType.Sale || w.invoice.invoiceType == InvoiceType.BackFrmSale - || w.invoice.invoiceType == InvoiceType.Repair) && !w.invoice.BillReference.HasValue + && ((w.invoice.invoiceType == InvoiceType.Sale || w.invoice.invoiceType == InvoiceType.Repair) && !w.invoice.BillReference.HasValue || (w.invoice.invoiceType == InvoiceType.BackFrmSale)) && (dt.Contains(w.invoice.InvoiceDate))) .Include(inc => inc.cODItem) .GroupBy(g => g.CODID) @@ -313,10 +313,9 @@ namespace Back.Services }).OrderByDescending(o => o.count) .ToListAsync(); - request.MostInvoicedCustomer =await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted - && (w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale - || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue - && (dt.Contains(w.InvoiceDate))) + request.MostInvoicedCustomer = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted + && ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale)) + && dt.Contains(w.InvoiceDate)) .Include(inc => inc.Customer) .GroupBy(g => g.CustomerID) .Select(s => new IdNameByCount @@ -330,22 +329,22 @@ namespace Back.Services var cdate = DateTime.Now.ConvertMiladiToShamsiAndGetYearMonth(); - var sale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted - && (w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale - || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue && w.InvoiceDate.StartsWith(cdate)) - .Include(inc => inc.invoiceDetails) - .ThenInclude(inc => inc.cODItem) - .ThenInclude(inc => inc.CODUnit) - .Include(inc => inc.pattern) - .Select(s => s.tbill) - .ToListAsync(); - request.SaleInMonth = sale.Sum(); + var sale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted + && ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale)) + && w.InvoiceDate.StartsWith(cdate)) + .Include(inc => inc.invoiceDetails) + .ThenInclude(inc => inc.cODItem) + .ThenInclude(inc => inc.CODUnit) + .Include(inc => inc.pattern) + .Select(s => s.tbill) + .ToListAsync(); + request.SaleInMonth = sale.Sum(); cdate = DateTime.Now.AddMonths(-1).ConvertMiladiToShamsiAndGetYearMonth(); var lastonthsale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted - && (w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale - || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue && w.InvoiceDate.StartsWith(cdate)) + && ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale)) + && w.InvoiceDate.StartsWith(cdate)) .Include(inc => inc.invoiceDetails) .ThenInclude(inc => inc.cODItem) .ThenInclude(inc => inc.CODUnit) @@ -361,10 +360,36 @@ namespace Back.Services { if (!part.HasValue) part = 0; - request.Salepercent =decimal.Parse( ((part.Value / total.Value) * 100).ToString().Split('.')[0]); + request.Salepercent = decimal.Parse(((part.Value / total.Value) * 100).ToString().Split('.')[0]); } + // request.ForSaleChart.AddRange(new List>() + //{ + // new IdNameByCount{ID=0,Title="1",count=10}, + // new IdNameByCount{ID=1,Title="2",count=5}, + // new IdNameByCount{ID=2,Title="3",count=12}, + // new IdNameByCount{ID=3,Title="4",count=21} + //}); + var dateTime = DateTime.Now.ConvertMiladiToShamsi(); + for (int i = 1; i <= Convert.ToInt32(dateTime.Substring(6, 2)); i++) + { + var sumsale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted + && ((w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue || (w.invoiceType == InvoiceType.BackFrmSale)) + && w.InvoiceDate == dateTime.Substring(0, 4) + dateTime.Substring(4, 2) + i.ToString("00")) + .Include(inc => inc.invoiceDetails) + .ThenInclude(inc => inc.cODItem) + .ThenInclude(inc => inc.CODUnit) + .Include(inc => inc.pattern) + .Select(s => s.tbill).ToListAsync(); + + request.ForSaleChart.Add(new IdNameByCount + { + count = sumsale.Sum(), + ID = i - 1, + Title = i.ToString() + }); + } return request; } public async Task UpdateUser(User user) diff --git a/Shared/DTOs/DashBoardDTO.cs b/Shared/DTOs/DashBoardDTO.cs index 33373a5..37ae3d9 100644 --- a/Shared/DTOs/DashBoardDTO.cs +++ b/Shared/DTOs/DashBoardDTO.cs @@ -19,6 +19,7 @@ namespace Shared.DTOs public List lastActivitiesSevices { get; set; }=new List(); public List>? MostInvoicedProduct { get; set; }=new List>(); public List>? MostInvoicedCustomer { get; set; } = new List>(); + public List> ForSaleChart { get; set; } = new List>(); public decimal? SaleInMonth { get; set; } = 0; public decimal? Salepercent { get; set; } = 0; } diff --git a/TaxPayerFull/Layout/SaleChart.razor b/TaxPayerFull/Layout/SaleChart.razor index b17ffca..5c7ce8f 100644 --- a/TaxPayerFull/Layout/SaleChart.razor +++ b/TaxPayerFull/Layout/SaleChart.razor @@ -5,16 +5,10 @@ private LineChart lineChart = default!; private LineChartOptions lineChartOptions = default!; private ChartData chartData = default!; - public List> items = new List>(); + [Parameter] public List> items { get;set; } protected override void OnInitialized() { - items.AddRange(new List>() - { - new IdNameByCount{ID=0,Title="1",count=10}, - new IdNameByCount{ID=1,Title="2",count=5}, - new IdNameByCount{ID=2,Title="3",count=12}, - new IdNameByCount{ID=3,Title="4",count=21} - }); + var colors = ColorBuilder.CategoricalTwelveColors; diff --git a/TaxPayerFull/Pages/UserPanel/Panel.razor b/TaxPayerFull/Pages/UserPanel/Panel.razor index a96db64..c60f274 100644 --- a/TaxPayerFull/Pages/UserPanel/Panel.razor +++ b/TaxPayerFull/Pages/UserPanel/Panel.razor @@ -215,10 +215,11 @@
- -
- -
+ @if (dashBoard != null) + { +
+ +
}