use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink 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);
}
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink in project estatio by estatio.
the class DocumentCommunicationSupportForDocumentsAttachedToDemoInvoice method addTo.
private <T extends CommunicationChannel> void addTo(final DemoInvoice invoice, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
final DemoObjectWithNotes customer = invoice.getCustomer();
final List<CommunicationChannelOwnerLink> links = communicationChannelOwnerLinkRepository.findByOwner(customer);
final List channels = links.stream().map(CommunicationChannelOwnerLink::getCommunicationChannel).filter(cc -> cc.getType() == channelType).collect(Collectors.toList());
header.getToChoices().addAll(channels);
}
Aggregations