Search in sources :

Example 1 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class PartySubscriptionsForIncomingInvoices 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();
    switch(ev.getEventPhase()) {
        case VALIDATE:
            if (replacementParty == null && incomingInvoiceRepository.findBySeller(sourceParty).size() > 0) {
                ev.invalidate("Party is in use as seller in an invoice. Provide replacement");
            }
            if (replacementParty == null && incomingInvoiceRepository.findByBuyer(sourceParty).size() > 0) {
                ev.invalidate("Party is in use as buyer in an invoice. Provide replacement");
            }
            break;
        case EXECUTING:
            if (replacementParty != null) {
                for (Invoice invoice : incomingInvoiceRepository.findByBuyer(sourceParty)) {
                    invoice.setBuyer(replacementParty);
                }
                for (Invoice invoice : incomingInvoiceRepository.findBySeller(sourceParty)) {
                    invoice.setSeller(replacementParty);
                }
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Invoice(org.estatio.module.invoice.dom.Invoice) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with Invoice

use of org.estatio.module.invoice.dom.Invoice 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 3 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class InvoiceSummaryAbstract method validate0InvoiceAll.

public String validate0InvoiceAll(final LocalDate invoiceDate) {
    for (Invoice invoice : getInvoices()) {
        try {
            final InvoiceForLease._invoice mixin = mixin(InvoiceForLease._invoice.class, invoice);
            wrapperFactory.wrapNoExecute(mixin).$$(invoiceDate);
        } catch (InvalidException ex) {
            final String reasonMessage = ex.getInteractionEvent() != null ? ex.getInteractionEvent().getReason() : null;
            return titleService.titleOf(invoice) + ": " + (reasonMessage != null ? reasonMessage : ex.getMessage());
        } catch (HiddenException | DisabledException ex) {
        // ignore
        }
    }
    return null;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) InvalidException(org.apache.isis.applib.services.wrapper.InvalidException) HiddenException(org.apache.isis.applib.services.wrapper.HiddenException)

Example 4 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class InvoiceSummaryForPropertyDueDateStatus_backgroundPrepareAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
    final List<InvoiceForLease> invoices = invoicesToPrepare();
    for (Invoice invoice : invoices) {
        final DocumentTemplate documentTemplate = documentTemplateFor(invoice);
        factoryService.mixin(InvoiceForLease_backgroundPrepare.class, invoice).$$(documentTemplate);
    }
    return this.invoiceSummary;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) InvoiceForLease_backgroundPrepare(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_backgroundPrepare) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 5 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class Invoice_DocumentManagement_IntegTest method sendToFor.

<T extends CommunicationChannel> T sendToFor(final Invoice invoice, final Class<T> communicationChannelClass) {
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (communicationChannelClass.isAssignableFrom(sendTo.getClass())) {
        return communicationChannelClass.cast(sendTo);
    }
    final List<CommunicationChannel> communicationChannels = mixin(InvoiceForLease_overrideSendTo.class, invoice).choices0$$();
    final Optional<CommunicationChannel> commChannelIfAny = communicationChannels.stream().filter(x -> communicationChannelClass.isAssignableFrom(x.getClass())).findFirst();
    if (!commChannelIfAny.isPresent()) {
        throw new IllegalStateException("could not locate communication channel of type " + communicationChannelClass.getSimpleName());
    }
    final CommunicationChannel communicationChannel = commChannelIfAny.get();
    wrap(mixin(InvoiceForLease_overrideSendTo.class, invoice)).$$(communicationChannel);
    return communicationChannelClass.cast(communicationChannel);
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) Invoice(org.estatio.module.invoice.dom.Invoice) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Percentage(org.assertj.core.data.Percentage) DocAndCommForInvoiceDoc(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) Assertions(org.assertj.core.api.Assertions) HiddenException(org.apache.isis.applib.services.wrapper.HiddenException) CommunicationState(org.incode.module.communications.dom.impl.comms.CommunicationState) InvoiceForLease_attachSupportingDocument(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_attachSupportingDocument) BookmarkService2(org.apache.isis.applib.services.bookmark.BookmarkService2) Blob(org.apache.isis.applib.value.Blob) DocumentTypeData(org.estatio.module.invoice.dom.DocumentTypeData) DocAndCommForPrelimLetter_communicationState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_communicationState) PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) DocumentSort(org.incode.module.document.dom.impl.docs.DocumentSort) DocAndCommForInvoiceDoc_document(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_document) InvoiceForLease_overrideSendTo(org.estatio.module.lease.dom.invoicing.InvoiceForLease_overrideSendTo) DocAndCommForInvoiceDoc_communicationState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_communicationState) Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Communication(org.incode.module.communications.dom.impl.comms.Communication) InvoiceStatus(org.estatio.module.invoice.dom.InvoiceStatus) Invoice_ForLease_preliminaryLetters(org.estatio.module.lease.dom.invoicing.summary.comms.Invoice_ForLease_preliminaryLetters) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Paperclip_changeRole(org.incode.module.document.dom.impl.paperclips.Paperclip_changeRole) Invoice_invoiceDocs(org.estatio.module.lease.dom.invoicing.summary.comms.Invoice_invoiceDocs) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) DocAndCommForPrelimLetter_document(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_document) List(java.util.List) TransactionService(org.apache.isis.applib.services.xactn.TransactionService) InvoiceForLease_enum(org.estatio.module.lease.fixtures.invoice.enums.InvoiceForLease_enum) LeaseModuleIntegTestAbstract(org.estatio.module.lease.integtests.LeaseModuleIntegTestAbstract) InvoiceForLease_sendByPost(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost) Optional(java.util.Optional) DocAndCommForPrelimLetter(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter) FixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Document(org.incode.module.document.dom.impl.docs.Document) Lease(org.estatio.module.lease.dom.Lease) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) DocumentState(org.incode.module.document.dom.impl.docs.DocumentState) InvoiceForLease_prepare(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_prepare) Inject(javax.inject.Inject) DocumentTemplateRepository(org.incode.module.document.dom.impl.docs.DocumentTemplateRepository) InvoiceRepository(org.estatio.module.invoice.dom.InvoiceRepository) InvoiceForLeaseRepository(org.estatio.module.lease.dom.invoicing.InvoiceForLeaseRepository) Document_delete(org.incode.module.document.dom.impl.docs.Document_delete) PaperclipRoleNames(org.estatio.module.lease.dom.invoicing.comms.PaperclipRoleNames) Before(org.junit.Before) PartyRepository(org.estatio.module.party.dom.PartyRepository) InvoiceForLease_sendByEmail(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail) ClockService(org.apache.isis.applib.services.clock.ClockService) PaperclipRepository(org.incode.module.document.dom.impl.paperclips.PaperclipRepository) Resources(com.google.common.io.Resources) DocumentTypesAndTemplatesForLeaseFixture(org.estatio.module.lease.seed.DocumentTypesAndTemplatesForLeaseFixture) DocumentTypeRepository(org.incode.module.document.dom.impl.types.DocumentTypeRepository) DocAndCommForPrelimLetter_documentState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_documentState) IOException(java.io.IOException) Test(org.junit.Test) DocAndCommForInvoiceDoc_documentState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_documentState) LocalDate(org.joda.time.LocalDate) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DocAndCommForPrelimLetter_communication(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_communication) Ignore(org.junit.Ignore) DocAndCommForInvoiceDoc_communication(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_communication) InvoiceForLease_overrideSendTo(org.estatio.module.lease.dom.invoicing.InvoiceForLease_overrideSendTo) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Aggregations

Invoice (org.estatio.module.invoice.dom.Invoice)9 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)4 Action (org.apache.isis.applib.annotation.Action)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Document (org.incode.module.document.dom.impl.docs.Document)3 HiddenException (org.apache.isis.applib.services.wrapper.HiddenException)2 Blob (org.apache.isis.applib.value.Blob)2 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)2 Lease (org.estatio.module.lease.dom.Lease)2 InvoiceForLease_sendByPost (org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost)2 Party (org.estatio.module.party.dom.Party)2 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 PostalAddress (org.incode.module.communications.dom.impl.commchannel.PostalAddress)2 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)2 Resources (com.google.common.io.Resources)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1