feat: Add expense analytics and dashboard support - #42
Merged
Conversation
banuka20431
approved these changes
Jun 9, 2026
There was a problem hiding this comment.
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
ExpenseAnalyticsResultmodel. - 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.
| @@ -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"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.