...
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user