Search in sources :

Example 6 with ReportSettings

use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.

the class ConformityCertificatePrintServiceImpl method prepareReportSettings.

@Override
public ReportSettings prepareReportSettings(StockMove stockMove, String format) throws AxelorException {
    if (stockMove.getPrintingSettings() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.STOCK_MOVES_MISSING_PRINTING_SETTINGS), stockMove.getStockMoveSeq()), stockMove);
    }
    String locale = ReportSettings.getPrintingLocale(stockMove.getPartner());
    String title = getFileName(stockMove);
    ReportSettings reportSetting = ReportFactory.createReport(IReport.CONFORMITY_CERTIFICATE, title + " - ${date}");
    return reportSetting.addParam("StockMoveId", stockMove.getId()).addParam("Timezone", stockMove.getCompany() != null ? stockMove.getCompany().getTimezone() : null).addParam("Locale", locale).addParam("HeaderHeight", stockMove.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", stockMove.getPrintingSettings().getPdfFooterHeight()).addFormat(format);
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Example 7 with ReportSettings

use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.

the class StockMoveServiceImpl method printStockMove.

@Override
public String printStockMove(StockMove stockMove, List<Integer> lstSelectedMove, String reportType) throws AxelorException {
    List<Long> selectedStockMoveListId;
    if (lstSelectedMove != null && !lstSelectedMove.isEmpty()) {
        selectedStockMoveListId = lstSelectedMove.stream().map(integer -> Long.parseLong(integer.toString())).collect(Collectors.toList());
        stockMove = stockMoveRepo.find(selectedStockMoveListId.get(0));
    } else if (stockMove != null && stockMove.getId() != null) {
        selectedStockMoveListId = new ArrayList<>();
        selectedStockMoveListId.add(stockMove.getId());
    } else {
        throw new AxelorException(StockMove.class, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.STOCK_MOVE_10));
    }
    List<StockMove> stockMoveList = stockMoveRepo.all().filter("self.id IN (" + selectedStockMoveListId.stream().map(Object::toString).collect(Collectors.joining(",")) + ") AND self.printingSettings IS NULL").fetch();
    if (!stockMoveList.isEmpty()) {
        String exceptionMessage = String.format(I18n.get(IExceptionMessage.STOCK_MOVES_MISSING_PRINTING_SETTINGS), "<ul>" + stockMoveList.stream().map(StockMove::getStockMoveSeq).collect(Collectors.joining("</li><li>", "<li>", "</li>")) + "<ul>");
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, exceptionMessage);
    }
    String stockMoveIds = selectedStockMoveListId.stream().map(Object::toString).collect(Collectors.joining(","));
    String title = I18n.get("Stock move");
    if (stockMove.getStockMoveSeq() != null) {
        title = selectedStockMoveListId.size() == 1 ? I18n.get("StockMove") + " " + stockMove.getStockMoveSeq() : I18n.get("StockMove(s)");
    }
    String locale = reportType.equals(IReport.PICKING_STOCK_MOVE) ? Beans.get(UserService.class).getLanguage() : ReportSettings.getPrintingLocale(stockMove.getPartner());
    ReportSettings reportSettings = ReportFactory.createReport(reportType, title + "-${date}").addParam("StockMoveId", stockMoveIds).addParam("Timezone", null).addParam("Locale", locale);
    if (reportType.equals(IReport.CONFORMITY_CERTIFICATE)) {
        reportSettings.toAttach(stockMove);
    }
    return reportSettings.generate().getFileLink();
}
Also used : AxelorException(com.axelor.exception.AxelorException) StockMove(com.axelor.apps.stock.db.StockMove) ReportSettings(com.axelor.apps.report.engine.ReportSettings) ArrayList(java.util.ArrayList)

Example 8 with ReportSettings

use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.

the class ManufOrderPrintServiceImpl method prepareReportSettings.

@Override
public ReportSettings prepareReportSettings(ManufOrder manufOrder) {
    String title = getFileName(manufOrder);
    ReportSettings reportSetting = ReportFactory.createReport(IReport.MANUF_ORDER, title);
    return reportSetting.addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", manufOrder.getCompany() != null ? manufOrder.getCompany().getTimezone() : null).addParam("ManufOrderId", manufOrder.getId().toString()).addParam("activateBarCodeGeneration", Beans.get(AppBaseService.class).getAppBase().getActivateBarCodeGeneration()).addFormat(ReportSettings.FORMAT_PDF);
}
Also used : ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Example 9 with ReportSettings

use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.

the class TemplateMessageServiceBaseImpl method generateBirtTemplateLink.

public String generateBirtTemplateLink(Templates templates, Map<String, Object> templatesContext, String fileName, String modelPath, String format, List<BirtTemplateParameter> birtTemplateParameterList) throws AxelorException {
    String birtTemplateFileLink = null;
    ReportSettings reportSettings = generateTemplate(null, templates, templatesContext, fileName, modelPath, format, birtTemplateParameterList);
    if (reportSettings != null) {
        birtTemplateFileLink = reportSettings.getFileLink();
    }
    return birtTemplateFileLink;
}
Also used : ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Example 10 with ReportSettings

use of com.axelor.apps.report.engine.ReportSettings in project axelor-open-suite by axelor.

the class QualityControlPrintServiceImpl method prepareReportSettings.

public ReportSettings prepareReportSettings(QualityControl qualityControl, String format) throws AxelorException {
    if (qualityControl.getPrintingSettings() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.QUALITY_CONTROL_MISSING_PRINTING_SETTINGS)), qualityControl);
    }
    String locale = ReportSettings.getPrintingLocale(qualityControl.getProject().getClientPartner());
    String title = getFileName(qualityControl);
    ReportSettings reportSetting = ReportFactory.createReport(IReport.QUALITY_CONTROL, title + " - ${date}");
    return reportSetting.addParam("QualityControlId", qualityControl.getId()).addParam("Timezone", getTimezone(qualityControl)).addParam("Locale", locale).addFormat(format);
}
Also used : AxelorException(com.axelor.exception.AxelorException) 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