43 $this->numero = 50400;
45 $this->family =
"financial";
46 $this->module_position =
'62';
48 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
49 $this->
description =
"Double entry accounting management";
52 $this->version =
'dolibarr';
54 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
55 $this->picto =
'accountancy';
58 $this->dirs = array(
'/accounting/temp',
'/accounting/export');
61 $this->config_page_url = array(
'accounting.php?mainmenu=accountancy&leftmenu=accountancy_admin');
64 $this->depends = array(
"modFacture",
"modBanque",
"modTax");
65 $this->requiredby = array();
66 $this->conflictwith = array(
"modComptabilite");
67 $this->phpmin = array(7, 0);
68 $this->need_dolibarr_version = array(3, 9);
69 $this->langfiles = array(
"accountancy",
"compta");
78 "MAIN_COMPANY_CODE_ALWAYS_REQUIRED",
81 "With this constants on, third party code is always required whatever is numbering module behaviour", 0,
'current', 1
84 "MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED",
87 "With this constants on, bank account number is always required", 0,
'current', 1
90 "ACCOUNTING_ACCOUNT_SUSPENSE",
96 "ACCOUNTING_ACCOUNT_TRANSFER_CASH",
108 "ACCOUNTING_EXPORT_MODELCSV",
114 "ACCOUNTING_LENGTH_GACCOUNT",
120 "ACCOUNTING_LENGTH_AACCOUNT",
126 "ACCOUNTING_EXPORT_DATE",
132 "ACCOUNTING_EXPORT_SEPARATORCSV",
138 "ACCOUNTING_EXPORT_FORMAT",
146 "mod_bookkeeping_argon",
152 $this->tabs = array();
155 $this->module_parts = array();
158 $this->boxes = array(
159 0=>array(
'file'=>
'box_accountancy_last_manual_entries.php',
'enabledbydefaulton'=>
'accountancyindex'),
160 1=>array(
'file'=>
'box_accountancy_suspense_account.php',
'enabledbydefaulton'=>
'accountancyindex')
164 $this->rights_class =
'accounting';
166 $this->rights = array();
169 $this->rights[$r][0] = 50440;
170 $this->rights[$r][1] =
'Manage chart of accounts, setup of accountancy';
171 $this->rights[$r][2] =
'r';
172 $this->rights[$r][3] = 0;
173 $this->rights[$r][4] =
'chartofaccount';
174 $this->rights[$r][5] =
'';
177 $this->rights[$r][0] = 50401;
178 $this->rights[$r][1] =
'Bind products and invoices with accounting accounts';
179 $this->rights[$r][2] =
'r';
180 $this->rights[$r][3] = 0;
181 $this->rights[$r][4] =
'bind';
182 $this->rights[$r][5] =
'write';
185 $this->rights[$r][0] = 50411;
186 $this->rights[$r][1] =
'Read operations in Ledger';
187 $this->rights[$r][2] =
'r';
188 $this->rights[$r][3] = 0;
189 $this->rights[$r][4] =
'mouvements';
190 $this->rights[$r][5] =
'lire';
193 $this->rights[$r][0] = 50412;
194 $this->rights[$r][1] =
'Write/Edit operations in Ledger';
195 $this->rights[$r][2] =
'w';
196 $this->rights[$r][3] = 0;
197 $this->rights[$r][4] =
'mouvements';
198 $this->rights[$r][5] =
'creer';
201 $this->rights[$r][0] = 50414;
202 $this->rights[$r][1] =
'Delete operations in Ledger';
203 $this->rights[$r][2] =
'd';
204 $this->rights[$r][3] = 0;
205 $this->rights[$r][4] =
'mouvements';
206 $this->rights[$r][5] =
'supprimer';
209 $this->rights[$r][0] = 50415;
210 $this->rights[$r][1] =
'Delete all operations by year and journal in Ledger';
211 $this->rights[$r][2] =
'd';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'mouvements';
214 $this->rights[$r][5] =
'supprimer_tous';
217 $this->rights[$r][0] = 50418;
218 $this->rights[$r][1] =
'Export operations of the Ledger';
219 $this->rights[$r][2] =
'r';
220 $this->rights[$r][3] = 0;
221 $this->rights[$r][4] =
'mouvements';
222 $this->rights[$r][5] =
'export';
225 $this->rights[$r][0] = 50420;
226 $this->rights[$r][1] =
'Report and export reports (turnover, balance, journals, ledger)';
227 $this->rights[$r][2] =
'r';
228 $this->rights[$r][3] = 0;
229 $this->rights[$r][4] =
'comptarapport';
230 $this->rights[$r][5] =
'lire';
233 $this->rights[$r][0] = 50430;
234 $this->rights[$r][1] =
'Manage fiscal periods, validate movements and close periods';
235 $this->rights[$r][2] =
'r';
236 $this->rights[$r][3] = 0;
237 $this->rights[$r][4] =
'fiscalyear';
238 $this->rights[$r][5] =
'write';
250 $this->export_code[$r] = $this->rights_class.
'_'.$r;
251 $this->export_label[$r] =
'Chartofaccounts';
252 $this->export_icon[$r] = $this->picto;
253 $this->export_permission[$r] = array(array(
"accounting",
"chartofaccount"));
254 $this->export_fields_array[$r] = array(
'ac.rowid'=>
'ChartofaccountsId',
'ac.pcg_version'=>
'Chartofaccounts',
'aa.rowid'=>
'ID',
'aa.account_number'=>
"AccountAccounting",
'aa.label'=>
"Label",
'aa2.account_number'=>
"Accountparent",
'aa.pcg_type'=>
"Pcgtype",
'aa.centralized'=>
'Centralized',
'aa.active'=>
'Status');
255 $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",
'aa2.account_number'=>
"Text",
'aa.pcg_type'=>
'Text',
'aa.centralized'=>
'Status',
'aa.active'=>
'Status');
256 $this->export_entities_array[$r] = array();
258 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
259 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'accounting_account as aa';
260 $this->export_sql_end[$r] .=
' ,'.MAIN_DB_PREFIX.
'accounting_system as ac';
261 $this->export_sql_end[$r] .=
' ,'.MAIN_DB_PREFIX.
'accounting_account as aa2';
262 $this->export_sql_end[$r] .=
' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity(
'accounting').
')';
263 $this->export_sql_end[$r] .=
' AND aa2.rowid = aa.account_parent AND aa2.active = 1 AND ac.pcg_version = aa2.fk_pcg_version AND aa2.entity IN ('.getEntity(
'accounting').
')';
272 $this->import_code[$r] = $this->rights_class.
'_'.$r;
273 $this->import_label[$r] =
"Chartofaccounts";
274 $this->import_icon[$r] = $this->picto;
275 $this->import_entities_array[$r] = array();
276 $this->import_tables_array[$r] = array(
'aa'=>MAIN_DB_PREFIX.
'accounting_account');
277 $this->import_tables_creator_array[$r] = array(
'aa'=>
'fk_user_author');
278 $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.centralized'=>
'Centralized*',
'aa.active'=>
'Status*',
'aa.datec'=>
"DateCreation");
279 $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.centralized'=>
'^0|1$',
'aa.active'=>
'^0|1$',
'aa.datec'=>
'^\d{4}-\d{2}-\d{2}$');
280 $this->import_convertvalue_array[$r] = array(
281 'aa.account_number'=>array(
'rule'=>
'accountingaccount'),
282 'aa.account_parent'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/accountancy/class/accountingaccount.class.php',
'class'=>
'AccountingAccount',
'method'=>
'fetch',
'element'=>
'AccountingAccount'),
283 'aa.fk_accounting_category'=>array(
'rule'=>
'fetchidfromcodeorlabel',
'classfile'=>
'/accountancy/class/accountancycategory.class.php',
'class'=>
'AccountancyCategory',
'method'=>
'fetch',
'dict'=>
'DictionaryAccountancyCategory'),
285 $this->import_examplevalues_array[$r] = array(
'aa.fk_pcg_version'=>
"PCG25-DEV",
'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.centralized'=>
'0',
'aa.active'=>
'1',
'aa.datec'=>
"2017-04-28");
286 $this->import_updatekeys_array[$r] = array(
'aa.fk_pcg_version'=>
'Chartofaccounts',
'aa.account_number'=>
'AccountAccounting');
290 $this->import_code[$r] = $this->rights_class.
'_'.$r;
291 $this->import_label[$r] =
'ImportAccountingEntries';
292 $this->import_icon[$r] = $this->picto;
293 $this->import_entities_array[$r] = array();
294 $this->import_tables_array[$r] = array(
'b'=>MAIN_DB_PREFIX.
'accounting_bookkeeping');
295 $this->import_fields_array[$r] = array(
296 'b.piece_num'=>
"TransactionNumShort",
297 'b.doc_date'=>
"Docdate",
299 'b.doc_ref'=>
'Piece',
300 'b.code_journal'=>
'Codejournal',
301 'b.journal_label'=>
'JournalLabel',
302 'b.numero_compte'=>
'AccountAccounting',
303 'b.label_compte'=>
'LabelAccount',
304 'b.subledger_account'=>
'SubledgerAccount',
305 'b.subledger_label'=>
'SubledgerAccountLabel',
306 'b.label_operation'=>
'LabelOperation',
308 'b.credit'=>
"Credit",
309 'b.sens'=>
'Direction'
311 $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'));
312 $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]$');
313 $this->import_convertvalue_array[$r] = array(
314 'b.numero_compte' => array(
'rule' =>
'accountingaccount'),
315 'b.subledger_account' => array(
'rule' =>
'accountingaccount')
317 $this->import_examplevalues_array[$r] = array(
318 'b.piece_num'=>
'123 (!!! use next value not already used)',
321 'b.doc_ref'=>
'My document ABC',
322 'b.code_journal'=>
"VTE",
323 'b.journal_label'=>
"Sale journal",
324 'b.numero_compte'=>
"707",
325 'b.label_compte'=>
'Product account 707',
326 'b.subledger_account'=>
'',
327 'b.subledger_label'=>
'',
328 'b.label_operation'=>
"Sale of ABC",
336 $this->import_code[$r] = $this->rights_class.
'_'.$r;
337 $this->import_label[$r] =
'ImportAccountingEntriesFECFormat';
338 $this->import_icon[$r] = $this->picto;
339 $this->import_entities_array[$r] = array();
340 $this->import_tables_array[$r] = array(
'b'=>MAIN_DB_PREFIX.
'accounting_bookkeeping');
341 $this->import_fields_array[$r] = array(
342 'b.code_journal'=>
'FECFormatJournalCode*',
343 'b.journal_label'=>
'FECFormatJournalLabel',
344 'b.piece_num'=>
'FECFormatEntryNum',
345 'b.doc_date'=>
'FECFormatEntryDate*',
346 'b.numero_compte'=>
'FECFormatGeneralAccountNumber*',
347 'b.label_compte'=>
'FECFormatGeneralAccountLabel*',
348 'b.subledger_account'=>
'FECFormatSubledgerAccountNumber',
349 'b.subledger_label'=>
'FECFormatSubledgerAccountLabel',
350 'b.doc_ref'=>
'FECFormatPieceRef*',
351 'b.date_creation'=>
'FECFormatPieceDate',
352 'b.label_operation'=>
'FECFormatLabelOperation',
353 'b.debit'=>
'FECFormatDebit*',
354 'b.credit'=>
'FECFormatCredit*',
355 'b.lettering_code'=>
'FECFormatReconcilableCode',
356 'b.date_lettering'=>
'FECFormatReconcilableDate',
357 'b.date_validated'=>
'FECFormatValidateDate',
358 'b.multicurrency_amount'=>
'FECFormatMulticurrencyAmount',
359 'b.multicurrency_code'=>
'FECFormatMulticurrencyCode'
361 $this->import_fieldshidden_array[$r] = array(
362 'b.doc_type'=>
'const-import_from_external',
363 'b.fk_doc'=>
'const-0',
364 'b.fk_docdet'=>
'const-0',
365 'b.fk_user_author'=>
'user->id',
366 'b.montant'=>
'rule-computeAmount',
367 'b.sens'=>
'rule-computeDirection'
369 $this->import_convertvalue_array[$r]=array(
370 'b.piece_num' => array(
'rule' =>
'compute',
'type' =>
'int',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'computePieceNum',
'element' =>
'Accountancy'),
371 'b.numero_compte'=>array(
'rule'=>
'accountingaccount'),
372 'b.subledger_account'=>array(
'rule'=>
'accountingaccount'),
373 'b.debit' => array(
'rule' =>
'compute',
'type' =>
'double',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'cleanAmount',
'element' =>
'Accountancy'),
374 'b.credit' => array(
'rule' =>
'compute',
'type' =>
'double',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'cleanAmount',
'element' =>
'Accountancy'),
375 'b.multicurrency_amount' => array(
'rule' =>
'compute',
'type' =>
'double',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'cleanAmount',
'element' =>
'Accountancy'),
376 'b.montant' => array(
'rule' =>
'compute',
'type' =>
'double',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'computeAmount',
'element' =>
'Accountancy'),
377 'b.sens' => array(
'rule' =>
'compute',
'type' =>
'varchar',
'classfile' =>
'/accountancy/class/accountancyimport.class.php',
'class' =>
'AccountancyImport',
'method' =>
'computeDirection',
'element' =>
'Accountancy'),
379 $this->import_regex_array[$r] = array(
381 'b.doc_ref'=>
'^.{1,300}$',
382 'b.numero_compte'=>
'^.{1,32}$',
383 'b.label_compte'=>
'^.{1,255}$',
384 'b.subledger_compte'=>
'^.{1,32}$',
385 'b.subledger_label'=>
'^.{1,255}$',
386 'b.label_operation'=>
'^.{1,255}$',
389 $this->import_examplevalues_array[$r] = array(
390 'b.code_journal'=>
"VT",
391 'b.journal_label'=>
"Sale journal",
392 'b.piece_num'=>
'123 (!!! use next value not already used)',
394 'b.numero_compte'=>
"707",
395 'b.label_compte'=>
'Sale',
396 'b.subledger_account'=>
'',
397 'b.subledger_label'=>
'',
398 'b.doc_ref'=>
'My document ABC',
400 'b.label_operation'=>
"Sale of ABC",
403 'b.lettering_code'=>
'ABC',
406 'b.multicurrency_amount'=>
"90 (Necessary if devise is different than EUR)",
407 'b.multicurrency_code'=>
"US (Necessary if devise is different than EUR)",