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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations