noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 03/03: Task #1072 - PRINTJRN : Totaux Add tot


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 03/03: Task #1072 - PRINTJRN : Totaux Add totals + report from beginning of exercice
Date: Sat, 13 Dec 2014 17:41:33 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 8194de0230d6d2131c9c35b0fa3dae47df55606e
Author: Dany De Bontridder <address@hidden>
Date:   Sat Dec 13 18:39:57 2014 +0100

    Task #1072 - PRINTJRN : Totaux
    Add totals + report from beginning of exercice
---
 include/class_acc_ledger.php       |   19 +++++++++++++++----
 include/class_print_ledger_fin.php |   33 ++++++++++++++++++++++++++++++---
 include/impress_jrn.inc.php        |   14 +++++++++++++-
 3 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php
index 4e22136..1f465f9 100644
--- a/include/class_acc_ledger.php
+++ b/include/class_acc_ledger.php
@@ -3156,8 +3156,9 @@ class Acc_Ledger extends jrn_def_sql
                                        
',coalesce(sum(qp_nd_tva_recup),0)+coalesce(sum(qp_nd_tva),0) as tva_nd' .
                                        ',coalesce(sum(qp_vat_sided),0) as 
tva_np' .
                                        '  from quant_purchase join jrnx 
using(j_id) ' .
-                                       ' where j_tech_per >= $1 and j_tech_per 
< $2';
-                       $array = $this->db->get_array($sql, array($min->p_id, 
$p_to));
+                                       ' where j_tech_per >= $1 and j_tech_per 
< $2'.
+                                ' and j_jrn_def = $3';
+                       $array = $this->db->get_array($sql, array($min->p_id, 
$p_to,$this->idq));
 
                        $ret = $array[0];
                        /* retrieve all vat code */
@@ -3175,8 +3176,9 @@ class Acc_Ledger extends jrn_def_sql
                                        ',0 as tva_nd' .
                                         ',coalesce(sum(qs_vat_sided),0) as 
tva_np' .
                                        '  from quant_sold join jrnx 
using(j_id) ' .
-                                       ' where j_tech_per >= $1 and j_tech_per 
< $2';
-                       $array = $this->db->get_array($sql, array($min->p_id, 
$p_to));
+                                       ' where j_tech_per >= $1 and j_tech_per 
< $2'.
+                                ' and j_jrn_def = $3';
+                       $array = $this->db->get_array($sql, array($min->p_id, 
$p_to,$this->id));
                        $ret = $array[0];
                        /* retrieve all vat code */
                        $array = $this->db->get_array('select 
coalesce(sum(qs_vat),0) as sum_vat,tva_id
@@ -3184,6 +3186,15 @@ class Acc_Ledger extends jrn_def_sql
                                         where tva_rate !=0 and j_tech_per >= 
$1 and j_tech_per < $2 group by tva_id', array($min->p_id, $p_to));
                        $ret['tva'] = $array;
                }
+                if ($this->type=="FIN") 
+                {
+                    /*  get all amount exclude vat */
+                       $sql = "select coalesce(sum(qf_amount),0) as amount" .
+                                       '  from quant_fin join jrn using(jr_id) 
' .
+                                       ' where jr_tech_per >= $1 and 
jr_tech_per < $2'.
+                                ' and jr_def_id=$3';
+                       $ret = $this->db->get_array($sql, array($min->p_id, 
$p_to,$this->id));
+                }
                return $ret;
        }
 
diff --git a/include/class_print_ledger_fin.php 
b/include/class_print_ledger_fin.php
index 8bed704..787e9b9 100644
--- a/include/class_print_ledger_fin.php
+++ b/include/class_print_ledger_fin.php
@@ -25,11 +25,23 @@
 require_once('class_pdf.php');
 class Print_Ledger_Financial extends PDF
 {
-    function __construct($p_cn,$p_jrn)
+    private $rap_amount; /* amount from begining exercice */
+    private $tp_amount; /* amount total page */
+    
+    function __construct($p_cn,  Acc_Ledger $p_jrn)
     {
         parent::__construct($p_cn,'L','mm','A4');
         $this->ledger=$p_jrn;
         $this->jrn_type=$p_jrn->get_type();
+        
+        // report from begin exercice
+        $this->rap_amount=0; 
+        
+        // total page
+        $this->tp_amount=0;
+        
+        $amount=$this->ledger->previous_amount($_GET['from_periode']);
+        $this->rap_amount=$amount[0]['amount'];
     }
     function Header()
     {
@@ -38,7 +50,11 @@ class Print_Ledger_Financial extends PDF
         //Title
         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
         //Line break
-        $this->Ln(20);
+        $this->SetFont('DejaVu', 'B', 7);
+        $this->Ln(10);
+        $this->Cell(100,6,_('report'),0,0,'R');
+        $this->Cell(120,6,nbm($this->rap_amount),0,0,'R');
+        $this->Ln(6);
         $this->SetFont('DejaVu', 'B', 7);
         $this->Cell(30,6,'Piece');
         $this->Cell(10,6,'Date');
@@ -47,10 +63,19 @@ class Print_Ledger_Financial extends PDF
         $this->Cell(105,6,'Commentaire');
         $this->Cell(15,6,'Montant');
         $this->Ln(6);
-
+        
     }
     function Footer()
     {
+        $this->SetFont('DejaVu', 'B', 7);
+
+        $this->Cell(50,6,_('Total page'),0,0,'R');
+        $this->Cell(50,6,nbm($this->tp_amount),0,0,'R');
+        bcscale(2);
+        $this->rap_amount=bcadd($this->rap_amount,$this->tp_amount);
+        $this->Cell(50,6,_('Total à reporter'),0,0,'R');
+        $this->Cell(50,6,nbm($this->rap_amount),0,0,'R');
+        $this->tp_amount=0;
         //Position at 2 cm from bottom
         $this->SetY(-20);
         //Arial italic 8
@@ -71,6 +96,7 @@ class Print_Ledger_Financial extends PDF
                                             $_GET['to_periode']);
         $this->SetFont('DejaVu', '', 6);
         if ( $a_jrn == null ) return;
+        bcscale(2);
         for ( $i=0;$i<count($a_jrn);$i++)
         {
             $row=$a_jrn[$i];
@@ -86,6 +112,7 @@ class Print_Ledger_Financial extends PDF
             $amount=$this->cn->get_value('select qf_amount from quant_fin 
where jr_id=$1',array( $row['id']));
             $this->Cell(15,5,sprintf('%s',nbm($amount)),0,0,'R');
             $this->Ln(5);
+            $this->tp_amount=bcadd($this->tp_amount,$amount);
 
         }
     }
diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php
index 37c357b..86b27d8 100644
--- a/include/impress_jrn.inc.php
+++ b/include/impress_jrn.inc.php
@@ -267,7 +267,8 @@ if (isset($_REQUEST['bt_html']))
                "<th>Total opération</th>" .
                "</TR>";
                // set a filter for the FIN
-               $i = 0;
+               $i = 0;$tot_amount=0;
+                bcscale(2);
                foreach ($Row as $line)
                {
                        $i++;
@@ -297,14 +298,25 @@ if (isset($_REQUEST['bt_html']))
                                echo "<TD align=\"right\">";
                                echo ( $positive == 0 ) ? "<font color=\"red\"> 
 - " . nbm($line['montant']) . "</font>" : nbm($line['montant']);
                                echo "</TD>";
+                                if ( $positive == 1 ) {
+                                    
$tot_amount=bcadd($tot_amount,$line['montant']);
+                                } else {
+                                    
$tot_amount=bcsub($tot_amount,$line['montant']);
+                                }
                        }
                        else
                        {
                                echo "<TD align=\"right\">" . 
nbm($line['montant']) . "</TD>";
+                                
$tot_amount=bcadd($tot_amount,$line['montant']);
                        }
 
                        echo "</tr>";
                }
+                echo '<tr class="highlight">';
+                echo '<td>'._('Totaux').'</td>';
+                echo td().td().td().td().td();
+                echo '<td class="num">'.nbm($tot_amount).'</td>';
+                echo '</tr>';
                echo "</table>";
             } else {
                 /*



reply via email to

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