Projects:Invoicing Process Base/Technical Specification
In this document are described all the developments needed to properly implement the Invoicing process base module.
The objective of the module is to create a framework to easily create massive invoicing processes.
The approach of this massive invoicing process is to do the invoicing in two steps:
- 1- Based on some filters generate a proposal of invoices to be generated
- 2- Select the temporary proposal made in the previous step and generate the final invoices.
Invoicing process Base Module
- Name: Invoicing process base
- Java Package: com.openbravo.gps.invoicingprocessbase
- DB Prefix: OBINBS
- Commercial: No
- Openbravo 3.0.20857
Invoicing process configuration
In this window is configured the Invoicing process implemented by the user. Each module implementing a massive invoice process have to include a record in this window specifying the java class of the process to execute and the process definition. Single tab structure
Temporary Sales Invoice Proposal
Window to store temporary the invoices proposed by the invoicing process. This window is not accessible by the menu, it is only opened after the execution of the invoicing process.
Notice that there is no Process definition in this module. The process definition will be defined in the massive invoicing process developed on top of this module.
Component to allow the execution of a process for several records in a window. This components has a method called execute() which is the responsible of the execution of the process to generate the final invoices. This method will be called by the handler defined on the 'Create Invoices' process implemented on top of this module.
Component provider for ob-multirecordprocess.
Action handler that should be declared in all the processes that implements and extends this module. This handler supports two actions:
- Generate the invoicing proposal: After generate the proposal it opens the window Temporary Sales Invoice Proposal showing only the temporary invoices just created by this instance of the process.
- Generate the committed invoices from the proposal. This action is executed by a button in the window Temporary Sales Invoice Proposal. Every process on top of this module will create a button/process to finally convert the temporary sales invoices into committed sales invoices.
Java interface that has two methods defined (one for each action called by BaseProcessHandler):
public InvoiceTempInstance createTemporalInvoices(JSONObject params) throws Exception; public OBError generateInvoices(JSONObject params) throws Exception;
Each invoicing massive processes developed on top of this module has to implement these methods.
Abstract class that implements the InvoiceProcess interface and some other generic methods ready to be overwritten by the any invoicing process that extends this module (i.e Re-invoicing process).
public void createTemporalInvoicesExtensionPoint(InvoiceTempInstance invoiceTempInstance) public String getDescription(Invoice invoice) public String getInvoiceLineDescription(InvoiceLine invoiceLine) public Date calculateInvoiceDate(Date currentDate, Order salesOrder, Date filterDateFrom, Date filterDateTo, String invoiceType)
There is a method called getInvoiceProcessClass that should not be overwritten. This is the method responsible for getting an instance of the java class configured in the Invoicing process configuration window. The returned java class instance will be the invoicing process that implements the BaseInvoiceProcess.
protected static BaseInvoiceProcess getInvoiceProcessClass(Client client, Process processDefinition) throws Exception
Class to manage the instances of the processes and link them to the generated invoices.
Utility with some useful methods reusable by any invoicing process: getListBreakBy1000: Creates a list of sets containing at max of 1000 elements each. Useful to avoid problems with more than 1000 items in oracle IN clause.
generateDocumentNo: Returns a document number using Utility.getDocumentNo
fromJSONArrayToSet: Convert an JSON array of string to a set of strings.
convertOBErrorToJSON: Converts the OBError message to a JSONObject message.
Some constants defined. Some examples:
public final static String SALES_INVOICE_PROPOSAL_HEADER_TAB = "3A35F9481CD14EAC86ACF6C7E756A9A4"; public final static String DRAFT = "DR";