Changed the if condition in expense list API
This commit is contained in:
parent
b9f2bc53c8
commit
c3571f76b8
@ -132,17 +132,16 @@ namespace Marco.Pms.Services.Service
|
|||||||
await _cache.AddExpensesListToCache(expenses: await expensesQuery.ToListAsync(), tenantId);
|
await _cache.AddExpensesListToCache(expenses: await expensesQuery.ToListAsync(), tenantId);
|
||||||
|
|
||||||
// Apply permission-based filtering BEFORE any other filters or pagination.
|
// Apply permission-based filtering BEFORE any other filters or pagination.
|
||||||
|
if (hasViewAllPermissionTask.Result)
|
||||||
if (!hasViewAllPermissionTask.Result && hasViewSelfPermissionTask.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.
|
// 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);
|
_logger.LogInfo("User {EmployeeId} has 'View Self' permission. Restricting query to their expenses.", loggedInEmployeeId);
|
||||||
expensesQuery = expensesQuery.Where(e => e.CreatedById == loggedInEmployeeId);
|
expensesQuery = expensesQuery.Where(e => e.CreatedById == loggedInEmployeeId);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
expensesQuery = expensesQuery.Where(e => e.CreatedById != loggedInEmployeeId || e.StatusId != Draft);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expenseFilter != null)
|
if (expenseFilter != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user