Search in sources :

Example 11 with Lease

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

the class CommunicationChannelImport method fetchLease.

private Lease fetchLease(final String leaseReference) {
    final Lease lease;
    lease = leaseRepository.findLeaseByReference(leaseReference.trim().replaceAll("~", "+"));
    if (lease == null) {
        throw new ApplicationException(String.format("Lease with reference %s not found.", leaseReference));
    }
    return lease;
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) Lease(org.estatio.module.lease.dom.Lease)

Example 12 with Lease

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

the class LeaseItemImport method importItem.

@Programmatic
public LeaseItem importItem(boolean updateExisting) {
    final Lease lease = fetchLease(leaseReference);
    final Charge charge = fetchCharge(chargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    // for deposit items the start date defaults to the start date of the lease
    LocalDate startDateOrDefault;
    if (itemType == LeaseItemType.DEPOSIT) {
        startDateOrDefault = ObjectUtils.firstNonNull(startDate, lease.getStartDate());
    } else {
        startDateOrDefault = startDate;
    }
    LeaseItem item = lease.findItem(itemType, startDateOrDefault, sequence);
    if (item == null) {
        item = lease.newItem(itemType, LeaseAgreementRoleTypeEnum.LANDLORD, charge, InvoicingFrequency.valueOf(invoicingFrequency), PaymentMethod.valueOf(paymentMethod), startDateOrDefault);
        item.setSequence(sequence);
    }
    if (updateExisting) {
        item.setApplicationTenancyPath(atPath);
        item.setEpochDate(epochDate);
        item.setNextDueDate(nextDueDate);
        item.setStatus(LeaseItemStatus.valueOfElse(status, LeaseItemStatus.ACTIVE));
    }
    return item;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 13 with Lease

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

the class LeaseUpgradeService method upgradeLinkedItems.

public BigInteger upgradeLinkedItems() {
    BigInteger numberOfItemsLinkedIfNotAlready = BigInteger.ZERO;
    for (Lease lease : leaseRepository.allLeases()) {
        for (LeaseItem depositItem : lease.findItemsOfType(LeaseItemType.DEPOSIT)) {
            for (LeaseItem rentItem : lease.findItemsOfType(LeaseItemType.RENT)) {
                depositItem.findOrCreateSourceItem(rentItem);
                numberOfItemsLinkedIfNotAlready = numberOfItemsLinkedIfNotAlready.add(BigInteger.ONE);
            }
        }
        for (LeaseItem trItem : lease.findItemsOfType(LeaseItemType.TURNOVER_RENT)) {
            for (LeaseItem rentItem : lease.findItemsOfType(LeaseItemType.RENT)) {
                trItem.findOrCreateSourceItem(rentItem);
                numberOfItemsLinkedIfNotAlready = numberOfItemsLinkedIfNotAlready.add(BigInteger.ONE);
            }
        }
        for (LeaseItem taxItem : lease.findItemsOfType(LeaseItemType.TAX)) {
            for (LeaseItem rentItem : lease.findItemsOfType(LeaseItemType.RENT)) {
                taxItem.findOrCreateSourceItem(rentItem);
                numberOfItemsLinkedIfNotAlready = numberOfItemsLinkedIfNotAlready.add(BigInteger.ONE);
            }
        }
    }
    return numberOfItemsLinkedIfNotAlready;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) BigInteger(java.math.BigInteger) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 14 with Lease

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

the class BankMandateImport method fetchLease.

private Lease fetchLease(final String leaseReference) {
    final Lease lease;
    lease = leaseRepository.findLeaseByReference(leaseReference.trim().replaceAll("~", "+"));
    if (lease == null) {
        throw new ApplicationException(String.format("Lease with reference %s not found.", leaseReference));
    }
    return lease;
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) Lease(org.estatio.module.lease.dom.Lease)

Example 15 with Lease

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

the class BreakOptionImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = fetchLease(leaseReference);
    final BreakType breakTypeValue = BreakType.valueOf(breakType);
    final BreakExerciseType breakExerciseTypeValue = BreakExerciseType.valueOf(breakExcerciseType);
    if (notificationDate != null) {
        final Period period = new Period(notificationDate, breakDate);
        notificationPeriod = JodaPeriodUtils.asSimpleString(period);
    }
    BreakOption br = breakOptionRepository.findByLeaseAndTypeAndBreakDateAndExerciseType(lease, breakTypeValue, breakDate, breakExerciseTypeValue);
    if (br == null) {
        breakOptionRepository.newBreakOption(lease, breakDate, notificationPeriod, breakTypeValue, breakExerciseTypeValue, description);
    }
    return Lists.newArrayList();
}
Also used : BreakOption(org.estatio.module.lease.dom.breaks.BreakOption) Lease(org.estatio.module.lease.dom.Lease) BreakType(org.estatio.module.lease.dom.breaks.BreakType) Period(org.joda.time.Period) BreakExerciseType(org.estatio.module.lease.dom.breaks.BreakExerciseType) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Lease (org.estatio.module.lease.dom.Lease)57 LocalDate (org.joda.time.LocalDate)17 Programmatic (org.apache.isis.applib.annotation.Programmatic)16 ApplicationException (org.apache.isis.applib.ApplicationException)11 Charge (org.estatio.module.charge.dom.Charge)11 Test (org.junit.Test)11 LeaseItem (org.estatio.module.lease.dom.LeaseItem)10 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)10 Unit (org.estatio.module.asset.dom.Unit)9 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)9 Property (org.estatio.module.asset.dom.Property)7 Party (org.estatio.module.party.dom.Party)6 Action (org.apache.isis.applib.annotation.Action)5 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)4 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)4 BigDecimal (java.math.BigDecimal)3