noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Acc_Tva Class Reference

Acc_Tva is used for to map the table tva_rate parameter are. More...

+ Collaboration diagram for Acc_Tva:

Public Member Functions

 __construct ($p_init, $p_tva_id=-1)
 
 get_parameter ($p_string)
 
 get_side ($p_side)
 get the account of the side (debit or credit)
 
 getTvaRateSql ()
 
 load ()
 Load the VAT, return 0 if the TVA_ID exists otherwise -1.
 
 set_parameter ($p_string, $p_value)
 
 setTvaRateSql (Tva_Rate_SQL $tva_rate_sql)
 

Static Public Member Functions

static build ($db, $p_code)
 retrieve TVA rate thanks the code that could be the tva_id or tva_code.
 

Data Fields

 $tva_both_side
 
 $tva_code
 
 $tva_comment
 
 $tva_id
 
 $tva_label
 
 $tva_poste
 
 $tva_rate
 
 $tva_reverse_account
 

Private Attributes

 $cn
 Database connection.
 
Tva_Rate_SQL $tva_rate_sql
 

Static Private Attributes

static $variable
 

Detailed Description

Acc_Tva is used for to map the table tva_rate parameter are.

  • private static $cn; database connection
  • private static $variable=array("id"=>"tva_id", "label"=>"tva_label", "rate"=>"tva_rate", "comment"=>"tva_comment", "account"=>"tva_poste");

Definition at line 36 of file acc_tva.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Tva::__construct ( $p_init,
$p_tva_id = -1 )

Definition at line 59 of file acc_tva.class.php.

60 {
61 $this->cn=$p_init;
62 $this->tva_rate_sql=new Tva_Rate_SQL($p_init,$p_tva_id);
63 $this->tva_id=$p_tva_id;
64 $this->tva_label=&$this->tva_rate_sql->tva_label;
65 $this->tva_rate=&$this->tva_rate_sql->tva_rate;
66 $this->tva_comment=&$this->tva_rate_sql->tva_comment;
67 $this->tva_poste=&$this->tva_rate_sql->tva_poste;
68 $this->tva_both_side=&$this->tva_rate_sql->tva_both_side;
69 $this->tva_code=&$this->tva_rate_sql->tva_code;
70 $this->tva_reverse_account=&$this->tva_rate_sql->tva_reverse_account;
71
72 }
$input_from cn

References cn.

Member Function Documentation

◆ build()

static Acc_Tva::build ( $db,
$p_code )
static

retrieve TVA rate thanks the code that could be the tva_id or tva_code.

Check first if p_code is a TVA_CODE and if not, check if it is a TVA_ID

Parameters
$dbDatabase connection
$p_codeeither tva_id or tva_code
Returns
Acc_Tva or Acc_TVA with tva_id=-1

Definition at line 155 of file acc_tva.class.php.

155 :Acc_Tva {
156 if (empty($p_code)) return new Acc_Tva($db,-1);
157 $tva_id = $db->get_value("select tva_id from public.tva_rate where tva_code=upper(trim($1))",[$p_code]);
158 if ( $db->size() == 1) {
159 return new Acc_Tva($db,$tva_id);
160 }
161 if (isNumber($p_code) == 0) return new Acc_Tva($db,-1);
162 $exist = $db->get_value("select count(*) from public.tva_rate where tva_id=$1",[$p_code]);
163 if ( $exist == 1) {
164 return new Acc_Tva($db,$p_code);
165 }
166 return new Acc_Tva($db,-1);
167
168 }
isNumber($p_int)

References $tva_id, if, and return.

Referenced by Acc_Ledger_Purchase\confirm(), Acc_Ledger_Sale\confirm(), ITva_Popup\display(), Tax_Detail\get_data(), Acc_Ledger_Purchase\insert(), Acc_Ledger_Sale\insert(), Document\replace(), PDF_Operation\str_vat(), Card_Property\update(), Acc_Ledger_Purchase\verify_operation(), and Acc_Ledger_Sale\verify_operation().

◆ get_parameter()

Acc_Tva::get_parameter ( $p_string)

Definition at line 90 of file acc_tva.class.php.

91 {
92 if ( array_key_exists($p_string,self::$variable) )
93 {
94 $idx=self::$variable[$p_string];
95 return $this->$idx;
96 }
97
98 throw new Exception("ACC98"."Attribut inexistant $p_string",EXC_INVALID);
99 }
const EXC_INVALID
Definition constant.php:346

References $idx, and EXC_INVALID.

◆ get_side()

Acc_Tva::get_side ( $p_side)

get the account of the side (debit or credit)

Parameters
$p_sideis d or C
Returns
the account to use
Note
call first load if tva_poste is empty

Definition at line 131 of file acc_tva.class.php.

132 {
133 if ( strlen($this->tva_poste??"") == 0 ) $this->load();
134 list($deb,$cred)=explode(",",$this->tva_poste);
135 switch ($p_side)
136 {
137 case 'd':
138 return $deb;
139 break;
140 case 'c':
141 return $cred;
142 break;
143 default:
144 throw (new Exception (__FILE__.':'.__LINE__." param est d ou c, on a recu [ $p_side ]"));
145 }
146 }
load()
Load the VAT, return 0 if the TVA_ID exists otherwise -1.
for($i=0;$i< $nb_jrn;$i++) $deb

References $cred, $deb, and load().

+ Here is the call graph for this function:

◆ getTvaRateSql()

Acc_Tva::getTvaRateSql ( )
Returns
Tva_Rate_SQL

Definition at line 76 of file acc_tva.class.php.

76 : Tva_Rate_SQL
77 {
79 }
Tva_Rate_SQL $tva_rate_sql

References $tva_rate_sql.

◆ load()

Acc_Tva::load ( )

Load the VAT, return 0 if the TVA_ID exists otherwise -1.

Note
if the label is not found then we get an message error, so the best is probably to initialize the VAT object with default value

Definition at line 119 of file acc_tva.class.php.

119 :int
120 {
121 $this->tva_rate_sql->setp("tva_id",$this->tva_id);
122
123 if ( ! $this->tva_rate_sql->load() ) return -1;
124 return 0;
125 }

Referenced by get_side().

◆ set_parameter()

Acc_Tva::set_parameter ( $p_string,
$p_value )

Definition at line 100 of file acc_tva.class.php.

101 {
102 if ( array_key_exists($p_string,self::$variable) )
103 {
104 $idx=self::$variable[$p_string];
105 $this->$idx=$p_value;
106 }
107 else
108 throw new Exception("ACC108"."Attribut inexistant $p_string",EXC_INVALID);
109
110
111 }

References $idx, and EXC_INVALID.

◆ setTvaRateSql()

Acc_Tva::setTvaRateSql ( Tva_Rate_SQL $tva_rate_sql)
Parameters
Tva_Rate_SQL$tva_rate_sql

Definition at line 84 of file acc_tva.class.php.

85 {
86 $this->tva_rate_sql = $tva_rate_sql;
87 return $this;
88 }

References $tva_rate_sql.

Field Documentation

◆ $cn

Acc_Tva::$cn
private

Database connection.

Definition at line 55 of file acc_tva.class.php.

◆ $tva_both_side

Acc_Tva::$tva_both_side

Definition at line 51 of file acc_tva.class.php.

◆ $tva_code

Acc_Tva::$tva_code

Definition at line 52 of file acc_tva.class.php.

◆ $tva_comment

Acc_Tva::$tva_comment

Definition at line 49 of file acc_tva.class.php.

◆ $tva_id

Acc_Tva::$tva_id

Definition at line 46 of file acc_tva.class.php.

Referenced by build().

◆ $tva_label

Acc_Tva::$tva_label

Definition at line 47 of file acc_tva.class.php.

◆ $tva_poste

Acc_Tva::$tva_poste

Definition at line 50 of file acc_tva.class.php.

◆ $tva_rate

Acc_Tva::$tva_rate

Definition at line 48 of file acc_tva.class.php.

◆ $tva_rate_sql

Tva_Rate_SQL Acc_Tva::$tva_rate_sql
private

Definition at line 57 of file acc_tva.class.php.

Referenced by getTvaRateSql(), and setTvaRateSql().

◆ $tva_reverse_account

Acc_Tva::$tva_reverse_account

Definition at line 53 of file acc_tva.class.php.

◆ $variable

Acc_Tva::$variable
staticprivate
Initial value:
=array("id"=>"tva_id",
"label"=>"tva_label",
"rate"=>"tva_rate",
"comment"=>"tva_comment",
"account"=>"tva_poste",
"both_side"=>'tva_both_side',
'tva_reverse_account'=>'tva_reverse_account',
'tva_code'=>'tva_code')

Definition at line 38 of file acc_tva.class.php.


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