Difference between revisions of "Using Jasper Report Form in place of Standard Forms"

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
(Number to Text in Jasper Form (Thai Language))
(Number to Text in Jasper Form (Thai Language))
Line 73: Line 73:
 
#Put this string function --> "("+org.isec.report.utils.Scriptlet.getAmtInWords($F{payamt}.setScale($V{v_scale}).toString(),"THB")+")" on the Text Field to run the amount
 
#Put this string function --> "("+org.isec.report.utils.Scriptlet.getAmtInWords($F{payamt}.setScale($V{v_scale}).toString(),"THB")+")" on the Text Field to run the amount
 
#Enjoy!
 
#Enjoy!
:[[File:number_to_thaitext.jpg]]
+
:[[File:number_to_thaitext.jpg|700px]]
  
 
==Registering Jasper Form==
 
==Registering Jasper Form==

Revision as of 02:48, 28 September 2010

This content contributed by Ecosoft, Thailand.

Overview

Jasper Report is adopted as more flexible and easy way to create reports. Without it, we need to create Forms or Reports using ADempiere's Print Format. In some case, it is ok, but many cases quite difficult to use.

There are many pages in this Wiki talking about how to user Jasper Report, which will be very informative to read. To be more specific, this page will give the overview with pictures how to use Jasper Report as a Form, i.e., Sales Order, Invoice, Receipt, etc.

By default, clicking on Print Preview in document window menu give, Sales Order Form generated by standard Print Format technique.

Sample Standard Order From

First - know how ADempiere locate Forms for each document type

Wondering, how Print Preview button discover which Form to use? Here is the answer,

Before the integration with Jasper Report, Print Format is the only way to create Print Form in ADempiere. As such, in the window that do the Form & Document mapping is using the Print Format to tell what form to use for which document type. This give some confusion at first, but we will see how jasper report form will be used on top of it later.

  • For most Document Type, Print Form window will be used as default, Some exception will be discussed later.

Print Form

  • To overwrite it to be more specific for different Document Type, use window Document Type, field Print Format

Document Type


  • You can right click on the Print Format field and Zoom to Print Format window to see them in detail.
  • Note that, by default, Jasper Report field is blank, which mean this Print Format is used directly as Printing Form

Print Format

  • Although we can use Print Format to customize this form using its Format Item tab, but trust me, it is the most time consuming work to do with ADempiere. Let's make our life easier with Jasper Report!
Summary on how Print Preview button on document window find Print Format to use
  • Purchase Order and Sales Order: "Document Type" overwrite "Print Form"
  • Invoice (Customer) and Invoice (Vendor): "Business Partner / Customer tab (Invoice Print Format)" overwrite "Document Type" overwrite "Print Form"
  • Shipment (Customer) and Material Receipt: "Document Type" overwrite "Print Form"
  • Payment: This type of document is a bit special, as it will be looking the Print Format from "Bank / Bank Account Document tab (Check Print Format)". In Payment window, based on selected Bank Account, right Print Format will be used.

Creating new Jasper Report Form and use it in place of the Print Format

Assuming that we already know how to use Jasper Report to create a form, the only trick is to ensure your Jasper Report will use $P{RECORD_ID} parameter to get ID from the calling window.

Jasper Sales Order

Note:

  • In most window, RECORD_ID is the real current record of the calling window. I.e., Sales Order = C_Order_ID, but not always.
  • Some window, such as Payment, is passing C_PaySelectionCheck_ID not C_Payment_ID.

After ensure that the Jasper Report running fine, deploy report and then register this Jasper Report to ADempiere

1) As System, create new record and tell where this report is located
Register Jasper Report
2) As Client, use this Jasper Report in the Print Format in question, i.e., following picture is for Sales Order Form
Use created Jasper Report on Sales Order Form
3) Now, test on Print Preview again, you should see the report in Jasper View as following.
Use created Jasper Report on Sales Order Form

Note as of 360LTS

  • It is recommended to use jasper report to overwrite the default print format, rather than creating new print format just for it. Although you might notice that, the overwritten default print format configuration is not used at all.
  • The reason is, Jasper Report is just overwriting. Internally, the report engine still execute the overwritten print format although not used eventually. It can give non-fatal log message if, i.e., not found the Format Items records, or pass RECORD_ID that is unmatched with the Print Format's Table.
  • Or if it is necessary, make sure you create with the right table and click on "Copy/Create" button to create some Format Item records (just to avoid error).

Number to Text in Jasper Form (Thai Language)

As Jasper Report can call java class that convert from number to text, so this problem is resolved easily using Scriptlet Java Class. Just following these steps to use Thai Text in Jasper Report.

  1. Compile this File:Scriptlet.java into your project
  2. In Jasper Report, create a Text Field where you want the Text to display.
  3. In Jasper Report, create a Variable field (Integer) and set value to 2. This value hold decimal point we want to use.
  4. Put this string function --> "("+org.isec.report.utils.Scriptlet.getAmtInWords($F{payamt}.setScale($V{v_scale}).toString(),"THB")+")" on the Text Field to run the amount
  5. Enjoy!
Number to thaitext.jpg

Registering Jasper Form

See Also