noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 11/24: Nouveau #0002178: Cotisation de solida


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 11/24: Nouveau #0002178: Cotisation de solidarité Impression : Listing (HTML, CSV et PDF) Impression : Extended (HTML, CSV et PDF) Negatif amount and currency
Date: Tue, 12 Jul 2022 07:05:30 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 56d26227141bf8744b1e171eae3ec79d3b0801e0
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sat May 28 15:47:23 2022 +0200

    Nouveau #0002178: Cotisation de solidarité
    Impression : Listing (HTML, CSV et PDF)
    Impression : Extended (HTML, CSV et PDF)
    Negatif amount and currency
---
 include/class/acc_ledger_history.class.php         |  12 +-
 .../class/acc_ledger_history_purchase.class.php    |  52 +++++++--
 include/class/acc_ledger_history_sale.class.php    |  32 +++++-
 include/class/acc_ledger_purchase.class.php        |   2 +
 include/class/acc_ledger_sale.class.php            |   5 +-
 include/class/additional_tax.class.php             |  33 +++++-
 include/class/print_ledger_detail_item.class.php   |   8 +-
 include/class/print_ledger_simple.class.php        |  51 ++++++++-
 include/export/export_ledger_csv.php               |   6 +-
 include/lib/manage_table_sql.class.php             |   2 +-
 .../acc_ledger_history_purchase_extended.php       |  32 +++++-
 .../acc_ledger_history_purchase_oneline.php        |  25 +++-
 .../template/acc_ledger_history_sale_extended.php  |  36 +++++-
 .../template/acc_ledger_history_sale_oneline.php   |  24 +++-
 include/template/ledger_detail_ven.php             |   3 +-
 sql/upgrade.sql                                    | 127 +++++++++++++++++++++
 16 files changed, 399 insertions(+), 51 deletions(-)

diff --git a/include/class/acc_ledger_history.class.php 
b/include/class/acc_ledger_history.class.php
index b36d28f6f..38b2b8847 100644
--- a/include/class/acc_ledger_history.class.php
+++ b/include/class/acc_ledger_history.class.php
@@ -387,11 +387,19 @@ abstract class Acc_Ledger_History
         $prepare=$this->db->is_prepare("supp_tax_info");
         if ( $prepare == false ){
             $this->db->prepare("supp_tax_info","
-                select j_montant,jt1.ac_id,ac_label,ac_rate,j_poste 
+                select 
+                   case when j.j_debit is false and jd.jrn_def_type='ACH'      
then 0-j_montant
+                      when j.j_debit is true and jd.jrn_def_type='VEN'      
then 0-j_montant
+                      else j.j_montant end j_montant,
+                    jt1.ac_id,
+                    ac_label,
+                    ac_rate,j_poste 
                 from 
                     jrn_tax jt1 
                     join acc_other_tax using (ac_id)
-                    join jrnx using (j_id) where j_grpt=$1
+                    join jrnx j using (j_id) 
+                    join jrn_def jd on (j.j_jrn_def=jd.jrn_def_id) 
+                where j_grpt=$1
             ");
 
         }
diff --git a/include/class/acc_ledger_history_purchase.class.php 
b/include/class/acc_ledger_history_purchase.class.php
index 474bfc430..0dca3160f 100644
--- a/include/class/acc_ledger_history_purchase.class.php
+++ b/include/class/acc_ledger_history_purchase.class.php
@@ -32,7 +32,17 @@
 class Acc_Ledger_History_Purchase extends Acc_Ledger_History
 {
 
-    private $data; //!< Contains rows from SQL
+    private $data;//!< Contains rows from SQL
+
+    /**
+     * @param mixed $data
+     */
+    public function set_data($data)
+    {
+        //!< Contains rows from SQL
+        $this->data = $data;
+        return $this;
+    }
    
     public function __construct(\Database $cn, $pa_ledger, $p_from, $p_to,
             $p_mode)
@@ -71,6 +81,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
     {
         $this->get_row();
         $this->add_vat_info();
+        $this->add_additional_tax_info();
         $this->prepare_detail();
         $this->prepare_reconcile_date();
         include NOALYSS_TEMPLATE."/acc_ledger_history_purchase_extended.php";
@@ -107,6 +118,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
     {
         $this->get_row();
         $this->prepare_reconcile_date();
+        $nb_other_tax=$this->has_other_tax();
         require_once 
NOALYSS_TEMPLATE.'/acc_ledger_history_purchase_oneline.php';
     }
 
@@ -146,13 +158,19 @@ class Acc_Ledger_History_Purchase extends 
Acc_Ledger_History
                 from 
                     operation_currency
                     join jrnx using (j_id)
+                    join quant_purchase qp  using (j_id)
                 group by j_grpt
-              )
+              ),
+              other_tax as (select sum(case when j_debit is true 
+                            then j_montant else 0-j_montant end) 
other_tax_amount
+                            ,j_grpt 
+               from jrnx j1
+               join jrn_tax jt2 on (j1.j_id=jt2.j_id) group by j_grpt)
             select   
                     name,
                     first_name,
                     qcode,
-                    jr_id,
+                    jrn.jr_id,
                     jr_pj_number,
                     to_char(jr_date,'DD.MM.YYYY') as str_date,
                     to_char(jr_date,'DDMMYY') as str_date_short,
@@ -175,7 +193,8 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
                     jrn.currency_rate_ref,
                     sum_oc_amount,
                     sum_oc_vat_amount,
-                    cr_code_iso
+                    cr_code_iso,
+                    coalesce (other_tax_amount,0) other_tax_amount
             from
                 jrn
                 join row_purchase on (qp_internal=jr_internal)
@@ -183,6 +202,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
                 left join jrn_note using (jr_id)
                 left join row_currency as rc on (rc.j_grpt = jrn.jr_grpt_id)
                 left join currency as c on (c.id=jrn.currency_id)
+                left join other_tax as ot on (ot.j_grpt=jrn.jr_grpt_id)
             where
                 jr_def_id in ({$ledger_list})
                 {$sql_filter}
@@ -260,12 +280,17 @@ class Acc_Ledger_History_Purchase extends 
Acc_Ledger_History
     {
         return $this->data;
     }
+
+    /**
+     * @brief export Purchase in CSV
+     */
     function export_csv()
     {
         // Prepare the query for reconcile date
         $prepared_query=new Prepared_Query($this->db);
         $prepared_query->prepare_reconcile_date();
-        
+        $nb_other_tax=$this->has_other_tax();
+
         $export=new Noalyss_Csv(_('journal'));
         $export->send_header();
         
@@ -287,8 +312,8 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
         $title[]=_("DNA");
         $title[]=_("tva non ded.");
         $title[]=_("TVA NP");
-       
-       
+
+
 
         if ( $own->MY_TVA_USE=='Y')
         {
@@ -298,13 +323,16 @@ class Acc_Ledger_History_Purchase extends 
Acc_Ledger_History
                 $title[]="Tva ".$line_tva['tva_label'];
             }
         }
+        if ($nb_other_tax>0) {
+            $title[]=_("Autre taxe");
+        }
         $title[]=_("TVAC/TTC");
         $title[]=_("Devise");
         $title[]=_("Devise HTVA");
         $title[]=_("Devise TVA");
         $title[]=_("Taux ref");
         $title[]=_("Taux utilisé");
-       $title[]=_("Date paiement");
+           $title[]=_("Date paiement");
         $title[]=_("Code paiement");
         $title[]=_("Méthode paiement");
         $title[]=_("Montant paiement");
@@ -349,7 +377,11 @@ class Acc_Ledger_History_Purchase extends 
Acc_Ledger_History
                     $export->add($a_tva_amount[$a], "number");
                 }
             }
-            $export->add($line['tvac'],"number");
+            if ( $nb_other_tax > 0)
+            {
+                $export->add($line['other_tax_amount'],"number");
+            }
+            
$export->add(bcadd($line['other_tax_amount'],$line['tvac'],2),"number");
             /**
              * Add currency info
              */
@@ -374,7 +406,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
                     $export->add($row['jr_internal']);
                 }
             }
-           $export->write();
+              $export->write();
 
         }
 
diff --git a/include/class/acc_ledger_history_sale.class.php 
b/include/class/acc_ledger_history_sale.class.php
index a6e4deff2..0240db9b1 100644
--- a/include/class/acc_ledger_history_sale.class.php
+++ b/include/class/acc_ledger_history_sale.class.php
@@ -69,6 +69,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
     {
        $this->get_row();
        $this->add_vat_info();
+       $this->add_additional_tax_info();
        $this->prepare_detail();
        $this->prepare_reconcile_date();
        include NOALYSS_TEMPLATE."/acc_ledger_history_sale_extended.php";
@@ -141,8 +142,14 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
                 from 
                     operation_currency
                     join jrnx using (j_id)
+                     join quant_sold  using (j_id)
                 group by j_grpt
-              )
+              ),
+              other_tax as (select sum(case when j_debit is false 
+                            then j_montant else 0-j_montant end) as 
other_tax_amount,
+                            j_grpt 
+               from jrnx j1
+               join jrn_tax jt2 on (j1.j_id=jt2.j_id) group by j_grpt)
             select   
                     name,
                     first_name,
@@ -166,13 +173,15 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
                     jrn.currency_rate_ref,
                     sum_oc_amount,
                     sum_oc_vat_amount,
-                    cr_code_iso
+                    cr_code_iso,
+                    coalesce (other_tax_amount,0) other_tax_amount
             from
                 jrn
                 join row_sale on (qs_internal=jr_internal)
                 join client_detail on (qs_client=f_id)
                 left join row_currency as rc on (rc.j_grpt = jrn.jr_grpt_id)
                 left join currency as c on (c.id=jrn.currency_id)
+                 left join other_tax as ot on (ot.j_grpt=jrn.jr_grpt_id)
             where
                 jr_def_id in ({$ledger_list})
                 {$sql_filter}
@@ -210,6 +219,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
             $this->data[$i]["detail_vat"]=$array;
         }
     }
+
     /**
      * @brief display in HTML following the mode 
      */
@@ -241,6 +251,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
     {
         $this->get_row();
         $this->prepare_reconcile_date();
+        $nb_other_tax=$this->has_other_tax();
         require_once NOALYSS_TEMPLATE.'/acc_ledger_history_sale_oneline.php';
         
     }
@@ -252,6 +263,11 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
     {
         return $this->data;
     }
+    function set_data($p_data)
+    {
+        $this->data=$p_data;
+        return $this;
+    }
     /**
      * export in csv with detail  VAT
      */
@@ -259,7 +275,8 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
     {
         $export=new Noalyss_Csv(_('journal'));
         $export->send_header();
-        
+        $nb_other_tax=$this->has_other_tax();
+
         $this->get_row();
         $this->prepare_reconcile_date();
         $this->add_vat_info();
@@ -285,6 +302,9 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
                 $title[]="Tva ".$line_tva['tva_label'];
             }
         }
+        if ($nb_other_tax>0) {
+            $title[]=_("Autre tx");
+        }
         $title[]=_("TVAC/TTC");
         $title[]=_("Devise");
         $title[]=_("Devise HTVA");
@@ -333,7 +353,11 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
                     $export->add($a_tva_amount[$a],"number");
                 }
             }
-            $export->add($line['tvac'],"number");
+            if ( $nb_other_tax > 0)
+            {
+                $export->add($line['other_tax_amount'],"number");
+            }
+            
$export->add(bcadd($line['other_tax_amount'],$line['tvac'],2),"number");
             /**
              * Add currency info
              */
diff --git a/include/class/acc_ledger_purchase.class.php 
b/include/class/acc_ledger_purchase.class.php
index 1b6e12f61..c21205f9a 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -2095,6 +2095,7 @@ EOF;
         $array['j_poste'] = _('Poste');
         $array['j_text'] = _('Commentaire');
         $array['j_qcode'] = _('Code Item');
+        $array['jr_rapt'] = _('Payé');
         $array['item_card'] = _('N° fiche');
         $array['item_name'] = _('Nom fiche');
         $array['qp_supplier'] = _('N° fiche fournisseur');
@@ -2115,6 +2116,7 @@ EOF;
         $array['htva'] = _('HTVA Opération');
         $array['tot_vat'] = _('TVA Opération');
         $array['tot_tva_np'] = _('TVA NP opération');
+        $array['other_tax'] = _("Autre taxe");
         $array['oc_amount'] = _('Mont. Devise');
         $array['oc_vat_amount'] = _('Mont. TVA Devise');
         $array['cr_code_iso'] = _('Devise');
diff --git a/include/class/acc_ledger_sale.class.php 
b/include/class/acc_ledger_sale.class.php
index b8a398c5b..067999802 100644
--- a/include/class/acc_ledger_sale.class.php
+++ b/include/class/acc_ledger_sale.class.php
@@ -1648,7 +1648,8 @@ EOF;
         $array['j_poste'] = _('Poste');
         $array['j_text'] = _('Commentaire');
         $array['j_qcode'] = _('Code Item');
-        $array['item_card'] = _('N° fiche');
+        $array['jr_rapt'] = _('Payé');
+        $array['item_card'] = _('N° item');
         $array['item_name'] = _('Nom fiche');
         $array['qs_client'] = _('N° fiche fournisseur');
         $array['tiers_name'] = _('Nom fournisseur');
@@ -1665,9 +1666,11 @@ EOF;
         $array['htva'] = _('HTVA Opération');
         $array['tot_vat'] = _('TVA Opération');
         $array['tot_vat_np'] = _('TVA ND');
+        $array['other_tax'] = _("Autre taxe");
         $array['oc_amount'] = _('Mont. Devise');
         $array['oc_vat_amount'] = _('Mont. TVA Devise');
         $array['cr_code_iso'] = _('Devise');
+
         
         return $array;
     }
diff --git a/include/class/additional_tax.class.php 
b/include/class/additional_tax.class.php
index da6788389..d26d05447 100644
--- a/include/class/additional_tax.class.php
+++ b/include/class/additional_tax.class.php
@@ -40,24 +40,37 @@ class Additional_Tax
         $this->ac_rate=$ac_rate;
         $this->ac_accounting=$ac_accounting;
     }
-
+/**
+ * @brief create an array of Additional_Tax
+ * @param $p_jrn_id
+ * @param $sum_euro
+ * @param $sum_currency
+ * @return array
+ */
     static function get_by_operation($p_jrn_id,&$sum_euro,&$sum_currency)
     {
         bcscale(4);
         global $cn;
-        $array = $cn->get_array('select j_montant,currency_id,
-        oc.oc_amount,
+        $array = $cn->get_array("select 
+        case when j_debit is false and jn.jrn_def_type='ACH' then 0-j_montant
+            when j_debit is true and jn.jrn_def_type='VEN' then 0-j_montant
+            else j_montant end j_montant,
+        jrn.currency_id,
+      oc_amount,
         jt.ac_id,
+        jrnx.j_debit,
         aot.ac_label,
         aot.ac_rate,
-        aot.ac_accounting
+        aot.ac_accounting,
+        jn.jrn_def_type
             from jrn_tax jt
             join jrnx using (j_id)
             join jrn on (jrnx.j_grpt=jrn.jr_grpt_id)
+            join jrn_def jn on (jrn.jr_def_id=jn.jrn_def_id)
             join acc_other_tax aot on (jt.ac_id=aot.ac_id)
             left join operation_currency oc ON  (oc.j_id=jt.j_id)
-            where
-            jr_id=$1', [$p_jrn_id]);
+                where
+            jr_id=$1", [$p_jrn_id]);
         $sum_currency=0;$sum_euro=0;
         if (empty($array)) { return array();}
         $nb=count($array);
@@ -77,6 +90,14 @@ class Additional_Tax
         $sum_euro=round($sum_euro,2);
         return $a_additional_tax;
     }
+
+    /**
+     * @brief display the additional_tax in the ledger_detail for Sales and 
Purchase
+     * @param $p_jrn_id
+     * @param $sum_euro
+     * @param $sum_currency
+     * @param int $decalage
+     */
     static function 
display_row($p_jrn_id,&$sum_euro,&$sum_currency,$decalage=0)
     {
         
$a_additional_tax=Additional_Tax::get_by_operation($p_jrn_id,$sum_euro,$sum_currency);
diff --git a/include/class/print_ledger_detail_item.class.php 
b/include/class/print_ledger_detail_item.class.php
index 8dc07f251..c34629437 100644
--- a/include/class/print_ledger_detail_item.class.php
+++ b/include/class/print_ledger_detail_item.class.php
@@ -56,7 +56,7 @@ class Print_Ledger_Detail_Item extends Print_Ledger
         $this->Cell(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, _("Autre Tx"), 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);
@@ -117,16 +117,18 @@ class Print_Ledger_Detail_Item extends Print_Ledger
             $row=Database::fetch_array($ret_detail, $i);
             if ($internal != $row['jr_internal'])
             {
+
                 // Print the general info line width=270mm
                 $this->LongLine(20, $high, $row['jr_date'],1,  'L', true);
-                $this->write_cell(20, $high, $row['jr_internal'], 1, 0, 'L', 
true);
+                $this->write_cell(20, $high,$row['jr_pj_number'].".". 
$row['jr_internal'], 1, 0, '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->write_cell(20, $high, nbm($row['htva']), 1, 0, 'R', 
true);
                 $this->write_cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 
'R', true);
-                $this->write_cell(20, $high, "", 1, 0, 'R', true);
+                $this->write_cell(20, $high, nbm($row['other_tax_amount']), 1, 
0, 'R', true);
                 $this->write_cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', 
true);
                 $sum=bcadd($row['htva'],$row['tot_vat']);
+                $sum=bcadd($row['other_tax_amount'],$sum);
                 $sum=bcsub($sum,$row['tot_tva_np']);
                 $this->write_cell(20, $high, nbm($sum), 1, 0, 'R', true);
                 $internal=$row['jr_internal'];
diff --git a/include/class/print_ledger_simple.class.php 
b/include/class/print_ledger_simple.class.php
index 18e48d2f0..05ec0f7e6 100644
--- a/include/class/print_ledger_simple.class.php
+++ b/include/class/print_ledger_simple.class.php
@@ -44,6 +44,7 @@ class Print_Ledger_Simple extends  \Print_Ledger
             $tmp1=$line_tva['tva_id'];
             $this->rap_tva[$tmp1]=0;
         }
+        $this->rap_other_tax=0;
         $this->jrn_type=$p_jrn->get_type();
         
//----------------------------------------------------------------------
         /* report
@@ -53,6 +54,7 @@ class Print_Ledger_Simple extends  \Print_Ledger
          */
         $from_periode=$this->get_from();
         $this->previous=$this->get_ledger()->previous_amount($from_periode);
+        
$this->other_tax_previous=$this->get_ledger()->previous_other_tax($from_periode);
 
         /* initialize the amount to report */
         foreach($this->previous['tva'] as $line_tva)
@@ -70,6 +72,24 @@ class Print_Ledger_Simple extends  \Print_Ledger
         $this->rap_priv=$this->previous['priv'];
         $this->rap_nd=$this->previous['tva_nd'];
         $this->rap_tva_np=$this->previous['tva_np'];
+        $this->flag_other_tax=false;
+
+        if ($this->jrn_type == 'ACH' || $this->jrn_type=='VEN') {
+            $periode=new Periode($p_cn,$p_from);
+            $first_date=$periode->first_day();
+            $periode=new Periode($p_cn,$p_to);
+            $last_date=$periode->last_day();
+
+            $count=$this->cn->get_value("
+                select          count(*) 
+                from jrn_tax join jrnx using (j_id) 
+                join jrn on (j_grpt=jr_grpt_id) where
+                    j_date >= to_date($1,'DD.MM.YYYY')
+                    and j_date <= to_date($2,'DD.MM.YYYY')
+                    and j_jrn_def=$3",
+                array($first_date,$last_date,$p_jrn->id));
+            if ($count>0) { $this->flag_other_tax=true;}
+        }
     }
 
     function setDossierInfo($dossier = "n/a")
@@ -119,6 +139,10 @@ class Print_Ledger_Simple extends  \Print_Ledger
         {
             $this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
         }
+        if ($this->flag_other_tax) {
+            $this->Cell(15,6,'Autre Tx',0,0,'R');
+
+        }
         $this->Cell(15,6,'TVAC',0,0,'R');
         $this->Ln(5);
 
@@ -137,6 +161,9 @@ class Print_Ledger_Simple extends  \Print_Ledger
         $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');
+        if ($this->flag_other_tax) {
+            $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other 
tax */
+        }
         $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
 
         $this->Ln(6);
@@ -146,6 +173,7 @@ class Print_Ledger_Simple extends  \Print_Ledger
         $this->tp_priv=0;
         $this->tp_nd=0;
         $this->tp_tva_np=0;
+        $this->tp_other_tax=0;
         foreach($this->a_Tva as $line_tva)
         {
             //initialize Amount TVA
@@ -179,7 +207,9 @@ class Print_Ledger_Simple extends  \Print_Ledger
             $l=$line_tva['tva_id'];
             $this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
         }
-        
+        if ($this->flag_other_tax) {
+            $this->Cell(15, 6, nbm($this->tp_other_tax), 'T', 0, 'R'); /* Tvac 
*/
+        }
         $this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R'); /* Tvac */
         $this->Ln(2);
         $flag_tva=(count($this->a_Tva) > 4)?true:false;
@@ -202,6 +232,9 @@ class Print_Ledger_Simple extends  \Print_Ledger
             $l=$line_tva['tva_id'];
             $this->Cell(15,6,nbm($this->rap_tva[$l]),0,0,'R');
         }
+        if ($this->flag_other_tax) {
+            $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other 
tax */
+        }
         $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
         $this->Ln(2);
 
@@ -290,8 +323,12 @@ class Print_Ledger_Simple extends  \Print_Ledger
                     $this->write_cell(15, 5, nbm($row_atva_amount), 0, 0, 'R');
             }
 
-           $l_tvac=bcadd($other['price'], 
bcsub($other['vat'],$other['tva_np']));
-           $l_tvac=bcadd($l_tvac,$other['tva_nd']);
+            $l_tvac=bcadd($other['price'], 
bcsub($other['vat'],$other['tva_np']));
+            $l_tvac=bcadd($l_tvac,$other['tva_nd']);
+               $l_tvac=bcadd($l_tvac,$a_jrn[$i]['other_tax_amount']);
+            if ($this->flag_other_tax) {
+                $this->write_cell(15, 5, nbm($a_jrn[$i]['other_tax_amount']), 
0, 0, 'R');
+            }
             $this->write_cell(15,5,nbm($l_tvac),0,0,'R');
             $this->line_new(2);
             // Add the payment information on another row
@@ -320,7 +357,8 @@ class Print_Ledger_Simple extends  \Print_Ledger
             $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']);
-            
+
+
             // Total report
             $this->rap_htva=bcadd($this->rap_htva,$other['price']);
             $this->rap_tvac=bcadd($this->rap_tvac,$other['price']);
@@ -331,6 +369,11 @@ class Print_Ledger_Simple extends  \Print_Ledger
             $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
             $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
 
+            if ($this->flag_other_tax) {
+                $this->tp_other_tax = bcadd($this->tp_other_tax, 
$a_jrn[$i]['other_tax_amount']);
+                $this->rap_other_tax = bcadd($this->rap_other_tax, 
$a_jrn[$i]['other_tax_amount']);
+            }
+
         }
     }
 
diff --git a/include/export/export_ledger_csv.php 
b/include/export/export_ledger_csv.php
index 51deda383..513bf7670 100644
--- a/include/export/export_ledger_csv.php
+++ b/include/export/export_ledger_csv.php
@@ -31,7 +31,7 @@ if (!defined('ALLOWED'))
 
 include_once NOALYSS_INCLUDE."/lib/ac_common.php";
 
-
+global $cn,$g_user;
 
 
 $gDossier=dossier::id();
@@ -130,9 +130,7 @@ if ( $get_option=="E")
         }
         if ($ret_detail==null)
             return;
-        $a_heading[]="";
-        $a_heading[]="";
-        $a_heading[]="";
+
         $a_heading[]=_("Date paiement");
         $a_heading[]=_("Montant paiement");
         $a_heading[]=_("Methode paiement");
diff --git a/include/lib/manage_table_sql.class.php 
b/include/lib/manage_table_sql.class.php
index 73f7a8a21..2dcb8899e 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -1223,7 +1223,7 @@ function check()
      * @return nothing
      */
     function input_custom($p_key,$p_value) {
-     throw new Exception(__FILE__.":".__LINE__."-"._("non implémenté"));
+     throw new Exception(__FILE__.":".__LINE__."- input_custom "._("non 
implémenté"));
     }
     /**
      * @brief Save the record from Request into the DB and returns an XML
diff --git a/include/template/acc_ledger_history_purchase_extended.php 
b/include/template/acc_ledger_history_purchase_extended.php
index db5d5644e..5d77428b6 100644
--- a/include/template/acc_ledger_history_purchase_extended.php
+++ b/include/template/acc_ledger_history_purchase_extended.php
@@ -24,6 +24,7 @@
  * @file
  * @brief detail of the list of operation with VAT and items
  */
+bcscale(2);
 ?>
 <table class="result">
     <tr>
@@ -69,6 +70,9 @@ for ($i=0;$i<$nb_data;$i++):
     $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']);
     $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']);
     $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']);
+    $supp_tax=$this->data[$i]['supp_tax'];
+    $tot_other_tax=array_sum(array_column($supp_tax,'j_montant'));
+    $all_tax=bcadd($tot_other_tax,$this->data[$i]['vat']);
 ?>
     <tr <?=$odd?> >
         <td>
@@ -90,17 +94,19 @@ for ($i=0;$i<$nb_data;$i++):
             <?=h($this->data[$i]['jr_comment'])?>
         </td>
         <td class="num">
-            
<?=nbm(bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount'],4),4)?>
+            <?php if ($this->data[$i]['currency_id'] !=0) : ?>
+            
<?=nbm(bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount'],4),2)?>
             <?=$this->data[$i]['cr_code_iso']?>
+            <?php endif;?>
         </td>
         <td class="num">
             <?=nbm($this->data[$i]['novat'])?>
         </td>
         <td class="num">
-            
<?=nbm(bcsub($this->data[$i]['vat'],$this->data[$i]['tva_sided']))?>
+            <?=nbm(bcsub($all_tax,$this->data[$i]['tva_sided']),2)?>
         </td>
         <td class="num">
-            <?=nbm($this->data[$i]['tvac'])?>
+            <?=nbm(bcadd($this->data[$i]['tvac'],$tot_other_tax))?>
         </td>
         <td>
             
@@ -154,7 +160,25 @@ for ($j=0;$j<$nb_detail;$j++):
 <?php
 endfor;
 ?>
-                
+                <?php
+                // print additional tax if any
+                $nb_supp_tax=count($this->data[$i]['supp_tax']);
+                for ($j=0;$j<$nb_supp_tax;$j++):
+                    ?>
+                    <tr>
+                        <td><?=$this->data[$i]['supp_tax'][$j]['j_poste']?>
+                            <?=$this->data[$i]['supp_tax'][$j]['ac_label']?>
+                        </td>
+                        <td></td>
+                        <td></td>
+                        <td></td>
+                        <td></td>
+                        <td></td>
+                        <td 
class="num"><?=nbm($this->data[$i]['supp_tax'][$j]['j_montant'])?></td>
+                    </tr>
+                <?php
+                endfor;
+                ?>
             </table>
         </td>
     </tr>    
diff --git a/include/template/acc_ledger_history_purchase_oneline.php 
b/include/template/acc_ledger_history_purchase_oneline.php
index 8409d1b52..b3e8aa70f 100644
--- a/include/template/acc_ledger_history_purchase_oneline.php
+++ b/include/template/acc_ledger_history_purchase_oneline.php
@@ -27,7 +27,7 @@ if (!defined('ALLOWED'))
  * @brief display purchase on one line with sum of VAT, Operation, Private exp.
  * @todo prévoir aussi pour les non assujetti : faire disparaître les montants 
TVA
  */
-
+bcscale(2);
 ?>
 <table class="result">
     <tr>
@@ -58,10 +58,15 @@ if (!defined('ALLOWED'))
         <th class="num">
             <?=_('TVA')?>
         </th>
-              
+        <?php if ($nb_other_tax>0) :?>
+        <th class="num">
+            <?=_('Autre Taxe')?>
+        </th>
+        <?php endif;?>
         <th class="num">
             <?=_('TVAC')?>
         </th>
+
         <th class="num">
             <?=_('Devise')?>
         </th>
@@ -77,16 +82,18 @@ $tot_amount_tvac=0;
 $tot_amount_private=0;
 $tot_nonded_vat=0;
 $tot_nonded_amount=0;
-
+$tot_other_tax=0;
 for ($i=0;$i<$nb_data;$i++):
     $odd=($i%2==0)?' class="even" ':' class="odd" ';
     $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']);
     $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']);
     $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']);
     $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']);
+    
$tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['other_tax_amount']);
     
$tot_nonded_amount=bcadd($tot_nonded_amount,$this->data[$i]['noded_amount']);
     
$tot_nonded_amount=bcadd($tot_nonded_amount,$this->data[$i]['private_amount']);
     $tot_nonded_vat=bcadd($tot_nonded_vat, $this->data[$i]['noded_vat']);
+    $tot_other_tax=bcadd($tot_other_tax,$this->data[$i]['other_tax_amount']);
 ?>
     <tr <?=$odd?> >
         <td>
@@ -117,11 +124,16 @@ for ($i=0;$i<$nb_data;$i++):
             
<?=nbm(bcsub($this->data[$i]['vat'],$this->data[$i]['tva_sided']))?>
         </td>
         <td class="num">
-            <?=nbm($this->data[$i]['tvac'])?>
+            <?=nbm($this->data[$i]['other_tax_amount'])?>
+        </td>
+        <?php if ($nb_other_tax>0) :?>
+        <td class="num">
+            <?=nbm(bcadd($this->data[$i]['other_tax_amount'] 
,$this->data[$i]['tvac']))?>
         </td>
+        <?php endif;?>
         <td class="num">
             <?php if ( $this->data[$i]['currency_id'] != '0') : ?>
-            <?=nbm ( 
bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount']),4)?>
+            <?=nbm ( 
bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount'],2),2)?>
             <?=$this->data[$i]['cr_code_iso']?>
             <?php endif;?>
         </td>
@@ -157,6 +169,9 @@ for ($i=0;$i<$nb_data;$i++):
             <td class="num"><?=nbm($tot_amount_novat)?></td>
             <td class="num"><?=nbm($tot_nonded_amount)?></td>
             <td class="num"><?=nbm($tot_amount_vat)?></td>
+            <?php if ($nb_other_tax>0) :?>
+            <td class="num"><?=nbm($tot_other_tax)?></td>
+            <?php endif;?>
             <td class="num"><?=nbm($tot_amount_tvac)?></td>
             <td></td>
             <td></td>
diff --git a/include/template/acc_ledger_history_sale_extended.php 
b/include/template/acc_ledger_history_sale_extended.php
index 09d836d0c..cb738620b 100644
--- a/include/template/acc_ledger_history_sale_extended.php
+++ b/include/template/acc_ledger_history_sale_extended.php
@@ -24,6 +24,7 @@
  * @file
  * @brief detail of the list of operation with VAT and items
  */
+bcscale(2);
 ?>
 <table class="result">
     <tr>
@@ -69,6 +70,9 @@ for ($i=0;$i<$nb_data;$i++):
     $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']);
     $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']);
     $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']);
+    $supp_tax=$this->data[$i]['supp_tax'];
+    $tot_other_tax=array_sum(array_column($supp_tax,'j_montant'));
+    $all_tax=bcadd($tot_other_tax,$this->data[$i]['vat']);
 ?>
     <tr <?=$odd?> >
         <td>
@@ -90,17 +94,21 @@ for ($i=0;$i<$nb_data;$i++):
             <?=h($this->data[$i]['jr_comment'])?>
         </td>
         <td class="num">
-            
<?=nbm(bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount'],4),4)?>
+            <?php if ($this->data[$i]['currency_id'] !=0) : ?>
+            
<?=nbm(bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount'],4),2)?>
             <?=$this->data[$i]['cr_code_iso']?>
+            <?php endif;?>
         </td>
         <td class="num">
             <?=nbm($this->data[$i]['novat'])?>
         </td>
         <td class="num">
-            
<?=nbm(bcsub($this->data[$i]['vat'],$this->data[$i]['tva_sided']))?>
+            <?=nbm(bcsub($all_tax,$this->data[$i]['tva_sided']),2)?>
+
         </td>
         <td class="num">
-            <?=nbm($this->data[$i]['tvac'])?>
+            <?=nbm(bcadd($this->data[$i]['tvac'],$tot_other_tax))?>
+
         </td>
         <td>
             
@@ -141,6 +149,9 @@ $a_detail=Database::fetch_all($det);
 <?php
 $nb_detail=count($a_detail);
 for ($j=0;$j<$nb_detail;$j++):
+
+
+
 ?>  
                 <tr>
                     <td><?=$a_detail[$j]['qcode']?>  
@@ -155,6 +166,25 @@ for ($j=0;$j<$nb_detail;$j++):
 <?php
 endfor;
 ?>
+                <?php
+                // print additional tax if any
+                  $nb_supp_tax=count($this->data[$i]['supp_tax']);
+                  for ($j=0;$j<$nb_supp_tax;$j++):
+                  ?>
+                <tr>
+                    <td><?=$this->data[$i]['supp_tax'][$j]['j_poste']?>
+                        <?=$this->data[$i]['supp_tax'][$j]['ac_label']?>
+                    </td>
+                    <td></td>
+                    <td></td>
+                    <td></td>
+                    <td></td>
+                    <td></td>
+                    <td 
class="num"><?=nbm($this->data[$i]['supp_tax'][$j]['j_montant'])?></td>
+                </tr>
+                <?php
+                endfor;
+                ?>
                 
             </table>
         </td>
diff --git a/include/template/acc_ledger_history_sale_oneline.php 
b/include/template/acc_ledger_history_sale_oneline.php
index eb78b4a39..4c7041ccc 100644
--- a/include/template/acc_ledger_history_sale_oneline.php
+++ b/include/template/acc_ledger_history_sale_oneline.php
@@ -49,9 +49,15 @@
         <th class="num">
             <?=_('HTVA')?>
         </th>
+
         <th class="num">
             <?=_('TVA')?>
         </th>
+<?php if ($nb_other_tax>0) :?>
+        <th class="num">
+            <?=_('Autre Taxe')?>
+        </th>
+<?php endif;?>
         <th class="num">
             <?=_('TVAC')?>
         </th>
@@ -64,12 +70,15 @@ $nb_data=count($this->data);
 $tot_amount_novat=0;
 $tot_amount_vat=0;
 $tot_amount_tvac=0;
+$tot_other_tax=0;
 for ($i=0;$i<$nb_data;$i++):
     $odd=($i%2==0)?' class="even" ':' class="odd" ';
     $tot_amount_novat=bcadd($tot_amount_novat,$this->data[$i]['novat']);
     $tot_amount_vat=bcadd($tot_amount_vat,$this->data[$i]['vat']);
     $tot_amount_vat=bcsub($tot_amount_vat,$this->data[$i]['tva_sided']);
     $tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['tvac']);
+    
$tot_amount_tvac=bcadd($tot_amount_tvac,$this->data[$i]['other_tax_amount']);
+    $tot_other_tax=bcadd($tot_other_tax,$this->data[$i]['other_tax_amount']);
 ?>
     <tr <?=$odd?> >
         <td>
@@ -96,12 +105,18 @@ for ($i=0;$i<$nb_data;$i++):
         <td class="num">
             
<?=nbm(bcsub($this->data[$i]['vat'],$this->data[$i]['tva_sided']))?>
         </td>
+        <?php if ($nb_other_tax>0) :?>
         <td class="num">
-            <?=nbm($this->data[$i]['tvac'])?>
+            <?=nbm($this->data[$i]['other_tax_amount'])?>
         </td>
+<?php endif;?>
         <td class="num">
-            <?php if ( $this->data[$i]['cr_code_iso'] != 0) : ?>
-            <?=nbm ( 
bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount']),4)?>
+            <?=nbm(bcadd($this->data[$i]['other_tax_amount'] 
,$this->data[$i]['tvac']))?>
+        </td>
+        <td class="num">
+
+            <?php if ( $this->data[$i]['currency_id'] != '0') : ?>
+            <?=nbm ( 
bcadd($this->data[$i]['sum_oc_amount'],$this->data[$i]['sum_oc_vat_amount']),2)?>
             <?=$this->data[$i]['cr_code_iso']?>
             <?php endif;?>
         </td>
@@ -137,6 +152,9 @@ for ($i=0;$i<$nb_data;$i++):
             <td></td>
             <td class="num"><?=nbm($tot_amount_novat)?></td>
             <td class="num"><?=nbm($tot_amount_vat)?></td>
+            <?php if ($nb_other_tax>0) :?>
+            <td class="num"><?=nbm($tot_other_tax)?></td>
+            <?php endif;?>
             <td class="num"><?=nbm($tot_amount_tvac)?></td>
             <td></td>
             <td></td>
diff --git a/include/template/ledger_detail_ven.php 
b/include/template/ledger_detail_ven.php
index 4de0cbc31..935a55aec 100644
--- a/include/template/ledger_detail_ven.php
+++ b/include/template/ledger_detail_ven.php
@@ -274,6 +274,7 @@ echo $ipaid->input();
                  */
                 $sum_add_tax=0;$sum_add_tax_cur=0;
                 
Additional_Tax::display_row($jr_id,$sum_add_tax,$sum_add_tax_cur);
+                print_r("sum_add_tax_cur $sum_add_tax_cur");
                 $sum_prod_currency=bcadd($sum_prod_currency,$sum_add_tax_cur);
 
                 $total_tvac=bcadd($sum_add_tax,$total_tvac);
@@ -289,7 +290,7 @@ echo $ipaid->input();
                 //Display total in currency
                 if ( $obj->det->currency_id != "" && $obj->det->currency_id > 
0) 
                 {
-                    $row.= td(nbm($sum_prod_currency,4),' class="num" 
style="font-style:italic;font-weight: bolder;"');
+                    $row.= td(nbm($sum_prod_currency,2),' class="num" 
style="font-style:italic;font-weight: bolder;"');
                 }
                 echo tr($row);
                 ?>
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 60c43838b..34d3b0373 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -42,3 +42,130 @@ COMMENT ON COLUMN public.jrn_tax.ac_id IS 'FK to 
acc_other_tax';
 
 ALTER TABLE public.jrn_tax ADD CONSTRAINT jrn_tax_acc_other_tax_fk FOREIGN KEY 
(ac_id) REFERENCES public.acc_other_tax(ac_id);
 ALTER TABLE public.jrn_tax ADD CONSTRAINT jrn_tax_fk FOREIGN KEY (j_id) 
REFERENCES public.jrnx(j_id);
+
+drop view if exists v_detail_sale;
+create or replace view v_detail_sale
+            (jr_id, jr_date, jr_date_paid, jr_ech, jr_tech_per, jr_comment, 
jr_pj_number, jr_internal, jr_def_id,
+             j_poste, j_text, j_qcode, jr_rapt, item_card, item_name, 
qs_client, tiers_name, quick_code, tva_label,
+             tva_comment, tva_both_side, vat_sided, vat_code, vat, price, 
quantity, price_per_unit, htva, tot_vat,
+             tot_tva_np,other_tax_amount, oc_amount, oc_vat_amount, 
cr_code_iso)
+as
+WITH m AS (
+    SELECT sum(quant_sold_1.qs_price)     AS htva,
+           sum(quant_sold_1.qs_vat)       AS tot_vat,
+           sum(quant_sold_1.qs_vat_sided) AS tot_tva_np,
+           jrn_1.jr_id
+    FROM quant_sold quant_sold_1
+             JOIN jrnx jrnx_1 USING (j_id)
+             JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
+    GROUP BY jrn_1.jr_id
+),other_tax as (
+    select j_grpt , sum(case when j_debit is true then 0-j_montant else 
j_montant end) other_tax_amount from jrnx join jrn_tax using (j_id) group by 
j_grpt  )
+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,
+       jrn.jr_rapt,
+       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 price,
+       quant_sold.qs_quantite                       AS quantity,
+       quant_sold.qs_price / quant_sold.qs_quantite AS price_per_unit,
+       m.htva,
+       m.tot_vat,
+       m.tot_tva_np,
+       ot.other_tax_amount,
+       oc.oc_amount,
+       oc.oc_vat_amount,
+       (SELECT currency.cr_code_iso
+        FROM currency
+        WHERE jrn.currency_id = currency.id)        AS cr_code_iso
+FROM jrn
+         JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
+         JOIN quant_sold USING (j_id)
+         JOIN vw_fiche_name a ON quant_sold.qs_fiche = a.f_id
+         JOIN vw_fiche_attr b ON quant_sold.qs_client = b.f_id
+         LEFT JOIN tva_rate ON quant_sold.qs_vat_code = tva_rate.tva_id
+         JOIN m ON m.jr_id = jrn.jr_id
+         LEFT JOIN operation_currency oc ON oc.j_id = jrnx.j_id
+         left join other_tax ot on ot.j_grpt=jrn.jr_grpt_id;
+
+drop view if exists public.v_detail_purchase;
+
+create VIEW public.v_detail_purchase
+AS WITH m AS (
+    SELECT sum(quant_purchase_1.qp_price) AS htva,
+           sum(quant_purchase_1.qp_vat) AS tot_vat,
+           sum(quant_purchase_1.qp_vat_sided) AS tot_tva_np,
+           jrn_1.jr_id
+    FROM quant_purchase quant_purchase_1
+             JOIN jrnx jrnx_1 USING (j_id)
+             JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
+    GROUP BY jrn_1.jr_id
+),other_tax as (
+    select j_grpt , sum(case when j_debit is false then 0-j_montant else 
j_montant end) other_tax_amount from jrnx join jrn_tax using (j_id) group by 
j_grpt  )
+   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,
+          jrn.jr_rapt,
+          quant_purchase.qp_fiche AS item_card,
+          a.name AS item_name,
+          quant_purchase.qp_supplier,
+          b.vw_name AS tiers_name,
+          b.quick_code,
+          tva_rate.tva_label,
+          tva_rate.tva_comment,
+          tva_rate.tva_both_side,
+          quant_purchase.qp_vat_sided AS vat_sided,
+          quant_purchase.qp_vat_code AS vat_code,
+          quant_purchase.qp_vat AS vat,
+          quant_purchase.qp_price AS price,
+          quant_purchase.qp_quantite AS quantity,
+          quant_purchase.qp_price / quant_purchase.qp_quantite AS 
price_per_unit,
+          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,
+          ot.other_tax_amount,
+          oc.oc_amount,
+          oc.oc_vat_amount,
+          ( SELECT currency.cr_code_iso
+            FROM currency
+            WHERE jrn.currency_id = currency.id) AS cr_code_iso
+   FROM jrn
+            JOIN jrnx ON jrn.jr_grpt_id = jrnx.j_grpt
+            JOIN quant_purchase USING (j_id)
+            JOIN vw_fiche_name a ON quant_purchase.qp_fiche = a.f_id
+            JOIN vw_fiche_attr b ON quant_purchase.qp_supplier = b.f_id
+            LEFT JOIN tva_rate ON quant_purchase.qp_vat_code = tva_rate.tva_id
+            JOIN m ON m.jr_id = jrn.jr_id
+            LEFT JOIN operation_currency oc ON oc.j_id = jrnx.j_id
+            left join other_tax ot on ot.j_grpt=jrn.jr_grpt_id;
\ No newline at end of file



reply via email to

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