From 0561e356d8111d9fe24ecbc73b63c4f36dfdd1c9 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Mon, 6 Oct 2025 15:29:00 +0530 Subject: [PATCH] Added the condition to get all records in expense monthly report API --- .../Controllers/DashboardController.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Marco.Pms.Services/Controllers/DashboardController.cs b/Marco.Pms.Services/Controllers/DashboardController.cs index 901027b..4cf27de 100644 --- a/Marco.Pms.Services/Controllers/DashboardController.cs +++ b/Marco.Pms.Services/Controllers/DashboardController.cs @@ -618,9 +618,6 @@ namespace Marco.Pms.Services.Controllers [HttpGet("expense/monthly")] public async Task GetExpenseReportByProjectsAsync([FromQuery] Guid? projectId, [FromQuery] Guid? categoryId, [FromQuery] int months) { - months = 0 - months; - var end = DateTime.UtcNow.Date; - var start = end.AddMonths(months); // inclusive EOD try { @@ -630,15 +627,22 @@ namespace Marco.Pms.Services.Controllers .Where(e => e.TenantId == tenantId && e.IsActive - && e.StatusId != Draft - && e.TransactionDate >= start - && e.TransactionDate <= end); // [Server Filters] + && e.StatusId != Draft); // [Server Filters] + + if (months != 0) + { + months = 0 - months; + var end = DateTime.UtcNow.Date; + var start = end.AddMonths(months); // inclusive EOD + baseQuery = baseQuery.Where(e => e.TransactionDate >= start + && e.TransactionDate <= end); + } if (projectId.HasValue) - baseQuery.Where(e => e.ProjectId == projectId); + baseQuery = baseQuery.Where(e => e.ProjectId == projectId); if (categoryId.HasValue) - baseQuery.Where(e => e.ExpensesTypeId == categoryId); + baseQuery = baseQuery.Where(e => e.ExpensesTypeId == categoryId); // Single server-side group/aggregate by project var report = await baseQuery