Added the condition to get all records in expense monthly report API

This commit is contained in:
ashutosh.nehete 2025-10-06 15:29:00 +05:30
parent e2ee3f325c
commit 0561e356d8

View File

@ -618,9 +618,6 @@ namespace Marco.Pms.Services.Controllers
[HttpGet("expense/monthly")]
public async Task<IActionResult> 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