Projects:Reinvoice/Technical Specification
Contents |
Introduction
In this document are described all the developments needed to create a massive invoice process to generate sales invoices from re-invoicing purchase invoices.
Module Definition
- Name: Re-Invoicing
- Java Package: com.openbravo.gps.reinvoicing
- DB Prefix: OBREINV
- Commercial: Yes
- Dependencies:
- Invoicing Process Base 1.0.0
Process Definition
Two processes have been created:
Re-invoice process
- Re-Invoice process: To create the proposal invoicing.
Process definition
- Handler: com.openbravo.gps.invoicingprocessbase.process.BaseProcessHandler. Notice that this handler belongs to Invoicing base process. All the logics in this module will be developed in ReinvoiceProcess.java which extends BaseInvoiceProcess class.
Create invoices
- Create Invoices: To confirm the temporary invoices as completed invoices.
Process definition
- Handler: OB.OBREINV.Process.createInvoices. This handler calls the following javascript piece of code located in web/com.openbravo.gps.reinvoicing.js/ob-reinvoice-multirecordprocess.js
OB.OBREINV = OB.OBREINV || {}; OB.OBREINV.Process = { createInvoices: function (params, view) { params.action = 'PROCESS'; params.actionHandler = 'com.openbravo.gps.invoicingprocessbase.process.BaseProcessHandler'; params.adTabId = '3A35F9481CD14EAC86ACF6C7E756A9A4'; params.processId = '12FFAFDAF219415B8BD2303C337483D0'; params.vadidate = function (row) { // Blocked invoices cannot be selected //if (row.oBSCNTRInvoiceType === 'B') { //return OB.I18N.getLabel('OBINBS_BlockedNoPossibleInvoice'); //} return false; }; OB.OBINBS.Process.execute(params, view); } };
The objective of this js is to initialize some parameters that will be used by BaseProcessHandler.
Process parameters
- Organization: it may be empty.
- Starting date - Ending date: compulsory filters, period of purchase invoices pending to be reinvoiced.
- Sales invoice date: compulsory value, the value by default will be todays date, it will be the date of the sales invoices generated.
- Business Partner (Customer): allow to filter by those customers to whom it is required to invoice.
- Contract: if it is required to filter by any specific contract.
- Product: to indicate the products to those purchase invoice lines that must be re-invoiced.
- Purchase invoice: it allows to filter for those purchase invoices that are required to re-invoice.
- Current: Checked by default. To launch just the invoices considering all the filters.
- Previous: Un-checked by default. To launch all the invoices considering all the filters but also if there are any purchase invoice pending to be re-invoiced previous to the starting date (but considering also the other filters)
- Group sales invoice by: the user may indicate how the sales invoices must be grouped, the available options will be:
- Purchase invoice: it will be the option checked by default. one sales invoice will be generated per purchase invoice, considering all the lines checked as re-invoiced and with the same customer.
- Customer: all purchase invoice lines checked as re-invoiced with the same customer will generate a unique sales invoice.
- Project/Contract: it will be generated so many sales invoices as purchase invoice lines to re-invoiced considering the same customer and project.
Modified tables and windows
Temporary sales invoice proposal
Add a column in C_INVOICE table:
- em_obreinv_createinv: character(1) NOT NULL DEFAULT 'N'
Add a field linked to the defined column above in Temporary sales invoice proposal window:
- Create Invoices: Button. Process definition = Create Invoices
Menu entries
Created a menu entry linked to the process Re-invoicing
Dataset
- Name: Re-invoicing configuration
- Tables:
- obinsb_invpro_config: Contains the record in the invoicing configuration window where is specified the java class that will implement BaseInvoiceProcess.
- obreinv_groupby: Contains three types of grouping for the result of the proposal generation (group by project, customer or purchase invoice)
Java artifacts
ReinvoiceComponentProvider
Just to register the component ob-reinvoice-multirecordprocess.js.
ReinvoiceDao
Data access object to centralize all the DB transactions.
ReinvoiceProcess
ReInvoiceProcess extends BaseInvoiceProcess and overrides two methods:
- createTemporalInvoices: Method that creates the temporary invoices to show in the window Temporary sales invoice proposal after the execution of the process.
- generateInvoices: Assign a document number to the selected invoices from the proposal and completes them.
Notice that this class is not defined in process definition but in Invoicing configuration window. The reason is that the BaseProcessHandler manages all the requests and execute the instance of the java class of process to be executed, ReinvoiceProcess in this case.