Customize prints for SaleOrder StockMove AccountInvoice
This commit is contained in:
@@ -23,6 +23,7 @@ import com.axelor.apps.account.db.repo.AccountConfigRepository;
|
|||||||
import com.axelor.apps.account.db.repo.InvoiceRepository;
|
import com.axelor.apps.account.db.repo.InvoiceRepository;
|
||||||
import com.axelor.apps.account.exception.IExceptionMessage;
|
import com.axelor.apps.account.exception.IExceptionMessage;
|
||||||
import com.axelor.apps.account.report.IReport;
|
import com.axelor.apps.account.report.IReport;
|
||||||
|
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||||
import com.axelor.apps.base.service.app.AppBaseService;
|
import com.axelor.apps.base.service.app.AppBaseService;
|
||||||
import com.axelor.apps.report.engine.ReportSettings;
|
import com.axelor.apps.report.engine.ReportSettings;
|
||||||
import com.axelor.apps.tool.ModelTool;
|
import com.axelor.apps.tool.ModelTool;
|
||||||
@@ -220,7 +221,17 @@ public class InvoicePrintServiceImpl implements InvoicePrintService {
|
|||||||
: partnerLanguageCode;
|
: partnerLanguageCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String[] arrOfStr = invoice.getInTaxTotal().toString().split("\\.");
|
||||||
|
|
||||||
|
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+" Cts";
|
||||||
|
|
||||||
return reportSetting
|
return reportSetting
|
||||||
|
.addParam("NumberToWords", number)
|
||||||
.addParam("InvoiceId", invoice.getId())
|
.addParam("InvoiceId", invoice.getId())
|
||||||
.addParam("Locale", locale)
|
.addParam("Locale", locale)
|
||||||
.addParam("ReportType", reportType == null ? 0 : reportType)
|
.addParam("ReportType", reportType == null ? 0 : reportType)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.axelor.apps.account.db.PaymentCondition;
|
|||||||
import com.axelor.apps.account.db.PaymentMode;
|
import com.axelor.apps.account.db.PaymentMode;
|
||||||
import com.axelor.apps.account.db.PaymentVoucher;
|
import com.axelor.apps.account.db.PaymentVoucher;
|
||||||
import com.axelor.apps.account.db.Journal;
|
import com.axelor.apps.account.db.Journal;
|
||||||
|
import com.axelor.apps.account.db.repo.AccountConfigRepository;
|
||||||
import com.axelor.apps.account.db.repo.InvoiceRepository;
|
import com.axelor.apps.account.db.repo.InvoiceRepository;
|
||||||
import com.axelor.apps.account.exception.IExceptionMessage;
|
import com.axelor.apps.account.exception.IExceptionMessage;
|
||||||
import com.axelor.apps.account.service.AccountingSituationService;
|
import com.axelor.apps.account.service.AccountingSituationService;
|
||||||
@@ -71,6 +72,7 @@ import java.lang.invoke.MethodHandles;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -1016,6 +1018,60 @@ public class InvoiceController {
|
|||||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showInvoice2(ActionRequest request, ActionResponse response)
|
||||||
|
throws AxelorException {
|
||||||
|
|
||||||
|
Context context = request.getContext();
|
||||||
|
|
||||||
|
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 format = context.get("format") != null ? context.get("format").toString() : "pdf";
|
||||||
|
Integer reportType =
|
||||||
|
context.get("reportType") != null
|
||||||
|
? Integer.parseInt(context.get("reportType").toString())
|
||||||
|
: null;
|
||||||
|
|
||||||
|
Map languageMap =
|
||||||
|
reportType != null
|
||||||
|
&& (reportType == 1 || reportType == 3)
|
||||||
|
&& context.get("language") != null
|
||||||
|
? (Map<String, Object>) request.getContext().get("language")
|
||||||
|
: null;
|
||||||
|
String locale =
|
||||||
|
languageMap != null && languageMap.get("id") != null
|
||||||
|
? Beans.get(LanguageRepository.class)
|
||||||
|
.find(Long.parseLong(languageMap.get("id").toString()))
|
||||||
|
.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();
|
||||||
|
|
||||||
|
logger.debug("Printing " + name);
|
||||||
|
|
||||||
|
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||||
|
response.setCanClose(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set default value for automatic invoice Journal = supplier Purchase Journal
|
* set default value for automatic invoice Journal = supplier Purchase Journal
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package com.axelor.apps.sale.service.saleorder.print;
|
package com.axelor.apps.sale.service.saleorder.print;
|
||||||
|
|
||||||
import com.axelor.apps.ReportFactory;
|
import com.axelor.apps.ReportFactory;
|
||||||
|
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||||
import com.axelor.apps.base.service.app.AppBaseService;
|
import com.axelor.apps.base.service.app.AppBaseService;
|
||||||
import com.axelor.apps.report.engine.ReportSettings;
|
import com.axelor.apps.report.engine.ReportSettings;
|
||||||
import com.axelor.apps.sale.db.SaleOrder;
|
import com.axelor.apps.sale.db.SaleOrder;
|
||||||
@@ -92,8 +93,15 @@ public class SaleOrderPrintServiceImpl implements SaleOrderPrintService {
|
|||||||
|
|
||||||
ReportSettings reportSetting =
|
ReportSettings reportSetting =
|
||||||
ReportFactory.createReport(IReport.SALES_ORDER, title + " - ${date}");
|
ReportFactory.createReport(IReport.SALES_ORDER, title + " - ${date}");
|
||||||
|
|
||||||
|
String[] arrOfStr = saleOrder.getInTaxTotal().toString().split("\\.");
|
||||||
|
|
||||||
|
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+" Cts";
|
||||||
|
|
||||||
return reportSetting
|
return reportSetting
|
||||||
|
.addParam("NumberToWords", number)
|
||||||
.addParam("SaleOrderId", saleOrder.getId())
|
.addParam("SaleOrderId", saleOrder.getId())
|
||||||
.addParam("Locale", locale)
|
.addParam("Locale", locale)
|
||||||
.addParam("ProformaInvoice", proforma)
|
.addParam("ProformaInvoice", proforma)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package com.axelor.apps.stock.service.stockmove.print;
|
package com.axelor.apps.stock.service.stockmove.print;
|
||||||
|
|
||||||
import com.axelor.apps.ReportFactory;
|
import com.axelor.apps.ReportFactory;
|
||||||
|
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||||
import com.axelor.apps.base.service.app.AppBaseService;
|
import com.axelor.apps.base.service.app.AppBaseService;
|
||||||
import com.axelor.apps.report.engine.ReportSettings;
|
import com.axelor.apps.report.engine.ReportSettings;
|
||||||
import com.axelor.apps.stock.db.StockMove;
|
import com.axelor.apps.stock.db.StockMove;
|
||||||
@@ -71,8 +72,17 @@ public class StockMovePrintServiceImpl implements StockMovePrintService {
|
|||||||
|
|
||||||
ReportSettings reportSetting =
|
ReportSettings reportSetting =
|
||||||
ReportFactory.createReport(IReport.STOCK_MOVE, title + " - ${date}");
|
ReportFactory.createReport(IReport.STOCK_MOVE, title + " - ${date}");
|
||||||
|
|
||||||
|
|
||||||
|
String[] exTaxTotal = stockMove.getExTaxTotal().toString().split("\\.");
|
||||||
|
|
||||||
|
String left = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(exTaxTotal[0]));
|
||||||
|
String right = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(exTaxTotal[1]));
|
||||||
|
String number = left+" dinars algériens et "+right+" Cts";
|
||||||
|
|
||||||
return reportSetting
|
return reportSetting
|
||||||
.addParam("StockMoveId", stockMove.getId())
|
.addParam("StockMoveId", stockMove.getId())
|
||||||
|
.addParam("NumberToWords", number)
|
||||||
.addParam("Locale", locale)
|
.addParam("Locale", locale)
|
||||||
.addParam("HeaderHeight", stockMove.getPrintingSettings().getPdfHeaderHeight())
|
.addParam("HeaderHeight", stockMove.getPrintingSettings().getPdfHeaderHeight())
|
||||||
.addParam("FooterHeight", stockMove.getPrintingSettings().getPdfFooterHeight())
|
.addParam("FooterHeight", stockMove.getPrintingSettings().getPdfFooterHeight())
|
||||||
|
|||||||
Reference in New Issue
Block a user