diff --git a/Back/Back.csproj b/Back/Back.csproj index 899d7e4..fd97cd7 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -36,7 +36,7 @@ - ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll + ..\..\Dlls\Service.dll diff --git a/Back/Common/ExtentionMethods.cs b/Back/Common/ExtentionMethods.cs index bbcbd35..542165c 100644 --- a/Back/Common/ExtentionMethods.cs +++ b/Back/Common/ExtentionMethods.cs @@ -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(); diff --git a/Back/Services/servInvoice.cs b/Back/Services/servInvoice.cs index b13feb7..15ec723 100644 --- a/Back/Services/servInvoice.cs +++ b/Back/Services/servInvoice.cs @@ -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() { diff --git a/Back/Services/servUser.cs b/Back/Services/servUser.cs index 1e2e102..fd4661a 100644 --- a/Back/Services/servUser.cs +++ b/Back/Services/servUser.cs @@ -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 dt = new List(); + 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 - // { - // 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 + { + 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 + { + 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]); } diff --git a/Shared/DTOs/DashBoardDTO.cs b/Shared/DTOs/DashBoardDTO.cs index a172a25..33373a5 100644 --- a/Shared/DTOs/DashBoardDTO.cs +++ b/Shared/DTOs/DashBoardDTO.cs @@ -18,6 +18,9 @@ namespace Shared.DTOs public List Notifications { get; set; } = new List(); public List lastActivitiesSevices { get; set; }=new List(); public List>? MostInvoicedProduct { get; set; }=new List>(); + public List>? MostInvoicedCustomer { get; set; } = new List>(); + public decimal? SaleInMonth { get; set; } = 0; + public decimal? Salepercent { get; set; } = 0; } public class ServiceInDashBoardDTO { diff --git a/Shared/DTOs/IdName.cs b/Shared/DTOs/IdName.cs index ae87eaa..f78048e 100644 --- a/Shared/DTOs/IdName.cs +++ b/Shared/DTOs/IdName.cs @@ -17,6 +17,6 @@ namespace Shared.DTOs } public class IdNameByCount : IdName { - public int count { get; set; } + public decimal? count { get; set; } } } diff --git a/TaxPayerFull/Layout/MostInvoicedCustomer.razor b/TaxPayerFull/Layout/MostInvoicedCustomer.razor new file mode 100644 index 0000000..b0f698f --- /dev/null +++ b/TaxPayerFull/Layout/MostInvoicedCustomer.razor @@ -0,0 +1,55 @@ +@using Shared.DTOs +@using Front.Services +@inject HttpClientController hc; +@inject Fixedvalues fv; + +
+
+
+
فاکتور برای مشتری
+ هفنه گدشته +
+
+
    + @foreach (var item in model) + { +
  • +
    +
    + + + +
    +
    @item.count.Value.ToString("N0")
    عدد
    +
    +
  • + } + +
+
+
+
+ +@code { + [Parameter] public List>? model { get; set; } + private Modal cusmodal = default!; +} +@functions{ + public async Task CallBackCustomerItem(ActionInResultComponent result) + { + + } + public async Task CustomerItem(int ID) + { + var rsp = await hc.Get($"Customer/GetCustomer/{ID}"); + if (rsp.IsSuccessStatusCode) + { + var cus = await rsp.Content.ReadFromJsonAsync(); + var parameters = new Dictionary(); + parameters.Add("Cus", cus); + parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBackCustomerItem)); + await cusmodal.ShowAsync(title: "ویرایش اطلاعات", parameters: parameters); + } + } +} + diff --git a/TaxPayerFull/Layout/MostInvoicedProduct.razor b/TaxPayerFull/Layout/MostInvoicedProduct.razor index 38cc7ab..34d5ffd 100644 --- a/TaxPayerFull/Layout/MostInvoicedProduct.razor +++ b/TaxPayerFull/Layout/MostInvoicedProduct.razor @@ -1,6 +1,60 @@ @using Shared.DTOs -

MostInvoicedProduct

+@using Front.Services +@inject HttpClientController hc; +@inject Fixedvalues fv; + +
+
+
+
کالا های فاکتور شده
+ هفنه گدشته +
+
+
    + + @foreach (var item in model) + { + if (indexer == 6) + break; +
  • +
    +
    + + + +
    +
    @item.count.Value.ToString("N0")
    عدد
    +
    +
  • + indexer++; + } + +
+
+
+
@code { + int indexer = 1; [Parameter] public List>? model { get; set; } + private Modal codmodal = default!; +} +@functions{ + public async Task CallBackCodItem(ActionInResultComponent result) { } + public async Task CODItem(int ID) + { + var rsp = await hc.Get($"Cod/GetCod/{ID}"); + if (rsp.IsSuccessStatusCode) + { + var cod = await rsp.Content.ReadFromJsonAsync(); + var parameters = new Dictionary(); + var Unitrequest = await fv.GetUnits(); + parameters.Add("Cod", cod); + parameters.Add("Unitrequest", Unitrequest); + parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBackCodItem)); + await codmodal.ShowAsync(title: "ویرایش اطلاعات", parameters: parameters); + + } + + } } diff --git a/TaxPayerFull/Pages/UserPanel/Panel.razor b/TaxPayerFull/Pages/UserPanel/Panel.razor index f166249..ec21449 100644 --- a/TaxPayerFull/Pages/UserPanel/Panel.razor +++ b/TaxPayerFull/Pages/UserPanel/Panel.razor @@ -10,7 +10,7 @@ کاربری
-
+
@@ -22,7 +22,48 @@
- View Badge User + View Badge User +
+
+
+
+
+
+
+
+
+
+
+ +
+
گزارش فروش
+ این ماه +
+ @if (dashBoard != null && dashBoard.SaleInMonth.HasValue) + { +
+ @if (dashBoard.Salepercent.HasValue && dashBoard.Salepercent.Value>0) + { + if (dashBoard.Salepercent.Value>=100) + { + @dashBoard.Salepercent % + + } + else + { + @dashBoard.Salepercent % + + } + } + +
@dashBoard?.SaleInMonth.Value.ToString("N0") + ریال +
+
+ } + +
+
@@ -32,7 +73,7 @@
@if (dashBoard != null && dashBoard.AlistofServices.Any(w => w.PermissionID == 3)) { - +
@@ -45,7 +86,7 @@
@@ -54,7 +95,7 @@

مانده

@if (dashBoard.AlistofServices.Any(w => w.PermissionID == 3 && w.CalTypeID == 1)) { - @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 3 && w.CalTypeID == 1).Select(s => s.Remaining).First()>0) + @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 3 && w.CalTypeID == 1).Select(s => s.Remaining).First() > 0) { @@ -88,7 +129,7 @@ تا تاریخ @dashBoard.AlistofServices.Where(w => w.PermissionID == 3 && w.CalTypeID == 1).Select(s => s.Remaining).First().ToString().ShamciToFormatShamciinFront() } - else + else { @@ -114,7 +155,7 @@
@@ -123,7 +164,7 @@

مانده

@if (dashBoard.AlistofServices.Any(w => w.PermissionID == 4 && w.CalTypeID == 1)) { - @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 4 && w.CalTypeID == 1).Select(s => s.Remaining).First()>0) + @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 4 && w.CalTypeID == 1).Select(s => s.Remaining).First() > 0) { @@ -246,7 +287,7 @@

مانده

@if (dashBoard.AlistofServices.Any(w => w.PermissionID == 5 && w.CalTypeID == 1)) { - @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 5 && w.CalTypeID == 1).Select(s => s.Remaining).First()>0) + @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 5 && w.CalTypeID == 1).Select(s => s.Remaining).First() > 0) { @@ -315,7 +356,7 @@

مانده

@if (dashBoard.AlistofServices.Any(w => w.PermissionID == 16 && w.CalTypeID == 1)) { - @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 16 && w.CalTypeID == 1).Select(s => s.Remaining).First()>0) + @if (dashBoard.AlistofServices.Where(w => w.PermissionID == 16 && w.CalTypeID == 1).Select(s => s.Remaining).First() > 0) { @@ -360,28 +401,10 @@
} - + -
-
-
-
-
-
-
گزارش نمایه
- سال 1399 -
-
- 68.2% -

84,686تومان

-
-
-
-
-
-
-
+
@@ -389,163 +412,20 @@ - -
-
-
- -
-
-
- -
-
-
-
- - -
-
-
-
معاملات
- -
-
-
    -
  • -
    - User -
    -
    -
    - پی پال -
    ارسال پول
    -
    -
    -
    +82.6
    ریال -
    -
    -
  • -
  • -
    - User -
    -
    -
    - کیف پول -
    مک دی
    -
    -
    -
    +270.69
    ریال -
    -
    -
  • -
  • -
    - User -
    -
    -
    - منتقل کردن -
    بازپرداخت
    -
    -
    -
    +637.91
    ریال -
    -
    -
  • -
  • -
    - User -
    -
    -
    - کارت اعتباری -
    غذا سفارش داد
    -
    -
    -
    -838.71
    ریال -
    -
    -
  • -
  • -
    - User -
    -
    -
    - کیف پول -
    استارباکس
    -
    -
    -
    +203.33
    ریال -
    -
    -
  • -
  • -
    - User -
    -
    -
    - مسترکارت -
    غذا سفارش داد
    -
    -
    -
    -92.45
    ریال -
    -
    -
  • -
-
-
-
- + + @if (dashBoard != null) + { + + + } + + + @if (dashBoard!=null) + { + + + } +
@@ -556,7 +436,7 @@ if (!await localserv.OnlineUser()) nav.NavigateTo("/"); - dashBoard =await fv.GetDashBoard(); + dashBoard = await fv.GetDashBoard(); //var rsp = await hc.Get("User/GetDashBoard"); // if (rsp.IsSuccessStatusCode) // { diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index f8805c2..628e6c3 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() }) ; -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");