CURRENCY : conversion problem
This commit is contained in:
parent
3bb09a45b9
commit
58cc7c7c04
4 changed files with 24 additions and 4 deletions
|
|
@ -140,15 +140,20 @@ class Acc_Currency
|
|||
*/
|
||||
function get_rate_date($p_date)
|
||||
{
|
||||
if ( $this->get_id() == 0 ) { return 1;}
|
||||
|
||||
if (isDate($p_date) == null ) return -1;
|
||||
if (isDate($p_date) == null ) {
|
||||
throw new Exception(_("Date invalide"));
|
||||
}
|
||||
|
||||
$sql="select ch_value from currency_history
|
||||
where
|
||||
ch_from=(select max(ch_from) from currency_history where ch_from <= to_date($1,'DD.MM.YYYY') and currency_id=$2)
|
||||
and currency_id=$2";
|
||||
$value=$this->cn->get_value($sql,[$p_date,$this->get_id()]);
|
||||
if ($value == "") return -2;
|
||||
if ($value == "") {
|
||||
throw new Exception(_("Aucun taux à cette date , aller sur CFGCURRENCY"));
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3210,6 +3210,9 @@ class Acc_Ledger extends jrn_def_sql
|
|||
function get_currency()
|
||||
{
|
||||
$cr=new Acc_Currency($this->db,$this->currency_id);
|
||||
if ( $cr->get_id() < 0 ) {
|
||||
throw new Exception("ACL.3214"._("Taux invalide"));
|
||||
}
|
||||
return $cr;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -806,8 +806,14 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$get_solde=true;
|
||||
|
||||
$acc_currency=new Acc_Currency($this->db,$this->currency_id);
|
||||
$currency_rate=$acc_currency->get_rate_date($e_date);
|
||||
|
||||
// get the currency_rate when we have one date for all the operations
|
||||
if ( $chdate != 2 ) {
|
||||
$currency_rate=$acc_currency->get_rate_date($e_date);
|
||||
}
|
||||
if (DEBUGNOALYSS > 1) {
|
||||
printf("<p> rate %s </p>",$currency_rate);
|
||||
}
|
||||
// for each item
|
||||
for ($i = 0; $i < $nb_item; $i++)
|
||||
{
|
||||
|
|
@ -816,7 +822,11 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
if (strlen(trim(${"e_other$i"})) == 0)
|
||||
continue;
|
||||
|
||||
if ( $chdate == 2 ) $e_date=${'dateop'.$i};
|
||||
// get the currency_rate when each operation has its own date
|
||||
if ( $chdate == 2 ) {
|
||||
$e_date=${'dateop'.$i};
|
||||
$currency_rate=$acc_currency->get_rate_date($e_date);
|
||||
}
|
||||
// if date is date of operation
|
||||
if ($chdate == 2 && $get_solde )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ if ( $jrn_priv == 'X')
|
|||
NoAccess();
|
||||
exit -1;
|
||||
}
|
||||
$Ledger->set_currency_id();
|
||||
|
||||
$p_msg="";
|
||||
//----------------------------------------
|
||||
// Confirm the operations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue