use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.
the class PurchaseOrderPrintServiceImpl method prepareReportSettings.
public ReportSettings prepareReportSettings(PurchaseOrder purchaseOrder, String formatPdf) throws AxelorException {
if (purchaseOrder.getPrintingSettings() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.PURCHASE_ORDER_MISSING_PRINTING_SETTINGS), purchaseOrder.getPurchaseOrderSeq()), purchaseOrder);
}
String locale = ReportSettings.getPrintingLocale(purchaseOrder.getSupplierPartner());
String title = getFileName(purchaseOrder);
AppBase appBase = appBaseService.getAppBase();
ReportSettings reportSetting = ReportFactory.createReport(IReport.PURCHASE_ORDER, title + " - ${date}");
return reportSetting.addParam("PurchaseOrderId", purchaseOrder.getId()).addParam("Timezone", purchaseOrder.getCompany() != null ? purchaseOrder.getCompany().getTimezone() : null).addParam("Locale", locale).addParam("GroupProducts", appBase.getIsRegroupProductsOnPrintings() && purchaseOrder.getGroupProductsOnPrintings()).addParam("GroupProductTypes", appBase.getRegroupProductsTypeSelect()).addParam("GroupProductLevel", appBase.getRegroupProductsLevelSelect()).addParam("GroupProductProductTitle", appBase.getRegroupProductsLabelProducts()).addParam("GroupProductServiceTitle", appBase.getRegroupProductsLabelServices()).addParam("HeaderHeight", purchaseOrder.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", purchaseOrder.getPrintingSettings().getPdfFooterHeight()).addFormat(formatPdf);
}
use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.
the class InvoicingProjectService method generateAnnex.
public void generateAnnex(InvoicingProject invoicingProject) throws AxelorException, IOException {
String title = I18n.get("InvoicingProjectAnnex") + "-" + Beans.get(AppBaseService.class).getTodayDateTime().format(DateTimeFormatter.ofPattern(DATE_FORMAT_YYYYMMDDHHMM));
ReportSettings reportSettings = ReportFactory.createReport(IReport.INVOICING_PROJECT_ANNEX, title).addParam("InvProjectId", invoicingProject.getId()).addParam("Timezone", getTimezone(invoicingProject)).addParam("Locale", ReportSettings.getPrintingLocale(null));
if (invoicingProject.getAttachAnnexToInvoice()) {
List<File> fileList = new ArrayList<>();
MetaFiles metaFiles = Beans.get(MetaFiles.class);
Invoice invoice = invoicingProject.getInvoice();
fileList.add(Beans.get(InvoicePrintServiceImpl.class).print(invoice, null, ReportSettings.FORMAT_PDF, null));
fileList.add(reportSettings.generate().getFile());
MetaFile metaFile = metaFiles.upload(PdfTool.mergePdf(fileList));
metaFile.setFileName(title + ".pdf");
metaFiles.attach(metaFile, null, invoicingProject);
return;
}
reportSettings.toAttach(invoicingProject).generate();
}
use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.
the class EbicsController method printCertificates.
public void printCertificates(ActionRequest request, ActionResponse response) throws AxelorException {
EbicsUser ebicsUser = request.getContext().asType(EbicsUser.class);
ArrayList<Long> certIds = new ArrayList<Long>();
if (ebicsUser.getA005Certificate() != null) {
certIds.add(ebicsUser.getA005Certificate().getId());
}
if (ebicsUser.getE002Certificate() != null) {
certIds.add(ebicsUser.getE002Certificate().getId());
}
if (ebicsUser.getX002Certificate() != null) {
certIds.add(ebicsUser.getX002Certificate().getId());
}
if (certIds.isEmpty()) {
throw new AxelorException(ebicsUser, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EBICS_MISSING_CERTIFICATES));
}
String title = I18n.get("EbicsCertificate");
ReportSettings report = ReportFactory.createReport(IReport.EBICS_CERTIFICATE, title + "-${date}${time}");
report.addParam("CertificateId", Joiner.on(",").join(certIds));
report.addParam("EbicsUserId", ebicsUser.getId());
report.addParam("Timezone", ebicsUser.getAssociatedUser() != null ? ebicsUser.getAssociatedUser().getActiveCompany() : null);
report.toAttach(ebicsUser);
report.generate();
response.setView(ActionView.define(title).add("html", report.getFileLink()).map());
}
use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.
the class InvoiceServiceProjectImpl method editInvoiceAnnex.
public List<String> editInvoiceAnnex(Invoice invoice, String invoiceIds, boolean toAttach) throws AxelorException {
if (invoice.getPrintingSettings() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.INVOICE_MISSING_PRINTING_SETTINGS), invoice.getInvoiceId()), invoice);
}
if (Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null) != null && !AuthUtils.getUser().getActiveCompany().getAccountConfig().getDisplayTimesheetOnPrinting() && !AuthUtils.getUser().getActiveCompany().getAccountConfig().getDisplayExpenseOnPrinting()) {
return null;
}
String language = ReportSettings.getPrintingLocale(invoice.getPartner());
String title = I18n.get("Invoice");
if (invoice.getInvoiceId() != null) {
title += invoice.getInvoiceId();
}
Integer invoicesCopy = invoice.getInvoicesCopySelect();
ReportSettings rS = ReportFactory.createReport(IReport.INVOICE_ANNEX, title + "-" + I18n.get("Annex") + "-${date}");
if (toAttach) {
rS.toAttach(invoice);
}
String fileLink = rS.addParam("InvoiceId", invoiceIds).addParam("Locale", language).addParam("Timezone", invoice.getCompany() != null ? invoice.getCompany().getTimezone() : null).addParam("InvoicesCopy", invoicesCopy).addParam("HeaderHeight", invoice.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", invoice.getPrintingSettings().getPdfFooterHeight()).generate().getFileLink();
List<String> res = Arrays.asList(title, fileLink);
return res;
}
use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.
the class SubrogationReleaseServiceImpl method printToPDF.
@Override
public String printToPDF(SubrogationRelease subrogationRelease, String name) throws AxelorException {
ReportSettings reportSettings = ReportFactory.createReport(IReport.SUBROGATION_RELEASE, name);
reportSettings.addParam("SubrogationReleaseId", subrogationRelease.getId());
reportSettings.addParam("Locale", ReportSettings.getPrintingLocale(null));
reportSettings.addParam("Timezone", subrogationRelease.getCompany() != null ? subrogationRelease.getCompany().getTimezone() : null);
reportSettings.addFormat("pdf");
reportSettings.toAttach(subrogationRelease);
reportSettings.generate();
return reportSettings.getFileLink();
}
Aggregations