Creating Financial Documents using API's
The following documentation explains how to create financial documents (i.e. customer invoices, quotes, purchase orders, delivery notes
etc.) in such a way that they will be recognized by the ]po[ financial module.
The documentation covers the creation of financial documents via:
Financial Documents and Financial Document Items
A financial document (customer invoice, quote, purchase order, provider bill, ...) consists of an object of type financial document
which is a sub-type of cost item
(please note that the object type for financial documents is called "im_invoice" for historical reasons).
The cost item
is responsible of storing generic financial information include the customer and provider of the financial item and the amount.
The financial document
extends this common financial information with information on the accounting contact and the accounting office of the customer and the invoice template. In addition, the financial document
assumes that there is at least one financial document item or "line"
containing information about amount and type of product or service delivered or requested.
Financial Document Lines Consistency Constraint
A consistency constraint exists linking the sum of the financial document items
with the financial document
: The subtotal of the financial document should be equal to the sum of its lines. This constraint is enforced on the application level:
- GUI level:
The sum of the financial document is automatically calculated as the sum of the document lines.
- REST interface:
The constraint is enforced by re-calculating the financial document subtotal every time a new line is added to the document.
- PL/SQL API (creating financial documents directly via ODBC/SQL):
You will have to implement the constraint manually.
Multiple Projects per Financial Documents
The ]po[ finance module
data-model supports multiple projects per financial document. This feature basically allows companies to include several (typically small) projects into a single invoice, greatly reducing administrative effort in some usage cases.
Relationship Projects - Financial Documents
In order to implement this features, ]po[ defines a generic N:M relationwhip between projects and financial documents, implemented via a [[object-type-acs-rels|
acs_rels]]. The following three cases are important in practice:
- The financial document is not associated to any project. In this case, no acs_rel exists, and the im_cost.project_id field is set to NULL.
- The financial document is associated with exactly one main project. In this case, an acs_rel exists linking the project to the invoice, and the im_cost.project_id is set to the ID of the project.
- The financial document is associated with more then one main project. In this case, the im_cost.project_id field is NULL, and an acs_rel exists for every project.
- The financial document is associated to exactly one main project and several of it's (the main project's) sub-projects. In this case the association to the sub-projects needs to be eliminated by the application, so that the financial document is associated to exactly one main project (see above).