noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 11/11: Task #1062 - PRINTJRN : si autoliquida


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 11/11: Task #1062 - PRINTJRN : si autoliquidation montant incorrect remove commented code
Date: Wed, 03 Dec 2014 22:39:33 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 658bf197bed259a05200637e8c17396047c2b0f9
Author: Dany De Bontridder <address@hidden>
Date:   Wed Dec 3 23:38:03 2014 +0100

    Task #1062 - PRINTJRN : si autoliquidation montant incorrect
    remove commented code
---
 include/class_acc_ledger.php       |   14 +++++++++++++-
 include/class_gestion_purchase.php |    7 +++++--
 include/class_gestion_sold.php     |   35 ++++++++++++++++++++++++++++++++++-
 include/export_ledger_csv.php      |    7 ++++---
 4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php
index 1255de2..a42b315 100644
--- a/include/class_acc_ledger.php
+++ b/include/class_acc_ledger.php
@@ -35,6 +35,7 @@ require_once ('class_pre_op_advanced.php');
 require_once ('class_acc_reconciliation.php');
 require_once ('class_periode.php');
 require_once ('class_gestion_purchase.php');
+require_once ('class_gestion_sold.php');
 require_once ('class_acc_account.php');
 require_once('ac_common.php');
 require_once('class_inum.php');
@@ -1062,6 +1063,8 @@ class Acc_Ledger extends jrn_def_sql
 
        function get_detail(&$p_array, $p_jrn_type, $trunc = 0, $a_TVA = null, 
$a_ParmCode = null)
        {
+            bcscale(2);
+            
                if ($a_TVA == null)
                {
                        //Load TVA array
@@ -1081,6 +1084,7 @@ class Acc_Ledger extends jrn_def_sql
                $p_array['dep_priv'] = 0;
                $p_array['dna'] = 0;
                $p_array['tva_dna'] = 0;
+               $p_array['autoliq'] = 0;
                $dep_priv = 0.0;
                 
                //
@@ -1193,11 +1197,19 @@ class Acc_Ledger extends jrn_def_sql
                                $p_array['dep_priv'] = $dep_priv;
                                 
$p_array['dna']=bcadd($p_array['dna'],$purchase->qp_nd_amount);
                                 
$p_array['tva_dna']=bcadd($p_array['tva_dna'],bcadd($purchase->qp_nd_tva,$purchase->qp_nd_tva_recup));
+                                
$p_array['autoliq']=bcadd($purchase->qp_vat_sided,$p_array['autoliq']);
                        }
+                       if ($p_array['jrn_def_type'] == 'VEN') {
+                            $sold=new gestion_sold($this->db);
+                            $sold->search_by_jid($code['j_id']);
+                            $sold->load();
+                            
$p_array['autoliq']=bcadd($sold->qs_vat_sided,$p_array['autoliq']);
+                        }
+                        
                         
                }
                $p_array['TVAC'] = sprintf('% 10.2f', $p_array['TVAC'] );
-               $p_array['HTVA'] = sprintf('% 10.2f', $p_array['TVAC'] - 
$p_array['AMOUNT_TVA']);
+               $p_array['HTVA'] = sprintf('% 10.2f', $p_array['TVAC'] - 
$p_array['AMOUNT_TVA']-$p_array['tva_dna']);
                $r = "";
                $a_tva_amount = array();
                // inline TVA (used for the PDF)
diff --git a/include/class_gestion_purchase.php 
b/include/class_gestion_purchase.php
index d36c92f..4ba52fe 100644
--- a/include/class_gestion_purchase.php
+++ b/include/class_gestion_purchase.php
@@ -46,6 +46,7 @@ class gestion_purchase extends gestion_table
     var $j_id;                                         /*!< jrnx.j_id
                                                                  */
     var $qp_dep_priv;          /*!< private purchase */
+    var $qp_vat_sided;      /* autoliquidation */
     /*!\brief return an array of gestion_table, the object are
      * retrieved thanks the qs_internal
      */
@@ -67,7 +68,8 @@ class gestion_purchase extends gestion_table
              qp_nd_tva_recup,
              qp_supplier,
              j_id,
-             qp_dep_priv
+             qp_dep_priv,
+             qp_vat_sided
              from quant_purchase left join tva_rate on (qp_vat_code=tva_id)
              where qp_internal='".$this->qp_internal."'";
         $ret=$this->db->exec_sql($sql);
@@ -109,7 +111,8 @@ class gestion_purchase extends gestion_table
              qp_nd_tva_recup,
              qp_supplier,
              j_id,
-             qp_dep_priv
+             qp_dep_priv,
+             qp_vat_sided
              from quant_purchase
              where qp_id=".$this->qp_id;
         $ret=$this->db->exec_sql($sql);
diff --git a/include/class_gestion_sold.php b/include/class_gestion_sold.php
index fb0705c..9f31033 100644
--- a/include/class_gestion_sold.php
+++ b/include/class_gestion_sold.php
@@ -42,6 +42,7 @@ class gestion_sold extends gestion_table
     var $qs_client;                            /*!< f_id of the customer */
     var $qs_valid;                             /*!< will not be used */
     var $j_id;                                 /*!< jrnx.j_id */
+    var $qs_vat_sided;
     /*!\brief return an array of gestion_table, the object are
      * retrieved thanks the qs_internal
      */
@@ -59,7 +60,8 @@ class gestion_sold extends gestion_table
              tva_rate,
              qs_vat_code,
              qs_client,
-             j_id
+             j_id,
+             qs_vat_sided
              from quant_sold left join tva_rate on (qs_vat_code=tva_id)
              where qs_internal='".$this->qs_internal."'";
         $ret=$this->db->exec_sql($sql);
@@ -79,4 +81,35 @@ class gestion_sold extends gestion_table
         }
         return $array;
     }
+     function search_by_jid($p_jid)
+    {
+        $res=$this->db->exec_sql("select qs_id from quant_sold where 
j_id=".$p_jid);
+
+        if ( Database::num_row($res) == 1)
+            $this->qs_id=Database::fetch_result($res,0,0);
+        else
+            $this->qs_id=0;
+    }
+    function load()
+    {
+       $sql=" select  qs_id,
+             qs_internal,
+             qs_fiche,
+             qs_quantite,
+             qs_price,
+             qs_vat,
+             qs_vat_code,
+             qs_client,
+             j_id,
+             qs_vat_sided
+             from quant_sold 
+             where qs_id=$1";
+       $ret=$this->db->exec_sql($sql,array($this->qs_id));
+        // $res contains all the line
+        $res=Database::fetch_all($ret);
+
+        if ( empty($res) ) return null;
+        foreach ($res[0] as $idx=>$value)
+        $this->$idx=$value;
+    }
 }
diff --git a/include/export_ledger_csv.php b/include/export_ledger_csv.php
index 83baf1d..47da94b 100644
--- a/include/export_ledger_csv.php
+++ b/include/export_ledger_csv.php
@@ -227,10 +227,10 @@ if  ($get_option == 1)
                 $col_tva.='"Tva '.$line_tva['tva_label'].'";';
             }
         }
-        echo 
'"Date";"Paiement";"operation";"Pièce";"Client/Fourn.";"Commentaire";"inter.";"HTVA";privé;DNA;tva
 non ded.;'.$col_tva.'"TVAC";"opérations liées"'."\n\r";
+        echo 
'"Date";"Paiement";"operation";"Pièce";"Client/Fourn.";"Commentaire";"inter.";"HTVA";"privé";"DNA";"tva
 non ded.";"autoliquidation";'.$col_tva.'"TVAC";"opérations liées"'."\n\r";
         foreach ($Row as $line)
         {
-            printf('"%s";"%s";"%s";"%s";"%s";%s;%s;%s;%s;%s;%s;',
+            printf('"%s";"%s";"%s";"%s";"%s";%s;%s;%s;%s;%s;%s;%s;',
                    $line['date'],
                    $line['date_paid'],
                    $line['num'],
@@ -241,7 +241,8 @@ if  ($get_option == 1)
                    nb($line['HTVA']),
                    nb($line['dep_priv']),
                    nb($line['dna']),
-                   nb($line['tva_dna'])
+                   nb($line['tva_dna']),
+                    nb($line['autoliq'])
                    );
             $a_tva_amount=array();
             //- set all TVA to 0



reply via email to

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