Draft:Accountancy

This is a draft on how a expert accountancy module (double side accountancy) can be designed.

= Prerequisites Dolibarr = Changes needed in Dolibarr before start accounting development:
 * Register fields localtax(1|2)_type into llx_facturedet.
 * Scan code to find TODO where we should use this field to make calculation or use value of this field instead of the select that is done to retrieve value because it was not stored (for example into pdf).
 * Replace field "tva" by "total_tva" into table llx_facture_fourn_det so we will be able to avec common code for customer and supplier invoices to manage accountancy "dispatching".

= Setup = Into config page of "accountancy expert" module, we should be able to
 * First tab: Choose the way we calculate (dispatch) sells and buy (done) and default options.
 * Second tab: A page that list all accountancy plan: Name, country... (All content of Table llx_accountingsystem). At top of this page, before the list, having a form to enter a new empty one (this add an entry int llx_accountingsystem) or cloning an existing one (with a combo to select source of accountancy plan to use. This duplicate line llx_accountingsystem but also all child lines into llx_accountingaccount). Into the list of plans, clicking onto a plan should open the third tab.
 * Third tad: View detail of accountancy plan (Table llx_accountingaccount) and can edit, remove and add new lines.

= Creating transactions = The field pcg_type is used to identity line that we will use to automatically dispatch data when an event occurs into accountancy records. For each Dolibarr event, we add:
 * One record and only one into Table llx_accountingtransaction. This table is link with Dolibarr event and credit/debit table.
 * We add as many records as required into table of debit/credit into Table llx_accountingdebcred.

Lines should be inserted into this table automatically by adding a trigger (file core/triggers/mod_50_modAccountancy_Dispatch.class.php to create). Each Dolibarr event, call trigger and this create several records into this table.

= Editing accountancy = Then we should have entry menus into "Accountancy" menu to add link to accountancy area: htdocs/accountancy/index.php On this page, a summary of accountancy information. Into menu entry, we should also find links to view/edit accountancy records (Table llx_accountingdebcred). Into menu entry, we should also find links to reports (that use Table llx_accountingdebcred).

= Closing an exercice (fiscal year) =