Search in sources :

Example 16 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class LeaseTermForTurnoverRent method doAlign.

// //////////////////////////////////////
@Override
protected void doAlign() {
    if (getStatus() != LeaseTermStatus.APPROVED) {
        // Collect all results
        BigDecimal newContractualRent = BigDecimal.ZERO;
        List<LeaseItemSource> sourceItems = getLeaseItem().getSourceItems();
        List<CalculationResult> calculationResults = new ArrayList<>();
        for (LeaseItemSource leaseItemSource : sourceItems) {
            // Make the calculation interval deliberately longer then the duration of the turnover rent term to make sure
            // that indexations that are done in retrospect are included in the calculation
            final LocalDateInterval calculationInterval = new LocalDateInterval(getStartDate(), getEndDate().plusYears(1));
            calculationResults.addAll(leaseItemSource.getSourceItem().calculationResults(calculationInterval));
        }
        // TODO: do prorata when intervals don't match
        for (CalculationResult result : calculationResults) {
            if (getInterval().contains(result.invoicingInterval().asLocalDateInterval())) {
                newContractualRent = newContractualRent.add(result.value());
            }
        }
        if (ObjectUtils.compare(getContractualRent(), newContractualRent) != 0) {
            setContractualRent(newContractualRent);
        }
        // Budgeted Turnover Rent
        if (getTotalBudgetedRent() != null) {
            BigDecimal newBudgetedTurnoverRent = getTotalBudgetedRent().subtract(getContractualRent());
            if (newBudgetedTurnoverRent.compareTo(BigDecimal.ZERO) < 0) {
                newBudgetedTurnoverRent = BigDecimal.ZERO;
            }
            if (ObjectUtils.compare(getBudgetedTurnoverRent(), newBudgetedTurnoverRent) != 0) {
                setBudgetedTurnoverRent(newBudgetedTurnoverRent);
            }
        }
        // Audited Turnover Rent
        if (getTurnoverRentRule() != null) {
            // Ignore the rule when empty
            TurnoverRentRuleHelper helper = new TurnoverRentRuleHelper(getTurnoverRentRule());
            BigDecimal newAuditedTurnoverRent = helper.calculateRent(getAuditedTurnover()).subtract(getContractualRent());
            if (ObjectUtils.compare(newAuditedTurnoverRent, BigDecimal.ZERO) < 0) {
                newAuditedTurnoverRent = BigDecimal.ZERO;
            }
            if (ObjectUtils.compare(getAuditedTurnoverRent(), newAuditedTurnoverRent) != 0) {
                setAuditedTurnoverRent(newAuditedTurnoverRent);
            }
        }
    }
}
Also used : CalculationResult(org.estatio.module.lease.dom.invoicing.InvoiceCalculationService.CalculationResult) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval)

Example 17 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class BreakOption method changeDates.

@MemberOrder(name = "breakDate", sequence = "1")
public BreakOption changeDates(final LocalDate breakDate, final LocalDate excerciseDate) {
    setBreakDate(breakDate);
    setExerciseDate(excerciseDate);
    LocalDateInterval ldi = new LocalDateInterval(excerciseDate, breakDate, AbstractInterval.IntervalEnding.EXCLUDING_END_DATE);
    final String s = JodaPeriodUtils.asSimpleString(new Period(ldi.asInterval(), PeriodType.yearMonthDay()));
    setNotificationPeriod(s);
    // re-create events
    removeExistingEvents();
    createEvents();
    return this;
}
Also used : Period(org.joda.time.Period) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Aggregations

LocalDateInterval (org.incode.module.base.dom.valuetypes.LocalDateInterval)17 LocalDate (org.joda.time.LocalDate)8 BigDecimal (java.math.BigDecimal)4 Action (org.apache.isis.applib.annotation.Action)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ArrayList (java.util.ArrayList)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)2 Charge (org.estatio.module.charge.dom.Charge)2 InvoicingInterval (org.estatio.module.invoice.dom.InvoicingInterval)2 LeaseItem (org.estatio.module.lease.dom.LeaseItem)2 Test (org.junit.Test)2 Nullable (javax.annotation.Nullable)1 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)1 FixedAssetRole (org.estatio.module.asset.dom.role.FixedAssetRole)1 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)1 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)1 CodaElement (org.estatio.module.capex.dom.coda.CodaElement)1 CodaElementLevel (org.estatio.module.capex.dom.coda.CodaElementLevel)1 CodaTransactionType (org.estatio.module.capex.dom.coda.CodaTransactionType)1 DocumentType (org.estatio.module.capex.dom.coda.DocumentType)1