Merge pull request #17053 from aspangaro/14a30
NEW: Accountancy - Add FEC import
This commit is contained in:
commit
55741506c8
101
htdocs/accountancy/class/accountancyimport.class.php
Normal file
101
htdocs/accountancy/class/accountancyimport.class.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
|
||||
* Copyright (C) 2016-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
|
||||
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
|
||||
* Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (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
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/class/accountancyimport.class.php
|
||||
* \ingroup Accountancy (Double entries)
|
||||
* \brief Class accountancy import
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Manage the different format accountancy import
|
||||
*/
|
||||
class AccountancyImport
|
||||
{
|
||||
/**
|
||||
* Compute amount
|
||||
*
|
||||
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||
* @param string $fieldname Field name with alias
|
||||
* @param array $listfields Fields list to add
|
||||
* @param array $listvalues Values list to add
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
||||
{
|
||||
$fieldArr = explode('.', $fieldname);
|
||||
if (count($fieldArr) > 0) {
|
||||
$fieldname = $fieldArr[1];
|
||||
}
|
||||
|
||||
$debit = trim($arrayrecord[11]['val']);
|
||||
$credit = trim($arrayrecord[12]['val']);
|
||||
if (!empty($debit)) {
|
||||
$amount = $debit;
|
||||
} else {
|
||||
$amount = $credit;
|
||||
}
|
||||
|
||||
$listfields[] = $fieldname;
|
||||
$listvalues[] = "'" . abs($amount) . "'";
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute sens
|
||||
*
|
||||
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||
* @param string $fieldname Field name with alias
|
||||
* @param array $listfields Fields list to add
|
||||
* @param array $listvalues Values list to add
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
||||
{
|
||||
$fieldArr = explode('.', $fieldname);
|
||||
if (count($fieldArr) > 0) {
|
||||
$fieldname = $fieldArr[1];
|
||||
}
|
||||
|
||||
$debit = trim($arrayrecord[11]['val']);
|
||||
if (!empty($debit)) {
|
||||
$sens = 'D';
|
||||
} else {
|
||||
$sens = 'C';
|
||||
}
|
||||
|
||||
$listfields[] = $fieldname;
|
||||
$listvalues[] = "'" . $sens . "'";
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2019 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 Open-DSI <support@open-dsi.fr>
|
||||
/* 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>
|
||||
*
|
||||
* 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
|
||||
@ -314,6 +314,76 @@ class modAccounting extends DolibarrModules
|
||||
'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
|
||||
);
|
||||
|
||||
// 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',
|
||||
'b.montant'=>'rule-computeMontant',
|
||||
'b.sens'=>'rule-computeSens'
|
||||
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
'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'),
|
||||
);
|
||||
$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)",
|
||||
);
|
||||
|
||||
// Chart of accounts
|
||||
$r++;
|
||||
$this->import_code[$r] = $this->rights_class.'_'.$r;
|
||||
|
||||
@ -402,6 +402,26 @@ UseMenuToSetBindindManualy=Lines not yet bound, use menu <a href="%s">%s</a> to
|
||||
|
||||
## Import
|
||||
ImportAccountingEntries=Accounting entries
|
||||
ImportAccountingEntriesFECFormat=Accounting entries - FEC format
|
||||
FECFormatJournalCode=Code journal (JournalCode)
|
||||
FECFormatJournalLabel=Label journal (JournalLib)
|
||||
FECFormatEntryNum=Piece number (EcritureNum)
|
||||
FECFormatEntryDate=Piece date (EcritureDate)
|
||||
FECFormatGeneralAccountNumber=General account number (CompteNum)
|
||||
FECFormatGeneralAccountLabel=General account label (CompteLib)
|
||||
FECFormatSubledgerAccountNumber=Subledger account number (CompAuxNum)
|
||||
FECFormatSubledgerAccountLabel=Subledger account number (CompAuxLib)
|
||||
FECFormatPieceRef=Piece ref (PieceRef)
|
||||
FECFormatPieceDate=Piece date creation (PieceDate)
|
||||
FECFormatLabelOperation=Label operation (EcritureLib)
|
||||
FECFormatDebit=Debit (Debit)
|
||||
FECFormatCredit=Credit (Credit)
|
||||
FECFormatReconcilableCode=Reconcilable code (EcritureLet)
|
||||
FECFormatReconcilableDate=Reconcilable date (DateLet)
|
||||
FECFormatValidateDate=Piece date validated (ValidDate)
|
||||
FECFormatMulticurrencyAmount=Multicurrency amount (Montantdevise)
|
||||
FECFormatMulticurrencyCode=Multicurrency code (Idevise)
|
||||
|
||||
DateExport=Date export
|
||||
WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manually in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate.
|
||||
ExpenseReportJournal=Expense Report Journal
|
||||
|
||||
Loading…
Reference in New Issue
Block a user