Search in sources :

Example 1 with Lease

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

the class BudgetAssignmentService method calculateResultsForLeases.

public List<BudgetCalculationRun> calculateResultsForLeases(final Budget budget, final BudgetCalculationType type) {
    List<BudgetCalculationRun> results = new ArrayList<>();
    for (Lease lease : leasesWithActiveOccupations(budget)) {
        removeNewOverrideValues(lease);
        calculateOverrideValues(lease, budget);
        results.add(executeCalculationRun(lease, budget, type));
    }
    return results;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) ArrayList(java.util.ArrayList) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)

Example 2 with Lease

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

the class BudgetAssignmentService_Test method findOrCreateLeaseItemForServiceChargeBudgeted_returns_active_item_when_found.

@Test
public void findOrCreateLeaseItemForServiceChargeBudgeted_returns_active_item_when_found() throws Exception {
    // given
    LeaseItem itemToBeFound = new LeaseItem();
    Lease lease = new Lease() {

        @Override
        public LeaseItem findFirstActiveItemOfTypeAndChargeOnDate(final LeaseItemType leaseItemType, final Charge charge, final LocalDate date) {
            return itemToBeFound;
        }
    };
    BudgetCalculationResult budgetCalculationResult = new BudgetCalculationResult();
    LocalDate termStartDate = new LocalDate(2018, 1, 1);
    // when
    LeaseItem itemFound = budgetAssignmentService.findOrCreateLeaseItemForServiceChargeBudgeted(lease, budgetCalculationResult, termStartDate);
    // then
    assertThat(itemFound).isEqualTo(itemToBeFound);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) Test(org.junit.Test)

Example 3 with Lease

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

the class InvoiceForLeaseBuilder method createInvoiceItemsForTermsOfFirstLeaseItemOfType.

private List<InvoiceItemForLease> createInvoiceItemsForTermsOfFirstLeaseItemOfType(final InvoiceForLease invoice, final LeaseItemType leaseItemType, final LocalDate startDate, final LocalDateInterval interval, final ExecutionContext ec) {
    final Lease lease = invoice.getLease();
    final LeaseItem firstLeaseItem = lease.findFirstItemOfType(leaseItemType);
    final SortedSet<LeaseTerm> terms = firstLeaseItem.getTerms();
    List<InvoiceItemForLease> items = Lists.newArrayList();
    for (final LeaseTerm term : terms) {
        InvoiceItemForLease item = invoiceItemForLeaseRepository.newInvoiceItem(term, interval, interval, interval, startDate, null);
        item.setInvoice(invoice);
        item.setSequence(invoice.nextItemSequence());
        ec.addResult(this, item);
        items.add(item);
    }
    return items;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm)

Example 4 with Lease

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

the class LeaseBuilder method addInvoiceAddressForTenant.

private void addInvoiceAddressForTenant(final Lease lease, final Party tenant, final CommunicationChannelType channelType) {
    final AgreementRoleType inRoleOfTenant = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
    final AgreementRoleCommunicationChannelType inRoleOfInvoiceAddress = agreementRoleCommunicationChannelTypeRepository.find(AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
    final List<CommunicationChannelOwnerLink> addressLinks = communicationChannelOwnerLinkRepository.findByOwnerAndCommunicationChannelType(tenant, channelType);
    final Optional<CommunicationChannel> communicationChannelIfAny = addressLinks.stream().map(CommunicationChannelOwnerLink::getCommunicationChannel).findFirst();
    final SortedSet<AgreementRole> roles = lease.getRoles();
    final Optional<AgreementRole> agreementRoleIfAny = Lists.newArrayList(roles).stream().filter(x -> x.getType() == inRoleOfTenant).findFirst();
    if (agreementRoleIfAny.isPresent() && communicationChannelIfAny.isPresent()) {
        final AgreementRole agreementRole = agreementRoleIfAny.get();
        if (!Sets.filter(agreementRole.getCommunicationChannels(), inRoleOfInvoiceAddress.matchingCommunicationChannel()).isEmpty()) {
            // already one set up
            return;
        }
        final CommunicationChannel communicationChannel = communicationChannelIfAny.get();
        agreementRole.addCommunicationChannel(inRoleOfInvoiceAddress, communicationChannel, null, null);
    }
}
Also used : Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) SortedSet(java.util.SortedSet) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Getter(lombok.Getter) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Lease(org.estatio.module.lease.dom.Lease) BuilderScriptAbstract(org.apache.isis.applib.fixturescripts.BuilderScriptAbstract) VT.ld(org.incode.module.base.integtests.VT.ld) Inject(javax.inject.Inject) AgreementRoleCommunicationChannelTypeEnum(org.estatio.module.lease.dom.AgreementRoleCommunicationChannelTypeEnum) Lists(com.google.common.collect.Lists) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) ToString(lombok.ToString) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Unit(org.estatio.module.asset.dom.Unit) OccupancyRepository(org.estatio.module.lease.dom.occupancy.OccupancyRepository) CommunicationChannelOwnerLinkRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLinkRepository) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) AgreementRoleCommunicationChannelTypeRepository(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelTypeRepository) Party(org.estatio.module.party.dom.Party) CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) ApplicationTenancy_enum(org.incode.module.apptenancy.fixtures.enums.ApplicationTenancy_enum) LeaseType(org.estatio.module.lease.dom.LeaseType) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Property(org.estatio.module.asset.dom.Property) EqualsAndHashCode(lombok.EqualsAndHashCode) CommunicationChannelRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelRepository) Sets(com.google.common.collect.Sets) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) LocalDate(org.joda.time.LocalDate) List(java.util.List) LeaseRoleTypeEnum(org.estatio.module.lease.dom.LeaseRoleTypeEnum) BrandCoverage(org.estatio.module.lease.dom.occupancy.tags.BrandCoverage) Data(lombok.Data) Optional(java.util.Optional) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) Country(org.incode.module.country.dom.impl.Country) AllArgsConstructor(lombok.AllArgsConstructor) LeaseTypeRepository(org.estatio.module.lease.dom.LeaseTypeRepository) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 5 with Lease

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

the class LeaseBuilderLEGACY method createLease.

protected Lease createLease(String reference, String name, String unitReference, String brand, BrandCoverage brandCoverage, String countryOfOriginRef, String sector, String activity, String landlordReference, String tenantReference, LocalDate startDate, LocalDate endDate, boolean createManagerRole, boolean createLeaseUnitAndTags, Party manager, ExecutionContext fixtureResults) {
    Unit unit = unitRepository.findUnitByReference(unitReference);
    Party landlord = findPartyByReferenceOrNameElseNull(landlordReference);
    Party tenant = findPartyByReferenceOrNameElseNull(tenantReference);
    Lease lease = leaseRepository.newLease(unit.getApplicationTenancy(), reference, name, null, startDate, null, endDate, landlord, tenant);
    fixtureResults.addResult(this, lease.getReference(), lease);
    if (createManagerRole) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.MANAGER.getTitle()), manager, null, null);
        fixtureResults.addResult(this, role);
    }
    if (createLeaseUnitAndTags) {
        Country countryOfOrigin = countryRepository.findCountry(countryOfOriginRef);
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
        occupancy.setBrandName(brand, brandCoverage, countryOfOrigin);
        occupancy.setSectorName(sector);
        occupancy.setActivityName(activity);
        fixtureResults.addResult(this, occupancy);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    return lease;
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Country(org.incode.module.country.dom.impl.Country) Unit(org.estatio.module.asset.dom.Unit)

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