Skip to content

feat: Add expense analytics and dashboard support - #42

Merged
banuka20431 merged 1 commit into
mainfrom
dev/rashmika
Jun 9, 2026
Merged

feat: Add expense analytics and dashboard support#42
banuka20431 merged 1 commit into
mainfrom
dev/rashmika

Conversation

@rashmika0729shehan

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 9, 2026 19:26
@banuka20431
banuka20431 merged commit 8712efa into main Jun 9, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the existing analytics flow to support an Expenses dashboard alongside the Sales dashboard, including retrieving expense records from SQLite, computing expense analytics, and updating the dashboard UI to conditionally display Sales vs. Expense modules.

Changes:

  • Added async expense data retrieval by date range and hooked it into the “Run Analysis” flow.
  • Implemented expense analytics aggregation (totals, breakdowns, trends, anomalies) and a new ExpenseAnalyticsResult model.
  • Updated the analytics dashboard view/viewmodel to support switching UI modules (Sales vs Expenses) via bindings.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Views/ProcessView.xaml.cs Runs either Sales or Expenses analysis and opens the dashboard; now fetches expenses from SQLite for a selected date range.
Views/AnalyticsDashboardView.xaml Adds bindings and sections for displaying Expenses charts/cards and a dynamic subtitle.
ViewModels/AnalyticsDashboardViewModel.cs Adds Expenses-specific properties/constructor and visibility toggles for Sales vs Expenses dashboard modes.
Services/ExpensesAnalysisService.cs Replaces placeholder logic with real expense analytics computations (totals, groupings, trend, anomalies).
Services/Data/Repository/ExpensesRecordRepository.cs Adds a date-range query method for expenses records.
Models/ExpenseAnalyticsResult.cs Introduces a model to transport computed expense analytics to the dashboard VM.
nexgensales.csproj Adds a Database\ folder entry to the project.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Views/ProcessView.xaml.cs
@@ -93,23 +97,60 @@ private void BtnRunAnalysis_Click(object sender, RoutedEventArgs e)

if (reportType == "Expense Data")
Comment on lines +117 to +120
using var command = new Microsoft.Data.Sqlite.SqliteCommand(sql, connection);
command.Parameters.AddWithValue("@StartDate", startDate.ToString("yyyy-MM-dd HH:mm:ss"));
command.Parameters.AddWithValue("@EndDate", endDate.ToString("yyyy-MM-dd HH:mm:ss"));

Comment on lines +26 to +29
// New Chart 1: Daily expense trend (for Line Chart)
result.DailyTrend = expenses
.GroupBy(e => e.Date_Recorded.ToString("MMM dd"))
.ToDictionary(g => g.Key, g => g.Sum(e => e.Amount));
Comment on lines 148 to +152
public string GenerateReport(List<(string Title, FrameworkElement Chart)> charts)
{
string filePath = ReportFileNameHelper.Generate(_reportType);
return _service.GenerateReport(charts, filePath);
if (_reportType == "Sales") return _salesService.GenerateReport(charts, filePath);
else return string.Empty;
Comment on lines +79 to +80
// Subtitle for the expenses dashboard
DashboardSubtitle = "Expenses simulation data — 5 analysis modules";
VerticalAlignment="Center"
Width="200" Height="44"
Click="GenerateReport_Click"/>
<Button x:Name="GenerateReportButton" Content="🖨 Generate Report" Style="{StaticResource TealButton}" HorizontalAlignment="Right" VerticalAlignment="Center" Width="200" Height="44" Click="GenerateReport_Click"/>
<TextBlock Text="5 analyses complete — ready for export"
Foreground="#788896" FontSize="13"
VerticalAlignment="Center"/>
<TextBlock Text="Analysis complete — ready for export" Foreground="#788896" FontSize="13" VerticalAlignment="Center"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants