Search in sources :

Example 46 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class PaymentBatch method downloadReviewPdf.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob downloadReviewPdf(final String documentName, @ParameterLayout(named = "How many first pages of each invoice's PDF?") final Integer numFirstPages, @ParameterLayout(named = "How many final pages of each invoice's PDF?") final Integer numLastPages) throws IOException {
    final List<File> pdfFiles = Lists.newArrayList();
    final List<CreditTransfer> transfers = this.getTransfers();
    for (CreditTransfer transfer : transfers) {
        final List<PaymentLine> lines = transfer.getLines();
        for (final PaymentLine line : lines) {
            final IncomingInvoice invoice = line.getInvoice();
            final BankAccount bankAccount = invoice.getBankAccount();
            final Optional<org.incode.module.document.dom.impl.docs.Document> invoiceDocIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
            if (invoiceDocIfAny.isPresent()) {
                final org.incode.module.document.dom.impl.docs.Document invoiceDoc = invoiceDocIfAny.get();
                final byte[] invoiceDocBytes = invoiceDoc.asBytes();
                final Optional<org.incode.module.document.dom.impl.docs.Document> ibanProofDocIfAny = lookupAttachedPdfService.lookupIbanProofPdfFrom(bankAccount);
                List<String> leftLines = Lists.newArrayList();
                leftLines.add("xfer id: " + transfer.getEndToEndId() + " / " + line.getSequence());
                for (IncomingInvoice.ApprovalString approvalString : invoice.getApprovals()) {
                    leftLines.add(String.format("approved by: %s", approvalString.getCompletedBy()));
                    leftLines.add("on: " + approvalString.getCompletedOn());
                }
                final List<String> rightLines = Lists.newArrayList();
                rightLines.add(String.format("debtor IBAN: %s", line.getBatch().getDebtorBankAccount().getIban()));
                rightLines.add(String.format("crdtor IBAN: %s", line.getCreditorBankAccount().getIban()));
                rightLines.add(String.format("gross Amt  : %s", new DecimalFormat("0.00").format(line.getAmount())));
                boolean attachProof = false;
                final String proof;
                if (ibanProofDocIfAny.isPresent()) {
                    final org.incode.module.document.dom.impl.docs.Document ibanProofDoc = ibanProofDocIfAny.get();
                    if (DocumentTypeData.IBAN_PROOF.isDocTypeFor(ibanProofDoc)) {
                        proof = "Separate IBAN proof (next page)";
                        attachProof = true;
                    } else {
                        proof = "Invoice used as IBAN proof";
                    }
                } else {
                    proof = "No IBAN proof";
                }
                rightLines.add(proof);
                URI uri = deepLinkService.deepLinkFor(invoice);
                final Stamp stamp = new Stamp(leftLines, rightLines, uri.toString());
                final byte[] extractedInvoiceDocBytes = pdfManipulator.extractAndStamp(invoiceDocBytes, new ExtractSpec(numFirstPages, numLastPages), stamp);
                appendTempFile(extractedInvoiceDocBytes, documentName, pdfFiles);
                if (attachProof) {
                    final org.incode.module.document.dom.impl.docs.Document ibanProofDoc = ibanProofDocIfAny.get();
                    final byte[] ibanProofBytes = ibanProofDoc.asBytes();
                    final byte[] firstPageIbanProofDocBytes = pdfManipulator.extract(ibanProofBytes, ExtractSpec.FIRST_PAGE_ONLY);
                    appendTempFile(firstPageIbanProofDocBytes, documentName, pdfFiles);
                }
            }
        }
    }
    byte[] pdfMergedBytes = pdfBoxService.merge(pdfFiles);
    pdfFiles.stream().forEach(this::cleanup);
    return new Blob(documentName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, pdfMergedBytes);
}
Also used : DecimalFormat(java.text.DecimalFormat) Document(iso.std.iso._20022.tech.xsd.pain_001_001.Document) URI(java.net.URI) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Blob(org.apache.isis.applib.value.Blob) Stamp(org.estatio.module.capex.platform.pdfmanipulator.Stamp) BankAccount(org.estatio.module.financial.dom.BankAccount) ExtractSpec(org.estatio.module.capex.platform.pdfmanipulator.ExtractSpec) File(java.io.File) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 47 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class Task_reprioritizeBringForward method act.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION, cssClassFa = "fa-arrow-left")
public Task act(final Integer bringForwardByDays) {
    final LocalDateTime newDateTime = task.getCreatedOn().minusDays(bringForwardByDays);
    task.setCreatedOn(newDateTime);
    return task;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 48 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class IncomingInvoice_reject method act.

@Action(domainEvent = IncomingInvoice_next.ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-o-down", cssClass = "btn-warning")
public Object act(final String role, @Nullable final Person personToAssignNextTo, final String reason) {
    final List<PaymentLine> paymentLines = paymentLineRepository.findByInvoice(incomingInvoice);
    // because of the disableXxx guard, this should return either 0 or 1 lines.
    for (PaymentLine paymentLine : paymentLines) {
        final PaymentBatch paymentBatch = paymentLine.getBatch();
        paymentBatch.removeLineFor(incomingInvoice);
    }
    trigger(personToAssignNextTo, reason, reason);
    return objectToReturn();
}
Also used : PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 49 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class InvoiceImportManager method getLines.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ASSOCIATION)
public List<InvoiceImportLine> getLines() {
    List<InvoiceImportLine> result = new ArrayList<>();
    for (Lease lease : leaseRepository.findByAssetAndActiveOnDate(getProperty(), clockService.now())) {
        PaymentMethod paymentMethod = null;
        Unit unit = lease.primaryOccupancy().get().getUnit();
        if (lease.getItems().size() > 0) {
            if (leaseItemRepository.findLeaseItemsByType(lease, LeaseItemType.RENT).size() > 0) {
                paymentMethod = leaseItemRepository.findLeaseItemsByType(lease, LeaseItemType.RENT).get(0).getPaymentMethod();
            } else {
                paymentMethod = lease.getItems().first().getPaymentMethod();
            }
            result.add(new InvoiceImportLine(lease.getReference(), null, paymentMethod.name(), null, null, null, null, null, unit.getReference()));
        } else {
            result.add(new InvoiceImportLine(lease.getReference(), null, null, null, null, null, null, null, unit.getReference()));
        }
    }
    return result;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) ArrayList(java.util.ArrayList) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) Unit(org.estatio.module.asset.dom.Unit) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 50 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class InvoiceImportManager method downloadTemplate.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(cssClassFa = "fa-download")
public Blob downloadTemplate() {
    final String fileName = "template.xlsx";
    WorksheetSpec spec = new WorksheetSpec(InvoiceImportLine.class, "invoiceImportLine");
    WorksheetContent worksheetContent = new WorksheetContent(getLines(), spec);
    return excelService.toExcel(worksheetContent, fileName);
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

ActionLayout (org.apache.isis.applib.annotation.ActionLayout)62 Action (org.apache.isis.applib.annotation.Action)61 Document (org.incode.module.document.dom.impl.docs.Document)22 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)14 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)9 WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)7 Blob (org.apache.isis.applib.value.Blob)6 ArrayList (java.util.ArrayList)5 WorksheetContent (org.isisaddons.module.excel.dom.WorksheetContent)5 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)2 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)2 IncomingDocViewModel (org.estatio.module.capex.app.document.IncomingDocViewModel)2 Invoice (org.estatio.module.invoice.dom.Invoice)2 Lease (org.estatio.module.lease.dom.Lease)2 Organisation (org.estatio.module.party.dom.Organisation)2 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)2 LocalDate (org.joda.time.LocalDate)2 LocalDateTime (org.joda.time.LocalDateTime)2