From faddcb28ac9fafb54ad8124f0eef77f2561926f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Apr 2017 14:53:29 +0200 Subject: [PATCH] FIX serious bugs in accounting (error management, transactions, bad values set) --- .../accountancy/class/bookkeeping.class.php | 15 +- htdocs/accountancy/customer/lines.php | 16 +- htdocs/accountancy/customer/list.php | 9 +- htdocs/accountancy/journal/bankjournal.php | 291 +++++++++--------- .../journal/expensereportsjournal.php | 250 ++++++++------- .../accountancy/journal/purchasesjournal.php | 259 +++++++++------- htdocs/accountancy/journal/sellsjournal.php | 240 +++++++++------ htdocs/accountancy/supplier/lines.php | 9 +- htdocs/accountancy/supplier/list.php | 9 +- htdocs/core/lib/accounting.lib.php | 92 ++++++ htdocs/core/lib/functions.lib.php | 2 +- 11 files changed, 731 insertions(+), 461 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 754dd262369..8f31b40bc54 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -169,7 +169,15 @@ class BookKeeping extends CommonObject if (empty($this->numero_compte) || $this->numero_compte == '-1') { $langs->load("errors"); - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet); + if (in_array($this->doc_type, array('bank', 'expense_report'))) + { + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); + } + else + { + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + } + return -1; } @@ -178,11 +186,12 @@ class BookKeeping extends CommonObject $this->piece_num = 0; - // first check if line not yet in bookkeeping + // First check if line not yet already in bookkeeping $sql = "SELECT count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; - $sql .= " AND fk_docdet = " . $this->fk_docdet; + $sql .= " AND fk_doc = " . $this->fk_doc; + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index a015fa05929..428e490aff7 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -43,6 +43,7 @@ $langs->load("productbatch"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); // Search Getpost +$search_lineid = GETPOST('search_lineid', 'int'); $search_ref = GETPOST('search_ref', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -86,6 +87,7 @@ $formventilation = new FormVentilation($db); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -151,7 +153,7 @@ print '