Search in sources :

Example 11 with ReportSettings

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);
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings) AppBase(com.axelor.apps.base.db.AppBase)

Example 12 with ReportSettings

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();
}
Also used : MetaFiles(com.axelor.meta.MetaFiles) Invoice(com.axelor.apps.account.db.Invoice) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) ReportSettings(com.axelor.apps.report.engine.ReportSettings) ArrayList(java.util.ArrayList) MetaFile(com.axelor.meta.db.MetaFile) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile)

Example 13 with ReportSettings

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());
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) ArrayList(java.util.ArrayList)

Example 14 with ReportSettings

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) User(com.axelor.auth.db.User) ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Example 15 with ReportSettings

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();
}
Also used : ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Aggregations

ReportSettings (com.axelor.apps.report.engine.ReportSettings)20 AxelorException (com.axelor.exception.AxelorException)12 MetaFile (com.axelor.meta.db.MetaFile)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 AppBase (com.axelor.apps.base.db.AppBase)2 MetaFiles (com.axelor.meta.MetaFiles)2 Invoice (com.axelor.apps.account.db.Invoice)1 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)1 BirtTemplateParameter (com.axelor.apps.base.db.BirtTemplateParameter)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 StockMove (com.axelor.apps.stock.db.StockMove)1 User (com.axelor.auth.db.User)1 Transactional (com.google.inject.persist.Transactional)1 IOException (java.io.IOException)1 BirtException (org.eclipse.birt.core.exception.BirtException)1