From f95b5be971ded339888d57099c3af77288b73538 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 30 Jun 2021 04:55:22 +0200 Subject: [PATCH] FIX Accountancy - Clean virtual zero on the import --- htdocs/core/modules/import/import_csv.modules.php | 6 +++++- htdocs/core/modules/import/import_xlsx.modules.php | 6 +++++- htdocs/core/modules/modAccounting.class.php | 6 +++--- htdocs/core/modules/modProduct.class.php | 8 +++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 52b7af1fee5..6bec94d6130 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -624,7 +624,11 @@ class ImportCsv extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { - $newval = rtrim($newval, "0"); + if (empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + $newval = rtrim(trim($newval), "0"); + } else { + $newval = trim($newval); + } } //print 'Val to use as insert is '.$newval.'
'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index abc2a80abc9..0378180475d 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -665,7 +665,11 @@ class ImportXlsx extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { - $newval = rtrim($newval, "0"); + if (empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + $newval = rtrim(trim($newval), "0"); + } else { + $newval = trim($newval); + } } //print 'Val to use as insert is '.$newval.'
'; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index f86a2078c9e..d6127f65b83 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -297,9 +297,9 @@ class modAccounting extends DolibarrModules ); $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]$'); - $this->import_convertvalue_array[$r]=array( - 'b.numero_compte'=>array('rule'=>'accountingaccount'), - 'b.subledger_account'=>array('rule'=>'accountingaccount') + $this->import_convertvalue_array[$r] = array( + 'b.numero_compte' => array('rule' => 'accountingaccount'), + 'b.subledger_account' => array('rule' => 'accountingaccount') ); $this->import_examplevalues_array[$r] = array( 'b.piece_num'=>'123 (!!! use next value not already used)', diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 3459973a699..37cda4b7b30 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -572,7 +572,13 @@ class modProduct extends DolibarrModules 'class' => 'CProductNature', 'method' => 'fetch', 'dict' => 'DictionaryProductNature' - ), + ), + 'p.accountancy_code_sell'=>array('rule'=>'accountingaccount'), + 'p.accountancy_code_sell_intra'=>array('rule'=>'accountingaccount'), + 'p.accountancy_code_sell_export'=>array('rule'=>'accountingaccount'), + 'p.accountancy_code_buy'=>array('rule'=>'accountingaccount'), + 'p.accountancy_code_buy_intra'=>array('rule'=>'accountingaccount'), + 'p.accountancy_code_buy_export'=>array('rule'=>'accountingaccount'), ); $this->import_regex_array[$r] = array(