Search in sources :

Example 1 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.

the class LeaseBuilder method createAddress.

private void createAddress(Lease lease, IAgreementRoleCommunicationChannelType addressType) {
    final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
    final AgreementRole agreementRole = lease.findRoleWithType(agreementRoleType, ld(2010, 7, 15));
    AgreementRoleCommunicationChannelType agreementRoleCommunicationChannelType = agreementRoleCommunicationChannelTypeRepository.find(addressType);
    final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwnerAndType(lease.getSecondaryParty(), CommunicationChannelType.POSTAL_ADDRESS);
    final CommunicationChannel postalAddress = channels.first();
    agreementRole.addCommunicationChannel(agreementRoleCommunicationChannelType, postalAddress, null);
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 2 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole 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 3 with AgreementRole

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

Example 4 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.

the class BankMandateBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("agreement", ec, Agreement.class);
    checkParam("bankAccount", ec, BankAccount.class);
    checkParam("sequence", ec, Integer.class);
    // these are optional in the domain, so perhaps don't need to be mandatory
    checkParam("sequenceType", ec, Integer.class);
    checkParam("scheme", ec, Scheme.class);
    checkParam("leaseDate", ec, LocalDate.class);
    final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.TENANT.getTitle());
    final AgreementRole role = agreementRoleRepository.findByAgreementAndTypeAndContainsDate(agreement, agreementRoleType, leaseDate);
    final Party owner = role.getParty();
    final BankMandate bankMandate = bankMandateRepository.newBankMandate(referenceFrom(owner, sequence), owner.getReference(), agreement.getStartDate(), agreement.getEndDate(), agreement.getSecondaryParty(), agreement.getPrimaryParty(), bankAccount, sequenceType, scheme, agreement.getStartDate());
    ec.addResult(this, bankMandate.getReference(), bankMandate);
    object = bankMandate;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) BankMandate(org.estatio.module.bankmandate.dom.BankMandate)

Example 5 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.

the class PartySubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.FixEvent ev) {
    switch(ev.getEventPhase()) {
        case EXECUTING:
            Party sourceParty = (Party) ev.getSource();
            final List<AgreementRole> roles = agreementRoleRepository.findByParty(sourceParty);
            for (AgreementRole role : roles) {
                sourceParty.addRole(role.getType());
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

AgreementRole (org.estatio.module.agreement.dom.AgreementRole)12 Party (org.estatio.module.party.dom.Party)8 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)4 List (java.util.List)3 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)3 Lease (org.estatio.module.lease.dom.Lease)3 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)3 Inject (javax.inject.Inject)2 AgreementRoleCommunicationChannel (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel)2 IAgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType)2 AgreementRoleTypeRepository (org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository)2 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)2 Unit (org.estatio.module.asset.dom.Unit)2 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2 LeaseType (org.estatio.module.lease.dom.LeaseType)2 Country (org.incode.module.country.dom.impl.Country)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1