noalyss Version-9
acc_tva.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief this class is used for the table tva_rate
24 */
25
26/*!\brief Acc_Tva is used for to map the table tva_rate
27 * parameter are
28- private static $cn; database connection
29- private static $variable=array("id"=>"tva_id",
30 "label"=>"tva_label",
31 "rate"=>"tva_rate",
32 "comment"=>"tva_comment",
33 "account"=>"tva_poste");
34
35*/
37{
38 private static $variable=array("id"=>"tva_id",
39 "label"=>"tva_label",
40 "rate"=>"tva_rate",
41 "comment"=>"tva_comment",
42 "account"=>"tva_poste",
43 "both_side"=>'tva_both_side');
44 public $tva_id,
50
52
53 function __construct ($p_init,$p_tva_id=-1)
54 {
55 $this->cn=$p_init;
56 $this->tva_rate_sql=new Tva_Rate_SQL($p_init,$p_tva_id);
57 $this->tva_id=$p_tva_id;
58 $this->tva_label=&$this->tva_rate_sql->tva_label;
59 $this->tva_rate=&$this->tva_rate_sql->tva_rate;
60 $this->tva_comment=&$this->tva_rate_sql->tva_comment;
61 $this->tva_poste=&$this->tva_rate_sql->tva_poste;
62 $this->tva_both_side=&$this->tva_rate_sql->tva_both_side;
63
64 }
65 /**
66 * @return Tva_Rate_SQL
67 */
68 public function getTvaRateSql(): Tva_Rate_SQL
69 {
71 }
72
73 /**
74 * @param Tva_Rate_SQL $tva_rate_sql
75 */
77 {
78 $this->tva_rate_sql = $tva_rate_sql;
79 return $this;
80 }
81
82 public function get_parameter($p_string)
83 {
84 if ( array_key_exists($p_string,self::$variable) )
85 {
86 $idx=self::$variable[$p_string];
87 return $this->$idx;
88 }
89
90 echo (__FILE__.":".__LINE__.'Erreur attribut inexistant');
91 }
92 public function set_parameter($p_string,$p_value)
93 {
94 if ( array_key_exists($p_string,self::$variable) )
95 {
96 $idx=self::$variable[$p_string];
97 $this->$idx=$p_value;
98 }
99 else
100 throw new Exception("Attribut inexistant $p_string");
101
102
103 }
104
105 /**
106 *Load the VAT,
107 *@note if the label is not found then we get an message error, so the best is probably
108 *to initialize the VAT object with default value
109 */
110 public function load():int
111 {
112 $this->tva_rate_sql->setp("tva_id",$this->tva_id);
113
114 if ( ! $this->tva_rate_sql->load() ) return -1;
115 return 0;
116 }
117 /*!\brief get the account of the side (debit or credit)
118 *\param $p_side is d or C
119 *\return the account to use
120 *\note call first load if tva_poste is empty
121 */
122 public function get_side($p_side)
123 {
124 if ( strlen($this->tva_poste??"") == 0 ) $this->load();
125 list($deb,$cred)=explode(",",$this->tva_poste);
126 switch ($p_side)
127 {
128 case 'd':
129 return $deb;
130 break;
131 case 'c':
132 return $cred;
133 break;
134 default:
135 throw (new Exception (__FILE__.':'.__LINE__." param est d ou c, on a recu [ $p_side ]"));
136 }
137 }
138}
$idx
$input_from cn
Definition: balance.inc.php:66
Acc_Tva is used for to map the table tva_rate parameter are.
setTvaRateSql(Tva_Rate_SQL $tva_rate_sql)
__construct($p_init, $p_tva_id=-1)
set_parameter($p_string, $p_value)
static $variable
get_parameter($p_string)
load()
Load the VAT,.
get_side($p_side)
get the account of the side (debit or credit)
Tva_Rate_SQL $tva_rate_sql
for($i=0;$i< $nb_jrn;$i++) $deb