Search in sources :

Example 6 with LeaseTerm

use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.

the class InvoiceCalculationService_normalRun_IntegTest method effective_interval_is_swapped.

@Test
public void effective_interval_is_swapped() throws Exception {
    // given
    lease.verifyUntil(VT.ld(2014, 1, 1));
    LeaseTerm leaseTopModelRentTerm = leaseTopModelRentItem.findTerm(VT.ld(2010, 7, 15));
    leaseTopModelRentTerm.approve();
    assertThat(leaseTopModelRentTerm.getStatus()).isEqualTo(LeaseTermStatus.APPROVED);
    assertThat(leaseTopModelRentTerm.getEffectiveValue()).isEqualTo(VT.bd2(20200));
    final String runId = calculateNormalRunAndAssert(leaseTopModelRentTerm, VT.ld(2010, 7, 1), VT.ld(2010, 10, 01), VT.ldi("2010-07-01/2010-10-01"), 4239.13, false, VT.ldi("2010-07-15/2010-10-01"));
    final InvoiceForLease invoiceForLease = invoiceForLeaseRepository.findInvoicesByRunId(runId).stream().findFirst().get();
    wrap(mixin(InvoiceForLease._approve.class, invoiceForLease)).$$();
    // when
    lease.terminate(VT.ld(2010, 8, 31));
    // then
    final String runId2 = calculateNormalRunAndAssert(leaseTopModelRentTerm, VT.ld(2010, 7, 1), VT.ld(2010, 10, 01), VT.ldi("2010-07-01/2010-10-01"), -1630.43, false, VT.ldi("2010-09-01/2010-10-01"));
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Test(org.junit.Test)

Example 7 with LeaseTerm

use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.

the class InvoiceCalculationService_normalRun_IntegTest method invoiceItemsForRentCreated.

@Test
public void invoiceItemsForRentCreated() throws Exception {
    leaseInvoicingSettingsService.updateEpochDate(null);
    LeaseTerm leaseTopModelRentTerm0 = (LeaseTerm) leaseTopModelRentItem.getTerms().first();
    // full term
    calculateNormalRunAndAssert(leaseTopModelRentTerm0, VT.ld(2010, 10, 1), VT.ld(2010, 10, 2), VT.ldi("2010-10-01/2011-01-01"), 5000.00, false, null);
    // invoice after effective date
    calculateNormalRunAndAssert(leaseTopModelRentTerm0, VT.ld(2010, 10, 1), VT.ld(2011, 4, 2), VT.ldi("2010-10-01/2011-01-01"), 5050.00, false, null);
    // restore epochdate for other integ tests
    leaseInvoicingSettingsService.updateEpochDate(VT.ld(2010, 1, 1));
}
Also used : LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Test(org.junit.Test)

Example 8 with LeaseTerm

use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.

the class LeaseTermForFixedImport method importData.

@Programmatic
@Override
public List<Object> importData(Object previousRow) {
    LeaseItem item = initLeaseItem();
    // create term
    LeaseTermForFixed term = (LeaseTermForFixed) item.findTermWithSequence(getSequence());
    if (term == null) {
        if (getStartDate() == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (getSequence().equals(BigInteger.ONE)) {
            term = (LeaseTermForFixed) item.newTerm(getStartDate(), getEndDate());
        } else {
            final LeaseTerm previousTerm = item.findTermWithSequence(getSequence().subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException("Previous term not found");
            }
            term = (LeaseTermForFixed) previousTerm.createNext(getStartDate(), getEndDate());
        }
        term.setSequence(getSequence());
    }
    term.setStatus(LeaseTermStatus.valueOf(getStatus()));
    // set turnover rent term values
    term.setValue(getValue());
    return Lists.newArrayList(term);
}
Also used : LeaseTermForFixed(org.estatio.module.lease.dom.LeaseTermForFixed) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 9 with LeaseTerm

use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.

the class LeaseTermForIndexableRentImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final LeaseItemImport leaseItemImport = new LeaseItemImport(leaseReference, itemTypeName, itemSequence, itemStartDate, itemChargeReference, itemEpochDate, itemNextDueDate, itemInvoicingFrequency, itemPaymentMethod, itemStatus, itemAtPath);
    domainObjectContainer.injectServicesInto(leaseItemImport);
    LeaseItem item = leaseItemImport.importItem(false);
    // create term
    LeaseTermForIndexable term = (LeaseTermForIndexable) item.findTermWithSequence(sequence);
    if (term == null) {
        if (startDate == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (sequence.equals(BigInteger.ONE) || !item.getType().autoCreateTerms()) {
            // create a standalone term on the first or when autoCreateTerms is false
            term = (LeaseTermForIndexable) item.newTerm(startDate, endDate);
        } else {
            // join the current with the previous
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException(String.format("Previous term not found: %s", this.toString()));
            }
            term = (LeaseTermForIndexable) previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(LeaseTermStatus.valueOf(status));
    final ApplicationTenancy applicationTenancy = term.getLeaseItem().getApplicationTenancy();
    // set indexation term values
    term.setIndexationMethod(indexationMethod == null ? null : IndexationMethod.valueOf(indexationMethod));
    term.setIndex(indexReference == null ? null : indexRepository.findOrCreateIndex(applicationTenancy, indexReference, indexReference));
    term.setFrequency(indexationFrequency == null ? null : LeaseTermFrequency.valueOf(indexationFrequency));
    term.setEffectiveDate(effectiveDate);
    term.setBaseValue(baseValue);
    term.setIndexedValue(indexedValue);
    term.setSettledValue(settledValue);
    term.setBaseIndexStartDate(baseIndexStartDate);
    term.setBaseIndexValue(baseIndexValue);
    term.setNextIndexStartDate(nextIndexStartDate);
    term.setNextIndexValue(nextIndexValue);
    term.setIndexationPercentage(indexationPercentage);
    term.setLevellingPercentage(levellingPercentage);
    return Lists.newArrayList(term);
}
Also used : LeaseTermForIndexable(org.estatio.module.lease.dom.LeaseTermForIndexable) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 10 with LeaseTerm

use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.

the class LeaseTermForServiceChargeImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    // find or create leaseItem
    final Lease lease = fetchLease(leaseReference);
    final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(leaseItemAtPath), lease.getApplicationTenancy());
    final Charge charge = fetchCharge(itemChargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    final LocalDate itemStartDateToUse = itemStartDate == null ? lease.getStartDate() : itemStartDate;
    final LeaseAgreementRoleTypeEnum invoicedByToUse = this.invoicedBy == null ? LeaseAgreementRoleTypeEnum.LANDLORD : LeaseAgreementRoleTypeEnum.valueOf(this.invoicedBy);
    final PaymentMethod paymentMethodToUse = itemPaymentMethod == null ? lease.defaultPaymentMethod() : PaymentMethod.valueOf(itemPaymentMethod);
    LeaseItem item = lease.findItem(itemType, charge, itemStartDateToUse, invoicedByToUse);
    if (item == null) {
        item = lease.newItem(itemType, invoicedByToUse, charge, InvoicingFrequency.valueOf(itemInvoicingFrequency), paymentMethodToUse, itemStartDateToUse);
        item.setSequence(itemSequence);
    }
    item.setEpochDate(itemEpochDate);
    item.setNextDueDate(itemNextDueDate);
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(itemStatus, LeaseItemStatus.ACTIVE);
    item.setStatus(leaseItemStatus);
    // create term
    LeaseTermForServiceCharge term = (LeaseTermForServiceCharge) item.findTermWithSequence(sequence);
    if (term == null) {
        if (startDate == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (sequence.equals(BigInteger.ONE)) {
            term = (LeaseTermForServiceCharge) item.newTerm(startDate, endDate);
        } else {
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException(String.format("Previous term not found %s", lease.getReference()));
            }
            term = (LeaseTermForServiceCharge) previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(LeaseTermStatus.valueOf(status));
    // set service charge term values
    term.setBudgetedValue(budgetedValue);
    term.setAuditedValue(auditedValue);
    return Lists.newArrayList(term);
}
Also used : LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Lease(org.estatio.module.lease.dom.Lease) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Charge(org.estatio.module.charge.dom.Charge) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)10 LeaseItem (org.estatio.module.lease.dom.LeaseItem)6 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 Lease (org.estatio.module.lease.dom.Lease)3 Test (org.junit.Test)3 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)2 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)2 Charge (org.estatio.module.charge.dom.Charge)1 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)1 LeaseAgreementRoleTypeEnum (org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum)1 LeaseItemStatus (org.estatio.module.lease.dom.LeaseItemStatus)1 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)1 LeaseTermForFixed (org.estatio.module.lease.dom.LeaseTermForFixed)1 LeaseTermForIndexable (org.estatio.module.lease.dom.LeaseTermForIndexable)1 LeaseTermForServiceCharge (org.estatio.module.lease.dom.LeaseTermForServiceCharge)1 LeaseTermForTesting (org.estatio.module.lease.dom.LeaseTermForTesting)1 LeaseTermForTurnoverRent (org.estatio.module.lease.dom.LeaseTermForTurnoverRent)1 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)1 LocalDate (org.joda.time.LocalDate)1