Example usage for org.joda.time LocalDate toDateTimeAtStartOfDay

List of usage examples for org.joda.time LocalDate toDateTimeAtStartOfDay

Introduction

In this page you can find the example usage for org.joda.time LocalDate toDateTimeAtStartOfDay.

Prototype

public DateTime toDateTimeAtStartOfDay() 

Source Link

Document

Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

Usage

From source file:org.fenixedu.treasury.domain.document.DebitNote.java

License:Open Source License

@Atomic
public void edit(final DebtAccount payorDebtAccount, final LocalDate documentDate, LocalDate documentDueDate,
        final String originDocumentNumber) {

    setPayorDebtAccount(payorDebtAccount);
    setDocumentDate(documentDate.toDateTimeAtStartOfDay());
    setDocumentDueDate(documentDueDate);
    setOriginDocumentNumber(originDocumentNumber);

    checkRules();/*w  ww  .j a  v  a2 s .  c  o m*/
}

From source file:org.fenixedu.treasury.domain.paymentcodes.pool.PaymentCodePool.java

License:Open Source License

public List<PaymentReferenceCode> getPaymentCodesToExport(LocalDate localDate) {
    if (this.getUseCheckDigit()) {
        return Collections.EMPTY_LIST;
    } else {/* ww w .  j a  va  2s . c  o m*/
        return this.getPaymentReferenceCodesSet().stream()
                .filter(x -> x.getState().equals(PaymentReferenceCodeStateType.ANNULLED) == false)
                .filter(x -> x.getValidInterval().contains(localDate.toDateTimeAtStartOfDay()))
                .collect(Collectors.toList());
    }
}

From source file:org.fenixedu.treasury.domain.paymentcodes.pool.PaymentCodePool.java

License:Open Source License

public List<PaymentReferenceCode> getAnnulledPaymentCodesToExport(LocalDate localDate) {
    if (this.getUseCheckDigit()) {
        return Collections.EMPTY_LIST;
    } else {/* w  w  w. jav a  2 s .  c  o  m*/
        return this.getPaymentReferenceCodesSet().stream()
                .filter(x -> x.getState().equals(PaymentReferenceCodeStateType.ANNULLED) == true)
                .filter(x -> x.getValidInterval().contains(localDate.toDateTimeAtStartOfDay()))
                .collect(Collectors.toList());
    }
}

From source file:org.fenixedu.treasury.services.integration.erp.ERPIntegrationService.java

License:Open Source License

@Atomic
private void processInterestEntries(final DebitEntry debitEntry, final InterestRateBean interestRateBean,
        final LocalDate paymentDate) {

    DocumentNumberSeries debitNoteSeries = DocumentNumberSeries
            .find(FinantialDocumentType.findForDebitNote(),
                    debitEntry.getDebtAccount().getFinantialInstitution())
            .filter(x -> Boolean.TRUE.equals(x.getSeries().getDefaultSeries())).findFirst().orElse(null);

    final DebitNote interestDebitNote = DebitNote.create(debitEntry.getDebtAccount(), debitNoteSeries,
            paymentDate.toDateTimeAtStartOfDay());

    debitEntry.createInterestRateDebitEntry(interestRateBean, paymentDate.toDateTimeAtStartOfDay(),
            Optional.<DebitNote>ofNullable(interestDebitNote));
    interestDebitNote.closeDocument();//w  w w .  j  a v  a2 s .c o m
}

From source file:org.fenixedu.treasury.ui.administration.base.managefixedtariff.FixedTariffController.java

License:Open Source License

@Atomic
public FixedTariff createFixedTariff(java.math.BigDecimal amount, boolean applyInterests,
        org.joda.time.LocalDate beginDate,
        org.fenixedu.treasury.domain.tariff.DueDateCalculationType dueDateCalculationType,
        org.joda.time.LocalDate endDate, org.fenixedu.treasury.domain.FinantialEntity finantialEntity,
        org.joda.time.LocalDate fixedDueDate, int numberOfDaysAfterCreationForDueDate,
        FixedTariffInterestRateBean interestRateBean, Product product) {
    InterestRate interestRate = null;//from w w  w  . j a v a  2  s  . c o m

    FixedTariff fixedTariff = FixedTariff.create(product, interestRate, finantialEntity, amount,
            beginDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay(), dueDateCalculationType,
            fixedDueDate, numberOfDaysAfterCreationForDueDate, false);
    if (applyInterests) {
        interestRate = InterestRate.createForTariff(fixedTariff, interestRateBean.getInterestType(),
                interestRateBean.getNumberOfDaysAfterDueDate(), interestRateBean.getApplyInFirstWorkday(),
                interestRateBean.getMaximumDaysToApplyPenalty(),
                interestRateBean.getMaximumMonthsToApplyPenalty(), interestRateBean.getInterestFixedAmount(),
                interestRateBean.getRate());
        fixedTariff.setInterestRate(interestRate);
        fixedTariff.setApplyInterests(true);
    }
    fixedTariff.checkRules();
    return fixedTariff;
}

From source file:org.fenixedu.ulisboa.specifications.domain.evaluation.markSheet.CompetenceCourseMarkSheet.java

License:Open Source License

@Atomic
public void edit(final LocalDate evaluationDate, final GradeScale gradeScale, final Person certifier,
        final LocalDate expireDate) {

    if (!isEdition()) {
        throw new ULisboaSpecificationsDomainException(
                "error.CompetenceCourseMarkSheet.markSheet.can.only.be.updated.in.edition.state");
    }//from  ww w  . j  a  va 2  s  .  c  o m

    getEnrolmentEvaluationSet().forEach(e -> {
        e.setExamDateYearMonthDay(
                evaluationDate == null ? null : evaluationDate.toDateTimeAtStartOfDay().toYearMonthDay());
        e.setPersonResponsibleForGrade(certifier);
    });

    init(getExecutionSemester(), getCompetenceCourse(), getExecutionCourse(), getEvaluationSeason(),
            evaluationDate, gradeScale, certifier, getShiftSet(), expireDate);

    checkRules();
}

From source file:org.fenixedu.ulisboa.specifications.service.StudentActive.java

License:Open Source License

public static boolean isActiveStudent(Student student) {
    boolean hasActiveRegistrationsWithEnrolments = false;
    boolean activeRegistrationCreatedInTheLastMonth = false;
    boolean isFirstYearFirstTime = false;
    //        boolean isOtherKindOfCandidate = false;

    // Handling the override list, more info about what his hack is can be read in the 
    // comments of ActiveStudentOverride class
    if (student != null && student.getPerson() != null
            && ActiveStudentOverride.isOverrideAvailablefor(student.getPerson())) {
        return true;
    }// w w w .  ja v  a2  s .c om

    if (student != null) {
        ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
        ExecutionYear previousExecutionYear = currentExecutionYear.getPreviousExecutionYear();
        Predicate<? super Registration> registrationHasEnrolmentsInLast2Years = registration -> !registration
                .getEnrolments(currentExecutionYear).isEmpty()
                || !registration.getEnrolments(previousExecutionYear).isEmpty();
        List<Registration> activeRegistrations = student.getActiveRegistrations();
        hasActiveRegistrationsWithEnrolments = !activeRegistrations.stream()
                .filter(registrationHasEnrolmentsInLast2Years).collect(Collectors.toList()).isEmpty();

        if (!hasActiveRegistrationsWithEnrolments) {
            // There are special kinds of students, for example in protocols, where they are created in Fenix,
            // without a candidacy and where they have no enrolments. Although we still want them to be considered 
            // active students so the attribute ULStudentActive is sent to LDAP with TRUE so the campus account is 
            // created.
            //
            // To take into account these special cases we'll check active registrations for the student and
            // see if any of them were created in the last month, if so we'll consider it's an active student.
            //
            // This solution was discussed with Joo Rafael and Daniela Mendes from ULisboa.
            //
            // 21 August 2015 - Paulo Abrantes
            //
            // UPDATE UPDATE UPDATE
            // 
            // There was a modification in the code so that registrationYear is a setter property, and we'll
            // now start using that slot instead of looking at the last active state.
            //
            // 15 September 2015 - Paulo Abrantes
            LocalDate today = new LocalDate();
            DateTime lastMonth = today.toDateTimeAtStartOfDay().minusMonths(1);
            for (Registration activeRegistration : activeRegistrations) {
                activeRegistrationCreatedInTheLastMonth = activeRegistration
                        .getRegistrationYear() == currentExecutionYear;

                if (!activeRegistrationCreatedInTheLastMonth) {
                    RegistrationState lastRegistrationState = activeRegistration
                            .getLastRegistrationState(currentExecutionYear);
                    activeRegistrationCreatedInTheLastMonth = lastRegistrationState != null
                            && lastRegistrationState.isActive() && lastRegistrationState.getStateDate() != null
                            && lastRegistrationState.getStateDate().isAfter(lastMonth);
                }
                if (activeRegistrationCreatedInTheLastMonth) {
                    break;
                }
            }
        }
        //
        // Detect if it's 1st year, 1st time
        //
        if (!hasActiveRegistrationsWithEnrolments && !activeRegistrationCreatedInTheLastMonth) {
            isFirstYearFirstTime = student.getPerson().getCandidaciesSet().stream()
                    .filter(candidacy -> candidacy instanceof StudentCandidacy)
                    .map(StudentCandidacy.class::cast)
                    .anyMatch(studentCandidacy -> studentCandidacy.isActive()
                            && studentCandidacy.getEntryPhase() != null
                            && studentCandidacy.getExecutionYear() == currentExecutionYear);
        }

        // Removing detecion of other kind of candidate (still leaving the code just in case) 
        // Ana Rute asked us to not send other candidates has active students, only 1stYearFirstTime.
        // This will be sent with the student flag active (and then synchronized with IDM) when they 
        // finalize their candidacy situation and become an actual student
        //
        // 27 July 2015 - Paulo Abrantes
        //            isOtherKindOfCandidate =
        //                    student.getPerson()
        //                            .getCandidaciesSet()
        //                            .stream()
        //                            .filter(candidacy -> candidacy instanceof StudentCandidacy)
        //                            .map(StudentCandidacy.class::cast)
        //                            .anyMatch(
        //                                    candidacy -> candidacy.getRegistration() != null && candidacy.getRegistration().isActive()
        //                                            && candidacy.getExecutionYear() == currentExecutionYear);
    }

    return hasActiveRegistrationsWithEnrolments || isFirstYearFirstTime
            || activeRegistrationCreatedInTheLastMonth;
}

From source file:org.fenixedu.ulisboa.specifications.ui.evaluation.managelooseevaluation.LooseEvaluationController.java

License:Open Source License

@Atomic
public void createLooseEvaluation(Enrolment enrolment, LocalDate examDate, Grade grade, LocalDate availableDate,
        EvaluationSeason type, ExecutionSemester improvementSemester) {

    final EnrolmentEvaluation evaluation = new EnrolmentEvaluation(enrolment, type);
    if (type.isImprovement()) {
        evaluation.setExecutionPeriod(improvementSemester);
    }/* www .j a v  a  2 s.  c o  m*/

    evaluation.edit(Authenticate.getUser().getPerson(), grade, availableDate.toDate(),
            examDate.toDateTimeAtStartOfDay().toDate());
    evaluation.confirmSubmission(Authenticate.getUser().getPerson(), "");
    EnrolmentServices.updateState(enrolment);
    CurriculumLineServices.updateAggregatorEvaluation(enrolment);
    EnrolmentEvaluationServices.onStateChange(evaluation);
}

From source file:org.fornax.cartridges.sculptor.framework.accessimpl.mongodb.JodaLocalDateMapper.java

License:Apache License

public Date toData(LocalDate from) {
    if (from == null) {
        return null;
    }// w w  w.ja  va  2s  .  c o  m
    return from.toDateTimeAtStartOfDay().toDate();
}

From source file:org.incode.module.document.dom.impl.docs.DocumentRepository.java

License:Apache License

@Programmatic
public List<Document> findBetween(final LocalDate startDate, final LocalDate endDateIfAny) {

    final DateTime startDateTime = startDate.toDateTimeAtStartOfDay();

    final QueryDefault<Document> query;
    if (endDateIfAny != null) {
        final DateTime endDateTime = endDateIfAny.plusDays(1).toDateTimeAtStartOfDay();
        query = new QueryDefault<>(Document.class, "findByCreatedAtBetween", "startDateTime", startDateTime,
                "endDateTime", endDateTime);
    } else {//from  www  . j  a  v a 2  s  . co  m
        query = new QueryDefault<>(Document.class, "findByCreatedAtAfter", "startDateTime", startDateTime);
    }

    return repositoryService.allMatches(query);
}