update mobile view for expense.
This commit is contained in:
@@ -174,8 +174,8 @@ public class ExpenseService : IExpenseService
|
||||
// FirstOrDefaultAsync (not FindAsync) so the soft-delete query filter applies.
|
||||
var e = await _db.Expenses.FirstOrDefaultAsync(x => x.Id == id)
|
||||
?? throw new KeyNotFoundException($"Expense {id} not found.");
|
||||
if (!isFinance && !(e.SubmittedBy == CurrentUserId && e.Status == "Draft"))
|
||||
throw new InvalidOperationException("You can only edit your own draft reimbursements.");
|
||||
if (!isFinance && !(e.SubmittedBy == CurrentUserId && (e.Status == "Draft" || e.Status == "PendingApproval")))
|
||||
throw new InvalidOperationException("You can only edit your own draft or pending reimbursements.");
|
||||
|
||||
e.MinistryId = r.MinistryId; e.CategoryGroupId = r.CategoryGroupId; e.SubCategoryId = r.SubCategoryId;
|
||||
e.Amount = r.Amount; e.Description = r.Description; e.CheckNumber = r.CheckNumber;
|
||||
@@ -245,8 +245,8 @@ public class ExpenseService : IExpenseService
|
||||
public async Task SaveReceiptAsync(int id, Stream content, string fileName, bool isFinance)
|
||||
{
|
||||
var e = await RequireAsync(id);
|
||||
if (!isFinance && e.SubmittedBy != CurrentUserId)
|
||||
throw new InvalidOperationException("You can only attach receipts to your own reimbursements.");
|
||||
if (!isFinance && !(e.SubmittedBy == CurrentUserId && (e.Status == "Draft" || e.Status == "PendingApproval")))
|
||||
throw new InvalidOperationException("You can only attach receipts to your own draft or pending reimbursements.");
|
||||
|
||||
var safe = Path.GetFileName(fileName).Replace(' ', '_');
|
||||
var path = $"finance/receipts/{e.ExpenseDate.Year}/{e.ExpenseDate.Month}/{e.Id}-{safe}";
|
||||
|
||||
Reference in New Issue
Block a user