class SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService {

    @Override
    @Transactional
    public ServiceResult<Void> completeSpendProfilesReview(Long projectId) {
        return getProject(projectId).andOnSuccess(project -> {
            if (project.getSpendProfiles().stream().anyMatch(spendProfile -> !spendProfile.isMarkedAsComplete())) {
                return serviceFailure(SPEND_PROFILES_MUST_BE_COMPLETE_BEFORE_SUBMISSION);
            }
            if (spendProfileWorkflowHandler.submit(project)) {
                project.setSpendProfileSubmittedDate(ZonedDateTime.now());
                updateApprovalOfSpendProfile(projectId, ApprovalType.UNSET);
                return serviceSuccess();
            } else {
                return serviceFailure(SPEND_PROFILES_HAVE_ALREADY_BEEN_SUBMITTED);
            }
        });
    }

}