Updated the expense details API
This commit is contained in:
parent
6a300db97c
commit
0395b46610
@ -17,7 +17,6 @@ namespace Marco.Pms.Model.Expenses
|
||||
|
||||
public ICollection<BillAttachments> Attachments { get; set; } = new List<BillAttachments>();
|
||||
public ICollection<ExpensesReimburseMapping> ExpensesReimburseMappings { get; set; } = new List<ExpensesReimburseMapping>();
|
||||
public ICollection<ExpenseLog> ExpenseLogs { get; set; } = new List<ExpenseLog>();
|
||||
|
||||
public Guid ExpenseCategoryId { get; set; }
|
||||
|
||||
|
||||
@ -528,9 +528,6 @@ namespace Marco.Pms.Services.Service
|
||||
.ThenInclude(erm => erm.ExpensesReimburse)
|
||||
.ThenInclude(er => er!.ReimburseBy)
|
||||
.ThenInclude(e => e!.JobRole)
|
||||
.Include(e => e.ExpenseLogs)
|
||||
.ThenInclude(el => el.UpdatedBy)
|
||||
.ThenInclude(e => e!.JobRole)
|
||||
.FirstOrDefaultAsync(e =>
|
||||
(e.Id == id || (e.UIDPrefix + "/" + e.UIDPostfix.ToString().PadLeft(5, '0')) == expenseUId)
|
||||
&& e.TenantId == tenantId);
|
||||
@ -563,6 +560,15 @@ namespace Marco.Pms.Services.Service
|
||||
var projectVm = await GetProjectDetailsAsync(expense.ProjectId, tenantId);
|
||||
response.Project = projectVm;
|
||||
|
||||
response.ExpenseLogs = await _context.ExpenseLogs
|
||||
.AsNoTracking() // Read-only query optimization
|
||||
.Include(el => el.UpdatedBy)
|
||||
.ThenInclude(e => e!.JobRole)
|
||||
.Where(el => el.ExpenseId == expense.Id)
|
||||
.OrderByDescending(el => el.UpdateAt)
|
||||
.ProjectTo<ExpenseLogVM>(_mapper.ConfigurationProvider) // Projection
|
||||
.ToListAsync();
|
||||
|
||||
// 9. Generate S3 Pre-signed URLs for attachments
|
||||
response.Documents = expense.Attachments
|
||||
.Where(ba => ba.Document != null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user