use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.
the class InvoiceForLeaseBuilder method createInvoiceItemsForTermsOfFirstLeaseItemOfType.
private List<InvoiceItemForLease> createInvoiceItemsForTermsOfFirstLeaseItemOfType(final InvoiceForLease invoice, final LeaseItemType leaseItemType, final LocalDate startDate, final LocalDateInterval interval, final ExecutionContext ec) {
final Lease lease = invoice.getLease();
final LeaseItem firstLeaseItem = lease.findFirstItemOfType(leaseItemType);
final SortedSet<LeaseTerm> terms = firstLeaseItem.getTerms();
List<InvoiceItemForLease> items = Lists.newArrayList();
for (final LeaseTerm term : terms) {
InvoiceItemForLease item = invoiceItemForLeaseRepository.newInvoiceItem(term, interval, interval, interval, startDate, null);
item.setInvoice(invoice);
item.setSequence(invoice.nextItemSequence());
ec.addResult(this, item);
items.add(item);
}
return items;
}
use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.
the class InvoiceCalculationService_normalRun_IntegTest method whenLeaseTermApproved.
@Test
public void whenLeaseTermApproved() 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));
// when, then
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"));
}
use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.
the class LeaseTermForTurnoverRentImport method importData.
@Programmatic
@Override
public List<Object> importData(Object previousRow) {
LeaseItem item = initLeaseItem();
// create term
LeaseTermForTurnoverRent term = (LeaseTermForTurnoverRent) item.findTermWithSequence(getSequence());
if (term == null) {
if (getStartDate() == null) {
throw new IllegalArgumentException("startDate cannot be empty");
}
if (getSequence().equals(BigInteger.ONE)) {
term = (LeaseTermForTurnoverRent) 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 = (LeaseTermForTurnoverRent) previousTerm.createNext(getStartDate(), getEndDate());
}
term.setSequence(getSequence());
}
term.setStatus(LeaseTermStatus.valueOf(getStatus()));
// set turnover rent term values
term.setTurnoverRentRule(turnoverRentRule);
term.setAuditedTurnover(auditedTurnover);
term.setAuditedTurnoverRent(auditedTurnoverRent);
return Lists.newArrayList(term);
}
use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.
the class InstantiatorForLeaseTerm method instantiate.
@Override
public Object instantiate() {
final LeaseTerm lt = new LeaseTermForTesting();
lt.setSequence(BigInteger.valueOf(sequence++));
return lt;
}
use of org.estatio.module.lease.dom.LeaseTerm in project estatio by estatio.
the class InvoiceCalculationService method calculateAndInvoice.
@Programmatic
public String calculateAndInvoice(InvoiceCalculationParameters parameters) {
String lastInteractionId = null;
invoiceForLeaseRepository.removeRuns(parameters);
try {
startInteraction(parameters.toString());
final List<Lease> leases = parameters.leases();
for (Lease lease : leases.size() == 0 ? leaseRepository.findLeasesByProperty(parameters.property()) : leases) {
lease.verifyUntil(parameters.dueDateRange().endDateExcluding());
if (lease.getStatus() != LeaseStatus.SUSPENDED) {
SortedSet<LeaseItem> leaseItems = parameters.leaseItem() == null ? lease.getItems() : new TreeSet<>(Arrays.asList(parameters.leaseItem()));
for (LeaseItem leaseItem : leaseItems) {
if (!leaseItem.getStatus().equals(LeaseItemStatus.SUSPENDED) && leaseItem.getInvoicedBy().equals(LeaseAgreementRoleTypeEnum.LANDLORD)) {
// TODO: We only filter the Landlords
if (parameters.leaseItemTypes() == null || parameters.leaseItemTypes().contains(leaseItem.getType())) {
SortedSet<LeaseTerm> leaseTerms = parameters.leaseTerm() == null ? leaseItem.getTerms() : new TreeSet<>(Arrays.asList(parameters.leaseTerm()));
for (LeaseTerm leaseTerm : leaseTerms) {
final List<CalculationResult> results;
results = calculateDueDateRange(leaseTerm, parameters);
createInvoiceItems(leaseTerm, parameters, results);
}
}
}
}
}
}
} finally {
lastInteractionId = interactionId;
endInteraction();
}
return lastInteractionId;
}
Aggregations