Search in sources :

Example 11 with Occupancy

use of org.estatio.module.lease.dom.occupancy.Occupancy in project estatio by estatio.

the class LeaseBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("reference", executionContext, String.class);
    checkParam("name", executionContext, String.class);
    checkParam("property", executionContext, Unit.class);
    checkParam("landlord", executionContext, Party.class);
    checkParam("tenant", executionContext, Party.class);
    checkParam("startDate", executionContext, LocalDate.class);
    checkParam("endDate", executionContext, LocalDate.class);
    defaultParam("invoiceAddressCreationPolicy", executionContext, InvoiceAddressCreationPolicy.DONT_CREATE);
    defaultParam("addressesCreationPolicy", executionContext, AddressesCreationPolicy.DONT_CREATE);
    landlord.addRole(LeaseRoleTypeEnum.LANDLORD);
    tenant.addRole(LeaseRoleTypeEnum.TENANT);
    final ApplicationTenancy atPath = ApplicationTenancy_enum.Global.findUsing(serviceRegistry);
    final LeaseType leaseType = leaseTypeRepository.findOrCreate("STD", "Standard", atPath);
    Lease lease = leaseRepository.newLease(property.getApplicationTenancy(), reference, name, leaseType, startDate, null, endDate, landlord, tenant);
    executionContext.addResult(this, lease.getReference(), lease);
    if (manager != null) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.MANAGER), manager, null, null);
        executionContext.addResult(this, role);
    }
    for (final OccupancySpec spec : occupancySpecs) {
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, spec.unit, spec.startDate);
        occupancy.setEndDate(spec.endDate);
        occupancy.setBrandName(spec.brand, spec.brandCoverage, spec.countryOfOrigin);
        occupancy.setSectorName(spec.sector);
        occupancy.setActivityName(spec.activity);
        executionContext.addResult(this, occupancy);
    }
    if (invoiceAddressCreationPolicy == InvoiceAddressCreationPolicy.CREATE) {
        addInvoiceAddressForTenant(lease, tenant, CommunicationChannelType.EMAIL_ADDRESS);
    }
    if (addressesCreationPolicy == AddressesCreationPolicy.CREATE) {
        createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.ADMINISTRATION_ADDRESS);
        createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    object = lease;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 12 with Occupancy

use of org.estatio.module.lease.dom.occupancy.Occupancy in project estatio by estatio.

the class ClassificationForOccImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = leaseRepository.findLeaseByReference(getLeaseReference());
    if (lease == null) {
        throw new IllegalArgumentException(String.format("No lease found for '%s'", getLeaseReference()));
    }
    final Unit unit = unitRepository.findUnitByReference(getUnitReference());
    if (unit == null) {
        throw new IllegalArgumentException(String.format("No unit found for '%s'", getUnitReference()));
    }
    final Occupancy occupancy = occupancyRepository.findByLease(lease).stream().filter(x -> x.getUnit().equals(unit)).findFirst().get();
    if (occupancy == null) {
        throw new IllegalArgumentException(String.format("No occupancy found for lease '%s' and unit '%s'", getLeaseReference(), getUnitReference()));
    }
    final Taxonomy taxonomy = (Taxonomy) categoryRepository.findByReference(getTaxonomyReference());
    if (taxonomy == null) {
        throw new IllegalArgumentException(String.format("No taxonomy found for '%s'", getTaxonomyReference()));
    }
    final Category category = categoryRepository.findByTaxonomyAndReference(taxonomy, getCategoryReference());
    if (category == null) {
        throw new IllegalArgumentException(String.format("No category found for '%s'", getCategoryReference()));
    }
    final Classification classification = classificationRepository.create(category, occupancy);
    return Lists.newArrayList(classification);
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Lease(org.estatio.module.lease.dom.Lease) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Classification(org.incode.module.classification.dom.impl.classification.Classification) Unit(org.estatio.module.asset.dom.Unit)

Example 13 with Occupancy

use of org.estatio.module.lease.dom.occupancy.Occupancy 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 14 with Occupancy

use of org.estatio.module.lease.dom.occupancy.Occupancy 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)

Example 15 with Occupancy

use of org.estatio.module.lease.dom.occupancy.Occupancy in project estatio by estatio.

the class InvoiceAttributesVM method getCurrentOccupancyBrandName.

@Programmatic
public String getCurrentOccupancyBrandName() {
    final Occupancy currentOccupancy = invoice.getCurrentOccupancy();
    if (currentOccupancy == null) {
        return null;
    }
    final Brand brand = currentOccupancy.getBrand();
    if (brand == null) {
        return null;
    }
    return brand.getName();
}
Also used : Brand(org.estatio.module.lease.dom.occupancy.tags.Brand) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)17 Lease (org.estatio.module.lease.dom.Lease)9 Unit (org.estatio.module.asset.dom.Unit)8 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)3 Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)3 LocalDate (org.joda.time.LocalDate)3 ArrayList (java.util.ArrayList)2 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)2 Property (org.estatio.module.asset.dom.Property)2 Budget (org.estatio.module.budget.dom.budget.Budget)2 Charge (org.estatio.module.charge.dom.Charge)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)2 Tax (org.estatio.module.tax.dom.Tax)2 Expectations (org.jmock.Expectations)2 Before (org.junit.Before)2 Test (org.junit.Test)2 BigDecimal (java.math.BigDecimal)1 SortedSet (java.util.SortedSet)1