phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4475 - in phpcompta/trunk: include sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r4475 - in phpcompta/trunk: include sql
Date: Fri, 25 Nov 2011 17:16:07 +0100 (CET)

Author: danydb
Date: 2011-11-25 17:16:05 +0100 (Fri, 25 Nov 2011)
New Revision: 4475

Modified:
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_ledger_sold.php
   phpcompta/trunk/sql/tva.sql
Log:
add both_sided VAT in table quant_purchase and quant_sold

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php       2011-11-25 
12:13:34 UTC (rev 4474)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php       2011-11-25 
16:16:05 UTC (rev 4475)
@@ -341,7 +341,7 @@
             $tot_perso=0;
             $tot_tva_nd=0;
             $tot_tva_ndded=0;
-
+            $n_both=0;
             /* Save all the items without vat and no deductible vat and 
expense*/
             for ($i=0;$i< $nb_item;$i++)
             {
@@ -486,6 +486,8 @@
                 //-----
                 if ( $g_parameter->MY_TVA_USE=='Y')
                 {
+                    if ( $oTva->get_parameter("both_side")==1) 
$n_both=$acc_amount->amount_vat;
+                        
                     $r=$this->db->exec_sql("select insert_quant_purchase ".
                                            "(null".
                                            ",".$j_id.           /* 2 */
@@ -498,7 +500,7 @@
                                            ",".$acc_amount->nd_vat.         /* 
9 */
                                            ",".$acc_amount->nd_ded_vat.    /* 
10 */
                                            ",".$acc_amount->amount_perso.  /* 
11 */
-                                           ",'".$e_client."')");            /* 
12 */
+                                           ",'".$e_client."',".$n_both.")");   
     /* 12 */
 
                 }
                 else
@@ -515,7 +517,7 @@
                                            ",0".
                                            ",".$acc_amount->nd_ded_vat.
                                            ",".$acc_amount->amount_perso.
-                                           ",'".$e_client."')");
+                                           ",'".$e_client."',".$n_both.")");
 
 
                 }
@@ -673,7 +675,7 @@
                         $acc_operation->jrn=$p_jrn;
                         $acc_operation->type='c';
                         $acc_operation->periode=$tperiode;
-                                               $acc_operation->insert_jrnx();
+                        $acc_operation->insert_jrnx();
                     }
 
                 }

Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php   2011-11-25 12:13:34 UTC 
(rev 4474)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php   2011-11-25 16:16:05 UTC 
(rev 4475)
@@ -272,6 +272,7 @@
             $tot_amount=0;
             $tot_tva=0;
             $tot_debit=0;
+            $n_both=0;
             $this->db->start();
             /* Save all the items without vat */
             for ($i=0;$i< $nb_item;$i++)
@@ -332,6 +333,7 @@
                     else
                         $tva[$idx_tva]=$tva_item;
                     if ($oTva->get_parameter("both_side")==0) 
$tot_tva=round(bcadd($tva_item,$tot_tva),2);
+                    else $n_both=$tva_item;
                 }
 
                 /* Save the stock */
@@ -361,7 +363,7 @@
                 if ( $g_parameter->MY_TVA_USE=='Y')
                 {
                     /* save into quant_sold */
-                    $r=$this->db->exec_sql("select insert_quant_sold 
($1,$2,$3,$4,$5,$6,$7,$8)",
+                    $r=$this->db->exec_sql("select insert_quant_sold 
($1,$2,$3,$4,$5,$6,$7,$8,$9)",
                                            array(null, /* 1 */
                                                  $j_id,        /* 2 */
                                                  ${'e_march'.$i} , /* 3 */
@@ -369,12 +371,13 @@
                                                  round($amount,2),            
/* 5 */
                                                  $tva_item,           /* 6 */
                                                  $idx_tva,            /* 7 */
-                                                 $e_client));      /* 8 */
+                                                 $e_client,      /* 8 */
+                                                 $n_both));
 
                 }
                 else
                 {
-                    $r=$this->db->exec_sql("select insert_quant_sold 
($1,$2,$3,$4,$5,$6,$7,$8) ",
+                    $r=$this->db->exec_sql("select insert_quant_sold 
($1,$2,$3,$4,$5,$6,$7,$8,$9) ",
                                            array(null, /* 1 */
                                                  $j_id,          /* 2 */
                                                  ${'e_march'.$i}, /* 3 */
@@ -382,7 +385,8 @@
                                                  $amount,              // 5
                                                  0,
                                                  null,
-                                                 $e_client));
+                                                 $e_client,
+                                                         0));
 
                 }  // if ( $g_parameter->MY_TVA_USE=='Y') {
             }// end loop : save all items
@@ -431,7 +435,6 @@
                     // if TVA is on both side, we deduce it immediately
                     if ( $oTva->get_parameter("both_side")==1)
                     {
-                     echo "remove_tva";
                         $poste_vat=$oTva->get_side('d');
                         $cust_amount=bcadd($tot_amount,$tot_tva);
                         $acc_operation=new Acc_Operation($this->db);
@@ -444,6 +447,7 @@
                         $acc_operation->periode=$tperiode;
                        $acc_operation->insert_jrnx();
                        $tot_debit=bcadd($tot_debit,$value);
+                        $n_both=$value;
                     }
 
 

Modified: phpcompta/trunk/sql/tva.sql
===================================================================
--- phpcompta/trunk/sql/tva.sql 2011-11-25 12:13:34 UTC (rev 4474)
+++ phpcompta/trunk/sql/tva.sql 2011-11-25 16:16:05 UTC (rev 4475)
@@ -83,3 +83,76 @@
 end;
 $function$
 LANGUAGE plpgsql;
+
+alter table quant_purchase add qp_vat_sided number (20,4);
+alter table quant_sold add qs_vat_sided number (20,4);
+
+DROP FUNCTION comptaproc.insert_quant_purchase(text,numeric, character 
varying,numeric,numeric,numeric,integer,,numeric,numeric,,numeric,numeric,character
 varying, numeric);
+-- procedure insert_quant_purchase
+CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, 
p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, 
p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, 
p_nd_tva_recup numeric, p_dep_priv numeric, p_client character 
varying,p_tva_sided numeric)
+ RETURNS void
+ LANGUAGE plpgsql
+AS $function$
+declare
+        fid_client integer;
+        fid_good   integer;
+begin
+        select f_id into fid_client from
+                fiche_detail where ad_id=23 and ad_value=upper(trim(p_client));
+        select f_id into fid_good from
+                 fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche));
+        insert into quant_purchase
+                (qp_internal,
+                j_id,
+                qp_fiche,
+                qp_quantite,
+                qp_price,
+                qp_vat,
+                qp_vat_code,
+                qp_nd_amount,
+                qp_nd_tva,
+                qp_nd_tva_recup,
+                qp_supplier,
+                qp_dep_priv,
+                qp_vat_sided)
+        values
+                (p_internal,
+                p_j_id,
+                fid_good,
+                p_quant,
+                p_price,
+                p_vat,
+                p_vat_code,
+                p_nd_amount,
+                p_nd_tva,
+                p_nd_tva_recup,
+                fid_client,
+                p_dep_priv,
+                p_tva_sided);
+        return;
+end;
+ $function$
+
+DROP FUNCTION comptaproc.insert_quant_sold(text, numeric, character varying, 
numeric, numeric, numeric, integer, character varying);
+
+-- procedure insert_quant_sold
+CREATE OR REPLACE FUNCTION comptaproc.insert_quant_sold(p_internal text, p_jid 
numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat 
numeric, p_vat_code integer, p_client character varying,p_tva_sided numeric)
+ RETURNS void
+ LANGUAGE plpgsql
+AS $function$
+declare
+        fid_client integer;
+        fid_good   integer;
+begin
+
+        select f_id into fid_client from
+                fiche_detail where ad_id=23 and ad_value=upper(trim(p_client));
+        select f_id into fid_good from
+                fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche));
+        insert into quant_sold
+                
(qs_internal,j_id,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client,qs_valid,qs_vat_sided)
+        values
+                
(p_internal,p_jid,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client,'Y',p_tva_sided);
+        return;
+end;
+ $function$




reply via email to

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