This commit is contained in:
mmrbnjd
2024-06-18 17:45:46 +03:30
parent e8c0bed48f
commit 2120c4d848

View File

@@ -295,17 +295,29 @@ namespace Back.Services
request.lastActivitiesSevices.Add(lastcus);
#endregion
request.MostInvoicedProduct = await _invoiceitemRepo.Get(w => w.invoice.CompanyID == user.RolUsers.First().CompanyID
try
{
var 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)
|| 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)
.ToListAsync();
}
catch (Exception ex)
{
throw;
}
return request;
}