Search in sources :

Example 6 with LeaseTermForIndexable

use of org.estatio.module.lease.dom.LeaseTermForIndexable 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 7 with LeaseTermForIndexable

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

the class IndexSubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final IndexValue.RemoveEvent ev) {
    List<LeaseTermForIndexable> terms;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            terms = leaseTermForIndexableRepository.findByIndexAndDate(ev.getSource().getIndexBase().getIndex(), ev.getSource().getStartDate());
            scratchpad.put(onIndexValueRemoveScratchpadKey = UUID.randomUUID(), terms);
            break;
        case EXECUTED:
            terms = (List<LeaseTermForIndexable>) scratchpad.get(onIndexValueRemoveScratchpadKey);
            for (LeaseTermForIndexable term : terms) {
                term.verify();
            }
            break;
        default:
            break;
    }
}
Also used : LeaseTermForIndexable(org.estatio.module.lease.dom.LeaseTermForIndexable) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

LeaseTermForIndexable (org.estatio.module.lease.dom.LeaseTermForIndexable)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 ChargeGroup_enum (org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum)2 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1