From 5601fab14f9d3f98cb76b47ea4f1d83da143008a Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 5 Dec 2023 10:41:02 +0100 Subject: [PATCH 1/2] fix sql error in case of balance is empty --- htdocs/compta/bank/class/account.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 70f03bc21c8..752de8f077b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -650,6 +650,14 @@ class Account extends CommonObject return -1; } + $balance = $this->balance; + if (empty($balance) && !empty($this->solde)) { + $balance = $this->solde; + } + if (empty($balance)) { + $balance = 0; + } + // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -721,7 +729,7 @@ class Account extends CommonObject $accline = new AccountLine($this->db); $accline->datec = $this->db->idate($now); $accline->label = '('.$langs->trans("InitialBankBalance").')'; - $accline->amount = price2num($this->solde); + $accline->amount = price2num($balance); $accline->fk_user_author = $user->id; $accline->fk_account = $this->id; $accline->datev = $this->db->idate($this->date_solde); From ea7afeb00735b959d0e6fc1493afa20d7b17f2b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Dec 2023 16:16:22 +0100 Subject: [PATCH 2/2] Fix warning --- htdocs/compta/bank/class/account.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 70f03bc21c8..cf5cabdddf3 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -219,6 +219,20 @@ class Account extends CommonObject */ public $date_solde; + /** + * Balance. Used in Account::create + * @var float + * @deprecated + * @see $balance + */ + public $solde; + + /** + * Balance. Used in Account::create + * @var float + */ + public $balance; + /** * Creditor Identifier CI. Some banks use different ICS for direct debit and bank tranfer * @var string