[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 21/28: Fix problem with Acc_Ledger_purchase o
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 21/28: Fix problem with Acc_Ledger_purchase or sold and quantity or vat amount were an empty string |
Date: |
Sat, 30 Nov 2019 07:51:25 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit c3e7bc0c3194f9a59bcfbb3d0e914639a57a2a3a
Author: Dany De Bontridder <address@hidden>
Date: Sun Nov 24 20:52:15 2019 +0100
Fix problem with Acc_Ledger_purchase or sold and quantity or vat amount
were an empty string
---
include/class/acc_ledger_purchase.class.php | 2 +-
include/class/acc_ledger_sold.class.php | 3 +-
.../include/class/acc_ledger_purchase.Test.php | 76 +++++++++++++++++++++-
unit-test/include/class/acc_ledger_sold.Test.php | 49 ++++++++++++++
4 files changed, 126 insertions(+), 4 deletions(-)
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 7306185..a37cea8 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -544,7 +544,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
for ($i=0;$i< $nb_item;$i++)
{
$n_both=0;
- if ( strlen(trim(${'e_march'.$i})) == 0 ) continue;
+ if ( empty(${'e_march'.$i}) || empty(${'e_quant'.$i}) )
continue;
/* First we save all the items without vat */
$fiche=new Fiche($this->db);
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index 524fa4c..e2dc5fd 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -285,8 +285,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
/* Save all the items without vat */
for ($i = 0; $i < $nb_item; $i++) {
$n_both = 0;
- if (strlen(trim(${'e_march' . $i})) == 0)
- continue;
+ if ( empty(${'e_march'.$i}) || empty(${'e_quant'.$i}) )
continue;
/* First we save all the items without vat */
$fiche = new Fiche($this->db);
diff --git a/unit-test/include/class/acc_ledger_purchase.Test.php
b/unit-test/include/class/acc_ledger_purchase.Test.php
index 966f613..b750733 100644
--- a/unit-test/include/class/acc_ledger_purchase.Test.php
+++ b/unit-test/include/class/acc_ledger_purchase.Test.php
@@ -123,7 +123,81 @@ class Acc_Ledger_PurchaseTest extends TestCase
$this->assertEquals(1,
$g_connection->get_value ("select count(*) from jrn where
jr_mt=$1",["1572704002.1732"]));
$this->clean_operation();
-
+
+ // If some data are corruptes
+ $sql="
+ from quant_purchase
+ join jrnx using(j_id)
+ join jrn on (jr_grpt_id=j_grpt)
+ where
+ jr_mt='1572704002.1732'
+ and j_qcode='DOCUME'
+ ";
+ // Test space in e_quant0 instead of zero
+ $array=$this->array;
+ $array["mt"]="1572704002.1732";
+ $array["nb_item"]=2;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0);
+ $array["amount_t0"]=658.25;
+ $array['hplan']=array(array(-1));
+ $array["val"]=array(array(658.25));
+ $array=array_merge($array, array("e_march1"=>"DOCUME",
+ "e_march1_price"=>18.25,
+ "e_quant1"=>"",
+ "htva_march1"=>18.25,
+ "e_march1_tva_id"=>1,
+ "e_march1_tva_amount"=>22.08,
+ "tva_march1"=>3.83,
+ "tvac_march1"=>22.05));
+
+ $this->object->insert($array);
+ $this->assertEquals(0,$g_connection->get_value("select count(*)
".$sql));
+ $this->clean_operation();
+
+ // Test space in e_march0_price instead of zero must be
+ $array=$this->array;
+ $array["mt"]="1572704002.1732";
+ $array["nb_item"]=2;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0);
+ $array["amount_t0"]=658.25;
+ $array['hplan']=array(array(-1));
+ $array["val"]=array(array(658.25));
+ $array=array_merge($array, array("e_march1"=>"DOCUME",
+ "e_march1_price"=>18.25,
+ "e_quant1"=>1,
+ "htva_march1"=>18.25,
+ "e_march1_tva_id"=>1,
+ "e_march1_tva_amount"=>"",
+ "tva_march1"=>3.83,
+ "tvac_march1"=>22.05));
+ $this->object->insert($array);
+ $this->assertEquals(3.83,$g_connection->get_value("select qp_vat
".$sql));
+ $this->clean_operation();
+
+ // Test space in e_march0_tva_amount instead of zero must be calculated
+ $array=$this->array;
+ $array["mt"]="1572704002.1732";
+ $array["nb_item"]=2;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0);
+ $array["amount_t0"]=658.25;
+ $array['hplan']=array(array(-1));
+ $array["val"]=array(array(658.25));
+ $array=array_merge($array, array("e_march1"=>"DOCUME",
+ "e_march1_price"=>18.25,
+ "e_quant1"=>1,
+ "htva_march1"=>18.25,
+ "e_march1_tva_id"=>1,
+ "e_march1_tva_amount"=>22.08,
+ "tva_march1"=>"",
+ "tvac_march1"=>22.05));
+
+ $this->object->insert($array);
+ $this->assertEquals(22.08,$g_connection->get_value("select qp_vat
".$sql));
+ $this->clean_operation();
+
}
/**
diff --git a/unit-test/include/class/acc_ledger_sold.Test.php
b/unit-test/include/class/acc_ledger_sold.Test.php
index c700a88..3ec3e87 100644
--- a/unit-test/include/class/acc_ledger_sold.Test.php
+++ b/unit-test/include/class/acc_ledger_sold.Test.php
@@ -115,6 +115,55 @@ class Acc_Ledger_SoldTest extends TestCase
$cnt=$g_connection->get_value("select count(*) from jrn where
jr_mt=$1",["1572714478.3155"]);
$this->assertEquals(1,$cnt);
$this->clean_operation();
+
+ // If some data are corruptes
+ $sql="
+ from quant_sold
+ join jrnx using(j_id)
+ join jrn on (jr_grpt_id=j_grpt)
+ where
+ jr_mt='1572714478.3155'
+ and j_qcode='MARCHA'
+ ";
+ // Test space in e_quant1 instead of zero
+ $array=$this->array;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0, 1);
+ $array["amount_t0"]=24.2;
+ $array["hplan"]=array(array(-1), array(-1));
+ $array["val"]=array(array(24, 2), array(1212.5));
+ $array["mt"]="1572714478.3155";
+ $array['e_quant1']="";
+ $this->object->insert($array);
+ $this->assertEquals(0,$g_connection->get_value("select count(*)
".$sql));
+ $this->clean_operation();
+
+ // Test space in e_march1_price instead of zero must be
+ $array=$this->array;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0, 1);
+ $array["amount_t0"]=24.2;
+ $array["hplan"]=array(array(-1), array(-1));
+ $array["val"]=array(array(24, 2), array(1212.5));
+ $array["mt"]="1572714478.3155";
+ $array['e_march1_tva_amount']="";
+ $this->object->insert($array);
+ $this->assertEquals(254.6250,$g_connection->get_value("select qs_vat
".$sql));
+ $this->clean_operation();
+
+ // Test space in e_march1_tva_amount instead of zero must be calculated
+ $array=$this->array;
+ $array["pa_id"]=array(2);
+ $array["op"]=array(0, 1);
+ $array["amount_t0"]=24.2;
+ $array["hplan"]=array(array(-1), array(-1));
+ $array["val"]=array(array(24, 2), array(1212.5));
+ $array["mt"]="1572714478.3155";
+ $array['tva_march1']="";
+ $this->object->insert($array);
+ $this->assertEquals(254.63,$g_connection->get_value("select qs_vat
".$sql));
+ $this->clean_operation();
+
}
/**
- [Noalyss-commit] [noalyss] 19/28: Data_SQL Function prefix turn an object to an array but key can have a prefix, (continued)
- [Noalyss-commit] [noalyss] 19/28: Data_SQL Function prefix turn an object to an array but key can have a prefix, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 06/28: PDFTK Convert in PDF if working from home, see http://wiki.noalyss.eu/doku.php?id=menu:ancgl, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 14/28: Bug PHP : confuse NULL and 0, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 13/28: cosmetid add a button close for the "forget-email-box", Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 15/28: Bug Array to string conversion error, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 16/28: Bug : when e_march is null it is considered as an empty string instead of 0, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 17/28: Cosmetic, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 12/28: Improve PHPUNIT test, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 22/28: Search operation : all, paid or unpaid, including the CSV export and the filter, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 10/28: Correct report amount, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 21/28: Fix problem with Acc_Ledger_purchase or sold and quantity or vat amount were an empty string,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 24/28: Merge branch 'dev-7200', Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 26/28: warning about session_start, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 28/28: Merge branch 'dev-7200', Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 02/28: Task #0001762: TVA France , add the possibility to compute VAT at the date of operation , payment. PRINTTVA : Add feature summary of VAT depending of operation date, payment date or VAT setting, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 03/28: Task #1762 , printtva peut mettre donner les totaux de tva suivant l'exigibilité configuré par Code TVA , par date de paiement ou par date d'opération, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 25/28: Acc_Ledger_Search , fix small bug + Test file, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 23/28: File to restore for testing, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 20/28: PHPUNIT Suppress risky test, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 27/28: Change logo, Dany De Bontridder, 2019/11/30
- [Noalyss-commit] [noalyss] 18/28: Remove useless Risky, Dany De Bontridder, 2019/11/30