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