Search in sources :

Example 1 with LeaseType

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

the class LeaseBuilderLEGACY method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    executionContext.executeChild(this, new LeaseTypeForItalyRefData());
    defaultParam("reference", executionContext, fakeDataService.strings().fixed(3));
    defaultParam("name", executionContext, fakeDataService.name().lastName() + " Mall");
    defaultParam("leaseType", executionContext, fakeDataService.collections().anyBounded(LeaseType.class));
    defaultParam("atPath", executionContext, ApplicationTenancy_enum.Gb.getPath());
    defaultParam("startDate", executionContext, fakeDataService2.dates().before(fakeDataService2.periods().daysUpTo(2 * 365)));
    if (getDuration() == null && getEndDate() == null) {
        defaultParam("endDate", executionContext, getStartDate().plus(fakeDataService2.periods().years(10, 20)));
    }
    final ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(getAtPath());
    this.lease = leaseRepository.newLease(applicationTenancy, getReference(), getName(), getLeaseType(), getStartDate(), getDuration(), getEndDate(), getLandlord(), getTenant());
}
Also used : LeaseTypeForItalyRefData(org.estatio.module.lease.fixtures.LeaseTypeForItalyRefData) LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 2 with LeaseType

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

the class LeaseTypeForItalyRefData method createLeaseType.

private void createLeaseType(ExecutionContext fixtureResults, LeaseTypeData ltd) {
    final LeaseType leaseType = leaseTypeRepository.findOrCreate(ltd.name(), ltd.title(), applicationTenancyRepository.findByPath("/ITA"));
    fixtureResults.addResult(this, leaseType.getReference(), leaseType);
}
Also used : LeaseType(org.estatio.module.lease.dom.LeaseType)

Example 3 with LeaseType

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

the class LeaseTypeImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final ApplicationTenancy appTenancy = applicationTenancyRepository.findByPath(atPath);
    final LeaseType leaseType = leaseTypeRepository.findOrCreate(reference, name, appTenancy);
    if (ObjectUtils.compare(name, leaseType.getName()) != 0) {
        leaseType.setName(name);
    }
    return Lists.newArrayList(leaseType);
}
Also used : LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with LeaseType

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

the class LeaseMenu method choices3NewLease.

public List<LeaseType> choices3NewLease(final Property property) {
    if (property == null) {
        return null;
    }
    final ApplicationTenancy propertyApplicationTenancy = property.getApplicationTenancy();
    List<LeaseType> result = Lists.newArrayList();
    for (LeaseType leaseType : leaseTypeRepository.allLeaseTypes()) {
        final ApplicationTenancyLevel propertyAppTenancyLevel = ApplicationTenancyLevel.of(propertyApplicationTenancy);
        final ApplicationTenancyLevel leaseTypeAppTenancyLevel = ApplicationTenancyLevel.of(leaseType.getApplicationTenancy());
        if (propertyAppTenancyLevel.equals(leaseTypeAppTenancyLevel) || propertyAppTenancyLevel.childOf(leaseTypeAppTenancyLevel)) {
            result.add(leaseType);
        }
    }
    return result;
}
Also used : LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 5 with LeaseType

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

Aggregations

LeaseType (org.estatio.module.lease.dom.LeaseType)6 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 Lease (org.estatio.module.lease.dom.Lease)2 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)1 Property (org.estatio.module.asset.dom.Property)1 ApplicationTenancyLevel (org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel)1 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)1 LeaseTypeForItalyRefData (org.estatio.module.lease.fixtures.LeaseTypeForItalyRefData)1 Party (org.estatio.module.party.dom.Party)1