-
-
-
-
Top 50 most purchased items
-
-
- @foreach (MostPurchasedItem purchasedItem in m_items.Take(5))
- {
-
- @($"{purchasedItem.ProductName} x{purchasedItem.NbrTimesSold}")
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @detail.ProductName
- @detail.ProductId
-
-
- Revenue: @m_calculator.FormatMoneyWithCurrencyKilo((double)detail.Revenue)
- Quantity Sold: @detail.NbrTimesSold
-
-
-
-
-
-
-
+
+
- }
+
+
+
+
+
+
+
+ @detail.ProductName
+ @detail.ProductId
+
+
+ Revenue: @m_calculator.FormatMoneyWithCurrencyKilo((double)detail.Revenue)
+ Quantity Sold: @detail.NbrTimesSold
+
+
+
+
+
+
+
+
}
else
{
@@ -77,4 +52,4 @@ else
justify-content: space-between;
flex-wrap: wrap;
}
-
\ No newline at end of file
+
diff --git a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor
new file mode 100644
index 0000000..eb03db0
--- /dev/null
+++ b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor
@@ -0,0 +1,18 @@
+@using Biskilog_Accounting.Shared.CustomModels;
+@using Biskilog_Accounting.Shared.Interfaces;
+@inject ICalculator m_calculator
+@if (!IsLoading)
+{
+
+}
+else
+{
+
+}
\ No newline at end of file
diff --git a/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs
new file mode 100644
index 0000000..7a83d41
--- /dev/null
+++ b/Client/Pages/Dashboard/Elements/ProductPriceHistory.razor.cs
@@ -0,0 +1,75 @@
+using ApexCharts;
+using Biskilog_Accounting.Shared.CustomModels;
+using Microsoft.AspNetCore.Components;
+
+namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements
+{
+ public partial class ProductPriceHistory
+ {
+ [Parameter]
+ public List
ProductHistory { get; set; }
+ [Parameter]
+ public bool IsLoading { get; set; } = true;
+ private List m_productHistory { get; set; } = new List();
+ private string m_currentProduct = string.Empty;
+ private double m_percentage { get; set; } = 0;
+ private bool m_increase { get; set; } = false;
+ private double m_currentPrice { get; set; } = 0;
+ private ApexChartOptions options = new ApexChartOptions();
+ private string m_productName { get; set; }= string.Empty;
+ private string m_subtitle { get;set; } = string.Empty;
+ private string m_title { get;set; } = string.Empty;
+ protected override void OnInitialized()
+ {
+
+ base.OnInitialized();
+ }
+ protected override void OnParametersSet()
+ {
+ if (!IsLoading)
+ {
+ options.Colors = new List { "#f4c414" };
+
+ options.Fill = new Fill
+ {
+ Type = new List { FillType.Gradient, FillType.Gradient },
+ Gradient = new FillGradient
+ {
+ ShadeIntensity = 1,
+ OpacityFrom = 0.2,
+ OpacityTo = 0.9,
+ }
+ };
+
+ options.Yaxis = new List
+ {
+ new YAxis
+ {
+ Labels = new YAxisLabels
+ {
+ Formatter = @"function (value, index, w) {
+ return Number(value).toLocaleString();}"
+ }
+ }
+ };
+
+ Random random = new Random();
+ int randomNumber = random.Next(ProductHistory.Count);
+ m_currentProduct = ProductHistory[randomNumber].Pcode;
+ m_productHistory = ProductHistory.Where(t => t.Pcode == m_currentProduct).ToList();
+
+ if (m_productHistory.Count > 0)
+ {
+ ProductPriceChange change = m_productHistory.First();
+ m_percentage = (double)((change.CurrentPrice - change.PreviousPrice) / change.PreviousPrice * 100);
+ m_increase = change.CurrentPrice > change.PreviousPrice;
+ m_currentPrice = (double)change.CurrentPrice;
+ m_productName = change.ProductName;
+ m_subtitle = $"Price :{m_calculator.GetCurrencyCode().CurrencySymbol}";
+ m_title = $"{m_productName} Price Changes";
+ }
+ }
+ base.OnParametersSet();
+ }
+ }
+}
diff --git a/Server/Controllers/AnalyticsController.cs b/Server/Controllers/AnalyticsController.cs
index a51a433..912a5b8 100644
--- a/Server/Controllers/AnalyticsController.cs
+++ b/Server/Controllers/AnalyticsController.cs
@@ -132,5 +132,14 @@ namespace Biskilog_Accounting.Server.Controllers
{
return m_analyticService.GetRecentPriceChanges(a_limit);
}
+ ///
+ /// Endpoint to return analysis on product price change history
+ ///
+ [Authorize]
+ [HttpGet, Route("pricechanges/product/history/{a_limit}")]
+ public IEnumerable GetPriceChangeHistory(int a_limit)
+ {
+ return m_analyticService.GetProductPriceChangeHistory(a_limit);
+ }
}
}
diff --git a/Server/Services/AnalyticalService.cs b/Server/Services/AnalyticalService.cs
index 82a1fe9..3140718 100644
--- a/Server/Services/AnalyticalService.cs
+++ b/Server/Services/AnalyticalService.cs
@@ -181,7 +181,38 @@ namespace Biskilog_Accounting.Server.Services
public IEnumerable GetProductPriceChangeHistory(int a_limit)
{
- throw new NotImplementedException();
+ string token = m_httpContext.Request.Headers[HeaderNames.Authorization]!;
+
+ if (AuthEnums.Valid == m_tokenService.ValidateToken(token))
+ {
+ IEnumerable accessiblebranches = m_tokenService.BranchIds(token);
+
+ using (var command = m_context.Database.GetDbConnection().CreateCommand())
+ {
+ command.CommandText = "CALL GetProductPriceChangeHistory(@p0,@p1)";
+ command.Parameters.Add(new MySqlParameter("@p0", string.Join(", ", accessiblebranches.ToArray())));
+ command.Parameters.Add(new MySqlParameter("@p1", a_limit));
+
+ m_context.Database.OpenConnection();
+
+ using (var reader = command.ExecuteReader())
+ {
+ while (reader.Read())
+ {
+ yield return new ProductPriceChange
+ {
+ Pcode = reader.GetString(0),
+ ProductName = reader.GetString(1),
+ PreviousPrice = reader.GetDecimal(2),
+ CurrentPrice = reader.GetDecimal(3),
+ ChangeDate = reader.GetDateTime(4),
+ BranchId = reader.GetString(5),
+ CountId = reader.GetString(6),
+ };
+ }
+ }
+ }
+ }
}
public IEnumerable GetRecentPriceChanges(int a_limit)