noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 01/01: Task #1063 - PRINTJRN : si autoliquida


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 01/01: Task #1063 - PRINTJRN : si autoliquidation montant incorrect
Date: Fri, 05 Dec 2014 20:27:35 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 6dec32404c5d81643e51003642155a370772525d
Author: Dany De Bontridder <address@hidden>
Date:   Fri Dec 5 21:25:58 2014 +0100

    Task #1063 - PRINTJRN : si autoliquidation montant incorrect
---
 include/class_acc_ledger.php               |   15 ++++++++-----
 include/class_acc_ledger_purchase.php      |   13 ++++++-----
 include/class_acc_ledger_sold.php          |    4 +-
 include/class_print_ledger_detail_item.php |   31 +++++++++++++++++++++------
 include/class_print_ledger_simple.php      |   28 +++++++++++++++++++------
 include/export_ledger_csv.php              |    4 +-
 include/export_ledger_pdf.php              |    2 +-
 include/template/operation_detail_ach.php  |    6 +++-
 include/template/operation_detail_ven.php  |    2 +
 sql/upgrade.sql                            |    9 ++++---
 10 files changed, 77 insertions(+), 37 deletions(-)

diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php
index a42b315..68b1e9e 100644
--- a/include/class_acc_ledger.php
+++ b/include/class_acc_ledger.php
@@ -1084,7 +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;
+               $p_array['tva_np'] = 0;
                $dep_priv = 0.0;
                 
                //
@@ -1197,13 +1197,13 @@ 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']);
+                                
$p_array['tva_np']=bcadd($purchase->qp_vat_sided,$p_array['tva_np']);
                        }
                        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['tva_np']=bcadd($sold->qs_vat_sided,$p_array['tva_np']);
                         }
                         
                         
@@ -3062,8 +3062,9 @@ class Acc_Ledger extends jrn_def_sql
                if ($this->type == 'ACH')
                {
                        $array = $this->db->get_array('select sum(qp_price) as 
price,sum(qp_vat) as vat ' .
-                                       
',coalesce(sum(qp_nd_amount),0)+coalesce(sum(qp_dep_priv),0) as priv' .
-                                       ',sum(qp_nd_tva_recup)+sum(qp_nd_tva) 
as tva_nd' .
+                                       
',sum(coalesce(qp_nd_amount,0)+coalesce(qp_dep_priv,0)) as priv' .
+                                       
',sum(coalesce(qp_nd_tva_recup,0)+coalesce(qp_nd_tva,0)) as tva_nd' .
+                                       ',sum(qp_vat_sided)  as tva_np' .
                                        '  from quant_purchase join jrnx 
using(j_id)
                                         where  j_grpt=$1 ', array($p_jr_id));
                        $ret = $array[0];
@@ -3073,6 +3074,7 @@ class Acc_Ledger extends jrn_def_sql
                        $array = $this->db->get_array('select sum(qs_price) as 
price,sum(qs_vat) as vat ' .
                                        ',0 as priv' .
                                        ',0 as tva_nd' .
+                                        ',sum(qs_vat_sided)  as tva_np' .
                                        '  from quant_sold join jrnx using(j_id)
                                         where  j_grpt=$1 ', array($p_jr_id));
                        $ret = $array[0];
@@ -3152,6 +3154,7 @@ class Acc_Ledger extends jrn_def_sql
                                        ',coalesce(sum(qp_dep_priv),0) as priv' 
.
                                        ',coalesce(sum(qp_vat_sided),0) as 
reversed' .
                                        
',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));
@@ -3170,7 +3173,7 @@ class Acc_Ledger extends jrn_def_sql
                                        " ,coalesce(sum(qs_vat),0) as vat " .
                                        ',0 as priv' .
                                        ',0 as tva_nd' .
-                                        ',coalesce(sum(qs_vat_sided),0) as 
reversed' .
+                                        ',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));
diff --git a/include/class_acc_ledger_purchase.php 
b/include/class_acc_ledger_purchase.php
index bff7555..8a0e674 100644
--- a/include/class_acc_ledger_purchase.php
+++ b/include/class_acc_ledger_purchase.php
@@ -588,8 +588,8 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                 $this->compute_no_deductible($acc_amount, $fiche);
                 $acc_amount->correct();
                 // TVA which avoid 
-                $acc_amount->amount_to_reverse=($tva_both == 1 ) ? 
$save_amount_vat :0 ;
-                
$tot_tva_reversed=bcadd($tot_tva_reversed,$acc_amount->amount_to_reverse);
+                $acc_amount->amount_unpaid=($tva_both == 1 ) ? 
$save_amount_vat :0 ;
+                
$tot_tva_reversed=bcadd($tot_tva_reversed,$acc_amount->amount_unpaid);
                 
 
               
@@ -674,7 +674,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                                            ",".$acc_amount->nd_vat.         /* 
9 */
                                            ",".$acc_amount->nd_ded_vat.    /* 
10 */
                                            ",".$acc_amount->amount_perso.  /* 
11 */ 
-                                           ",'".$e_client."',". 
$acc_amount->amount_to_reverse.")");        /* 12 */
+                                           ",'".$e_client."',". 
$acc_amount->amount_unpaid.")");            /* 12 */
 
                 }
                 else
@@ -691,7 +691,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                                            ",0".
                                            ",".$acc_amount->nd_ded_vat.
                                            ",".$acc_amount->amount_perso.
-                                           
",'".$e_client."',".$acc_amount->amount_to_reverse.")");
+                                           
",'".$e_client."',".$acc_amount->amount_unpaid.")");
 
 
                 }
@@ -1557,7 +1557,7 @@ EOF;
         if ( $g_parameter->MY_ANALYTIC!='nu' && !$p_summary) // use of AA
             $r.='<input type="button" class="button" value="'._('Vérifiez 
imputation analytique').'" onClick="verify_ca(\'\');">';
         
-        $r.=(! $p_summary )?'<div id="total_div_id" 
style="float:right;width:30%;margin-top:50px;">':'<div>';
+        $r.=(! $p_summary )?'<div id="total_div_id" >':'<div>';
         $r.='<h2>Totaux</h2>';
         /* use VAT */
         if ($g_parameter->MY_TVA_USE == 'Y') {
@@ -1782,7 +1782,7 @@ EOF;
         $array['tva_label'] = _('Nom TVA');
         $array['tva_comment'] = _('Commentaire TVA');
         $array['tva_both_side'] = _('TVA annulée');
-        $array['vat_sided'] = _('Retrait TVA');
+        $array['vat_sided'] = _('TVA Non Payé');
         $array['vat_code'] = _('Code TVA');
         $array['vat'] = _('Montant TVA');
         $array['price'] = _('Total HTVA');
@@ -1793,6 +1793,7 @@ EOF;
         $array['non_ded_tva_recup'] = _('TVA récup.');
         $array['htva'] = _('HTVA Opération');
         $array['tot_vat'] = _('TVA Opération');
+        $array['tot_tva_np'] = _('TVA NP opération');
         return $array;
     }
 
diff --git a/include/class_acc_ledger_sold.php 
b/include/class_acc_ledger_sold.php
index b40bc03..4449a73 100644
--- a/include/class_acc_ledger_sold.php
+++ b/include/class_acc_ledger_sold.php
@@ -827,7 +827,7 @@ EOF;
         $r.='</p>';
         if ($g_parameter->MY_ANALYTIC != 'nu' && ! $p_summary) // use of AA
             $r.='<input type="button" class="button" value="' . _('Vérifiez 
Imputation Analytique') . '" onClick="verify_ca(\'\');">';
-        $r.=(! $p_summary )?'<div id="total_div_id" 
style="float:right;width:30%;margin-top:50px;">':'<div>';
+        $r.=(! $p_summary )?'<div id="total_div_id" >':'<div>';
         $r.='<h2>Totaux</h2>';
        
         /* use VAT */
@@ -1351,7 +1351,7 @@ EOF;
         $array['tva_label'] = _('Nom TVA');
         $array['tva_comment'] = _('Commentaire TVA');
         $array['tva_both_side'] = _('TVA annulée');
-        $array['vat_sided'] = _('Retrait TVA');
+        $array['vat_sided'] = _('TVA Non Payé');
         $array['vat_code'] = _('Code TVA');
         $array['vat'] = _('Montant TVA');
         $array['price'] = _('Total HTVA');
diff --git a/include/class_print_ledger_detail_item.php 
b/include/class_print_ledger_detail_item.php
index 8a2f740..5d5927c 100644
--- a/include/class_print_ledger_detail_item.php
+++ b/include/class_print_ledger_detail_item.php
@@ -52,6 +52,18 @@ class Print_Ledger_Detail_Item extends PDFLand
         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
         //Line break
         $this->Ln(20);
+        $high=6;
+        $this->SetFont('DejaVu', '', 6);
+        $this->LongLine(20, $high, _('Date'),0,  'L', false);
+        $this->Cell(20, $high, _('Numéro interne'), 0, 0, 'L', false);
+        $this->LongLine(50, $high, _('Code'),0,'L',false);
+        $this->LongLine(80, $high, _('Libellé'),0,'L',false);
+        $this->Cell(20, $high, _('Tot HTVA'), 0, 0, 'R', false);
+        $this->Cell(20, $high, _('Tot TVA NP'), 0, 0, 'R', false);
+        $this->Cell(20, $high, "", 0, 0, 'R', false);
+        $this->Cell(20, $high, _('Tot TVA'), 0, 0, 'R', false);
+        $this->Cell(20, $high, _('TVAC'), 0, 0, 'R', false);
+        $this->Ln(6);
         
     }
     /**
@@ -60,11 +72,11 @@ class Print_Ledger_Detail_Item extends PDFLand
     function Footer()
     {
         $this->Ln(2);
-        $this->Cell(0,8,' Journal '.$this->ledger->get_name(),0,0,'C');
-        //Arial italic 8
         $this->SetFont('Arial', 'I', 8);
+        $this->Cell(50,8,' Journal '.$this->ledger->get_name(),0,0,'C');
+        //Arial italic 8
         //Page number
-        $this->Cell(0,8,'Date '.$this->date." - Page 
".$this->PageNo().'/{nb}',0,0,'L');
+        $this->Cell(30,8,'Date '.$this->date." - Page 
".$this->PageNo().'/{nb}',0,0,'L');
         // Created by NOALYSS
         $this->Cell(0,8,'Created by NOALYSS, online on 
http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
     }
@@ -109,11 +121,14 @@ class Print_Ledger_Detail_Item extends PDFLand
                 // Print the general info line width=270mm
                 $this->LongLine(20, $high, $row['jr_date'],1,  'L', true);
                 $this->Cell(20, $high, $row['jr_internal'], 1, 0, 'L', true);
-                $this->LongLine(70, $high, $row['quick_code']." 
".$row['tiers_name'],1,'L',true);
-                $this->LongLine(100, $high, $row['jr_comment'],1,'L',true);
+                $this->LongLine(50, $high, $row['quick_code']." 
".$row['tiers_name'],1,'L',true);
+                $this->LongLine(80, $high, $row['jr_comment'],1,'L',true);
                 $this->Cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
+                $this->Cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', 
true);
+                $this->Cell(20, $high, "", 1, 0, 'R', true);
                 $this->Cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true);
                 $sum=bcadd($row['htva'],$row['tot_vat']);
+                $sum=bcsub($sum,$row['tot_tva_np']);
                 $this->Cell(20, $high, nbm($sum), 1, 0, 'R', true);
                 $internal=$row['jr_internal'];
                 $this->Ln(6);
@@ -121,10 +136,11 @@ class Print_Ledger_Detail_Item extends PDFLand
                 // Header detail
                 $this->LongLine(30,$high,'QuickCode');
                 $this->Cell(30,$high,'Poste');
-                $this->LongLine(90,$high,'Libellé');
+                $this->LongLine(70,$high,'Libellé');
                 $this->Cell(20,$high,'Prix/Unit',0,0,'R');
                 $this->Cell(20,$high,'Quant.',0,0,'R');
                 $this->Cell(20,$high,'HTVA',0,0,'R');
+                $this->Cell(20,$high,'TVA NP',0,0,'R');
                 $this->Cell(20,$high,'Code TVA');
                 $this->Cell(20,$high,'TVA',0,0,'R');
                 $this->Cell(20,$high,'TVAC',0,0,'R');
@@ -134,10 +150,11 @@ class Print_Ledger_Detail_Item extends PDFLand
             $this->LongLine(30,$high,$row['j_qcode']);
             $this->Cell(30,$high,$row['j_poste']);
             $comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
-            $this->LongLine(90,$high,$comment);
+            $this->LongLine(70,$high,$comment);
             $this->Cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
             $this->Cell(20,$high,nbm($row['quantity']),0,0,'R');
             $this->Cell(20,$high,nbm($row['price']),0,0,'R');
+            $this->Cell(20,$high,nbm($row['vat_sided']),0,0,'R');
             $this->Cell(20,$high,$row['vat_code']." ".$row['tva_label']);
             $this->Cell(20,$high,nbm($row['vat']),0,0,'R');
             $sum=bcadd($row['price'],$row['vat']);
diff --git a/include/class_print_ledger_simple.php 
b/include/class_print_ledger_simple.php
index 978ea1a..424339f 100644
--- a/include/class_print_ledger_simple.php
+++ b/include/class_print_ledger_simple.php
@@ -27,7 +27,7 @@ require_once('class_pdf.php');
 
 class Print_Ledger_Simple extends PDF
 {
-    public function __construct ($p_cn,$p_jrn)
+    public function __construct ($p_cn,  Acc_Ledger $p_jrn)
     {
 
         if($p_cn == null) die("No database connection. Abort.");
@@ -62,6 +62,7 @@ class Print_Ledger_Simple extends PDF
         $this->rap_tvac=$this->previous['price']+$this->previous['vat'];
         $this->rap_priv=$this->previous['priv'];
         $this->rap_nd=$this->previous['tva_nd'];
+        $this->rap_tva_np=$this->previous['tva_np'];
     }
 
     function setDossierInfo($dossier = "n/a")
@@ -106,6 +107,7 @@ class Print_Ledger_Simple extends PDF
             $this->Cell(15,6,'Priv/DNA',0,0,'R');
             $this->Cell(15,6,'TVA ND',0,0,'R');
         }
+        $this->Cell(15,6,'TVA NP',0,0,'R'); // Unpaid TVA --> autoliquidation, 
NPR
         foreach($this->a_Tva as $line_tva)
         {
             $this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
@@ -122,6 +124,7 @@ class Print_Ledger_Simple extends PDF
             $this->Cell(15,6,nbm($this->rap_priv),0,0,'R');  /* prive */
             $this->Cell(15,6,nbm($this->rap_nd),0,0,'R');  /* Tva ND */
         }
+        $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R');  /* Tva ND */
         foreach($this->rap_tva as $line_tva)
         $this->Cell(15,6,nbm($line_tva),0,0,'R');
         $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
@@ -132,6 +135,7 @@ class Print_Ledger_Simple extends PDF
         $this->tp_tvac=0.0;
         $this->tp_priv=0;
         $this->tp_nd=0;
+        $this->tp_tva_np=0;
         foreach($this->a_Tva as $line_tva)
         {
             //initialize Amount TVA
@@ -154,11 +158,13 @@ class Print_Ledger_Simple extends PDF
             $this->Cell(15,6,nbm($this->tp_priv),'T',0,'R');  /* prive */
             $this->Cell(15,6,nbm($this->tp_nd),'T',0,'R');  /* Tva ND */
         }
+        $this->Cell(15,6,nbm($this->tp_tva_np),'T',0,'R');  /* Tva Unpaid */
         foreach($this->a_Tva as $line_tva)
         {
             $l=$line_tva['tva_id'];
             $this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
         }
+        
         $this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R'); /* Tvac */
         $this->Ln(2);
 
@@ -169,6 +175,8 @@ class Print_Ledger_Simple extends PDF
             $this->Cell(15,6,nbm($this->rap_priv),0,0,'R');  /* prive */
             $this->Cell(15,6,nbm($this->rap_nd),0,0,'R');  /* Tva ND */
         }
+        $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R');  /* Tva ND */
+        
         foreach($this->a_Tva as $line_tva)
         {
             $l=$line_tva['tva_id'];
@@ -219,6 +227,7 @@ class Print_Ledger_Simple extends PDF
                 
$atva_amount[$l]=bcadd($atva_amount[$l],$aAmountVat[$f]['sum_vat']);
                 
$this->tp_tva[$l]=bcadd($this->tp_tva[$l],$aAmountVat[$f]['sum_vat']);
                 
$this->rap_tva[$l]=bcadd($this->rap_tva[$l],$aAmountVat[$f]['sum_vat']);
+                
             }
 
             $row=$a_jrn[$i];
@@ -234,12 +243,14 @@ class Print_Ledger_Simple extends PDF
             $other=$this->ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
             $this->tp_htva=bcadd($this->tp_htva,$other['price']);
             $this->tp_tvac=bcadd($this->tp_tvac,$other['price']+$other['vat']);
+            $this->tp_tva_np=bcadd($this->tp_tva_np,$other['tva_np']);
             $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
             $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
             $this->rap_htva=bcadd($this->rap_htva,$other['price']);
-            
$this->rap_tvac=bcadd($this->rap_tvac,$other['price']+$other['vat']);
+            $this->rap_tvac=bcadd($this->rap_tvac,bcadd($other['price'], 
bcsub($other['vat'],$other['tva_np'])));
             $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
             $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
+            $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
 
 
             $this->Cell(15,5,nbm($other['price']),0,0,'R');
@@ -248,12 +259,15 @@ class Print_Ledger_Simple extends PDF
              $this->Cell(15,5,nbm($other['priv']),0,0,'R');
              $this->Cell(15,5,nbm($other['tva_nd']),0,0,'R');
             }
-                               foreach ($atva_amount as $row_atva_amount)
-                       {
-                               $this->Cell(15, 5, nbm($row_atva_amount), 0, 0, 
'R');
-                       }
+            
+           $this->Cell(15,5,nbm($other['tva_np']),0,0,'R');
+            
+            foreach ($atva_amount as $row_atva_amount)
+            {
+                    $this->Cell(15, 5, nbm($row_atva_amount), 0, 0, 'R');
+            }
 
-           $l_tvac=bcadd($other['price'],$other['vat']);
+           $l_tvac=bcadd($other['price'], 
bcsub($other['vat'],$other['tva_np']));
            $l_tvac=bcadd($l_tvac,$other['tva_nd']);
             $this->Cell(15,5,nbm($l_tvac),0,0,'R');
             $this->Ln(5);
diff --git a/include/export_ledger_csv.php b/include/export_ledger_csv.php
index 47da94b..a94e785 100644
--- a/include/export_ledger_csv.php
+++ b/include/export_ledger_csv.php
@@ -227,7 +227,7 @@ 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.";"autoliquidation";'.$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.";"TVA NP";'.$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;%s;',
@@ -242,7 +242,7 @@ if  ($get_option == 1)
                    nb($line['dep_priv']),
                    nb($line['dna']),
                    nb($line['tva_dna']),
-                    nb($line['autoliq'])
+                    nb($line['tva_np'])
                    );
             $a_tva_amount=array();
             //- set all TVA to 0
diff --git a/include/export_ledger_pdf.php b/include/export_ledger_pdf.php
index 2da727a..c377d71 100644
--- a/include/export_ledger_pdf.php
+++ b/include/export_ledger_pdf.php
@@ -67,7 +67,7 @@ $pdf->setDossierInfo($Jrn->name);
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->SetAuthor('NOALYSS');
-$pdf->setTitle("Journal", true);
+$pdf->setTitle(_("Journal"), true);
 
 $pdf->export();
 
diff --git a/include/template/operation_detail_ach.php 
b/include/template/operation_detail_ach.php
index 286d4ae..bff3105 100644
--- a/include/template/operation_detail_ach.php
+++ b/include/template/operation_detail_ach.php
@@ -50,6 +50,7 @@ global $g_parameter;
        if ($g_parameter->MY_TVA_USE == 'Y')
        {
                echo th(_('HTVA'), 'style="text-align:right"');
+               echo th(_('TVA NP'), 'style="text-align:right"');
                echo th(_('TVA'), 'style="text-align:right"');
                echo th(_('TVAC'), 'style="text-align:right"');
        }else
@@ -79,7 +80,7 @@ global $g_parameter;
                $row.=td($sym_tva, 'style="text-align:center"');
                $pu = 0;
                if ($q['qp_quantite'] != 0)
-                       $pu = bcdiv($q['qp_price'], $q['qp_quantite']);
+               $pu = bcdiv($q['qp_price'], $q['qp_quantite']);
                $row.=td(nbm($pu), 'class="num"');
                $row.=td(nbm($q['qp_quantite']), 'class="num"');
 
@@ -103,8 +104,9 @@ global $g_parameter;
                        if ($q['qp_vat_sided'] <> 0)
                        {
                                $class = ' 
style="text-decoration:line-through"';
-                               $tvac = bcsub($tvac, $q['qp_vat']);
+                               $tvac = bcsub($tvac, $q['qp_vat_sided']);
                        }
+                        $row.=td(nbm($q['qp_vat_sided']),'class="num"');
                        $row.=td(nbm($tva_amount), 'class="num" ' . $class);
                        $row.=td(nbm($tvac), 'class="num"');
                }
diff --git a/include/template/operation_detail_ven.php 
b/include/template/operation_detail_ven.php
index cb7577f..a56c0c6 100644
--- a/include/template/operation_detail_ven.php
+++ b/include/template/operation_detail_ven.php
@@ -42,6 +42,7 @@ else
   echo th('');
 if ( $g_parameter->MY_TVA_USE == 'Y') {
   echo th(_('HTVA'), 'style="text-align:right"');
+  echo th(_('TVA NP'), 'style="text-align:right"');
   echo th(_('TVA'), 'style="text-align:right"');
   echo th(_('TVAC'), 'style="text-align:right"');
 } else
@@ -87,6 +88,7 @@ echo '</tr>';
                        $class=' style="text-decoration:line-through"';
                        $tvac=bcsub($tvac,$q['qs_vat']);
                }
+               $row.=td(nbm($q['qs_vat_sided']),'class="num"');
                $row.=td(nbm($q['qs_vat']),'class="num"'.$class);
                $row.=td(nbm($tvac),'class="num"');
       }
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 1d94e02..40affea 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -123,13 +123,13 @@ LEFT JOIN ( SELECT fiche_detail.f_id, 
fiche_detail.ad_value
 
 create view v_detail_sale  as 
 WITH m AS (
-         SELECT sum(quant_sold.qs_price) AS htva, sum(quant_sold.qs_vat) AS 
tot_vat, jrn.jr_id
+         SELECT sum(quant_sold.qs_price) AS htva, sum(quant_sold.qs_vat) AS 
tot_vat,sum(quant_sold.qs_vat_sided) as tot_tva_np, jrn.jr_id
            FROM quant_sold
       JOIN jrnx USING (j_id)
    JOIN jrn ON jrnx.j_grpt = jrn.jr_grpt_id
   GROUP BY jrn.jr_id
         )
-SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid, jrn.jr_ech, jrn.jr_tech_per, 
jrn.jr_comment, jrn.jr_pj_number, jrn.jr_internal, jrn.jr_def_id, jrnx.j_poste, 
jrnx.j_text, jrnx.j_qcode, quant_sold.qs_fiche AS item_card, a.name AS 
item_name, quant_sold.qs_client, b.vw_name AS tiers_name, b.quick_code, 
tva_rate.tva_label, tva_rate.tva_comment, tva_rate.tva_both_side, 
quant_sold.qs_vat_sided AS vat_sided, quant_sold.qs_vat_code AS vat_code, 
quant_sold.qs_vat AS vat, quant_sold.qs_price AS pr [...]
+SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid, jrn.jr_ech, jrn.jr_tech_per, 
jrn.jr_comment, jrn.jr_pj_number, jrn.jr_internal, jrn.jr_def_id, jrnx.j_poste, 
jrnx.j_text, jrnx.j_qcode, quant_sold.qs_fiche AS item_card, a.name AS 
item_name, quant_sold.qs_client, b.vw_name AS tiers_name, b.quick_code, 
tva_rate.tva_label, tva_rate.tva_comment, tva_rate.tva_both_side, 
quant_sold.qs_vat_sided AS vat_sided, quant_sold.qs_vat_code AS vat_code, 
quant_sold.qs_vat AS vat, quant_sold.qs_price AS pr [...]
    FROM jrn
    JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
    JOIN quant_sold USING (j_id)
@@ -141,7 +141,7 @@ SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid, 
jrn.jr_ech, jrn.jr_tech_per, jr
 
 create view v_detail_purchase as
   WITH m AS (
-         SELECT sum(quant_purchase.qp_price) AS htva, 
sum(quant_purchase.qp_vat) AS tot_vat, jrn.jr_id
+         SELECT sum(quant_purchase.qp_price) AS htva, 
sum(quant_purchase.qp_vat) AS tot_vat, sum(quant_purchase.qp_vat_sided) as 
tot_tva_np, jrn.jr_id
            FROM quant_purchase
       JOIN jrnx USING (j_id)
    JOIN jrn ON jrnx.j_grpt = jrn.jr_grpt_id
@@ -160,6 +160,7 @@ quant_purchase.qp_nd_amount AS non_ded_amount,
  quant_purchase.qp_nd_tva AS non_ded_tva, 
 quant_purchase.qp_nd_tva_recup AS non_ded_tva_recup,
  m.htva, m.tot_vat
+,m.tot_tva_np
    FROM jrn
    JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
    JOIN quant_purchase USING (j_id)
@@ -173,7 +174,7 @@ create index jrnx_j_qcode_ix on jrnx (j_qcode);
 CREATE TABLE action_person 
 (
     ap_id  SERIAL NOT NULL, 
-    ag_id int4 NOT NULL references action_gestion(ag_id) on update cascade on 
delete cascade,, 
+    ag_id int4 NOT NULL references action_gestion(ag_id) on update cascade on 
delete cascade,
     f_id int4 not null references fiche(f_id) on update cascade on delete 
cascade, 
     PRIMARY KEY (ap_id));
 



reply via email to

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