use of org.incode.module.communications.dom.impl.commchannel.PostalAddress in project estatio by estatio.
the class CommunicationChannelSubscription_Integtest method replacement_provided.
@Test
public void replacement_provided() throws Exception {
// Given
final DemoObjectWithNotes owner = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
final PostalAddress postalAddress = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Some address", null, null, null, null, null, null);
final PostalAddress replaceWith = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Replacement Address", null, null, null, null, null, null);
final Communication communication = communicationRepository.createPostal("Subject", "/", postalAddress);
final int size = communicationChannelRepository.findByOwner(owner).size();
// When
wrapperFactory.wrap(postalAddress).remove(replaceWith);
// Then
Assertions.assertThat(communicationChannelRepository.findByOwner(owner).size()).isEqualTo(size - 1);
}
use of org.incode.module.communications.dom.impl.commchannel.PostalAddress in project estatio by estatio.
the class CommunicationChannelSubscription_Integtest method validate_fails_when_no_replacement_is_provided.
@Test
public void validate_fails_when_no_replacement_is_provided() throws Exception {
// Given
final DemoObjectWithNotes owner = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
final PostalAddress postalAddress = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Some address", null, null, null, null, null, null);
final Communication communication = communicationRepository.createPostal("Subject", "/", postalAddress);
// Expect
expectedExceptions.expectMessage("Communication channel is being used");
// When
wrap(postalAddress).remove(null);
}
use of org.incode.module.communications.dom.impl.commchannel.PostalAddress in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendByPostAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(final String fileName) throws IOException {
final List<byte[]> pdfBytes = Lists.newArrayList();
for (final InvoiceAndDocument invoiceAndDocument : invoiceAndDocumentsToSend()) {
final Invoice invoice = invoiceAndDocument.getInvoice();
final Document prelimLetterOrInvoiceNote = invoiceAndDocument.getDocument();
final InvoiceForLease_sendByPost invoice_sendByPost = invoice_sendByPost(invoice);
final PostalAddress postalAddress = invoice_sendByPost.default1$$(prelimLetterOrInvoiceNote);
invoice_sendByPost.createPostalCommunicationAsSent(prelimLetterOrInvoiceNote, postalAddress);
invoice_sendByPost.appendPdfBytes(prelimLetterOrInvoiceNote, pdfBytes);
}
final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
use of org.incode.module.communications.dom.impl.commchannel.PostalAddress in project estatio by estatio.
the class Smoke_IntegTest method can_create_postal_address.
@Test
public void can_create_postal_address() throws Exception {
// given
fixtureScripts.runFixtureScript(new DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate(), null);
transactionService.nextTransaction();
// and so given customer with an email
final DemoObjectWithNotes mary = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.MARY_HAS_PHONE_AND_POST).get(0);
final PostalAddress maryPost = (PostalAddress) linkRepository.findByOwnerAndCommunicationChannelType(mary, CommunicationChannelType.POSTAL_ADDRESS).get(0).getCommunicationChannel();
// and with an invoice
final DemoInvoice fredInvoice = invoiceRepository.findByCustomer(mary).get(0);
// that has an attached document
final Paperclip paperclip = paperclipRepository.findByAttachedTo(fredInvoice).get(0);
final DocumentAbstract document = paperclip.getDocument();
// when
final Document_sendByPost documentPrint = mixin(Document_sendByPost.class, document);
final Set<PostalAddress> postalAddresses = documentPrint.choices0Act();
// then
assertThat(postalAddresses).contains(maryPost);
// and when
final Communication comm = wrap(documentPrint).act(maryPost);
// then
assertThat(comm).isNotNull();
assertThat(comm.getState()).isEqualTo(CommunicationState.PENDING);
// same as emails
assertThat(comm.getCreatedAt()).isNotNull();
assertThat(comm.getType()).isEqualTo(CommunicationChannelType.POSTAL_ADDRESS);
assertThat(comm.getSubject()).isNotNull();
assertThat(comm.getSentAt()).isNull();
final List<CommunicationChannel> correspondentChannels = Lists.newArrayList(comm.getCorrespondents()).stream().map(CommChannelRole::getChannel).filter(Objects::nonNull).collect(Collectors.toList());
assertThat(correspondentChannels).contains(maryPost);
// when
final Communication_downloadPdfForPosting mixin = mixin(Communication_downloadPdfForPosting.class, comm);
wrap(mixin).act(mixin.default0Act());
// then
assertThat(comm.getState()).isEqualTo(CommunicationState.SENT);
assertThat(comm.getSentAt()).isNotNull();
}
use of org.incode.module.communications.dom.impl.commchannel.PostalAddress in project estatio by estatio.
the class CommunicationChannelImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
List<Object> results = new ArrayList<>();
// Party
final Party party = fetchParty(partyReference);
if (party == null)
throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
// Address
if (address1 != null || address2 != null || address3 != null) {
final Country country = countryRepository.findCountry(countryCode);
PostalAddress comm = (PostalAddress) postalAddressRepository.findByAddress(party, address1, address2, address3, postalCode, city, country);
if (comm == null) {
comm = communicationChannelRepository.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
}
if (legal != null && legal) {
comm.setLegal(true);
}
// attach to lease
if (leaseReference != null) {
Lease lease = fetchLease(leaseReference);
if (lease != null && addressType != null) {
final AgreementRoleType art = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
final AgreementRoleCommunicationChannelType arcct = agreementRoleCommunicationChannelTypeRepository.findByTitle(addressType);
lease.findRoleWithType(art, lease.getStartDate()).addCommunicationChannel(arcct, comm, lease.getStartDate());
}
}
}
// Phone
if (phoneNumber != null) {
CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, phoneNumber);
if (comm == null) {
comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
comm.setReference(leaseReference);
}
}
// Fax
if (faxNumber != null) {
CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, faxNumber);
if (comm == null) {
comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
comm.setReference(leaseReference);
}
}
// Email
if (emailAddress != null) {
CommunicationChannel comm = emailAddressRepository.findByEmailAddress(party, emailAddress);
if (comm == null) {
comm = communicationChannelRepository.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
comm.setReference(leaseReference);
}
}
return results;
}
Aggregations