Search in sources :

Example 51 with Lease

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

the class OccupancyImport 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 52 with Lease

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

the class OccupancyImport method importData.

@Override
@Programmatic
public List<Object> importData(Object previousRow) {
    final Lease lease = fetchLease(leaseReference);
    final Unit unit = unitRepository.findUnitByReference(unitReference);
    if (unitReference != null && unit == null) {
        throw new ApplicationException(String.format("Unit with reference %s not found.", unitReference));
    }
    Occupancy occupancy = occupancyRepository.findByLeaseAndUnitAndStartDate(lease, unit, startDate);
    if (occupancy == null) {
        occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
    }
    occupancy.setEndDate(endDate);
    occupancy.setUnitSizeName(size);
    occupancy.setBrandName(brand != null ? brand.replaceAll("\\p{C}", "").trim() : null, null, null);
    occupancy.setSectorName(sector);
    occupancy.setActivityName(activity);
    occupancy.setReportTurnover(reportTurnover != null ? Occupancy.OccupancyReportingType.valueOf(reportTurnover) : Occupancy.OccupancyReportingType.NO);
    occupancy.setReportRent(reportRent != null ? Occupancy.OccupancyReportingType.valueOf(reportRent) : Occupancy.OccupancyReportingType.NO);
    occupancy.setReportOCR(reportOCR != null ? Occupancy.OccupancyReportingType.valueOf(reportOCR) : Occupancy.OccupancyReportingType.NO);
    return Lists.newArrayList(occupancy);
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Unit(org.estatio.module.asset.dom.Unit) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 53 with Lease

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

the class CreateRetroInvoices method createProperties.

@Programmatic
public ExecutionContext createProperties(final List<Property> properties, final LocalDate startDueDate, final LocalDate nextDueDate, final ExecutionContext executionContext) {
    for (Property property : properties) {
        executionContext.addResult(this, property.getReference(), property);
        for (Lease lease : leaseRepository.findLeasesByProperty(property)) {
            executionContext.addResult(this, lease.getReference(), lease);
            createLease(lease, startDueDate, nextDueDate, executionContext);
        }
    }
    return executionContext;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 54 with Lease

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

the class BankMandateImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = fetchLease(leaseReference);
    BankAccount bankAccount;
    BankMandate bankMandate = null;
    // find or create bank account
    final Party owner = lease.getSecondaryParty();
    bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, bankAccountReference);
    if (bankAccount == null) {
        bankAccount = bankAccountRepository.newBankAccount(owner, bankAccountReference, null);
    }
    if (reference != null) {
        bankMandate = bankMandateRepository.findByReference(reference);
    }
    if (bankMandate == null) {
        lease.newMandate(bankAccount, reference, startDate, endDate, SequenceType.valueOf(sequenceType), Scheme.valueOf(scheme), signatureDate);
        bankMandate = lease.getPaidBy();
    }
    bankMandate.setBankAccount(bankAccount);
    bankMandate.setReference(reference);
    bankMandate.setName(name);
    bankMandate.setStartDate(startDate);
    bankMandate.setEndDate(endDate);
    bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
    bankMandate.setSequenceType(SequenceType.valueOf(sequenceType));
    bankMandate.setScheme(Scheme.valueOf(scheme));
    bankMandate.setSignatureDate(signatureDate);
    lease.paidBy(bankMandate);
    return Lists.newArrayList(bankMandate);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) BankAccount(org.estatio.module.financial.dom.BankAccount) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 55 with Lease

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

the class InvoiceForLease method getCurrentOccupancy.

@Programmatic
public Occupancy getCurrentOccupancy() {
    final InvoiceForLease invoice = this;
    final Lease leaseIfAny = invoice.getLease();
    if (leaseIfAny == null) {
        return null;
    }
    final SortedSet<Occupancy> occupancies = leaseIfAny.getOccupancies();
    if (occupancies.isEmpty()) {
        return null;
    }
    return occupancies.first();
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) 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