From 6f37fef05e9222d82f1eb54ed80e2683c8e3dad0 Mon Sep 17 00:00:00 2001
From: Jean-Pierre Morfin <jpfox@users.noreply.github.com>
Date: Tue, 20 Oct 2015 14:44:20 +0200
Subject: [PATCH] fix test against empty amount on book update

- amount < 1 was considered as 0
- 0.00 was not considered as empty so $book->sens was always C
---
 htdocs/accountancy/bookkeeping/card.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index d1bf69a8eee..d4c256dfbf2 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -51,7 +51,7 @@ if ($action == "confirm_update") {
 
     $error = 0;
 
-    if ((intval($debit) != 0) && (intval($credit) != 0)) {
+    if ((floatval($debit)!=0.0) && (floatval($credit)!=0.0)) {
         setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
         $error ++;
     }
@@ -69,11 +69,11 @@ if ($action == "confirm_update") {
             $book->debit = $debit;
             $book->credit = $credit;
 
-            if (! empty($debit)) {
+            if (floatval($debit)!=0.0) {
                 $book->montant = $debit;
                 $book->sens = 'D';
             }
-            if (! empty($credit)) {
+            if (floatval($credit)!=0.0) {
                 $book->montant = $credit;
                 $book->sens = 'C';
             }
@@ -372,4 +372,4 @@ if ($action == 'create') {
 }
 
 llxFooter();
-$db->close();
\ No newline at end of file
+$db->close();
-- 
GitLab