Search in sources :

Example 46 with ApplicationTenancy

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

the class LeaseTermForIndexableRentImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final LeaseItemImport leaseItemImport = new LeaseItemImport(leaseReference, itemTypeName, itemSequence, itemStartDate, itemChargeReference, itemEpochDate, itemNextDueDate, itemInvoicingFrequency, itemPaymentMethod, itemStatus, itemAtPath);
    domainObjectContainer.injectServicesInto(leaseItemImport);
    LeaseItem item = leaseItemImport.importItem(false);
    // create term
    LeaseTermForIndexable term = (LeaseTermForIndexable) item.findTermWithSequence(sequence);
    if (term == null) {
        if (startDate == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (sequence.equals(BigInteger.ONE) || !item.getType().autoCreateTerms()) {
            // create a standalone term on the first or when autoCreateTerms is false
            term = (LeaseTermForIndexable) item.newTerm(startDate, endDate);
        } else {
            // join the current with the previous
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException(String.format("Previous term not found: %s", this.toString()));
            }
            term = (LeaseTermForIndexable) previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(LeaseTermStatus.valueOf(status));
    final ApplicationTenancy applicationTenancy = term.getLeaseItem().getApplicationTenancy();
    // set indexation term values
    term.setIndexationMethod(indexationMethod == null ? null : IndexationMethod.valueOf(indexationMethod));
    term.setIndex(indexReference == null ? null : indexRepository.findOrCreateIndex(applicationTenancy, indexReference, indexReference));
    term.setFrequency(indexationFrequency == null ? null : LeaseTermFrequency.valueOf(indexationFrequency));
    term.setEffectiveDate(effectiveDate);
    term.setBaseValue(baseValue);
    term.setIndexedValue(indexedValue);
    term.setSettledValue(settledValue);
    term.setBaseIndexStartDate(baseIndexStartDate);
    term.setBaseIndexValue(baseIndexValue);
    term.setNextIndexStartDate(nextIndexStartDate);
    term.setNextIndexValue(nextIndexValue);
    term.setIndexationPercentage(indexationPercentage);
    term.setLevellingPercentage(levellingPercentage);
    return Lists.newArrayList(term);
}
Also used : LeaseTermForIndexable(org.estatio.module.lease.dom.LeaseTermForIndexable) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 47 with ApplicationTenancy

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

the class LeaseTermForServiceChargeImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    // find or create leaseItem
    final Lease lease = fetchLease(leaseReference);
    final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(leaseItemAtPath), lease.getApplicationTenancy());
    final Charge charge = fetchCharge(itemChargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    final LocalDate itemStartDateToUse = itemStartDate == null ? lease.getStartDate() : itemStartDate;
    final LeaseAgreementRoleTypeEnum invoicedByToUse = this.invoicedBy == null ? LeaseAgreementRoleTypeEnum.LANDLORD : LeaseAgreementRoleTypeEnum.valueOf(this.invoicedBy);
    final PaymentMethod paymentMethodToUse = itemPaymentMethod == null ? lease.defaultPaymentMethod() : PaymentMethod.valueOf(itemPaymentMethod);
    LeaseItem item = lease.findItem(itemType, charge, itemStartDateToUse, invoicedByToUse);
    if (item == null) {
        item = lease.newItem(itemType, invoicedByToUse, charge, InvoicingFrequency.valueOf(itemInvoicingFrequency), paymentMethodToUse, itemStartDateToUse);
        item.setSequence(itemSequence);
    }
    item.setEpochDate(itemEpochDate);
    item.setNextDueDate(itemNextDueDate);
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(itemStatus, LeaseItemStatus.ACTIVE);
    item.setStatus(leaseItemStatus);
    // create term
    LeaseTermForServiceCharge term = (LeaseTermForServiceCharge) item.findTermWithSequence(sequence);
    if (term == null) {
        if (startDate == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (sequence.equals(BigInteger.ONE)) {
            term = (LeaseTermForServiceCharge) item.newTerm(startDate, endDate);
        } else {
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException(String.format("Previous term not found %s", lease.getReference()));
            }
            term = (LeaseTermForServiceCharge) previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(LeaseTermStatus.valueOf(status));
    // set service charge term values
    term.setBudgetedValue(budgetedValue);
    term.setAuditedValue(auditedValue);
    return Lists.newArrayList(term);
}
Also used : LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Lease(org.estatio.module.lease.dom.Lease) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Charge(org.estatio.module.charge.dom.Charge) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 48 with ApplicationTenancy

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

the class PartyRelationshipRepository method newRelatedPerson.

// //////////////////////////////////////
@Programmatic
public PartyRelationship newRelatedPerson(final Party party, final String reference, final String initials, final String firstName, final String lastName, final PersonGenderType gender, final String relationshipType, final String description, final String phoneNumber, final String emailAddress) {
    RandomCodeGenerator10Chars generator = new RandomCodeGenerator10Chars();
    String newReference = reference == null ? generator.generateRandomCode().toUpperCase() : reference;
    final ApplicationTenancy applicationTenancy = party.getApplicationTenancy();
    Person person = personRepository.newPerson(newReference, initials, firstName, lastName, gender, applicationTenancy);
    if (phoneNumber != null && !phoneNumber.isEmpty()) {
        communicationChannelRepository.newPhoneOrFax(person, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
    }
    if (emailAddress != null && !emailAddress.isEmpty()) {
        communicationChannelRepository.newEmail(person, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
    }
    return newRelationship(party, person, relationshipType, description);
}
Also used : Person(org.estatio.module.party.dom.Person) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 49 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindOrCreateCountryTenancy_whenDoesNotExist.

@Test
public void testFindOrCreateCountryTenancy_whenDoesNotExist() throws Exception {
    // given
    final Country country = new Country("GBR", "UK", "United Kingdom");
    // expect
    final ApplicationTenancy newlyCreatedTenancy = new ApplicationTenancy();
    context.checking(new Expectations() {

        {
            oneOf(mockApplicationTenancies).newTenancy("GBR", "/GBR", global);
            will(returnValue(newlyCreatedTenancy));
        }
    });
    // when
    ApplicationTenancy countryTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(country);
    // then
    assertThat(countryTenancy).isEqualTo(newlyCreatedTenancy);
}
Also used : Expectations(org.jmock.Expectations) Country(org.incode.module.country.dom.impl.Country) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

Example 50 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForCountry_Test method tenancy.

private static ApplicationTenancy tenancy(final String path, final String name) {
    ApplicationTenancy applicationTenancy = new ApplicationTenancy();
    applicationTenancy.setPath(path);
    applicationTenancy.setName(name);
    return applicationTenancy;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

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