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);
}
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;
}
}
Aggregations