noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 21/73: Fix : warning when Acc_Param not set p


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 21/73: Fix : warning when Acc_Param not set properly for BANK, CASH,
Date: Fri, 28 May 2021 05:26:25 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 9d680016c8cbcb9368925b1ae5b2a49bf2e5ce72
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri Apr 16 14:52:55 2021 +0200

    Fix : warning when Acc_Param not set properly for BANK, CASH,
---
 include/class/fiche.class.php          | 19 ++++++++++++++-----
 unit-test/include/class/fiche.Test.php | 15 +++++++++++++++
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index 9c3db32..17d3254 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -62,6 +62,7 @@ class Fiche
         $this->quick_code='';
         $this->attribut=array();
         $this->f_enable='1';
+       
     }
     public function get_id()
     {
@@ -1933,8 +1934,8 @@ class Fiche
         }
         // Get The result Array
         
$step_tiers=$this->get_by_category($offset,$search.$filter_amount,'name');
-
-        if ( $all_tiers == 0 || count($step_tiers)==0 ) return "";
+        
+        if ( $all_tiers == 0 || empty($step_tiers ) ) { return ""; }
         $r="";
         $r.=$bar;
         
@@ -1966,12 +1967,19 @@ class Fiche
             $odd="";
              $odd  = ($i % 2 == 0 ) ? ' odd ': ' even ';
              $accounting=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
-             if ( ! empty($accounting) && $p_action == 'bank' && 
$amount['debit'] <  $amount['credit']  ){
-                 if ( strpos($accounting,$bank->p_value)===0 || 
strpos($accounting,$cash->p_value)===0 || strpos($accounting,$cc->p_value)===0){
+             if ( ! empty($accounting) && $p_action == 'bank' 
+                     && $amount['debit'] <  $amount['credit']  
+                     &&
+                     ( /** the accounting is a financial account *****/
+                         (!empty ($bank->value) && 
strpos($accounting,$bank->p_value)===0 )
+                      || (!empty ($cash->value) && 
strpos($accounting,$cash->p_value)===0 )
+                      || ( !empty ($cc->value) && 
strpos($accounting,$cc->p_value)===0)
+                    )
+                )
+                {
                  //put in red if c>d
                  $odd.=" notice ";
                  }
-             }
         
              $odd=' class="'.$odd.'"';
              
@@ -2019,6 +2027,7 @@ class Fiche
                $r.="</tfoot>";
         $r.="</TABLE>";
         $r.=$bar;
+        
         return $r;
     }
     /*!
diff --git a/unit-test/include/class/fiche.Test.php 
b/unit-test/include/class/fiche.Test.php
index 20758ca..56d3843 100644
--- a/unit-test/include/class/fiche.Test.php
+++ b/unit-test/include/class/fiche.Test.php
@@ -110,4 +110,19 @@ class FicheTest extends TestCase
             $this->assertTrue(true,"Inject SQL command found");
         }
     }
+    /**
+     * @covers Fiche->Summary
+     * @covers Fiche->get_by_category
+     * @covers Fiche::GetByDef
+     */
+    public function testSummary()
+    {
+        $_REQUEST['ac']="CARD";
+        $this->object->fiche_def_ref=-1;
+        $r=$this->object->summary();
+        $this->assertEquals('',$r);
+        $this->object->fiche_def_ref=9;
+        $r=$this->object->summary();
+        $this->assertContains('</TABLE>',$r);
+    }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]