2011-08-31 13:05:58 +02:00
< ? php
2021-03-31 04:59:12 +02:00
/* Copyright ( C ) 2013 - 2014 Olivier Geffroy < jeff @ jeffinfo . com >
* Copyright ( C ) 2013 - 2021 Alexandre Spangaro < aspangaro @ open - dsi . fr >
* Copyright ( C ) 2014 Ari Elbaz ( elarifr ) < github @ accedinfo . com >
* Copyright ( C ) 2014 Florian Henry < florian . henry @ open - concept . pro >
* Copyright ( C ) 2016 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2017 - 2021 Open - DSI < support @ open - dsi . fr >
2011-08-31 13:05:58 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2011-08-31 13:05:58 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2011-08-31 13:05:58 +02:00
*/
/**
2015-01-25 06:54:17 +01:00
* \file htdocs / core / modules / modAccounting . class . php
2019-04-08 13:35:06 +02:00
* \ingroup Double entry accounting
* \brief Module to activate the double entry accounting module
2011-08-31 13:05:58 +02:00
*/
2019-11-13 19:37:08 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2011-08-31 13:05:58 +02:00
/**
2021-03-20 13:55:43 +01:00
* Class to describe and enable double entry accounting module
2011-08-31 13:05:58 +02:00
*/
class modAccounting extends DolibarrModules
{
/**
2014-08-29 06:43:05 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
2011-08-31 13:05:58 +02:00
*
2014-08-29 06:43:05 +02:00
* @ param DoliDB $db Database handler
2017-09-16 06:53:29 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2011-08-31 13:05:58 +02:00
{
global $conf ;
2017-09-16 06:53:29 +02:00
$this -> db = $db ;
2014-08-27 07:03:42 +02:00
$this -> numero = 50400 ;
2014-09-09 09:46:57 +02:00
2011-08-31 13:05:58 +02:00
$this -> family = " financial " ;
2018-10-06 11:57:53 +02:00
$this -> module_position = '61' ;
2011-08-31 13:05:58 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2014-08-27 07:03:42 +02:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2019-04-08 13:35:06 +02:00
$this -> description = " Double entry accounting management " ;
2014-09-09 09:46:57 +02:00
2016-12-31 16:35:56 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this -> version = 'dolibarr' ;
2014-09-09 09:46:57 +02:00
2019-11-13 19:37:08 +01:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2021-04-30 15:22:17 +02:00
$this -> picto = 'accountancy' ;
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Data directories to create when module is enabled
2014-09-09 09:46:57 +02:00
$this -> dirs = array ( '/accounting/temp' );
2011-08-31 13:05:58 +02:00
// Config pages
2021-07-05 06:58:10 +02:00
$this -> config_page_url = array ( 'accounting.php?mainmenu=accountancy&leftmenu=accountancy_admin' );
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Dependencies
2019-11-13 19:37:08 +01:00
$this -> depends = array ( " modFacture " , " modBanque " , " modTax " ); // List of modules id that must be enabled if this module is enabled
2014-09-09 09:46:57 +02:00
$this -> requiredby = array (); // List of modules id to disable if this one is disabled
$this -> conflictwith = array ( " modComptabilite " ); // List of modules are in conflict with this module
2021-02-06 13:48:31 +01:00
$this -> phpmin = array ( 5 , 6 ); // Minimum version of PHP required by module
2016-06-29 16:54:37 +02:00
$this -> need_dolibarr_version = array ( 3 , 9 ); // Minimum version of Dolibarr required by module
2019-11-13 19:37:08 +01:00
$this -> langfiles = array ( " accountancy " , " compta " );
2014-09-09 09:46:57 +02:00
2011-08-31 13:05:58 +02:00
// Constants
2018-03-11 00:31:26 +01:00
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
2014-09-09 09:46:57 +02:00
$this -> const = array ();
$this -> const [ 1 ] = array (
2014-08-27 07:03:42 +02:00
" MAIN_COMPANY_CODE_ALWAYS_REQUIRED " ,
" chaine " ,
" 1 " ,
2018-11-28 17:04:42 +01:00
" With this constants on, third party code is always required whatever is numbering module behaviour " , 0 , 'current' , 1
2014-08-27 07:03:42 +02:00
);
2014-09-09 09:46:57 +02:00
$this -> const [ 2 ] = array (
2014-08-27 07:03:42 +02:00
" MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED " ,
" chaine " ,
" 1 " ,
2018-03-11 00:31:26 +01:00
" With this constants on, bank account number is always required " , 0 , 'current' , 1
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 3 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_ACCOUNT_SUSPENSE " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" 471 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2014-09-09 09:46:57 +02:00
$this -> const [ 4 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_ACCOUNT_TRANSFER_CASH " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" 58 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 5 ] = array (
2014-08-27 07:03:42 +02:00
" CHARTOFACCOUNTS " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" 2 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 6 ] = array (
2015-01-25 06:54:17 +01:00
" ACCOUNTING_EXPORT_MODELCSV " ,
2014-08-27 07:03:42 +02:00
" chaine " ,
2018-03-11 00:31:26 +01:00
" 1 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 7 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_LENGTH_GACCOUNT " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 8 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_LENGTH_AACCOUNT " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 9 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_LIST_SORT_VENTILATION_TODO " ,
" yesno " ,
2018-03-11 00:31:26 +01:00
" 1 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 10 ] = array (
2014-08-27 07:03:42 +02:00
" ACCOUNTING_LIST_SORT_VENTILATION_DONE " ,
" yesno " ,
2018-03-11 00:31:26 +01:00
" 1 " ,
" " , 0 , 'current' , 0
2014-08-27 07:03:42 +02:00
);
2019-11-13 19:37:08 +01:00
$this -> const [ 11 ] = array (
2015-01-25 06:54:17 +01:00
" ACCOUNTING_EXPORT_DATE " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" %d%m%Y " ,
" " , 0 , 'current' , 0
2015-01-25 06:54:17 +01:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 12 ] = array (
" ACCOUNTING_EXPORT_SEPARATORCSV " ,
" string " ,
2018-03-11 00:31:26 +01:00
" , " ,
" " , 0 , 'current' , 0
2015-05-02 06:42:06 +02:00
);
2017-09-16 06:53:29 +02:00
$this -> const [ 13 ] = array (
2015-09-07 21:51:48 +02:00
" ACCOUNTING_EXPORT_FORMAT " ,
" chaine " ,
2018-03-11 00:31:26 +01:00
" csv " ,
" " , 0 , 'current' , 0
2015-09-07 21:51:48 +02:00
);
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Tabs
$this -> tabs = array ();
2014-09-09 09:46:57 +02:00
2014-08-27 07:03:42 +02:00
// Css
2014-09-09 09:46:57 +02:00
$this -> module_parts = array ();
2011-08-31 13:05:58 +02:00
// Boxes
2019-09-23 20:42:50 +02:00
$this -> boxes = array (
2019-10-02 08:49:33 +02:00
0 => array ( 'file' => 'box_accountancy_last_manual_entries.php' , 'enabledbydefaulton' => 'accountancyindex' ),
1 => array ( 'file' => 'box_accountancy_suspense_account.php' , 'enabledbydefaulton' => 'accountancyindex' )
2019-09-23 20:42:50 +02:00
);
2014-09-09 09:46:57 +02:00
2011-08-31 13:05:58 +02:00
// Permissions
$this -> rights_class = 'accounting' ;
2014-09-09 09:46:57 +02:00
$this -> rights = array (); // Permission array used by this module
2014-08-27 07:03:42 +02:00
$r = 0 ;
2014-09-09 09:46:57 +02:00
2020-10-31 14:32:18 +01:00
$this -> rights [ $r ][ 0 ] = 50440 ;
$this -> rights [ $r ][ 1 ] = 'Manage chart of accounts, setup of accountancy' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'chartofaccount' ;
$this -> rights [ $r ][ 5 ] = '' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 50401 ;
2016-10-13 21:48:07 +02:00
$this -> rights [ $r ][ 1 ] = 'Bind products and invoices with accounting accounts' ;
2014-08-28 07:13:33 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
2016-10-13 21:48:07 +02:00
$this -> rights [ $r ][ 4 ] = 'bind' ;
$this -> rights [ $r ][ 5 ] = 'write' ;
2014-08-28 07:13:33 +02:00
$r ++ ;
2014-09-09 09:46:57 +02:00
2014-08-28 06:48:22 +02:00
$this -> rights [ $r ][ 0 ] = 50411 ;
2017-06-15 19:29:00 +02:00
$this -> rights [ $r ][ 1 ] = 'Read operations in Ledger' ;
2014-08-28 06:48:22 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'mouvements' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 50412 ;
2017-06-15 19:29:00 +02:00
$this -> rights [ $r ][ 1 ] = 'Write/Edit operations in Ledger' ;
2014-08-28 06:48:22 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'mouvements' ;
$this -> rights [ $r ][ 5 ] = 'creer' ;
$r ++ ;
2020-10-31 14:32:18 +01:00
$this -> rights [ $r ][ 0 ] = 50414 ;
$this -> rights [ $r ][ 1 ] = 'Delete operations in Ledger' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'mouvements' ;
$this -> rights [ $r ][ 5 ] = 'supprimer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 50415 ;
$this -> rights [ $r ][ 1 ] = 'Delete all operations by year and journal in Ledger' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'mouvements' ;
$this -> rights [ $r ][ 5 ] = 'supprimer_tous' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 50418 ;
$this -> rights [ $r ][ 1 ] = 'Export operations of the Ledger' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'mouvements' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
$r ++ ;
2019-04-17 07:26:39 +02:00
2014-08-28 06:48:22 +02:00
$this -> rights [ $r ][ 0 ] = 50420 ;
2017-06-15 19:29:00 +02:00
$this -> rights [ $r ][ 1 ] = 'Report and export reports (turnover, balance, journals, ledger)' ;
2014-08-28 06:48:22 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'comptarapport' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
$r ++ ;
2014-09-09 09:46:57 +02:00
$this -> rights [ $r ][ 0 ] = 50430 ;
2019-10-17 18:16:57 +02:00
$this -> rights [ $r ][ 1 ] = 'Manage fiscal periods, validate movements and close periods' ;
2014-09-09 09:46:57 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'fiscalyear' ;
2019-05-22 17:22:49 +02:00
$this -> rights [ $r ][ 5 ] = 'write' ;
2014-09-09 09:46:57 +02:00
$r ++ ;
2016-06-29 16:54:37 +02:00
2016-09-30 13:02:13 +02:00
// Menus
//-------
2020-04-10 10:59:32 +02:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2017-06-15 19:29:00 +02:00
2017-02-08 06:18:56 +01:00
// Exports
2018-05-19 07:29:17 +02:00
//--------
2020-04-10 10:59:32 +02:00
$r = 0 ;
2017-02-08 06:18:56 +01:00
2018-05-19 07:29:17 +02:00
$r ++ ;
2020-04-10 10:59:32 +02:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'Chartofaccounts' ;
2022-03-02 11:38:32 +01:00
$this -> export_icon [ $r ] = $this -> picto ;
2020-04-10 10:59:32 +02:00
$this -> export_permission [ $r ] = array ( array ( " accounting " , " chartofaccount " ));
2020-09-28 18:56:53 +02:00
$this -> export_fields_array [ $r ] = array ( 'ac.rowid' => 'ChartofaccountsId' , 'ac.pcg_version' => 'Chartofaccounts' , 'aa.rowid' => 'ID' , 'aa.account_number' => " AccountAccounting " , 'aa.label' => " Label " , 'aa.account_parent' => " Accountparent " , 'aa.pcg_type' => " Pcgtype " , 'aa.active' => 'Status' );
$this -> export_TypeFields_array [ $r ] = array ( 'ac.rowid' => 'List:accounting_system:pcg_version' , 'ac.pcg_version' => 'Text' , 'aa.rowid' => 'Numeric' , 'aa.account_number' => " Text " , 'aa.label' => " Text " , 'aa.account_parent' => " Text " , 'aa.pcg_type' => 'Text' , 'aa.active' => 'Status' );
2020-04-10 10:59:32 +02:00
$this -> export_entities_array [ $r ] = array ( 'ac.rowid' => " Accounting " , 'ac.pcg_version' => " Accounting " , 'aa.rowid' => 'Accounting' , 'aa.account_number' => " Accounting " , 'aa.label' => " Accounting " , 'aa.accountparent' => " Accounting " , 'aa.pcg_type' => " Accounting " , 'aa_active' => " Accounting " );
2018-05-19 07:29:17 +02:00
2020-04-10 10:59:32 +02:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as aa' ;
2020-10-31 14:32:18 +01:00
$this -> export_sql_end [ $r ] .= ' ,' . MAIN_DB_PREFIX . 'accounting_system as ac' ;
2020-04-10 10:59:32 +02:00
$this -> export_sql_end [ $r ] .= ' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN (' . getEntity ( 'accounting' ) . ') ' ;
2018-05-19 07:29:17 +02:00
// Imports
//--------
2020-04-10 10:59:32 +02:00
$r = 0 ;
2018-05-19 07:29:17 +02:00
// General ledger
$r ++ ;
2020-04-10 10:59:32 +02:00
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = 'ImportAccountingEntries' ;
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'b' => MAIN_DB_PREFIX . 'accounting_bookkeeping' ); // List of tables to insert into (insert done in same order)
$this -> import_fields_array [ $r ] = array (
2019-06-25 22:23:51 +02:00
'b.piece_num' => " TransactionNumShort " ,
'b.doc_date' => " Docdate " ,
//'b.doc_type'=>'Doctype',
'b.doc_ref' => 'Piece' ,
2020-10-31 14:32:18 +01:00
'b.code_journal' => 'Codejournal' ,
2021-03-31 13:53:36 +02:00
'b.journal_label' => 'JournalLabel' ,
2020-10-31 14:32:18 +01:00
'b.numero_compte' => 'AccountAccounting' ,
2021-03-31 13:53:36 +02:00
'b.label_compte' => 'LabelAccount' ,
2020-10-31 14:32:18 +01:00
'b.subledger_account' => 'SubledgerAccount' ,
'b.subledger_label' => 'SubledgerAccountLabel' ,
'b.label_operation' => 'LabelOperation' ,
'b.debit' => " Debit " ,
2021-02-26 19:18:03 +01:00
'b.credit' => " Credit " ,
2021-03-31 13:53:36 +02:00
'b.sens' => 'Direction' // This field is still used by accounting export. We can remove it once it has been replaced into accountancyexport.class.php by a detection using ->debit and ->credit
2020-10-31 14:32:18 +01:00
);
2020-04-10 10:59:32 +02:00
$this -> import_fieldshidden_array [ $r ] = array ( 'b.doc_type' => 'const-import_from_external' , 'b.fk_doc' => 'const-0' , 'b.fk_docdet' => 'const-0' , 'b.fk_user_author' => 'user->id' , 'b.date_creation' => 'const-' . dol_print_date ( dol_now (), 'standard' )); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this -> import_regex_array [ $r ] = array ( 'b.doc_date' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' );
2021-06-30 04:55:22 +02:00
$this -> import_convertvalue_array [ $r ] = array (
'b.numero_compte' => array ( 'rule' => 'accountingaccount' ),
'b.subledger_account' => array ( 'rule' => 'accountingaccount' )
2021-06-29 23:07:20 +02:00
);
2020-04-10 10:59:32 +02:00
$this -> import_examplevalues_array [ $r ] = array (
2020-10-31 14:32:18 +01:00
'b.piece_num' => '123 (!!! use next value not already used)' ,
2019-06-25 22:23:51 +02:00
'b.doc_date' => dol_print_date ( dol_now (), " %Y-%m-%d " ),
//'b.doc_type'=>'import',
'b.doc_ref' => 'My document ABC' ,
2020-10-31 14:32:18 +01:00
'b.code_journal' => " VTE " ,
2021-03-31 13:53:36 +02:00
'b.journal_label' => " Sale journal " ,
2020-10-31 14:32:18 +01:00
'b.numero_compte' => " 707 " ,
2021-03-31 13:53:36 +02:00
'b.label_compte' => 'Product account 707' ,
2020-10-31 14:32:18 +01:00
'b.subledger_account' => '' ,
'b.subledger_label' => '' ,
'b.label_operation' => " Sale of ABC " ,
'b.debit' => " 0 " ,
2021-02-26 19:18:03 +01:00
'b.credit' => " 100 " ,
'b.sens' => 'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit
2020-10-31 14:32:18 +01:00
);
2018-05-19 07:29:17 +02:00
2021-03-31 04:59:12 +02:00
// General ledger - Fichier FEC
$r ++ ;
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = 'ImportAccountingEntriesFECFormat' ;
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'b' => MAIN_DB_PREFIX . 'accounting_bookkeeping' ); // List of tables to insert into (insert done in same order)
$this -> import_fields_array [ $r ] = array (
'b.code_journal' => 'FECFormatJournalCode*' ,
'b.journal_label' => 'FECFormatJournalLabel' ,
'b.piece_num' => 'FECFormatEntryNum*' ,
'b.doc_date' => 'FECFormatEntryDate*' ,
'b.numero_compte' => 'FECFormatGeneralAccountNumber*' ,
'b.label_compte' => 'FECFormatGeneralAccountLabel*' ,
'b.subledger_account' => 'FECFormatSubledgerAccountNumber' ,
'b.subledger_label' => 'FECFormatSubledgerAccountLabel' ,
'b.doc_ref' => 'FECFormatPieceRef*' ,
'b.date_creation' => 'FECFormatPieceDate' ,
'b.label_operation' => 'FECFormatLabelOperation' ,
'b.debit' => 'FECFormatDebit*' ,
'b.credit' => 'FECFormatCredit*' ,
'b.lettering_code' => 'FECFormatReconcilableCode' ,
'b.date_lettering' => 'FECFormatReconcilableDate' ,
'b.date_validated' => 'FECFormatValidateDate' ,
'b.multicurrency_amount' => 'FECFormatMulticurrencyAmount' ,
'b.multicurrency_code' => 'FECFormatMulticurrencyCode'
);
$this -> import_fieldshidden_array [ $r ] = array (
'b.doc_type' => 'const-import_from_external' ,
'b.fk_doc' => 'const-0' ,
'b.fk_docdet' => 'const-0' ,
'b.fk_user_author' => 'user->id' ,
2022-02-03 05:53:05 +01:00
'b.montant' => 'rule-computeAmount' ,
'b.sens' => 'rule-computeDirection'
2021-03-31 04:59:12 +02:00
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this -> import_convertvalue_array [ $r ] = array (
2021-06-29 23:07:20 +02:00
'b.numero_compte' => array ( 'rule' => 'accountingaccount' ),
'b.subledger_account' => array ( 'rule' => 'accountingaccount' ),
2021-03-31 20:40:26 +02:00
'b.montant' => array ( 'rule' => 'compute' , 'classfile' => '/accountancy/class/accountancyimport.class.php' , 'class' => 'AccountancyImport' , 'method' => 'computeAmount' , 'element' => 'Accountancy' ),
'b.sens' => array ( 'rule' => 'compute' , 'classfile' => '/accountancy/class/accountancyimport.class.php' , 'class' => 'AccountancyImport' , 'method' => 'computeDirection' , 'element' => 'Accountancy' ),
2021-03-31 04:59:12 +02:00
);
$this -> import_regex_array [ $r ] = array (
//'b.doc_date'=>'^\d{4}\d{2}\d{2}$',
'b.doc_ref' => '^.{1,300}$' ,
'b.numero_compte' => '^.{1,32}$' ,
'b.label_compte' => '^.{1,255}$' ,
'b.subledger_compte' => '^.{1,32}$' ,
'b.subledger_label' => '^.{1,255}$' ,
'b.label_operation' => '^.{1,255}$' ,
//'b.sens'=>'^[D|C]$',
);
$this -> import_examplevalues_array [ $r ] = array (
'b.code_journal' => " VT " ,
'b.journal_label' => " Sale journal " ,
'b.piece_num' => '123 (!!! use next value not already used)' ,
'b.doc_date' => dol_print_date ( dol_now (), " %Y%m%d " ),
'b.numero_compte' => " 707 " ,
'b.label_compte' => 'Sale' ,
'b.subledger_account' => '' ,
'b.subledger_label' => '' ,
'b.doc_ref' => 'My document ABC' ,
'b.date_creation' => dol_print_date ( dol_now (), " %Y%m%d " ),
'b.label_operation' => " Sale of ABC " ,
'b.debit' => " 0 " ,
'b.credit' => " 100 " ,
'b.lettering_code' => 'ABC' ,
'b.date_lettering' => dol_print_date ( dol_now (), " %Y%m%d " ),
'b.date_validated' => dol_print_date ( dol_now (), " %Y%m%d " ),
'b.multicurrency_amount' => " 90 (Necessary if devise is different than EUR) " ,
'b.multicurrency_code' => " US (Necessary if devise is different than EUR) " ,
);
2018-05-19 07:29:17 +02:00
// Chart of accounts
$r ++ ;
2020-04-10 10:59:32 +02:00
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " Chartofaccounts " ; // Translation key
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'aa' => MAIN_DB_PREFIX . 'accounting_account' );
$this -> import_tables_creator_array [ $r ] = array ( 'aa' => 'fk_user_author' ); // Fields to store import user id
$this -> import_fields_array [ $r ] = array ( 'aa.fk_pcg_version' => " Chartofaccounts* " , 'aa.account_number' => " AccountAccounting* " , 'aa.label' => " Label* " , 'aa.account_parent' => " Accountparent " , " aa.fk_accounting_category " => " AccountingCategory " , " aa.pcg_type " => " Pcgtype* " , 'aa.active' => 'Status*' , 'aa.datec' => " DateCreation " );
$this -> import_regex_array [ $r ] = array ( 'aa.fk_pcg_version' => 'pcg_version@' . MAIN_DB_PREFIX . 'accounting_system' , 'aa.account_number' => '^.{1,32}$' , 'aa.label' => '^.{1,255}$' , 'aa.account_parent' => '^.{0,32}$' , 'aa.fk_accounting_category' => 'rowid@' . MAIN_DB_PREFIX . 'c_accounting_category' , 'aa.pcg_type' => '^.{1,20}$' , 'aa.active' => '^0|1$' , 'aa.datec' => '^\d{4}-\d{2}-\d{2}$' );
$this -> import_convertvalue_array [ $r ] = array (
2021-06-29 23:07:20 +02:00
'aa.account_number' => array ( 'rule' => 'accountingaccount' ),
2020-10-31 14:32:18 +01:00
'aa.account_parent' => array ( 'rule' => 'fetchidfromref' , 'classfile' => '/accountancy/class/accountingaccount.class.php' , 'class' => 'AccountingAccount' , 'method' => 'fetch' , 'element' => 'AccountingAccount' ),
'aa.fk_accounting_category' => array ( 'rule' => 'fetchidfromcodeorlabel' , 'classfile' => '/accountancy/class/accountancycategory.class.php' , 'class' => 'AccountancyCategory' , 'method' => 'fetch' , 'dict' => 'DictionaryAccountancyCategory' ),
2018-05-19 07:29:17 +02:00
);
2020-04-10 10:59:32 +02:00
$this -> import_examplevalues_array [ $r ] = array ( 'aa.fk_pcg_version' => " PCG99-ABREGE " , 'aa.account_number' => " 707 " , 'aa.label' => " Product sales " , 'aa.account_parent' => " ref:7 or id:1407 " , " aa.fk_accounting_category " => " " , " aa.pcg_type " => " PROD " , 'aa.active' => '1' , 'aa.datec' => " 2017-04-28 " );
$this -> import_updatekeys_array [ $r ] = array ( 'aa.fk_pcg_version' => 'Chartofaccounts' , 'aa.account_number' => 'AccountAccounting' );
2011-08-31 13:05:58 +02:00
}
}