This commit is contained in:
mmrbnjd
2024-06-20 18:22:34 +03:30
parent 2120c4d848
commit 309fac81d3
10 changed files with 258 additions and 212 deletions

View File

@@ -40,7 +40,7 @@ namespace Back.Services
.ThenInclude(inc => inc.CODUnit)
.Include(inc=>inc.sentTax)
//.Include(inc => inc.payments)
//.Include(inc => inc.pattern)
.Include(inc => inc.pattern)
.Select(s => new InvoiceDTO()
{
IsDeleted=s.IsDeleted,
@@ -135,7 +135,7 @@ namespace Back.Services
.ThenInclude(inc => inc.cODItem)
.ThenInclude(inc => inc.CODUnit)
//.Include(inc => inc.payments)
//.Include(inc => inc.pattern)
.Include(inc => inc.pattern)
.Select(s => new InvoiceGridDTO()
{

View File

@@ -295,27 +295,73 @@ namespace Back.Services
request.lastActivitiesSevices.Add(lastcus);
#endregion
try
{
var MostInvoicedProduct = await _invoiceitemRepo.Get(w => w.invoice.CompanyID == user.RolUsers.First().CompanyID
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.invoiceType == InvoiceType.Sale || w.invoice.invoiceType == InvoiceType.BackFrmSale
|| w.invoice.invoiceType == InvoiceType.Repair) && !w.invoice.BillReference.HasValue
)
//.Include(inc => inc.cODItem)
// .GroupBy(g => g.CODID)
// .Select(s => new IdNameByCount<int>
// {
// ID = s.Key,
// Title = s.Select(s => s.sstt).First(),
// count = Convert.ToInt32(s.Sum(s => s.am))
// }).OrderByDescending(o => o.count)
&& (dt.Contains(w.invoice.Cdate)))
.Include(inc => inc.cODItem)
.GroupBy(g => g.CODID)
.Select(s => new IdNameByCount<int>
{
ID = s.Key,
Title = s.Select(s => s.sstt).First(),
count = s.Sum(s => s.am)
}).OrderByDescending(o => o.count)
.ToListAsync();
}
catch (Exception ex)
{
throw;
request.MostInvoicedCustomer =await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID
&& (w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale
|| w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue
&& (dt.Contains(w.Cdate)))
.Include(inc => inc.Customer)
.GroupBy(g => g.CustomerID)
.Select(s => new IdNameByCount<int>
{
ID = s.Key,
Title = s.Select(s => s.Customer.FullName).First(),
count = s.Count()
}).OrderByDescending(o => o.count)
.ToListAsync();
var cdate = DateTime.Now.ConvertMiladiToShamsiAndGetYearMonth();
var sale = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID
&& (w.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale
|| w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue && w.Cdate.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.invoiceType == InvoiceType.Sale || w.invoiceType == InvoiceType.BackFrmSale
|| w.invoiceType == InvoiceType.Repair) && !w.BillReference.HasValue && w.Cdate.StartsWith(cdate))
.Include(inc => inc.invoiceDetails)
.ThenInclude(inc => inc.cODItem)
.ThenInclude(inc => inc.CODUnit)
.Include(inc => inc.pattern)
.Select(s => s.tbill)
.ToListAsync();
decimal? total = lastonthsale.Sum();
decimal? part = request.SaleInMonth;
//decimal? total = 17892909;
//decimal? part = request.SaleInMonth;
if (total.HasValue && total.Value > 0)
{
if (!part.HasValue) part = 0;
request.Salepercent =decimal.Parse( ((part.Value / total.Value) * 100).ToString().Split('.')[0]);
}