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