[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/02: Bug Anticipation échoue si aucune opér
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/02: Bug Anticipation échoue si aucune opération pour une fiche |
Date: |
Fri, 13 Aug 2021 12:44:30 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 53918bc981b841c9a47de06212f869f24a1a72cc
Author: Dany wm De Bontridder <danydb@noalyss.eu>
AuthorDate: Fri Aug 13 16:48:38 2021 +0200
Bug Anticipation échoue si aucune opération pour une fiche
---
include/class/anticipation.class.php | 3 +-
include/class/fiche.class.php | 3 +-
include/lib/impress.class.php | 2 +-
unit-test/include/class/impressTest.class.php | 49 +++++++++++++++++++--------
4 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/include/class/anticipation.class.php
b/include/class/anticipation.class.php
index cb9f24b..81d925b 100644
--- a/include/class/anticipation.class.php
+++ b/include/class/anticipation.class.php
@@ -25,6 +25,7 @@
*
*/
/**
+ * @class
* @brief Manage the anticipation of expense, sales,...
* @see Forecast Forecast_Cat Forecast_Item
*
@@ -259,7 +260,7 @@ EOF;
}
/**
- * Clone completely Forecast and returns the new forecast_id
+ * @brief Clone completely Forecast and returns the new forecast_id
* @return type
*/
public function object_clone()
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index d5b177d..2334eb2 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -1137,7 +1137,8 @@ class Fiche
$qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
if ( $p_cond != "") $p_cond=" and ".$p_cond;
- $Res=$this->cn->exec_sql("select sum(deb) as sum_deb, sum(cred) as
sum_cred from
+ $Res=$this->cn->exec_sql("select coalesce(sum(deb),0) as sum_deb,
+ coalesce(sum(cred),0) as sum_cred from
( select j_poste,
case when j_debit='t' then j_montant else 0
end as deb,
case when j_debit='f' then j_montant else 0
end as cred
diff --git a/include/lib/impress.class.php b/include/lib/impress.class.php
index 1520cc8..e597938 100644
--- a/include/lib/impress.class.php
+++ b/include/lib/impress.class.php
@@ -42,7 +42,7 @@ class Impress
* \param $p_formula
* \param $p_eval true if we eval here otherwise the function returns
* a string which must be evaluated
- * \param $p_type_date : type of the date 0 for accountant period or 1
+ \param $p_type_date : type of the date 0 for accountant period or 1
* for calendar
* \return array key [ desc , montant ]
*
diff --git a/unit-test/include/class/impressTest.class.php
b/unit-test/include/class/impressTest.class.php
index c229350..62a5e87 100644
--- a/unit-test/include/class/impressTest.class.php
+++ b/unit-test/include/class/impressTest.class.php
@@ -125,29 +125,48 @@ class ImpressTest extends TestCase
}
}
- /***
+
+ /**
+ * @brief supply data to test_compute_amount
+ * @return array[]
+ */
+ function getData_compute_amount()
+ {
+ return array(
+ ["[70%-s]", -456.8000],
+ ["[61%-s]", 1491.5000],
+ ["[61%-S]", -1491.5000],
+ ["[61%-d]", 1591.50],
+ ["[61%-c]", 100.00],
+ ["{EAU}", 915.00],
+ ["{EAU-d}", 915.00],
+ ["{EAU-c}", 0],
+ ["{EAU-s}", 915.00],
+ ["{EAU-S}", -915.00 ],
+ ["{ELECTR}", 0 ],
+ ["{ELECTR-c}", 0 ],
+ ["{ELECTR-d}", 0 ],
+ ["{ELECTR-s}", 0 ],
+ ["{ELECTR-S}", 0 ]
+ );
+ }
+ /**
* @covers Impress::parse_formula
+ * @dataProvider getData_compute_amount
*/
-
- function test_compute_amount()
+ function test_compute_amount($p_accounting,$p_amount)
{
global $g_connection;
// filter on period
$sql_periode="j_date >= '2018-01-01' and j_date <= '2018-12-31'";
$and_sql_periode="oa_date >= '2018-01-01' and oa_date <=
'2018-12-31'";
// 0 = formula , 1 is the expected value
- $aFormula=array(
- ["[70%-s]", -456.8000],
- ["[61%-s]", 1491.5000],
- ["[61%-S]", -1491.5000],
- ["[61%-d]", 1591.50],
- ["[61%-c]", 100.00]
- );
- foreach ($aFormula as $formula) {
-
$this->assertEquals($formula[1],\Impress::compute_amount($g_connection,$formula[0],
+
+
+
$this->assertEquals($p_amount,\Impress::compute_amount($g_connection,$p_accounting,
$sql_periode,$and_sql_periode),
- " {$formula[0]} = {$formula[1]}");
- }
+ " {$p_accounting} != {$p_amount}");
+
}
/**
@@ -226,6 +245,8 @@ class ImpressTest extends TestCase
array("sum 70% Débit", "[70%-d]",0),
array("sum FOURNI1 Crédit", "{FOURNI1-c}",1717.77),
array("sum FOURNI1 Débit", "{FOURNI1-d}",221.43),
+ array("sum FOURNI1 Débit", "{NOTEXIST-d}",0),
+ array("sum FOURNI1 Débit", "{{NOTEXIST-d}}",0),
);
// ------ Periode ----------
foreach ($a_formula as $formula)