Search in sources :

Example 11 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class DocAndCommAbstract_downloadSelected method act.

@Action(semantics = SemanticsOf.SAFE, invokeOn = InvokeOn.COLLECTION_ONLY)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Object act() throws IOException {
    final List<byte[]> pdfBytes = createOrLookupPdfBytes();
    final Document document = getDocument();
    // we just ignore those that do not
    if (document != null) {
        appendBytes(document, pdfBytes);
        final List<Document> supportingDocs = attachmentsProvider.attachmentsFor(document);
        for (Document supportingDoc : supportingDocs) {
            appendBytes(supportingDoc, pdfBytes);
        }
    }
    if (interactionContext.isLast()) {
        if (pdfBytes.isEmpty()) {
            messageService.warnUser("No documents to be merged");
            return null;
        }
        final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
        return new Blob(fileName, MIME_TYPE_APPLICATION_PDF, mergedBytes);
    }
    return null;
}
Also used : Blob(org.apache.isis.applib.value.Blob) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 12 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class IncomingInvoice_recategorize method act.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(cssClassFa = "mail-reply", cssClass = "btn-danger")
public Document act(@Nullable final String comment) {
    Document document = lookupPdf();
    document.setType(DocumentTypeData.INCOMING.findUsing(documentTypeRepository));
    stateTransitionService.trigger(document, IncomingDocumentCategorisationStateTransition.class, IncomingDocumentCategorisationStateTransitionType.RESET, comment, null);
    // use events to cascade delete, eg paperclips and state transitions/tasks
    incomingInvoiceRepository.delete(incomingInvoice);
    return document;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 13 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class IncomingInvoice_recategorize method disableAct.

public String disableAct() {
    final Document documentIfAny = lookupPdf();
    if (documentIfAny == null) {
        return "Cannot locate document";
    }
    if (incomingInvoice.getApprovalState() != IncomingInvoiceApprovalState.NEW) {
        return "Only NEW invoices can be recategorized";
    }
    if (incomingInvoice.isReported()) {
        return "This invoice is reported and cannot be recategorized";
    }
    final Person meAsPerson = personRepository.me();
    if (meAsPerson == null)
        return "Your login is not linked to a person in Estatio";
    if (!(meAsPerson.hasPartyRoleType(FixedAssetRoleTypeEnum.PROPERTY_MANAGER.findUsing(partyRoleTypeRepository)) || meAsPerson.hasPartyRoleType(PartyRoleTypeEnum.OFFICE_ADMINISTRATOR.findUsing(partyRoleTypeRepository)))) {
        return String.format("You need role %s or %s to recategorize", FixedAssetRoleTypeEnum.PROPERTY_MANAGER.getKey(), PartyRoleTypeEnum.OFFICE_ADMINISTRATOR);
    }
    return null;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Person(org.estatio.module.party.dom.Person)

Example 14 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class Order method title.

public String title() {
    final TitleBuffer buf = new TitleBuffer();
    final Optional<Document> document = lookupAttachedPdfService.lookupOrderPdfFrom(this);
    document.ifPresent(d -> buf.append(d.getName()));
    final Party seller = getSeller();
    if (seller != null) {
        buf.append(": ", seller);
    }
    final String orderNumber = getOrderNumber();
    if (orderNumber != null) {
        buf.append(", ", orderNumber);
    }
    return buf.toString();
}
Also used : Party(org.estatio.module.party.dom.Party) TitleBuffer(org.apache.isis.applib.util.TitleBuffer) Document(org.incode.module.document.dom.impl.docs.Document)

Example 15 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class IncomingInvoice method title.

public String title() {
    final TitleBuffer buf = new TitleBuffer();
    final Optional<Document> document = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(this);
    document.ifPresent(d -> buf.append(d.getName()));
    final Party seller = getSeller();
    if (seller != null) {
        buf.append(": ", seller);
    }
    final String invoiceNumber = getInvoiceNumber();
    if (invoiceNumber != null) {
        buf.append(", ", invoiceNumber);
    }
    return buf.toString();
}
Also used : Party(org.estatio.module.party.dom.Party) TitleBuffer(org.apache.isis.applib.util.TitleBuffer) Document(org.incode.module.document.dom.impl.docs.Document)

Aggregations

Document (org.incode.module.document.dom.impl.docs.Document)57 Action (org.apache.isis.applib.annotation.Action)23 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)22 Programmatic (org.apache.isis.applib.annotation.Programmatic)8 Blob (org.apache.isis.applib.value.Blob)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)7 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)7 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)5 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)4 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 Communication (org.incode.module.communications.dom.impl.comms.Communication)3 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 Expectations (org.jmock.Expectations)3 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)2 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)2 Order (org.estatio.module.capex.dom.order.Order)2 BankAccount (org.estatio.module.financial.dom.BankAccount)2 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)2