Search in sources :

Example 6 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.DeleteEvent ev) {
    Party sourceParty = (Party) ev.getSource();
    Party replacementParty = ev.getReplacement();
    List<AgreementRole> agreementRoles;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            agreementRoles = agreementRoleRepository.findByParty(sourceParty);
            if (replacementParty == null && agreementRoles.size() > 0) {
                ev.invalidate("Party is being used in an agreement role: remove roles or provide a replacement");
            } else {
                scratchpad.put(onPartyRemoveScratchpadKey = UUID.randomUUID(), agreementRoles);
            }
            break;
        case EXECUTING:
            agreementRoles = (List<AgreementRole>) scratchpad.get(onPartyRemoveScratchpadKey);
            for (AgreementRole agreementRole : agreementRoles) {
                agreementRole.setParty(replacementParty);
            }
            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)

Example 7 with AgreementRole

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

Example 8 with AgreementRole

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

the class Lease method disableNewMandate.

public String disableNewMandate() {
    final AgreementRole tenantRole = getSecondaryAgreementRole();
    if (tenantRole == null || !tenantRole.isCurrent()) {
        return "Could not determine the tenant (secondary party) of this lease";
    }
    final List<? extends FinancialAccount> validBankAccounts = existingBankAccountsForTenant();
    if (validBankAccounts.isEmpty()) {
        return "There are no bank accounts available for this tenant";
    }
    return null;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole)

Example 9 with AgreementRole

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

the class Lease method existingBankMandatesForTenant.

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<BankMandate> existingBankMandatesForTenant() {
    final AgreementRole tenantRole = getSecondaryAgreementRole();
    if (tenantRole == null || !tenantRole.isCurrent()) {
        return Collections.emptyList();
    }
    final Party tenant = partyOf(tenantRole);
    final AgreementType bankMandateAgreementType = bankMandateAgreementType();
    final AgreementRoleType debtorRoleType = debtorRoleType();
    return (List) agreementRepository.findByAgreementTypeAndRoleTypeAndParty(bankMandateAgreementType, debtorRoleType, tenant);
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with AgreementRole

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

the class PartyBankAccountsAndMandatesDtoFactory method newDto.

@Programmatic
public BankAccountsAndMandatesDto newDto(final Party party) {
    final BankAccountsAndMandatesDto dto = new BankAccountsAndMandatesDto();
    final List<FinancialAccount> financialAccountList = financialAccountRepository.findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
    final List<BankAccountDto> bankAccountDtos = financialAccountList.stream().map(x -> bankAccountDtoFactory.newDto((BankAccount) x)).collect(Collectors.toList());
    dto.setBankAccounts(bankAccountDtos);
    final AgreementType bankMandateAt = agreementTypeRepository.find(BankMandateAgreementTypeEnum.MANDATE);
    final AgreementRoleType debtorOfMandate = agreementRoleTypeRepository.findByAgreementTypeAndTitle(bankMandateAt, BankMandateAgreementRoleTypeEnum.DEBTOR.getTitle());
    final List<AgreementRole> agreementRoles = agreementRoleRepository.findByPartyAndType(party, debtorOfMandate);
    final List<BankMandateDto> mandateDtos = agreementRoles.stream().map(x -> x.getAgreement()).map(x -> bankMandateDtoFactory.newDto((BankMandate) x)).collect(Collectors.toList());
    dto.setBankMandates(mandateDtos);
    return dto;
}
Also used : BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) DtoFactoryAbstract(org.estatio.module.base.platform.applib.DtoFactoryAbstract) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementTypeRepository(org.estatio.module.agreement.dom.type.AgreementTypeRepository) DomainService(org.apache.isis.applib.annotation.DomainService) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) FinancialAccountRepository(org.estatio.module.financial.dom.FinancialAccountRepository) Programmatic(org.apache.isis.applib.annotation.Programmatic) Inject(javax.inject.Inject) BankMandateAgreementRoleTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementRoleTypeEnum) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccount(org.estatio.module.financial.dom.BankAccount) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) BankMandateAgreementTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementTypeEnum) Party(org.estatio.module.party.dom.Party) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Collectors(java.util.stream.Collectors) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) BankAccountDtoFactory(org.estatio.module.financial.canonical.v1.BankAccountDtoFactory) AgreementRoleRepository(org.estatio.module.agreement.dom.AgreementRoleRepository) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) 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