Search in sources :

Example 51 with Document

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

the class DocumentService method createForBlob.

/**
 * @param documentName - override the name of the blob (if null, then uses the blob's name)
 */
@Programmatic
public Document createForBlob(final DocumentType documentType, final String documentAtPath, String documentName, final Blob blob) {
    documentName = documentName != null ? documentName : blob.getName();
    final Document document = documentRepository.create(documentType, documentAtPath, documentName, blob.getMimeType().getBaseType());
    document.setRenderedAt(clockService.nowAsDateTime());
    document.setState(DocumentState.RENDERED);
    document.setSort(DocumentSort.BLOB);
    document.setBlobBytes(blob.getBytes());
    return document;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 52 with Document

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

the class Document_categoriseAsOrder method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "folder-open-o")
public Object act(@Nullable final Property property, @Nullable final String comment) {
    final Document document = getDomainObject();
    document.setType(DocumentTypeData.INCOMING_ORDER.findUsing(documentTypeRepository));
    // create order
    final Order order = orderRepository.create(property, // order number
    null, // sellerOrderReference
    null, // entryDate
    clockService.now(), // orderDate
    null, // seller
    null, // buyer
    buyerFinder.buyerDerivedFromDocumentName(document), document.getAtPath(), // approval state... will cause state transition to be created automatically by subscriber
    null);
    paperclipRepository.attach(document, null, order);
    trigger(comment, null);
    return order;
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 53 with Document

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

the class Document_categoriseAsPropertyInvoice method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "folder-open-o")
public Object act(final Property property, @Nullable final String comment) {
    final Document document = getDomainObject();
    document.setType(DocumentTypeData.INCOMING_INVOICE.findUsing(documentTypeRepository));
    LocalDate dateReceived = document.getCreatedAt().toLocalDate();
    LocalDate dueDate = document.getCreatedAt().toLocalDate().plusDays(30);
    final IncomingInvoice incomingInvoice = incomingInvoiceRepository.create(// EST-1508: the users prefer no default
    null, // invoiceNumber
    null, property, document.getAtPath(), // buyer
    buyerFinder.buyerDerivedFromDocumentName(document), // seller
    null, // invoiceDate
    null, dueDate, null, InvoiceStatus.NEW, dateReceived, // bankAccount
    null, // approval state... will cause state transition to be created automatically by subscriber
    null);
    paperclipRepository.attach(document, null, incomingInvoice);
    trigger(comment, null);
    return incomingInvoice;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document) LocalDate(org.joda.time.LocalDate) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 54 with Document

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

the class Document_categoriseAsOtherInvoice method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "folder-open-o")
public Object act(final IncomingInvoiceType incomingInvoiceType, @Nullable final String comment) {
    final Document document = getDomainObject();
    document.setType(DocumentTypeData.INCOMING_INVOICE.findUsing(documentTypeRepository));
    LocalDate dateReceived = document.getCreatedAt().toLocalDate();
    LocalDate dueDate = document.getCreatedAt().toLocalDate().plusDays(30);
    final IncomingInvoice incomingInvoice = incomingInvoiceRepository.create(incomingInvoiceType, // invoiceNumber
    null, // property
    null, document.getAtPath(), // buyer
    buyerFinder.buyerDerivedFromDocumentName(document), // seller
    null, // invoiceDate
    null, dueDate, null, InvoiceStatus.NEW, dateReceived, // bankAccount
    null, // approval state... will cause state transition to be created automatically by subscriber
    null);
    paperclipRepository.attach(document, null, incomingInvoice);
    trigger(comment, null);
    return incomingInvoice;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document) LocalDate(org.joda.time.LocalDate) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 55 with Document

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

the class BankAccountVerificationStateSubscriber method attachDocumentAsPossibleIbanProofIfNone.

private void attachDocumentAsPossibleIbanProofIfNone(final IncomingInvoice incomingInvoice) {
    final BankAccount bankAccount = incomingInvoice.getBankAccount();
    if (bankAccount == null) {
        return;
    }
    // if already have some proof, then no need to attach any other
    final Optional<Document> currentProofIfAny = lookupAttachedPdfService.lookupIbanProofPdfFrom(bankAccount);
    if (currentProofIfAny.isPresent()) {
        return;
    }
    // else, attach this invoice as possible iban proof.
    final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(incomingInvoice);
    if (documentIfAny.isPresent()) {
        final Document document = documentIfAny.get();
        paperclipRepository.attach(document, BankAccount_attachPdfAsIbanProof.ROLE_NAME_FOR_IBAN_PROOF, bankAccount);
    }
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount) 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