mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix patch lunas BOP
This commit is contained in:
@@ -1326,14 +1326,16 @@ func (s *expenseService) Pay(c *fiber.Ctx, id uint) (*expenseDto.ExpenseDetailDT
|
|||||||
return nil, fiber.NewError(fiber.StatusBadRequest, "Expense is already paid")
|
return nil, fiber.NewError(fiber.StatusBadRequest, "Expense is already paid")
|
||||||
}
|
}
|
||||||
|
|
||||||
latestApproval, err := s.ApprovalSvc.LatestByTarget(c.Context(), utils.ApprovalWorkflowExpense, id, nil)
|
latestApproval, err := s.ApprovalSvc.LatestByTarget(c.Context(), utils.ApprovalWorkflowExpense, id, func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Where("action = ?", entity.ApprovalActionApproved)
|
||||||
|
})
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to validate workflow")
|
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to validate workflow")
|
||||||
}
|
}
|
||||||
if latestApproval == nil {
|
if latestApproval == nil {
|
||||||
return nil, fiber.NewError(fiber.StatusBadRequest, "No approval found. Please create expense first.")
|
return nil, fiber.NewError(fiber.StatusBadRequest, "Expense must be approved by Finance (step 4) before payment")
|
||||||
}
|
}
|
||||||
if latestApproval.StepNumber < uint16(utils.ExpenseStepFinance) || latestApproval.Action == nil || *latestApproval.Action != entity.ApprovalActionApproved {
|
if latestApproval.StepNumber < uint16(utils.ExpenseStepFinance) {
|
||||||
return nil, fiber.NewError(fiber.StatusBadRequest, "Expense must be approved by Finance (step 4) before payment")
|
return nil, fiber.NewError(fiber.StatusBadRequest, "Expense must be approved by Finance (step 4) before payment")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user