noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 30/219: Task #0001443: opérations rapprochée


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 30/219: Task #0001443: opérations rapprochées : bug quand on utilise des tva avec autoliquidation 1. Correct export CSV 2. Improve code : new function Acc_Reconciliation:get_amount_noautovat
Date: Mon, 18 Dec 2017 13:22:30 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit d3a04efd68bf6faf0e678aaff217d86fb5099c95
Author: Dany De Bontridder <address@hidden>
Date:   Thu Aug 31 11:12:33 2017 +0200

    Task #0001443: opérations rapprochées : bug quand on utilise des tva avec 
autoliquidation
    1. Correct export CSV
    2. Improve code : new function Acc_Reconciliation:get_amount_noautovat
---
 include/class/acc_reconciliation.class.php  | 32 ++++++++++++++++++++++++-----
 include/template/impress_reconciliation.php | 31 ++++++----------------------
 2 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/include/class/acc_reconciliation.class.php 
b/include/class/acc_reconciliation.class.php
index 4233d7c..ed5427c 100644
--- a/include/class/acc_reconciliation.class.php
+++ b/include/class/acc_reconciliation.class.php
@@ -515,6 +515,11 @@ j1.j_poste as poste
                 }
             }
             $export->write_header($title);
+            //-----------------------------------------
+            //Retrieve amount without autoreversed VAT
+            //-----------------------------------------
+            
$amount=$this->get_amount_noautovat($first['jr_id'],$first['jr_montant']);
+            
             // --------------------------
             // Print First
             // --------------------------
@@ -525,7 +530,7 @@ j1.j_poste as poste
             $export->add($first['jr_pj_number']);
             $export->add($first['jrn_def_name']);
             $export->add($first['jrn_def_type']);
-            $export->add($first['jr_montant'],"number");
+            $export->add($amount,"number");
             if (count($a_depend) > 0)
             {
                 // --------------------------------------
@@ -533,20 +538,21 @@ j1.j_poste as poste
                 // --------------------------------------
                 $depend = $a_depend[0];
                 $export->add("<->");
-                
+                
$amount_dep=$this->get_amount_noautovat($depend['jr_id'],$depend['jr_montant']);
                 $export->add($depend['jr_date']);
                 $export->add($depend['jr_internal']);
                 $export->add($depend['jr_comment']);
                 $export->add($depend['jr_pj_number']);
                 $export->add($depend['jrn_def_name']);
                 $export->add($depend['jrn_def_type']);
-                $export->add($depend['jr_montant'],"number");
+                $export->add($amount_dep,"number");
                 $export->write();
                 // --------------------------------------
                 // print other depending operation if any
                 // --------------------------------------
                 for ($e = 1; $e < count($a_depend); $e++)
                 {
+                    
$amount_dep=$this->get_amount_noautovat($depend['jr_id'],$depend['jr_montant']);
                     $depend = $a_depend[$e];
                     $export->add("");
                     $export->add("");
@@ -563,7 +569,7 @@ j1.j_poste as poste
                     $export->add($depend['jr_pj_number']);
                     $export->add($depend['jrn_def_name']);
                     $export->add($depend['jrn_def_type']);
-                    $export->add($depend['jr_montant'],"number");
+                    $export->add($amount_dep,"number");
                     $export->write();
                 }
             }
@@ -605,7 +611,23 @@ j1.j_poste as poste
         }
         return $array;
     }
-
+    function get_amount_noautovat($p_jrn_id,$p_default_amount) {
+        $retdb=$this->db->execute("detail_quant",array($p_jrn_id));
+        if ( Database::num_row($retdb) != 0)
+        {
+            // then second_amount takes in account the vat_sided
+            $row=Database::fetch_array($retdb, 0);
+            $total_price=bcadd($row['price'],$row['vat_amount']);
+            $total_price=bcsub($total_price,$row['vat_sided']);
+            $first_amount=$total_price;
+
+        } else {
+            // else take the amount from jrn
+            $first_amount=$p_default_amount;
+        }
+        return $first_amount;
+        
+    }
     static function test_me()
     {
         $cn=Dossier::connect();
diff --git a/include/template/impress_reconciliation.php 
b/include/template/impress_reconciliation.php
index d6b3f19..d0c7d69 100644
--- a/include/template/impress_reconciliation.php
+++ b/include/template/impress_reconciliation.php
@@ -24,17 +24,8 @@
 </tr>
 <?php 
 for ($i=0;$i<count($array);$i++) {
-        $tot=$array[$i]['first']['jr_montant'];
-        
$retdb=$cn->execute("detail_quant",array($array[$i]['first']['jr_id']));
-        if ( Database::num_row($retdb) != 0)
-        {
-            // then second_amount takes in account the vat_sided
-            $row=Database::fetch_array($retdb, 0);
-            $total_price=bcadd($row['price'],$row['vat_amount']);
-            $total_price=bcsub($total_price,$row['vat_sided']);
-            $tot=$total_price;
-
-        }
+        
$tot=$acc_reconciliation->get_amount_noautovat($array[$i]['first']['jr_id'],$array[$i]['first']['jr_montant']);
+        
        $r='';
        $r.=td($i);
        $r.=td(format_date($array[$i]['first']['jr_date']));
@@ -60,20 +51,10 @@ for ($i=0;$i<count($array);$i++) {
                     $r.=td($array[$i]['depend'][$e]['jr_pj_number']);
                     $r.=td($array[$i]['depend'][$e]['jr_comment']);
                     
$r.=td(nbm($array[$i]['depend'][$e]['jr_montant']),'style="text-align:right"');
-                    
$retdb=$cn->execute("detail_quant",array($array[$i]['depend'][$e]['jr_id']));
-                    // if exist in v_quant_detail
-                    if ( Database::num_row($retdb) != 0)
-                    {
-                        // then second_amount takes in account the vat_sided
-                        $row=Database::fetch_array($retdb, 0);
-                        $total_price=bcadd($row['price'],$row['vat_amount']);
-                        $total_price=bcsub($total_price,$row['vat_sided']);
-                        $tot2=bcadd($tot2,$total_price);
+                    
+                    
$amount_dep=$acc_reconciliation->get_amount_noautovat($array[$i]['depend'][$e]['jr_id'],$array[$i]['depend'][$e]['jr_montant']);
+                    $tot2=bcadd($tot2,$amount_dep);
 
-                    } else {
-                    // else take the amount from jrn
-                      
$tot2=bcadd($tot2,$array[$i]['depend'][$e]['jr_montant']);
-                    }
                     if ( $e==$limit)
                             echo '<tr>'.$r.'</tr>';
                     else
@@ -81,7 +62,7 @@ for ($i=0;$i<count($array);$i++) {
                     
$ret=$acc_reconciliation->db->execute('detail_quant',array($array[$i]['depend'][$e]['jr_id']));
                     $acc_reconciliation->show_detail($ret);
                     }
-           echo tr(td(_('Total 
')).td(_('operation')).td(nbm($tot)).td(_('operations 
dépendantes')).td(nbm($tot2)).td(_('Delta')).td(bcsub($tot,$tot2)),' 
class="highlight"');
+           echo tr(td(_('Total 
')).td(_('opération')).td(nbm($tot)).td(_('opérations 
dépendantes')).td(nbm($tot2)).td(_('Delta')).td(bcsub($tot,$tot2)),' 
class="highlight"');
            echo tr(td('<hr>',' colspan="6" style="witdh:auto"'));              
          
                          
        }



reply via email to

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