This commit is contained in:
mmrbnjd
2024-06-23 19:56:05 +03:30
parent 279ed3b843
commit 638baf02c8
4 changed files with 53 additions and 32 deletions

View File

@@ -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<string> dt = new List<string>();
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<int>
@@ -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<IdNameByCount<int>>()
//{
// new IdNameByCount<int>{ID=0,Title="1",count=10},
// new IdNameByCount<int>{ID=1,Title="2",count=5},
// new IdNameByCount<int>{ID=2,Title="3",count=12},
// new IdNameByCount<int>{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<int>
{
count = sumsale.Sum(),
ID = i - 1,
Title = i.ToString()
});
}
return request;
}
public async Task<User> UpdateUser(User user)

View File

@@ -19,6 +19,7 @@ namespace Shared.DTOs
public List<LastActivitySevice> lastActivitiesSevices { get; set; }=new List<LastActivitySevice>();
public List<IdNameByCount<int>>? MostInvoicedProduct { get; set; }=new List<IdNameByCount<int>>();
public List<IdNameByCount<int>>? MostInvoicedCustomer { get; set; } = new List<IdNameByCount<int>>();
public List<IdNameByCount<int>> ForSaleChart { get; set; } = new List<IdNameByCount<int>>();
public decimal? SaleInMonth { get; set; } = 0;
public decimal? Salepercent { get; set; } = 0;
}

View File

@@ -5,16 +5,10 @@
private LineChart lineChart = default!;
private LineChartOptions lineChartOptions = default!;
private ChartData chartData = default!;
public List<IdNameByCount<int>> items = new List<IdNameByCount<int>>();
[Parameter] public List<IdNameByCount<int>> items { get;set; }
protected override void OnInitialized()
{
items.AddRange(new List<IdNameByCount<int>>()
{
new IdNameByCount<int>{ID=0,Title="1",count=10},
new IdNameByCount<int>{ID=1,Title="2",count=5},
new IdNameByCount<int>{ID=2,Title="3",count=12},
new IdNameByCount<int>{ID=3,Title="4",count=21}
});
var colors = ColorBuilder.CategoricalTwelveColors;

View File

@@ -215,10 +215,11 @@
<div class="col-12 col-lg-8 order-2 order-md-3 order-lg-2 mb-4">
<div class="card col-12">
<div class="row row-bordered g-0">
<div class="col-md-12">
<SaleChart />
</div>
@if (dashBoard != null)
{
<div class="col-md-12">
<SaleChart items="dashBoard?.ForSaleChart" />
</div>}
</div>
</div>
</div>