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