Search in sources :

Example 1 with AgreementRoleType

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

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

use of org.estatio.module.agreement.dom.role.AgreementRoleType 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 4 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.

the class GuaranteeRepository method newGuarantee.

@Programmatic
public Guarantee newGuarantee(final Lease lease, @Parameter(regexPattern = ReferenceType.Meta.REGEX, regexPatternReplacement = ReferenceType.Meta.REGEX_DESCRIPTION) final String reference, final String name, final GuaranteeType guaranteeType, final LocalDate startDate, final LocalDate endDate, final String description, final BigDecimal contractualAmount, final BigDecimal startAmount) {
    AgreementRoleType artGuarantee = agreementRoleTypeRepository.find(GuaranteeAgreementRoleTypeEnum.GUARANTEE);
    Party leasePrimaryParty = lease.getPrimaryParty();
    AgreementRoleType artGuarantor = agreementRoleTypeRepository.find(GuaranteeAgreementRoleTypeEnum.GUARANTOR);
    Party leaseSecondaryParty = lease.getSecondaryParty();
    Guarantee guarantee = newTransientInstance(Guarantee.class);
    final AgreementType at = agreementTypeRepository.find(GuaranteeAgreementTypeEnum.GUARANTEE);
    guarantee.setType(at);
    guarantee.setReference(reference);
    guarantee.setDescription(description);
    guarantee.setName(name);
    guarantee.setStartDate(startDate);
    guarantee.setEndDate(endDate);
    guarantee.setGuaranteeType(guaranteeType);
    guarantee.setLease(lease);
    guarantee.setContractualAmount(contractualAmount);
    guarantee.newRole(artGuarantee, leasePrimaryParty, null, null);
    guarantee.newRole(artGuarantor, leaseSecondaryParty, null, null);
    FinancialAccountType financialAccountType = guaranteeType.getFinancialAccountType();
    if (financialAccountType != null) {
        FinancialAccount financialAccount = financialAccountRepository.newFinancialAccount(financialAccountType, reference, name, leaseSecondaryParty);
        guarantee.setFinancialAccount(financialAccount);
        if (ObjectUtils.compare(startAmount, BigDecimal.ZERO) > 0) {
            financialAccountTransactionRepository.newTransaction(guarantee.getFinancialAccount(), startDate, null, startAmount);
        }
    }
    persistIfNotAlready(guarantee);
    return guarantee;
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.

the class AgreementCommunicationChannelLocator method current.

@Programmatic
public List<CommunicationChannel> current(final Agreement agreement, final String art, final String arcct, final List<CommunicationChannelType> communicationChannelTypes) {
    final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
    final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
    final AgreementRoleCommunicationChannelType commChannelInRoleOf = agreementRoleCommunicationChannelTypeRepository.findByTitle(arcct);
    final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
    for (final AgreementRole role : agreementRoles) {
        if (role.getType() == partyInRoleOf) {
            final SortedSet<AgreementRoleCommunicationChannel> rolesOfChannels = role.getCommunicationChannels();
            for (AgreementRoleCommunicationChannel roleOfChannel : rolesOfChannels) {
                if (roleOfChannel.getType() == commChannelInRoleOf) {
                    final CommunicationChannel communicationChannel = roleOfChannel.getCommunicationChannel();
                    if (roleOfChannel.isCurrent() && communicationChannelTypes.contains(communicationChannel.getType())) {
                        communicationChannels.add(communicationChannel);
                    }
                }
            }
        }
    }
    return communicationChannels;
}
Also used : AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)13 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)7 Party (org.estatio.module.party.dom.Party)7 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)5 List (java.util.List)4 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)4 ArrayList (java.util.ArrayList)2 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 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2 FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)2 FinancialAccountType (org.estatio.module.financial.dom.FinancialAccountType)2 Lease (org.estatio.module.lease.dom.Lease)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Optional (java.util.Optional)1