[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 26/238: Task #448 : rounded problem add debug
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 26/238: Task #448 : rounded problem add debug info |
Date: |
Sat, 26 Oct 2019 04:40:19 -0400 (EDT) |
sparkyx pushed a commit to annotated tag rel7110
in repository noalyss.
commit 1096958e3dfbe8370fa7bfb3551967f089e2cded
Author: Dany De Bontridder <address@hidden>
Date: Fri May 11 17:13:58 2018 +0200
Task #448 : rounded problem add debug info
---
include/class/acc_ledger_purchase.class.php | 12 ++++++-
include/class/acc_ledger_sold.class.php | 53 +++++++++++++++++++++--------
include/class/acc_operation.class.php | 6 ++--
3 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 2d509f7..f72c258 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -609,6 +609,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
}
// convert amount in eur
$tot_tva=bcadd($tot_tva,$acc_amount->amount_vat);
+ $tot_tva=round($tot_tva,2);
}
@@ -754,6 +755,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger
} // end loop : save all items
/* save total customer */
+ if ( DEBUG ) {
+ echo __LINE__." tot_amount $tot_amount<br>";
+ echo __LINE__." tot_tva $tot_tva<br>";
+
+ }
$cust_amount=round(bcadd($tot_amount,$tot_tva),2);
$acc_operation=new Acc_Operation($this->db);
$acc_operation->date=$e_date;
@@ -784,7 +790,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$poste_vat=$oTva->get_side('d');
- $cust_amount=bcadd($tot_amount,$tot_tva);
+ $cust_amount=round(bcadd($tot_amount,$tot_tva),2);
$acc_operation=new Acc_Operation($this->db);
$acc_operation->date=$e_date;
$acc_operation->poste=$poste_vat;
@@ -825,6 +831,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
// Total DEB
$acc_operation->amount=$this->db->get_value("select sum(j_montant)
from jrnx where j_grpt = $1 and j_debit='t'",
array($seq));
+ if ( DEBUG ) {
+ echo __LINE__." amount ".$acc_operation->amount."<br>";
+
+ }
$acc_operation->desc=$e_comm;
$acc_operation->grpt=$seq;
$acc_operation->jrn=$p_jrn;
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index 7d14a82..65f8793 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -302,8 +302,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
// convert amount to currency
$amount=bcmul($amount_currency,$p_currency_rate);
- $tot_amount = bcadd($tot_amount, $amount,2);
- echo "tot_amount $tot_amount<br>";
+ $tot_amount = bcadd($tot_amount, $amount);
+ $tot_amount = round($tot_amount, 2);
+ if ( DEBUG ) { echo __LINE__." tot_amount $tot_amount<br>";}
$acc_operation = new Acc_Operation($this->db);
$acc_operation->date = $e_date;
$sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
@@ -353,18 +354,20 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$l->load();
$tva_item_currency = bcmul($amount,
$l->get_parameter('rate'));
}
- $tva_item=bcmul($tva_item_currency,$p_currency_rate,2);
-
+ $tva_item=bcmul($tva_item_currency,$p_currency_rate);
+ $tva_item=round($tva_item,2);
if (isset($tva[$idx_tva]))
{
- $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva],2);
+ $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]);
+ $tva[$idx_tva]=round($tva[$idx_tva],2);
}
else
{
$tva[$idx_tva]=$tva_item;
}
if ($oTva->get_parameter("both_side") == 0) {
- $tot_tva = bcadd($tva_item, $tot_tva, 2);
+ $tot_tva = bcadd($tva_item, $tot_tva);
+ $tot_tva = round($tot_tva, 2);
} else {
$n_both = $tva_item;
if ($n_both<0)
@@ -440,8 +443,14 @@ class Acc_Ledger_Sold extends Acc_Ledger {
}// end loop : save all items
/* save total customer */
- $cust_amount = bcadd($tot_amount, $tot_tva,2);
- echo "cust_amount $cust_amount<br>";
+ $cust_amount = bcadd($tot_amount, $tot_tva);
+ $cust_amount = round($cust_amount,2);
+ if ( DEBUG ) {
+ echo __LINE__." cust_amount $cust_amount<br>";
+ echo __LINE__." tot_amount $tot_amount<br>";
+ echo __LINE__." tot_tva $tot_tva<br>";
+
+ }
$acc_operation = new Acc_Operation($this->db);
$acc_operation->date = $e_date;
@@ -454,7 +463,8 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$acc_operation->qcode = ${"e_client"};
if ($cust_amount>0)
{
- $tot_debit=bcadd($tot_debit, $cust_amount,2);
+ $tot_debit=bcadd($tot_debit, $cust_amount);
+ $tot_debit=round($tot_debit, 2);
}
$let_tiers = $acc_operation->insert_jrnx();
@@ -464,6 +474,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
* if if ($g_parameter->MY_TVA_USE == 'Y' )
*/
if ($g_parameter->MY_TVA_USE == 'Y') {
+ if (DEBUG ) {
+ var_dump($tva);
+ }
foreach ($tva as $i => $value) {
$oTva = new Acc_Tva($this->db);
$oTva->set_parameter('id', $i);
@@ -482,10 +495,14 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$acc_operation->periode = $tperiode;
if ($value<0)
{
- $tot_debit=bcadd($tot_debit, abs($value),2);
+ $tot_debit=bcadd($tot_debit, abs($value));
+ $tot_debit=round($tot_debit, 2);
}
$acc_operation->insert_jrnx();
+ if ( DEBUG ) {
+ echo __LINE__." tot_tva $tot_tva<br>";
+ }
// if TVA is on both side, we deduce it immediately
if ($oTva->get_parameter("both_side") == 1) {
$poste_vat = $oTva->get_side('d');
@@ -499,12 +516,19 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$acc_operation->type = 'd';
$acc_operation->periode = $tperiode;
$acc_operation->insert_jrnx();
- $tot_debit = bcadd($tot_debit, $value,2);
+ $tot_debit = bcadd($tot_debit, $value);
+ $tot_debit = round($tot_debit, 2);
$n_both = $value;
}
}
} // if ($g_parameter->MY_TVA_USE=='Y')
+ /*
+ * Balance the amount on D and C , the difference must be inserted
as "difference due to a rounded value"
+ * Value are retrieve thanks $seq
+ */
+
/* insert into jrn */
+ if ( DEBUG ) { echo __LINE__." tot_debit
".round($tot_debit,2)."<br>"; }
$acc_operation = new Acc_Operation($this->db);
$acc_operation->date = $e_date;
$acc_operation->echeance = $e_ech;
@@ -655,6 +679,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
}
}
} catch (Exception $e) {
+ record_log($e->getMessage());
record_log($e->getTraceAsString());
echo '<span class="error">' .
'Erreur dans l\'enregistrement ' .
@@ -823,7 +848,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$tva_computed = $op->get_parameter('amount_vat');
$tva_item = ${"e_march" . $i . "_tva_amount"};
if (isset($tva[$idx_tva]))
- $tva[$idx_tva]+=$tva_item;
+ $tva[$idx_tva]=bcadd($tva[$idx_tva],$tva_item,2);
else
$tva[$idx_tva] = $tva_item;
$tot_tva = round(bcadd($tva_item, $tot_tva), 2);
@@ -891,9 +916,8 @@ class Acc_Ledger_Sold extends Acc_Ledger {
//
// Add the sum
$decalage=($g_parameter->MY_TVA_USE ==
'Y')?'<td></td><td></td><td></td><td></td>':'<td></td>';
- $tot = round(bcadd($tot_amount, $tot_tva), 2);
+ $tot = bcadd($tot_amount, $tot_tva, 2);
$tot_eur=round(bcmul($tot, $p_currency_rate),2);
- $tot_tva=nbm($tot_tva);
$tot=nbm($tot);
$str_tot=_('Totaux');
@@ -907,7 +931,6 @@ class Acc_Ledger_Sold extends Acc_Ledger {
// Format amount
$tot_amount=nbm($tot_amount);
$tot_tva=nbm($tot_tva);
- $tot=nbm($tot);
if ( $g_parameter->MY_TVA_USE=="Y") {
$r.=<<<EOF
diff --git a/include/class/acc_operation.class.php
b/include/class/acc_operation.class.php
index 1361d19..b19ce1a 100644
--- a/include/class/acc_operation.class.php
+++ b/include/class/acc_operation.class.php
@@ -187,7 +187,7 @@ class Acc_Operation
$this->type=($this->type=='d')?'c':'d';
}
if ( DEBUG ) {
- echo "insert_jrnx = {$this->amount} type {$this->type}<br>";
+ echo "insert_jrnx = [{ $this->poste}] {$this->amount} rounded
".round($this->amount,2)." type {$this->type}<br>";
}
$this->amount=abs($this->amount);
$debit=($this->type=='c')?'false':'true';
@@ -282,7 +282,9 @@ class Acc_Operation
function insert_jrn()
{
$p_comment=$this->desc;
-
+ if (DEBUG ) {
+ echo "insert_jrn = {$this->amount} <br>";
+ }
$diff=$this->db->get_value("select check_balance
($1)",array($this->grpt));
if ( $diff != 0 )
{
- [Noalyss-commit] [noalyss] 22/238: Task #448 : identical operation with currency, (continued)
- [Noalyss-commit] [noalyss] 22/238: Task #448 : identical operation with currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 24/238: Task #448 : rounded value for VEN, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 10/238: Currency : add SQL constraint + doc, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 17/238: Currency : fix rounded bugs in detail operation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 19/238: Task #448 : currency : cosmetic operation detail, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 27/238: Task #448 : delete unused currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 18/238: task #448 : Currency : display currency info into operation detail, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 20/238: Task #448 : check currency rate > 0 and payment in eur, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 21/238: Task #448 : issue with reconciliation amount, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 23/238: Display the balance difference, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 26/238: Task #448 : rounded problem add debug info,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 29/238: Task #448 : currency_id = 0 for the default currency + display currency rate in confirm operation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 34/238: Task #448 : Currency : purchase, fix bug for autoreverse VAT, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 06/238: Currency : add ajax call to delete one rate , add documentation , remove debug info, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 31/238: task #448 : currency always used and remove parameter 'use_currency' from parameters, add SQL script, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 32/238: Task #448 : SQL integrated into upgrade128, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 28/238: Task #448 : currency , EUR cannot be changed and not display, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 33/238: Task #448 : correct bug if VAT Rate = 0 , amount was reset, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 25/238: Task #448 : payment method VEN, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 30/238: remove debug info, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 16/238: Currency : insert operation with currency in VEN and ACH, Dany De Bontridder, 2019/10/26