Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes
Tva_Amount Class Reference
Collaboration diagram for Tva_Amount:
Collaboration graph

Public Member Functions

 __construct ($p_init, $p_dir, $p_start_periode, $p_end_periode)
 
 get_parameter ($p_string)
 
 set_parameter ($p_string, $p_value)
 
 get_info ()
 
 verify ()
 
 load_parameter ()
 load parameters and set param to a array of value from parameter_chld More...
 
 amount_operation ()
 get the amount of vat thanks its code More...
 
 amount_vat ()
 
 record_ledger ()
 record into the ledger the operation for purging the the vat accouting More...
 

Static Public Member Functions

static test_me ()
 

Private Member Functions

 get_amount_filter ($p_code, $p_account)
 get the amount of operation from the table quant_sold or quant_purchase More...
 
 get_vat_filter ($p_code, $p_account)
 get the amount of VAT from the table quant_sold or quant_purchase More...
 

Static Private Attributes

static $variable
 

Detailed Description

Definition at line 32 of file class_tva_amount.php.

Constructor & Destructor Documentation

Tva_Amount::__construct (   $p_init,
  $p_dir,
  $p_start_periode,
  $p_end_periode 
)

Definition at line 43 of file class_tva_amount.php.

43  {
44  $this->db=$p_init;
45  $this->start_periode=$p_start_periode;
46  $this->end_periode=$p_end_periode;
47  $this->dir=$p_dir;
48  }

Member Function Documentation

Tva_Amount::amount_operation ( )

get the amount of vat thanks its code

Parameters
$p_grilis the gril code
$p_diris out or in in for the table quant_purchase and out for the table quant_sold
Returns
a number

Definition at line 89 of file class_tva_amount.php.

References get_amount_filter(), and load_parameter().

89  {
90  // get the VAT code
91  $this->load_parameter();
92  $result=0;
93  bcscale(4);
94  for ($i=0;$i<count($this->param);$i++)
95  {
96  $tmp_calc=$this->get_amount_filter($this->param[$i]['tva_id'],$this->param[$i]['pcm_val']);
97  $result=bcadd($result,$tmp_calc);
98 
99  }
100  return round($result,2);
101 
102 
103  }
get_amount_filter($p_code, $p_account)
get the amount of operation from the table quant_sold or quant_purchase
load_parameter()
load parameters and set param to a array of value from parameter_chld
Tva_Amount::amount_vat ( )

Definition at line 104 of file class_tva_amount.php.

References get_vat_filter(), and load_parameter().

104  {
105  // get the VAT code
106  $this->load_parameter();
107  $result=0;
108  bcscale(4);
109  for ($i=0;$i<count($this->param);$i++)
110  {
111  $tmp_calc=$this->get_vat_filter($this->param[$i]['tva_id'],$this->param[$i]['pcm_val']);
112  $result=bcadd($result,$tmp_calc);
113 
114  }
115  return round($result,2);
116 
117 
118  }
get_vat_filter($p_code, $p_account)
get the amount of VAT from the table quant_sold or quant_purchase
load_parameter()
load parameters and set param to a array of value from parameter_chld
Tva_Amount::get_amount_filter (   $p_code,
  $p_account 
)
private

get the amount of operation from the table quant_sold or quant_purchase

Returns
amount

Definition at line 124 of file class_tva_amount.php.

References $res, and $sql.

Referenced by amount_operation().

124  {
125  if ( $this->dir == 'out' && trim($p_account) !='' && trim($p_code) !='' ) {
126  $sql="select coalesce(sum(qs_price),0) as amount from quant_sold
127  join jrnx using (j_id)
128  where qs_vat_code=$1 and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date($3,'DD.MM.YYYY'))
129  and j_poste::text like ($4)";
130  $res=$this->db->get_array($sql,array($p_code,
131  $this->start_periode,
132  $this->end_periode,
133  $p_account));
134  return $res[0]['amount'];
135  }
136 
137  if ( $this->dir == 'in' && trim($p_account) !='' && trim($p_code) !='' ) {
138  $sql="select coalesce(sum(qp_price),0) as amount from quant_purchase join jrnx using (j_id)
139  where qp_vat_code=$1 and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date($3,'DD.MM.YYYY'))
140  and j_poste::text like ($4)";
141  $res=$this->db->get_array($sql,array($p_code,
142  $this->start_periode,
143  $this->end_periode,
144  $p_account));
145  return $res[0]['amount'];
146  }
147 
148 
149  return 0;
150  }
$res
$sql
Tva_Amount::get_info ( )

Definition at line 67 of file class_tva_amount.php.

67 { return var_export(self::$variable,true); }
Tva_Amount::get_parameter (   $p_string)

Definition at line 49 of file class_tva_amount.php.

49  {
50  if ( array_key_exists($p_string,self::$variable) ) {
51  $idx=self::$variable[$p_string];
52  return $this->$idx;
53  }
54  else
55  throw new Exception("Attribut inexistant $p_string");
56  }
Tva_Amount::get_vat_filter (   $p_code,
  $p_account 
)
private

get the amount of VAT from the table quant_sold or quant_purchase

Returns
amount

Definition at line 156 of file class_tva_amount.php.

References $res, and $sql.

Referenced by amount_vat().

156  {
157  if ( $this->dir == 'out' && trim($p_account) !='' && trim($p_code) !='' ) {
158  $sql="select coalesce(sum(qs_vat),0) as amount from quant_sold join jrnx using (j_id)
159  where qs_vat_code=$1 and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date($3,'DD.MM.YYYY'))
160  and j_poste::text like ($4)";
161  $res=$this->db->get_array($sql,array($p_code,
162  $this->start_periode,
163  $this->end_periode,
164  $p_account));
165  return $res[0]['amount'];
166  }
167 
168  if ( $this->dir == 'in' && trim($p_account) !='' && trim($p_code) !='' ) {
169  $sql="select coalesce(sum(qp_vat),0) as amount from quant_purchase join jrnx using (j_id)
170  where qp_vat_code=$1 and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date($3,'DD.MM.YYYY'))
171  and j_poste::text like ($4)";
172  $res=$this->db->get_array($sql,array($p_code,
173  $this->start_periode,
174  $this->end_periode,
175  $p_account));
176  return $res[0]['amount'];
177  }
178 
179 
180  return 0;
181  }
$res
$sql
Tva_Amount::load_parameter ( )

load parameters and set param to a array of value from parameter_chld

Definition at line 74 of file class_tva_amount.php.

Referenced by amount_operation(), and amount_vat().

74  {
75  // get the vat code
76  $ctva=$this->db->get_array("select tva_id,pcm_val from tva_belge.parameter_chld where pcode=$1",array($this->grid));
77  if ( count($ctva)== 0 ) {
78  $this->param=null;
79  }
80  $this->param=$ctva;
81  }
Tva_Amount::record_ledger ( )

record into the ledger the operation for purging the the vat accouting

Definition at line 188 of file class_tva_amount.php.

188  {
189 
190 }
Tva_Amount::set_parameter (   $p_string,
  $p_value 
)

Definition at line 57 of file class_tva_amount.php.

57  {
58  if ( array_key_exists($p_string,self::$variable) ) {
59  $idx=self::$variable[$p_string];
60  $this->$idx=$p_value;
61  }
62  else
63  throw new Exception("Attribut inexistant $p_string");
64 
65 
66  }
static Tva_Amount::test_me ( )
static
Parameters
\return
Note
See Also
Todo:

Definition at line 199 of file class_tva_amount.php.

199  {
200  }
Tva_Amount::verify ( )

Definition at line 68 of file class_tva_amount.php.

68  {
69  // Verify that the elt we want to add is correct
70  }

Field Documentation

Tva_Amount::$variable
staticprivate
Initial value:
=array('amount'=>'amount',
'amount_tva'=>'amount_tva',
'param'=>'param',
'dir'=>'dir',
'start_periode'=>'start_periode',
'end_periode'=>'end_periode',
'grid'=>'grid'
)

Definition at line 35 of file class_tva_amount.php.


The documentation for this class was generated from the following file: