class SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService {

    @Override
    @Transactional
    public ServiceResult<Void> approveOrRejectSpendProfile(Long projectId, ApprovalType approvalType) {
        Project project = projectRepository.findById(projectId).orElse(null);
        if (null != project && spendProfileWorkflowHandler.isReadyToApprove(project) &&
                (APPROVED.equals(approvalType) || REJECTED.equals(approvalType))) {
            updateApprovalOfSpendProfile(projectId, approvalType);
            return approveSpendProfile(approvalType, project);
        } else {
            return serviceFailure(SPEND_PROFILE_NOT_READY_TO_APPROVE);
        }
    }

}