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