From c3571f76b820781d769a7e64d305dc7bb93e6cfa Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Mon, 4 Aug 2025 14:46:40 +0530 Subject: [PATCH] Changed the if condition in expense list API --- Marco.Pms.Services/Service/ExpensesService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Marco.Pms.Services/Service/ExpensesService.cs b/Marco.Pms.Services/Service/ExpensesService.cs index 38d554d..0443b2b 100644 --- a/Marco.Pms.Services/Service/ExpensesService.cs +++ b/Marco.Pms.Services/Service/ExpensesService.cs @@ -132,17 +132,16 @@ namespace Marco.Pms.Services.Service await _cache.AddExpensesListToCache(expenses: await expensesQuery.ToListAsync(), tenantId); // Apply permission-based filtering BEFORE any other filters or pagination. - - if (!hasViewAllPermissionTask.Result && hasViewSelfPermissionTask.Result) + if (hasViewAllPermissionTask.Result) + { + expensesQuery = expensesQuery.Where(e => e.CreatedById != loggedInEmployeeId || e.StatusId != Draft); + } + else if (hasViewSelfPermissionTask.Result) { // User only has 'View Self' permission, so restrict the query to their own expenses. _logger.LogInfo("User {EmployeeId} has 'View Self' permission. Restricting query to their expenses.", loggedInEmployeeId); expensesQuery = expensesQuery.Where(e => e.CreatedById == loggedInEmployeeId); } - else - { - expensesQuery = expensesQuery.Where(e => e.CreatedById != loggedInEmployeeId || e.StatusId != Draft); - } if (expenseFilter != null) {