use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType 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.CommunicationChannelType in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendAbstract method appendTuplesToSend.
private void appendTuplesToSend(final Invoice invoice, final Predicate<InvoiceAndDocument> filter, final List<InvoiceAndDocument> invoiceAndDocuments) {
final CommunicationChannel sendTo = invoice.getSendTo();
if (sendTo == null) {
return;
}
final CommunicationChannelType channelType = sendTo.getType();
if (channelType != communicationChannelType) {
return;
}
final Document document = findMostRecentAttachedTo(invoice, getDocumentType());
if (document == null) {
return;
}
if (document.getState() == DocumentState.NOT_RENDERED) {
return;
}
if (invoiceDocAndCommService.findFirstCommunication(document) != null) {
return;
}
final InvoiceAndDocument invoiceAndDocument = new InvoiceAndDocument(invoice, document);
if (!filter.apply(invoiceAndDocument)) {
return;
}
invoiceAndDocuments.add(invoiceAndDocument);
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType 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