Projects:Massinvoicing/Specifications
This document contains the functional specification of the mass invoicing module.
Contents |
General Description
The mass invoicing function allows a user to create multiple sales invoices in one step for multiple business partners. The generated invoices are based on an invoice template. The invoice template defines default and pre-set information which is to be used in the generation of the invoices.
This module will use the prefix: MINV.
The menu options for the mass invoicing functions can be found in the following locations
- Sales Management > Transactions menu: contains Mass Invoicing
- Sales Management > Setup: contains the Invoice Template maintenance function
Relation to other modules
This module is related to (but not dependent on) the inter-company invoicing module. The invoices generated by mass invoicing can be used as input for the inter company invoicing process.
This module makes use of and is dependent on the multi-business-partner selector module. The business partner delivered by that module is used in the generation wizard.
MassInvoicing Wizard
To generate invoices the user will go through a multi-step wizard:
- select business partners, organization, invoice template and select which products will be in each invoice and their default price and quantity
- set a price quantity per business partner-invoice line combination and generate the invoices
- show the result of the generation step (invoices created)
Step 1: Select Organization, business partner and products
This step allows the user to:
- select an organization
- select one or more business partners
- set the invoice date
- select which invoice template to use
- set for the chosen invoice template which lines should be used and the price/quantity per line
A first version of the user interface is shown below.
The invoice template listbox will only show invoice templates which are active and which have at least one active line.
The product list in the bottom is refreshed when the user selects another invoice template.
When the user selects an invoice template then all product lines are initially selected.
The product list will only show active lines. The user can (de-)select all invoice template lines by checking the 'global' checkbox in the product list.
The price and quantity fields are only enabled if their corresponding line-checkbox is checked.
The price field is not mandatory, if it not set then the system will automatically use the price from the price list. This price is shown in step 2 of the wizard.
The business partner selector is implemented by the business partner selector module. It allows filtering business partners and to select one or more business partners.
The following validations should be done in step 1 of the wizard:
- at least one business partner should be selected (client-side)
- the business partners should belong to the accessible organizations for the selected organization in the window.
- the business partners should have access to the price-list defined in the selected invoice template.
- the business partners should all have an invoicing address (at least active c_bpartner_location with billto=='Y').
- invoice date should be set and have the right format (client-side)
- an invoice template should be selected (client-side)
- at least one line should be selected (client-side)
- the quantity of the selected lines should be set and have the correct format (client-side)
The validations marked with client-side are performed on the client-side (in the browser). The remaining validations are done when the user presses next. If a validation fails the same window is displayed with all the information as entered and a message box explaining the validation failure. The validation message should show enough detail (list specific business partners for which the above check fails).
When the user is satisfied the user can select the next button to go to step 2. The information entered in step 1 is stored and the user can return back from step 2 to change the information.
Step 2: Set price/quantity per business partner/invoice line
The second step uses the information from the first step to show a product list by business partner. All the lines of the selected invoice template are shown. Only the ones which have been selected in the first step are also selected in step 2 of the wizard. Also the price and quantity from step 1 are used, for the non-selected lines the price and quantity from the invoice template line is used.
When for a line in the first step no price was set, then the price is read from the price list and shown in this step 2. The price list is either taken from the invoice template or if not set there from the business partner.
Step 2 allows the user to change price/quantity on a business partner-invoice line level. If the price field is cleared/not set then the price from the price list is used in the invoice generation.
When the user presses generate the system validates the inputs and asks for confirmation. If the user confirms then system generates invoices (see later section for a description of the generate process).
The validation, validates that each selected line has a valid quantity and price.
If the generation fails then the step 2 window is re-shown with a detailed error message in a red message box.
Step 3: The result
In step 3 the result for of the generation step is shown. The proposal is to show the following information: a table with a list of invoices with for each invoice:
- the invoice identifier
- total amount
- grand total (incl. taxes)
The invoice identifier is a link to the invoice itself.
In addition the sum of the total amount and grand total are displayed.
Invoice Templates
In the first step of the invoice generation wizard the user can select the invoice template. The invoice template defines which products are used as the basis for the generated invoice.
In addition it allows the definition of the following information which is used in each generated invoice:
On invoice header level:
- description
- pricelist (non-mandatory)
- payment rule (non-mandatory)
- payment term (non-mandatory)
On invoice line level:
- line
- description
- product
- quantity (can be overridden in the wizard)
- price (can be overridden in the wizard)
- tax (non-mandatory)
If the non-mandatory information is not set then it is computed when the invoice generation takes place.
Generating Invoices
This section of the functional spec describes in some detail how the invoices are created and which information is used to set which invoice header and line column.
When the user presses the generate button the following actions are performed:
- For each business partner which has at least one selected product an invoice header is created.
- For each checked line an invoice line is created which is linked to its invoice header.
- The created invoice is posted.
- The resulting identifier and totals are displayed on the result page.
The information on the invoice header (c_invoice) is set as follows:
Column | Value |
---|---|
ad_client_id | the current user client |
ad_org_id | the organization selected in step 1 |
isactive | Y |
created, createdby, updated, updatedby | current user, current date |
issotrx | Y |
documentno | will be computed |
docstatus | DR |
docaction | CO |
processing | N |
processed | N |
posted | N |
c_doctype_id | initially set to 0 |
c_doctypetarget_id | set to the c_doctype_id from the template |
c_order_id | null |
description | set from the invoice template |
salesrep_id | copied from the business partner |
dateinvoiced | set to invoice date set in step 1 of the wizard |
dateprinted | null |
dateacct | set to invoice date set in step 1 of the wizard |
c_bpartner_id | the business partner for which the invoice is generated |
c_businesspartner_location | the first business partner location in c_bpartner_location which has billto='Y' |
poreference | null |
isdiscountprinted | taken from the business partner |
dateordered | null |
c_currency_id | taken from the invoice template price list, or from the price list of the invoice |
paymentrule | taken from the invoice template, or from the business partner |
c_paymentterm_id | taken from the invoice template, or from the business partner |
c_charge_id | null |
chargeamt | null |
totallines, grandtotal | computed by triggers |
m_pricelist-id | taken from the invoice template, or from the business partner (the po price list) |
tax_included | N |
c_campaign_id, c_project_id, c_activity_id | all null |
createfrom, generateto, copyfrom | null |
isselfservice | null |
ad_orgtrx_id | null |
user1_id, user2_id | null |
witholdingamount | null |
taxdate | invoice date entered in step 1 |
c_withholding_id | null |
The invoice line (c_invoice_line) is set as follows:
Column | Value |
---|---|
ad_client_id | the current user client |
ad_org_id | the organization selected in step 1 |
isactive | Y |
created, createdby, updated, updatedby | current user, current date |
c_invoice_id | the id of the invoice header |
c_orderline_id, c_inoutline_id | null |
line | from the invoice template line |
description | from the invoice template line |
m_product_id | from the invoice template line |
qtyinvoiced | entered quantity on page 2 of the wizard |
pricelist | computed using the PriceListVersion and ProductPrice |
priceactual | price entered on page 2 of the wizard |
pricelimit | computed using the PriceListVersion and ProductPrice |
linenetamt | pricestd * quantity entered by the user in step 2 |
c_charge_id | null |
chargeamt | null |
c_uom_id | taken from the product: c_product.c_uom_id |
c_tax_id | from the invoice template line, or computed |
s_resourceassignment_id | null |
taxamt | null |
m_attributesetinstance_id | null |
isdescription | N |
quantityorder | null |
m_product_uom_id | same as c_uom_id |
c_invoice_discount_id, c_projectline_id, c_offer_id | null |
pricestd | computed from pricelist using the SLOrderProductData.getOffersStdPriceInvoice method |
excludeforwithholding | null |
The following related tables are handled by triggers:
- c_invoice_discount
- c_invoiceline_offer
- c_invoicetax
- c_invoice_acctdimenstion
A created invoice is stored in the database and directly posted using the C_INVOICE_POST stored procedure.
Other considerations
- The invoice template name is not translated.
- Labels and messages should be translatable.
- The date and numeric formats used by the rest of the application should also be used here.
Maintaining Invoice Templates: table definitions and windows/tabs
Table: Invoice Template and Invoice Template Line
To maintain and store invoice templates two new tables are created:
- minv_invoice_template: with the following fields:
- standard columns: minv_invoice_template_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby
- name: the name of the invoice template, is displayed to the user generating the invoices
- description: is used to create the invoice description (c_invoice.description)
- c_doctype_id (required): a required reference to he c_doctype table, only document types accessible from the organization of the template can be selected.
- m_pricelist_id (not-required): foreign key to the m_pricelist table
- paymentrule (not-required): a free format string field
- c_paymentterm_id (not-required): foreign key to the c_paymentterm table
- minv_invoice_template_line: with the following fields:
- standard columns: minv_invoice_template_line_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby
- minv_invoice_template_id: the reference to the invoice template header
- line (required): a line number to identify the order of the lines, will be used to create the line number on the invoice line
- description (required): the description, is used to set the description on the invoice line
- m_product_id (required): foreign key reference to the m_product table
- qty (required): initial quantity (can be changed in the wizard)
- price (required): initial price in the uom of the product (can be changed in the wizard)
- c_tax_id (not required): foreign key to the c_tax table
Window/Tabs for maintaining Invoice Templates
The following screenshots show examples of the maintenance windows for the invoice templates.
Server-Side Implementation
The server-side logic to create invoices will be using the DAL.
The idea is to implement the creation of invoices in two steps:
- first create the invoice(line) object
- then have a separate object/service set or compute the non-set properties of the invoice(line) object
This pattern can be the basis for future more generic solutions as it is a common requirement that it should be easy to create business objects and set computable information automatically.
The posting of the invoice is done through a stored procedure. The implementation of this module will try to create a generic api for passing parameters to stored procedures and running stored procedures from java.