Search in sources :

Example 1 with PostalAddress

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);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Example 2 with PostalAddress

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);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Example 3 with PostalAddress

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);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Blob(org.apache.isis.applib.value.Blob) Invoice(org.estatio.module.invoice.dom.Invoice) Document(org.incode.module.document.dom.impl.docs.Document) InvoiceForLease_sendByPost(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 4 with PostalAddress

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();
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice) CommChannelRole(org.incode.module.communications.dom.impl.comms.CommChannelRole) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication_downloadPdfForPosting(org.incode.module.communications.dom.impl.comms.Communication_downloadPdfForPosting) PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Document_sendByPost(org.incode.module.communications.dom.mixins.Document_sendByPost) DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate(org.incode.platform.dom.communications.integtests.dom.communications.fixture.DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Example 5 with PostalAddress

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;
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) ApplicationException(org.apache.isis.applib.ApplicationException) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Lease(org.estatio.module.lease.dom.Lease) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ArrayList(java.util.ArrayList) Country(org.incode.module.country.dom.impl.Country) DomainObject(org.apache.isis.applib.annotation.DomainObject) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

PostalAddress (org.incode.module.communications.dom.impl.commchannel.PostalAddress)5 Communication (org.incode.module.communications.dom.impl.comms.Communication)3 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)3 Test (org.junit.Test)3 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 ArrayList (java.util.ArrayList)1 ApplicationException (org.apache.isis.applib.ApplicationException)1 Action (org.apache.isis.applib.annotation.Action)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 DomainObject (org.apache.isis.applib.annotation.DomainObject)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 Blob (org.apache.isis.applib.value.Blob)1 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)1 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 Lease (org.estatio.module.lease.dom.Lease)1 InvoiceForLease_sendByPost (org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost)1 Party (org.estatio.module.party.dom.Party)1 CommChannelRole (org.incode.module.communications.dom.impl.comms.CommChannelRole)1 Communication_downloadPdfForPosting (org.incode.module.communications.dom.impl.comms.Communication_downloadPdfForPosting)1