Search in sources :

Example 41 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class PropertyImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Party owner = partyRepository.findPartyByReference(ownerReference);
    final Country country = countryRepository.findCountry(countryCode);
    final ApplicationTenancy appTenancy = applicationTenancyRepository.findByPath(atPath);
    Property property = propertyRepository.findPropertyByReference(reference);
    if (property == null) {
        property = propertyRepository.newProperty(reference, name, PropertyType.valueOf(type), city, country, acquireDate);
    }
    property.setName(name);
    property.setFullName(fullName);
    property.setCountry(country);
    property.setCity(city);
    property.setType(PropertyType.valueOf(type));
    property.setAcquireDate(acquireDate);
    property.setDisposalDate(disposalDate);
    property.setOpeningDate(openingDate);
    property.setExternalReference(externalReference);
    property.addRoleIfDoesNotExist(owner, FixedAssetRoleTypeEnum.PROPERTY_OWNER, null, null);
    property.setParkingSpaces(parkingSpaces);
    property.setArea(grossLettableArea);
    property.setDisplayOrder(displayOrder);
    return Lists.newArrayList(property);
}
Also used : Party(org.estatio.module.party.dom.Party) Country(org.incode.module.country.dom.impl.Country) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 42 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class PropertyRepository method newProperty.

public Property newProperty(final String propertyReference, final String name, final PropertyType propertyType, final String city, final Country country, final LocalDate acquireDate) {
    final Property property = newTransientInstance();
    property.setReference(propertyReference);
    property.setName(name);
    property.setType(propertyType);
    property.setCity(city);
    property.setCountry(country);
    property.setAcquireDate(acquireDate);
    if (city != null && country != null && property.getLocation() == null) {
        property.lookupLocation(city.concat(", ").concat(country.getName()));
    }
    final ApplicationTenancy propertyApplicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(property);
    property.setApplicationTenancyPath(propertyApplicationTenancy.getPath());
    persistIfNotAlready(property);
    return property;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 43 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy 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 44 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class LeaseItemBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("lease", ec, Lease.class);
    checkParam("charge", ec, Charge.class);
    checkParam("leaseItemType", ec, LeaseItemType.class);
    checkParam("invoicingFrequency", ec, InvoicingFrequency.class);
    defaultParam("sequence", ec, bi(1));
    defaultParam("invoicedBy", ec, LeaseAgreementRoleTypeEnum.LANDLORD);
    defaultParam("paymentMethod", ec, PaymentMethod.DIRECT_DEBIT);
    defaultParam("status", ec, LeaseItemStatus.ACTIVE);
    final ApplicationTenancy leaseApplicationTenancy = lease.getApplicationTenancy();
    final ApplicationTenancy countryApplicationTenancy = leaseApplicationTenancy.getParent();
    if (!ApplicationTenancyLevel.of(countryApplicationTenancy).isCountry()) {
        // not expected to happen...
        throw new IllegalStateException(String.format("Lease '%s' has an app tenancy '%s' whose parent is not at the country level", lease.getReference(), leaseApplicationTenancy.getName()));
    }
    LeaseItem leaseItem = lease.findItem(leaseItemType, lease.getStartDate(), invoicedBy);
    if (leaseItem == null) {
        leaseItem = lease.newItem(leaseItemType, invoicedBy, charge, invoicingFrequency, paymentMethod, lease.getStartDate());
        leaseItem.setType(leaseItemType);
        leaseItem.setStatus(status);
        leaseItem.setEndDate(lease.getEndDate());
        leaseItem.setSequence(sequence);
        ec.addResult(this, leaseItem);
    }
    object = leaseItem;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 45 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class InvoiceImportLine method importData.

@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
    List<Object> result = new ArrayList<>();
    Lease lease = fetchLease(getLeaseReference());
    PaymentMethod paymentMethod = fetchPaymentMethod(getPaymentMethod());
    String atPath = lease.getApplicationTenancyPath().concat("/").concat(lease.getPrimaryParty().getReference());
    ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(atPath);
    Invoice invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, lease.getPrimaryParty(), lease.getSecondaryParty(), paymentMethod, currencyRepository.findCurrency("EUR"), getDueDate(), lease, null);
    InvoiceItem invoiceItem = factoryService.mixin(InvoiceForLease._newItem.class, invoice).$$(fetchCharge(getItemChargeReference()), BigDecimal.ONE, getItemNetAmount(), getItemStartDate(), getItemEndDate());
    if (getItemDescription() != null) {
        invoiceItem.setDescription(getItemDescription());
    }
    result.add(invoice);
    return result;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) ArrayList(java.util.ArrayList) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) DomainObject(org.apache.isis.applib.annotation.DomainObject) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)9 Test (org.junit.Test)6 Property (org.estatio.module.asset.dom.Property)4 Lease (org.estatio.module.lease.dom.Lease)4 LeaseItem (org.estatio.module.lease.dom.LeaseItem)4 LeaseType (org.estatio.module.lease.dom.LeaseType)4 Expectations (org.jmock.Expectations)4 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)3 ApplicationTenancyLevel (org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel)3 Charge (org.estatio.module.charge.dom.Charge)3 Numerator (org.estatio.module.numerator.dom.Numerator)3 Country (org.incode.module.country.dom.impl.Country)3 Action (org.apache.isis.applib.annotation.Action)2 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 Charge (org.estatio.dom.charge.Charge)2 IndexValue (org.estatio.module.index.dom.IndexValue)2 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)2 LeaseItemStatus (org.estatio.module.lease.dom.LeaseItemStatus)2 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)2