class SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService {

    private ServiceResult<Void> approveSpendProfile(ApprovalType approvalType, Project project) {
        return getCurrentlyLoggedInUser().andOnSuccess(user -> {
            if (approvalType.equals(APPROVED)) {
                if (spendProfileWorkflowHandler.spendProfileApproved(project, user))
                    return serviceSuccess();
                else
                    return serviceFailure(SPEND_PROFILE_CANNOT_BE_APPROVED);
            }
            if (approvalType.equals(REJECTED)) {
                if (spendProfileWorkflowHandler.spendProfileRejected(project, user))
                    return serviceSuccess();
                else
                    return serviceFailure(SPEND_PROFILE_CANNOT_BE_REJECTED);
            }
            return serviceFailure(SPEND_PROFILE_NOT_READY_TO_APPROVE);
        });
    }

}