@Override
 protected final void checkParameters(final DocumentRequestCreateBean bean) {
   if (bean.getMobilityProgram() != null && bean.isIgnoreExternalEntries()) {
     throw new DomainException(
         "ApprovementCertificateRequest.cannot.ignore.external.entries.within.a.mobility.program");
   }
 }
  public ApprovementCertificateRequest(final DocumentRequestCreateBean bean) {
    this();
    super.init(bean);

    checkParameters(bean);
    super.setMobilityProgram(bean.getMobilityProgram());
    super.setIgnoreExternalEntries(bean.isIgnoreExternalEntries());
    super.setIgnoreCurriculumInAdvance(bean.isIgnoreCurriculumInAdvance());

    // TODO: remove this after DEA diplomas and certificates
    if (!isDEARegistration()) {

      if (getRegistration().isConcluded()) {
        throw new DomainException("ApprovementCertificateRequest.registration.is.concluded");
      }

      if (getRegistration().isRegistrationConclusionProcessed()) {
        throw new DomainException(
            "ApprovementCertificateRequest.registration.has.conclusion.processed");
      }
    }

    if (getEntriesToReport(isDEARegistration()).isEmpty()) {
      throw new DomainException("ApprovementCertificateRequest.registration.without.approvements");
    }
  }
  public ExternalCourseLoadRequest(final DocumentRequestCreateBean bean) {
    this();
    super.init(bean);

    checkParameters(bean);
    super.setNumberOfCourseLoads(bean.getNumberOfCourseLoads());
    super.setInstitution(bean.getInstitution());
  }
 @Override
 protected void checkParameters(final DocumentRequestCreateBean bean) {
   if (bean.getNumberOfCourseLoads() == null || bean.getNumberOfCourseLoads().intValue() == 0) {
     throw new DomainException("error.ExternalCourseLoadRequest.invalid.numberOfCourseLoads");
   }
   if (bean.getInstitution() == null) {
     throw new DomainException("error.ExternalCourseLoadRequest.invalid.institution");
   }
 }
  private static void createPaymentSituation(
      PastDiplomaRequest request, DocumentRequestCreateBean bean) {
    if (isPayed(bean)) {
      PastDegreeDiplomaRequestEvent event =
          new PastDegreeDiplomaRequestEvent(
              request.getAdministrativeOffice(),
              request.getPerson(),
              request,
              bean.getPastPaymentAmount());

      event.depositAmount(
          AccessControl.getPerson().getUser(),
          bean.getPastPaymentAmount(),
          createTransactionDetailDTO(bean));
    }
  }
 private static AccountingTransactionDetailDTO createTransactionDetailDTO(
     DocumentRequestCreateBean bean) {
   return new AccountingTransactionDetailDTO(
       bean.getPastPaymentDate().toDateTimeAtStartOfDay(), PaymentMode.CASH);
 }
 private static boolean isPayed(DocumentRequestCreateBean bean) {
   return bean.getPastPaymentAmount() != null && bean.getPastPaymentAmount().isPositive();
 }
  private static void createSituations(PastDiplomaRequest request, DocumentRequestCreateBean bean) {
    if (!bean.getRegistration().isRegistrationConclusionProcessed()) {
      throw new DomainException("DiplomaRequest.diploma.cannot.be.concluded");
    }

    LocalDate latestDate = bean.getPastRequestDate();
    if (bean.getPastPaymentDate() == null) {
      bean.setPastPaymentDate(latestDate);
    } else {
      latestDate =
          (latestDate.compareTo(bean.getPastPaymentDate()) < 0)
              ? bean.getPastPaymentDate()
              : latestDate;
    }
    if (bean.getPastEmissionDate() == null) {
      bean.setPastEmissionDate(latestDate);
    } else {
      latestDate =
          (latestDate.compareTo(bean.getPastEmissionDate()) < 0)
              ? bean.getPastEmissionDate()
              : latestDate;
    }
    if (bean.getPastDispatchDate() == null) {
      bean.setPastDispatchDate(latestDate);
    }

    createPaymentSituation(request, bean);
    process(request, bean.getPastRequestDate());
    request.setNumberOfPages(1);
    send(request, bean.getPastRequestDate());
    receive(request, bean.getPastRequestDate());
    conclude(request, bean.getPastEmissionDate());
    deliver(request, bean.getPastDispatchDate());
  }