Search in sources :

Example 1 with LeaseTerm

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;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm)

Example 2 with LeaseTerm

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"));
}
Also used : LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Test(org.junit.Test)

Example 3 with LeaseTerm

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);
}
Also used : LeaseTermForTurnoverRent(org.estatio.module.lease.dom.LeaseTermForTurnoverRent) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with LeaseTerm

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;
}
Also used : LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) LeaseTermForTesting(org.estatio.module.lease.dom.LeaseTermForTesting)

Example 5 with LeaseTerm

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;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) 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