diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java index 04f7611..a164f7f 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java @@ -49,6 +49,7 @@ import com.axelor.apps.base.service.BankDetailsService; import com.axelor.apps.base.service.PartnerPriceListService; import com.axelor.apps.base.service.PartnerService; import com.axelor.apps.base.service.TradingNameService; +import com.axelor.apps.report.engine.ReportSettings; import com.axelor.apps.tool.StringTool; import com.axelor.common.ObjectUtils; import com.axelor.db.JPA; @@ -355,13 +356,13 @@ public class InvoiceController { reportType, locale); title = I18n.get("Invoice"); - response.setCanClose(true); + // response.setCanClose(true); } else { throw new AxelorException( TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.INVOICE_3)); } response.setView(ActionView.define(title).add("html", fileLink).map()); - response.setCanClose(true); + // response.setCanClose(true); } catch (Exception e) { TraceBackService.trace(response, e); } @@ -1026,10 +1027,7 @@ public class InvoiceController { Invoice invoice = Beans.get(InvoiceRepository.class) .find(Long.parseLong(context.get("id").toString())); - String name = I18n.get("Invoice"); - String inTaxTotal = invoice.getInTaxTotal().toString(); - String[] arrOfStr = inTaxTotal.split("\\."); - + String name = I18n.get("Invoice"); String format = context.get("format") != null ? context.get("format").toString() : "pdf"; Integer reportType = @@ -1050,26 +1048,11 @@ public class InvoiceController { .getCode() : null; - String left = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[0])); - String right = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[1])); - String number = left+" dinars algériens et "+right+" centimes"; - - String fileLink = - ReportFactory.createReport("invoice.rptdesign", name + "-${date}") - .addParam("NumberToWords", number) - .addParam("InvoiceId", invoice.getId()) - .addParam("Locale", locale) - .addParam("ReportType", reportType == null ? 0 : reportType) - .addParam("HeaderHeight", invoice.getPrintingSettings().getPdfHeaderHeight()) - .addParam("FooterHeight", invoice.getPrintingSettings().getPdfFooterHeight()) - .generate() - .getFileLink(); + ReportSettings reportSettings = Beans.get(InvoicePrintService.class).prepareReportSettings(invoice, reportType, format, locale); logger.debug("Printing " + name); - response.setView(ActionView.define(name).add("html", fileLink).map()); - response.setCanClose(true); - + response.setView(ActionView.define(name).add("html", reportSettings.generate().getFileLink()).map()); }