noalyss Version-10
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 (Database $cn, $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_peppol_code
 
 $tva_poste
 
 $tva_rate
 
 $tva_reverse_account
 
 $vx_code
 

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" tva_peppol_code 'vx_code' );

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

Constructor & Destructor Documentation

◆ __construct()

Acc_Tva::__construct ( Database $cn,
$p_tva_id = -1 )

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

70 {
71 $this->cn=$cn;
72 $this->tva_rate_sql=new Tva_Rate_SQL($cn,$p_tva_id);
73 $this->tva_id=$p_tva_id;
74 $this->tva_label=&$this->tva_rate_sql->tva_label;
75 $this->tva_rate=&$this->tva_rate_sql->tva_rate;
76 $this->tva_comment=&$this->tva_rate_sql->tva_comment;
77 $this->tva_poste=&$this->tva_rate_sql->tva_poste;
78 $this->tva_both_side=&$this->tva_rate_sql->tva_both_side;
79 $this->tva_code=&$this->tva_rate_sql->tva_code;
80 $this->tva_reverse_account=&$this->tva_rate_sql->tva_reverse_account;
81 $this->tva_peppol_code=&$this->tva_rate_sql->tva_peppol_code;
82 $this->vx_code=&$this->tva_rate_sql->vx_code;
83
84 }
$input_from cn
$cn
Database connection.

References $cn, and 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 167 of file acc_tva.class.php.

167 :Acc_Tva {
168 if (empty($p_code)) return new Acc_Tva($db,-1);
169 $tva_id = $db->get_value("select tva_id from public.tva_rate where tva_code=upper(trim($1))",[$p_code]);
170 if ( $db->size() == 1) {
171 return new Acc_Tva($db,$tva_id);
172 }
173 if (isNumber($p_code) == 0) return new Acc_Tva($db,-1);
174 $exist = $db->get_value("select count(*) from public.tva_rate where tva_id=$1",[$p_code]);
175 if ( $exist == 1) {
176 return new Acc_Tva($db,$p_code);
177 }
178 return new Acc_Tva($db,-1);
179
180 }
isNumber($p_int)

References $tva_id, if, and return.

Referenced by Noalyss\XMLDocument\InvoiceUBL21\check_VAT(), Acc_Ledger_Purchase\confirm(), Acc_Ledger_Sale\confirm(), ITva_Popup\display(), Noalyss\XMLDocument\XMLInvoice\fill_operation_from_array(), 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 102 of file acc_tva.class.php.

103 {
104 if ( array_key_exists($p_string,self::$variable) )
105 {
106 $idx=self::$variable[$p_string];
107 return $this->$idx;
108 }
109
110 throw new Exception("ACC98"."Attribut inexistant $p_string",EXC_INVALID);
111 }
const EXC_INVALID
Definition constant.php:358

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 143 of file acc_tva.class.php.

144 {
145 if ( strlen($this->tva_poste??"") == 0 ) $this->load();
146 list($deb,$cred)=explode(",",$this->tva_poste);
147 switch ($p_side)
148 {
149 case 'd':
150 return $deb;
151 break;
152 case 'c':
153 return $cred;
154 break;
155 default:
156 throw (new Exception (__FILE__.':'.__LINE__." param est d ou c, on a recu [ $p_side ]"));
157 }
158 }
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 88 of file acc_tva.class.php.

88 : Tva_Rate_SQL
89 {
91 }
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 131 of file acc_tva.class.php.

131 :int
132 {
133 $this->tva_rate_sql->setp("tva_id",$this->tva_id);
134
135 if ( ! $this->tva_rate_sql->load() ) return -1;
136 return 0;
137 }

Referenced by get_side().

◆ set_parameter()

Acc_Tva::set_parameter ( $p_string,
$p_value )

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

113 {
114 if ( array_key_exists($p_string,self::$variable) )
115 {
116 $idx=self::$variable[$p_string];
117 $this->$idx=$p_value;
118 }
119 else
120 throw new Exception("ACC108"."Attribut inexistant $p_string",EXC_INVALID);
121
122
123 }

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 96 of file acc_tva.class.php.

97 {
98 $this->tva_rate_sql = $tva_rate_sql;
99 return $this;
100 }

References $tva_rate_sql.

Field Documentation

◆ $cn

Acc_Tva::$cn
private

Database connection.

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

Referenced by __construct().

◆ $tva_both_side

Acc_Tva::$tva_both_side

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

◆ $tva_code

Acc_Tva::$tva_code

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

◆ $tva_comment

Acc_Tva::$tva_comment

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

◆ $tva_id

Acc_Tva::$tva_id

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

Referenced by build().

◆ $tva_label

Acc_Tva::$tva_label

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

◆ $tva_peppol_code

Acc_Tva::$tva_peppol_code

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

◆ $tva_poste

Acc_Tva::$tva_poste

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

◆ $tva_rate

Acc_Tva::$tva_rate

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

◆ $tva_rate_sql

Tva_Rate_SQL Acc_Tva::$tva_rate_sql
private

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

Referenced by getTvaRateSql(), and setTvaRateSql().

◆ $tva_reverse_account

Acc_Tva::$tva_reverse_account

Definition at line 60 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',
"tva_peppol_code"=>"tva_peppol_code",
'vx_code'=>'vx_code'
)

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

◆ $vx_code

Acc_Tva::$vx_code

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


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