phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r369 - in trunk/tva: . sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r369 - in trunk/tva: . sql
Date: Sun, 27 May 2012 22:09:23 +0200 (CEST)

Author: danydb
Date: 2012-05-27 22:09:23 +0200 (Sun, 27 May 2012)
New Revision: 369

Modified:
   trunk/tva/class_ext_list_assujetti.php
   trunk/tva/class_ext_list_intra.php
   trunk/tva/class_listing.php
   trunk/tva/list_intra.inc.php
   trunk/tva/sql/patch2.sql
Log:
Create listing


Modified: trunk/tva/class_ext_list_assujetti.php
===================================================================
--- trunk/tva/class_ext_list_assujetti.php      2012-05-27 19:14:22 UTC (rev 
368)
+++ trunk/tva/class_ext_list_assujetti.php      2012-05-27 20:09:23 UTC (rev 
369)
@@ -185,8 +185,7 @@
     $code_customer=new Acc_Parm_Code($this->db);
     $code_customer->p_code='CUSTOMER';
     $code_customer->load();
-    $a=$this->find_tva_code(array('GRIL01','GRIL02','GRIL03'));
-    echo $a;
+    $a=$this->find_tva_code('ASSUJETTI');
     if (trim($a)=='') $a=-1;
     $sql=<<<EOF
       select sum(j_montant) as amount,j_qcode
@@ -281,14 +280,6 @@
       $res.=tr($r);
 
     }
-    $r=td('');
-    $r.=td('');
-    $r.=td(hb('Total'));
-    $r.=td(hb(sprintf('%.02f',$amount)));
-    $r.=td(hb(sprintf('%.02f',$amount_vat)));
-
-
-    $res.=tr($r);
     $res.='</table>';
     $res.='</fieldset>';
     return $res;

Modified: trunk/tva/class_ext_list_intra.php
===================================================================
--- trunk/tva/class_ext_list_intra.php  2012-05-27 19:14:22 UTC (rev 368)
+++ trunk/tva/class_ext_list_intra.php  2012-05-27 20:09:23 UTC (rev 369)
@@ -168,7 +168,7 @@
     $code_customer=new Acc_Parm_Code($this->db);
     $code_customer->p_code='CUSTOMER';
     $code_customer->load();
-    $a=$this->find_tva_code(array('GRIL44','GRIL46'));
+    $a=$this->find_tva_code('LINTRA');
 
     if (trim($a)=='') $a=-1;
     $sql=<<<EOF
@@ -189,21 +189,21 @@
 
     // retrieve missing and compute an array
     for ($i=0;$i<count($all);$i++){
-      $child=new Ext_List_Intra_Child($this->db);
-      $child->set_parameter('amount',$all[$i]['amount']);
-      switch ($this->flag_periode) {
-      case 1:
-       // by month
-       
$child->set_parameter('periode',sprintf('%02d%s',$this->periode_dec,$this->exercice));
-       break;
-      case 2:
-       /* quaterly */
-       
$child->set_parameter('periode',sprintf('3%d%s',$this->periode_dec,$this->exercice));
-       break;
-      case 3:
-       /* yearly */
-       
$child->set_parameter('periode',sprintf('00%s',$this->periode_dec,$this->exercice));
-       break;
+               $child=new Ext_List_Intra_Child($this->db);
+               $child->set_parameter('amount',$all[$i]['amount']);
+               switch ($this->flag_periode) {
+               case 1:
+               // by month
+               
$child->set_parameter('periode',sprintf('%02d%s',$this->periode_dec,$this->exercice));
+               break;
+               case 2:
+               /* quaterly */
+               
$child->set_parameter('periode',sprintf('3%d%s',$this->periode_dec,$this->exercice));
+               break;
+               case 3:
+               /* yearly */
+               
$child->set_parameter('periode',sprintf('00%s',$this->periode_dec,$this->exercice));
+               break;
       } // end switch
 
       $child->set_parameter('qcode',$all[$i]['j_qcode']);
@@ -211,7 +211,7 @@
       $fiche->get_by_qcode($all[$i]['j_qcode'],false);
       $num_tva=$fiche->strAttribut(ATTR_DEF_NUMTVA);
 
-      if ( strpos($num_tva,'BE') === 0) { echo "pas bon";continue;}
+      if ( trim($num_tva) === "") {continue;}
       $child->set_parameter('tva_num',$num_tva);
 
       $child->set_parameter('name_child',$fiche->strAttribut(ATTR_DEF_NAME));

Modified: trunk/tva/class_listing.php
===================================================================
--- trunk/tva/class_listing.php 2012-05-27 19:14:22 UTC (rev 368)
+++ trunk/tva/class_listing.php 2012-05-27 20:09:23 UTC (rev 369)
@@ -26,21 +26,15 @@
 require_once('class_ext_tvagen.php');
 require_once('class_acc_parm_code.php');
 class Listing extends Ext_Tva_Gen {
-  function find_tva_code($p_array) {
-    $a='';$and='';
-    for ($e=0;$e<count($p_array);$e++){
-      $tva_parameter=new Tva_Parameter($this->db);
-      if ( $tva_parameter->set_parameter('code',$p_array[$e]) == -1 )
-       throw new Exception ("code : $p_array[$e] non trouve");
-      $tva_parameter->load();
-      if ( ($c=$tva_parameter->get_parameter('value')) != ''){
-       $a=$and.$c;$and=',';
-      }
-    }//end for
-    $aa=get_array_nodup($a);
-    $a=join(',',$aa);
-    return $a;
-  }
+  function find_tva_code($p_array)
+       {
+               $array=$this->db->make_list("
+                       select distinct tva_id  from tva_belge.parameter_chld
+                       where
+                       pcode=$1",
+                               array($p_array));
 
-  
+               return $array;
+       }
+
 }
\ No newline at end of file

Modified: trunk/tva/list_intra.inc.php
===================================================================
--- trunk/tva/list_intra.inc.php        2012-05-27 19:14:22 UTC (rev 368)
+++ trunk/tva/list_intra.inc.php        2012-05-27 20:09:23 UTC (rev 369)
@@ -1,4 +1,4 @@
-<?php
+ <?php
 /*
  *   This file is part of PhpCompta.
  *

Modified: trunk/tva/sql/patch2.sql
===================================================================
--- trunk/tva/sql/patch2.sql    2012-05-27 19:14:22 UTC (rev 368)
+++ trunk/tva/sql/patch2.sql    2012-05-27 20:09:23 UTC (rev 369)
@@ -73,7 +73,60 @@
 $BODY$
 LANGUAGE plpgsql;
 
+CREATE OR REPLACE FUNCTION tva_belge.fill_parameter_chld_assujetti()
+  RETURNS void AS
+$BODY$
+
+declare
+   a_account text[];
+   a_tva_id text[];
+   i record;
+   e record;
+   f record;
+   n_size_tva int;
+   n_size_account int;
+
+begin
+
+for i in select distinct pvalue from tva_belge.parameter WHERE pcode in 
('GRILL00','GRIL02','GRIL03')
+loop
+       if length(trim(i.pvalue)) = 0 or length(trim(i.paccount)) = 0 then
+               continue;
+       end if;
+
+       a_account := string_to_array(i.paccount, ',');
+       a_tva_id  := string_to_array(i.pvalue,',');
+
+       n_size_tva := array_upper(a_tva_id,1);
+       n_size_account := array_upper(a_account,1);
+
+
+       while n_size_tva <> 0 loop
+
+               while n_size_account <> 0 loop
+
+                       insert into tva_belge.parameter_chld (pcode,tva_id)
+                               values 
('ASSUJETTI',a_tva_id[n_size_tva]::numeric);
+
+                       n_size_account := n_size_account -1;
+               end loop;
+               n_size_account := array_upper(a_account,1);
+               n_size_tva := n_size_tva -1;
+       end loop;
+
+end loop;
+
+return;
+
+end;
+
+$BODY$
+LANGUAGE plpgsql;
+
 select tva_belge.fill_parameter_chld();
+select tva_belge.fill_parameter_chld_assujetti();
 insert into tva_belge.parameter_chld (pcode,pcm_val) select pcode,paccount 
from tva_belge.parameter where pcode in ('ATVA','CRTVA','DTTVA');
+drop function tva_belge.fill_parameter_chld();
+drop function tva_belge.fill_parameter_chld_assujetti();
 alter table tva_belge.parameter drop column paccount;
 alter table tva_belge.parameter drop column pvalue;



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

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