panel
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -43,6 +43,14 @@ namespace Back.Common
|
||||
PersianCal.GetDayOfMonth(date).ToString("00")
|
||||
;
|
||||
}
|
||||
public static string ConvertMiladiToShamsiAndGetYearMonth(this DateTime date)
|
||||
{
|
||||
PersianCalendar PersianCal = new PersianCalendar();
|
||||
return
|
||||
PersianCal.GetYear(date).ToString("0000") +
|
||||
PersianCal.GetMonth(date).ToString("00");
|
||||
|
||||
}
|
||||
public static string ConvertMiladiToShamsiByTime(this DateTime date)
|
||||
{
|
||||
PersianCalendar PersianCal = new PersianCalendar();
|
||||
|
@@ -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()
|
||||
{
|
||||
|
||||
|
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user