noalyss Version-9
Public Member Functions | Private Attributes
Acc_Currency Class Reference

display currency , convert to euro , and save them if used. More...

+ Collaboration diagram for Acc_Currency:

Public Member Functions

 __construct (Database $p_cn, $p_id=-1)
 
 __toString ()
 
 get_by_iso ($p_iso)
 Retrieve a V_Currency_Last_Value_SQL thanks its iso_code. More...
 
 get_code ()
 return the iso code of the currency More...
 
 get_id ()
 return the id of the currency More...
 
 get_rate ()
 return the rate of the currency More...
 
 get_rate_date ($p_date)
 Return the rate used at a certain date or -1 if date if not in the format DD.MM.YYYY or -2 if no value is found. More...
 
 is_found ()
 Check if the record is found. More...
 
 select_currency ()
 Create an object iselect to select the currency,. More...
 
 set_id ($p_id)
 Retrieve a V_Currency_Last_Value_SQL thanks its id. More...
 
 sum_amount ($p_jr_id)
 Return sum of the w/o VAT and VAT or an operation. More...
 

Private Attributes

 $cn
 database conx More...
 
 $currency
 v_currency_last_value_sql More...
 

Detailed Description

display currency , convert to euro , and save them if used.

The default currency has the id 0 and is normally EUR

Definition at line 33 of file acc_currency.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Currency::__construct ( Database  $p_cn,
  $p_id = -1 
)

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

40 {
41 $this->cn=$p_cn;
42 $this->currency=new V_Currency_Last_Value_SQL($p_cn, $p_id);
43 }
$input_from cn
Definition: balance.inc.php:66
class_currency_history_sql.php

References $p_id, and cn.

Member Function Documentation

◆ __toString()

Acc_Currency::__toString ( )

Definition at line 45 of file acc_currency.class.php.

45 : string
46 {
47 return "Acc_Currency [".$this->currency->__toString()."]";
48 }

◆ get_by_iso()

Acc_Currency::get_by_iso (   $p_iso)

Retrieve a V_Currency_Last_Value_SQL thanks its iso_code.

Parameters
string$p_iso

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

55 {
56 $p_iso=trim(strtoupper($p_iso));
57 $id=$this->cn->get_value("select currency_id from v_currency_last_value where cr_code_iso=$1", [$p_iso]);
58 if ($id!="")
59 {
60 $this->currency->setp("currency_id", $id);
61 $this->currency->load();
62 }
63 }

References $id, and cn.

◆ get_code()

Acc_Currency::get_code ( )

return the iso code of the currency

Definition at line 96 of file acc_currency.class.php.

97 {
98 return $this->currency->getp("cr_code_iso");
99
100
101 }

◆ get_id()

Acc_Currency::get_id ( )

return the id of the currency

Definition at line 105 of file acc_currency.class.php.

106 {
107 return $this->currency->getp("currency_id");
108
109 }

Referenced by get_rate_date().

◆ get_rate()

Acc_Currency::get_rate ( )

return the rate of the currency

Definition at line 88 of file acc_currency.class.php.

89 {
90 return $this->currency->getp("ch_value");
91
92 }

◆ get_rate_date()

Acc_Currency::get_rate_date (   $p_date)

Return the rate used at a certain date or -1 if date if not in the format DD.MM.YYYY or -2 if no value is found.

Parameters
date$p_date

Definition at line 146 of file acc_currency.class.php.

147 {
148 if ( $this->get_id() == 0 ) { return 1;}
149
150 if (isDate($p_date) == null ) {
151 throw new Exception(_("Date invalide"));
152 }
153
154 $sql="select ch_value from currency_history
155 where
156 ch_from=(select max(ch_from) from currency_history where ch_from <= to_date($1,'DD.MM.YYYY') and currency_id=$2)
157 and currency_id=$2";
158 $value=$this->cn->get_value($sql,[$p_date,$this->get_id()]);
159 if ($value == "") {
160 throw new Exception(_("Aucun taux à cette date , aller sur CFGCURRENCY"));
161 }
162 return $value;
163 }
isDate($p_date)
Definition: ac_common.php:236
get_id()
return the id of the currency

References $p_date, $sql, $value, cn, get_id(), and isDate().

+ Here is the call graph for this function:

◆ is_found()

Acc_Currency::is_found ( )

Check if the record is found.

Returns
boolean

Definition at line 78 of file acc_currency.class.php.

78 {
79 if ($this->currency->currency_id==-1)
80 {
81 return FALSE;
82 }
83 return TRUE;
84 }

◆ select_currency()

Acc_Currency::select_currency ( )

Create an object iselect to select the currency,.

Returns
\ISelect

Definition at line 114 of file acc_currency.class.php.

115 {
116 $select=new ISelect('p_currency_code');
117 $a_currency=$this->cn->make_array("select currency_id,cr_code_iso from v_currency_last_value order by cr_code_iso");
118 $select->value=$a_currency;
119 $select->selected=$this->currency->cr_code_iso;
120
121 return $select;
122 }
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...

References $select, and cn.

◆ set_id()

Acc_Currency::set_id (   $p_id)

Retrieve a V_Currency_Last_Value_SQL thanks its id.

Parameters
number$p_id

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

70 {
71 $this->currency->setp("currency_id", $p_id);
72 $this->currency->load();
73 }

References $p_id.

◆ sum_amount()

Acc_Currency::sum_amount (   $p_jr_id)

Return sum of the w/o VAT and VAT or an operation.

Definition at line 126 of file acc_currency.class.php.

127 {
128 $sql = "
129 select sum(round(oc_amount,2)) +
130 sum(round(oc_vat_amount,2))
131 from operation_currency
132 where
133 j_id in (
134 select j_id
135 from jrnx
136 where
137 j_grpt in ( select jr_grpt_id from jrn where jr_id=$1))";
138 $sum=$this->cn->get_value($sql, [$p_jr_id]);
139 return $sum;
140
141 }

References $sql, and cn.

Field Documentation

◆ $cn

Acc_Currency::$cn
private

database conx

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

◆ $currency

Acc_Currency::$currency
private

v_currency_last_value_sql

Definition at line 37 of file acc_currency.class.php.


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