Task #0001961: Devise : faciliter les calculs d'écarts de conversion
This commit is contained in:
parent
fe8f13b1bc
commit
099d90df95
12 changed files with 1006 additions and 115 deletions
165
include/class/data_currency_operation.class.php
Normal file
165
include/class/data_currency_operation.class.php
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief build the SQL and fetch data currency operation from database ,
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief build the SQL and fetch data of data currency operation from database ,
|
||||
*/
|
||||
class Data_Currency_Operation
|
||||
{
|
||||
|
||||
private $dbconx;
|
||||
private $currency_id;
|
||||
private $from_date;
|
||||
private $to_date;
|
||||
|
||||
function __construct($cn, $from_date="", $to_date="", $currency_id=0)
|
||||
{
|
||||
global $g_user;
|
||||
$this->dbconx=$cn;
|
||||
$this->currency_id=$currency_id;
|
||||
|
||||
$periode_limit=$g_user->get_limit_current_exercice();
|
||||
$this->from_date=($from_date=="")?$periode_limit[0]:$from_date;
|
||||
$this->to_date=($to_date=="")?$periode_limit[1]:$to_date;
|
||||
}
|
||||
/**
|
||||
* @brief retrieve the currency code
|
||||
* @return string ISO CODE
|
||||
*/
|
||||
public function to_currency_code()
|
||||
{
|
||||
$currency_code=$this->dbconx->get_value("select cr_code_iso from currency where id=$1",[$this->currency_id]);
|
||||
return $currency_code;
|
||||
}
|
||||
/**
|
||||
* @brief retrieve currency.od
|
||||
*/
|
||||
public function getCurrency_id()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function getFrom_date()
|
||||
{
|
||||
return $this->from_date;
|
||||
}
|
||||
|
||||
public function getTo_date()
|
||||
{
|
||||
return $this->to_date;
|
||||
}
|
||||
|
||||
public function setFrom_date($from_date)
|
||||
{
|
||||
$this->from_date=$from_date;
|
||||
}
|
||||
|
||||
public function setTo_date($to_date)
|
||||
{
|
||||
$this->to_date=$to_date;
|
||||
}
|
||||
/**
|
||||
* @brief retrieve currency.od
|
||||
*/
|
||||
|
||||
public function setCurrency_id($currency_id)
|
||||
{
|
||||
$this->currency_id=$currency_id;
|
||||
}
|
||||
/**
|
||||
* Database connection
|
||||
*/
|
||||
public function getDbconx()
|
||||
{
|
||||
return $this->dbconx;
|
||||
}
|
||||
|
||||
public function setDbconx($dbconx)
|
||||
{
|
||||
$this->dbconx=$dbconx;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief build the SQL to execute
|
||||
*/
|
||||
function build_SQL()
|
||||
{
|
||||
$sql=" select jr_id,
|
||||
j_date,
|
||||
j_montant,
|
||||
coalesce(oc_amount,j_montant) oc_amount,
|
||||
j_poste,
|
||||
jr_comment,
|
||||
jr_internal,
|
||||
jr_pj_number,
|
||||
jrn.currency_id,
|
||||
(select cr_code_iso from currency c where c.id=jrn.currency_id) as currency_code_iso,
|
||||
coalesce (currency_rate,1) currency_rate,
|
||||
coalesce (currency_rate_ref,1) currency_rate_ref,
|
||||
f_id,
|
||||
(select ad_value from fiche_detail fd1 where fd1.f_id=jrnx.f_id and ad_id=23) as fiche_qcode
|
||||
from jrnx
|
||||
join jrn on (jr_grpt_id=jrnx.j_grpt)
|
||||
left join operation_currency oc using (j_id)
|
||||
join jrn_def on (jr_def_id=jrn_def.jrn_def_id)
|
||||
";
|
||||
$sql.=$this->SQL_Condition();
|
||||
|
||||
$sql.=" order by j_poste,j_date ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @brief build the SQL condition
|
||||
* @return SQL condition
|
||||
*/
|
||||
function SQL_Condition()
|
||||
{
|
||||
global $g_user;
|
||||
|
||||
return " where jrn.currency_id = $1 and ".$g_user->get_ledger_sql('ALL', 3)
|
||||
." and jr_date >= to_date($2,'DD.MM.YYYY')"
|
||||
." and jr_date <= to_date($3,'DD.MM.YYYY')"
|
||||
;
|
||||
}
|
||||
/**
|
||||
* @brief returns data
|
||||
* @return array
|
||||
*/
|
||||
function get_data()
|
||||
{
|
||||
$sql=$this->build_SQL();
|
||||
$aArray=$this->dbconx->get_array($sql, [$this->getCurrency_id(), $this->getFrom_date(),$this->getTo_date()]);
|
||||
|
||||
return $aArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
118
include/class/filter_data_currency_accounting.class.php
Normal file
118
include/class/filter_data_currency_accounting.class.php
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
require_once NOALYSS_INCLUDE."/class/data_currency_operation.class.php";
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief filter data in currency from datase , inherit from Data_Currency_Operation, filter on
|
||||
* a range of accounting or only one
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief filter data in currency from datase , inherit from Data_Currency_Operation, filter on
|
||||
* a range of accounting or only one
|
||||
*/
|
||||
class Filter_Data_Currency_Accounting extends Data_Currency_Operation
|
||||
{
|
||||
|
||||
private $from_accounting;
|
||||
private $to_accounting;
|
||||
|
||||
function __construct($cn, $from_date, $to_date, $currency_id, $from_accounting, $to_accounting)
|
||||
{
|
||||
parent::__construct($cn, $from_date, $to_date, $currency_id);
|
||||
$this->from_accounting=$from_accounting;
|
||||
$this->to_accounting=$to_accounting;
|
||||
}
|
||||
/**
|
||||
* @brief from_accounting : lowest accounting range
|
||||
* @return accounting (string)
|
||||
*/
|
||||
public function getFrom_accounting()
|
||||
{
|
||||
return $this->from_accounting;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @brief to_accounting : highest accounting range
|
||||
* @return accounting (string)
|
||||
*/
|
||||
public function getTo_accounting()
|
||||
{
|
||||
return $this->to_accounting;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @brief from_accounting : lowest accounting range
|
||||
* @return accounting (string)
|
||||
*/
|
||||
public function setFrom_accounting($from_accounting)
|
||||
{
|
||||
$this->from_accounting=$from_accounting;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @brief to_accounting : highest accounting range
|
||||
* @return accounting (string)
|
||||
*/
|
||||
public function setTo_accounting($to_accounting)
|
||||
{
|
||||
$this->to_accounting=$to_accounting;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @brief build the SQL condition
|
||||
* @return SQL condition
|
||||
*/
|
||||
public function SQL_Condition()
|
||||
{
|
||||
$sql=parent::SQL_Condition();
|
||||
$sql.=' and j_poste >= $4 and j_poste <= $5';
|
||||
return $sql;
|
||||
}
|
||||
/**
|
||||
* @brief returns data
|
||||
* @return array
|
||||
*/
|
||||
public function get_data()
|
||||
{
|
||||
$sql=$this->build_SQL();
|
||||
$aArray=$this->getDbconx()->get_array($sql,
|
||||
[$this->getCurrency_id(),
|
||||
$this->getFrom_date(),
|
||||
$this->getTo_date(),
|
||||
$this->getFrom_accounting(),
|
||||
$this->getTo_accounting()]);
|
||||
|
||||
return $aArray;
|
||||
}
|
||||
public function info()
|
||||
{
|
||||
return sprintf("currency_id %s from_date %s to_date %s from_accounting %s to_accounting %s",
|
||||
$this->getCurrency_id(),$this->getFrom_date(),$this->getTo_date(),$this->getFrom_accounting(),
|
||||
$this->getTo_accounting());
|
||||
}
|
||||
|
||||
}
|
||||
90
include/class/filter_data_currency_card.class.php
Normal file
90
include/class/filter_data_currency_card.class.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
require_once NOALYSS_INCLUDE."/class/data_currency_operation.class.php";
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief filter data in currency froqm datase , inherit from Data_Currency_Operation, filter on
|
||||
* a specific card
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @brief filter data in currency froqm datase , inherit from Data_Currency_Operation, filter on
|
||||
* a specific card
|
||||
*/
|
||||
class Filter_Data_Currency_Card extends Data_Currency_Operation
|
||||
{
|
||||
|
||||
private $card; //!< qcode of a card
|
||||
|
||||
function __construct($cn, $from_date, $to_date, $currency_id, $card)
|
||||
{
|
||||
parent::__construct($cn, $from_date, $to_date, $currency_id);
|
||||
$this->card=$card;
|
||||
}
|
||||
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
public function setCard($card)
|
||||
{
|
||||
$this->card=$card;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief build the SQL condition
|
||||
* @return SQL condition
|
||||
*/
|
||||
public function SQL_Condition()
|
||||
{
|
||||
$sql=parent::SQL_Condition();
|
||||
$sql.=" and f_id=$4";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns data
|
||||
* @return array
|
||||
*/
|
||||
public function get_data()
|
||||
{
|
||||
$sql=$this->build_SQL();
|
||||
$card_id=$this->getDbconx()->get_value("select f_id from fiche_detail where ad_id=23 and ad_value=$1",
|
||||
[trim(strtoupper($this->card))]);
|
||||
if (empty($card_id))
|
||||
{
|
||||
throw new Exception(_("Fiche non trouvée"));
|
||||
}
|
||||
$aArray=$this->getDbconx()->get_array($sql,
|
||||
[$this->getCurrency_id(),
|
||||
$this->getFrom_date(),
|
||||
$this->getTo_date(),
|
||||
$card_id]);
|
||||
|
||||
return $aArray;
|
||||
}
|
||||
|
||||
}
|
||||
85
include/class/filter_data_currency_card_category.class.php
Normal file
85
include/class/filter_data_currency_card_category.class.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
require_once NOALYSS_INCLUDE."/class/data_currency_operation.class.php";
|
||||
/**
|
||||
* \file
|
||||
* \brief filter data in currency from datase , inherit from Data_Currency_Operation, filter on
|
||||
* card category
|
||||
*/
|
||||
|
||||
/**
|
||||
* \class
|
||||
* \brief filter data in currency from datase , inherit from Data_Currency_Operation, filter on
|
||||
* card category
|
||||
*/
|
||||
class Filter_Data_Currency_Card_Category extends Data_Currency_Operation
|
||||
{
|
||||
|
||||
private $card_category;
|
||||
|
||||
function __construct($cn, $from_date, $to_date, $currency_id, $card_category)
|
||||
{
|
||||
parent::__construct($cn, $from_date, $to_date, $currency_id);
|
||||
$this->card_category=$card_category;
|
||||
}
|
||||
|
||||
public function getCard_category()
|
||||
{
|
||||
return $this->card_category;
|
||||
}
|
||||
|
||||
public function setCard_category($card_category)
|
||||
{
|
||||
$this->card_category=$card_category;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief build the SQL condition
|
||||
* @return SQL condition
|
||||
*/
|
||||
public function SQL_Condition()
|
||||
{
|
||||
$sql=parent::SQL_Condition();
|
||||
$sql.=" and jrnx.f_id in ( select f_id from fiche where fd_id=$4)";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns data
|
||||
* @return array
|
||||
*/
|
||||
public function get_data()
|
||||
{
|
||||
$sql=$this->build_SQL();
|
||||
$aArray=$this->getDbconx()->get_array($sql,
|
||||
[$this->getCurrency_id(),
|
||||
$this->getFrom_date(),
|
||||
$this->getTo_date(),
|
||||
$this->card_category]);
|
||||
|
||||
return $aArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -24,120 +24,196 @@
|
|||
* @brief manage the operation in currency : export CSV, export PDF , output in HTML
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE."/class/acc_currency.class.php";
|
||||
|
||||
require_once NOALYSS_INCLUDE."/class/data_currency_operation.class.php";
|
||||
require_once NOALYSS_INCLUDE."/class/filter_data_currency_card.class.php";
|
||||
require_once NOALYSS_INCLUDE."/class/filter_data_currency_accounting.class.php";
|
||||
require_once NOALYSS_INCLUDE."/class/filter_data_currency_card_category.class.php";
|
||||
require_once NOALYSS_INCLUDE."/lib/noalyss_csv.class.php";
|
||||
/**
|
||||
* @class
|
||||
* @brief manage the operation in currency : export CSV , output in HTML
|
||||
*/
|
||||
class Print_Operation_Currency
|
||||
{
|
||||
|
||||
private $from_date;
|
||||
private $to_date;
|
||||
private $currency_id;
|
||||
private $from_account;
|
||||
private $to_account;
|
||||
|
||||
function __construct($cn)
|
||||
private $data_operation;
|
||||
|
||||
|
||||
function __construct(Data_Currency_Operation $data_operation)
|
||||
{
|
||||
|
||||
$this->data_operation=$data_operation;
|
||||
}
|
||||
|
||||
public function getFrom_date()
|
||||
{
|
||||
return $this->from_date;
|
||||
}
|
||||
|
||||
|
||||
public function getTo_date()
|
||||
/**
|
||||
* @brief build a Print_Operation_Currency Object thanks the http request ($_REQUEST) with the right Filter
|
||||
* @param string $p_search possible values are "by_card" if we filter by card, by_account if we
|
||||
* filter by accounting, by_category or empty if we take everything
|
||||
*/
|
||||
static function build($p_search)
|
||||
{
|
||||
return $this->to_date;
|
||||
}
|
||||
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function getFrom_account()
|
||||
{
|
||||
return $this->from_account;
|
||||
}
|
||||
|
||||
public function getTo_account()
|
||||
{
|
||||
return $this->to_account;
|
||||
}
|
||||
|
||||
public function setFrom_date($from_date)
|
||||
{
|
||||
$this->from_date=$from_date;
|
||||
}
|
||||
|
||||
public function setTo_date($to_date)
|
||||
{
|
||||
$this->to_date=$to_date;
|
||||
}
|
||||
|
||||
public function setCurrency($currency)
|
||||
{
|
||||
$this->currency=$currency;
|
||||
}
|
||||
|
||||
public function setFrom_account($from_account)
|
||||
{
|
||||
$this->from_account=$from_account;
|
||||
}
|
||||
public function from_get()
|
||||
{
|
||||
$http=new HttpInput();
|
||||
$this->from_date=$http->get("from_date","date");
|
||||
$this->to_date=$http->get("to_date","date");
|
||||
$this->from_account=$http->get("from_account");
|
||||
$this->to_account=$http->get("to_account");
|
||||
$this->currency_id=$http->get("currency_id","numeric");
|
||||
|
||||
}
|
||||
public function setTo_account($to_account)
|
||||
{
|
||||
$this->to_account=$to_account;
|
||||
$from_account=$http->request("from_account", "string", "");
|
||||
$to_account=$http->request("to_account", "string", "");
|
||||
$currency_code=$http->request("p_currency_code", "string", "0");
|
||||
$from_date=$http->request("from_date", "date", "");
|
||||
$to_date=$http->request("to_date", "date", "");
|
||||
$card=$http->request("card","string","");
|
||||
$card_category_id=$http->request("card_category_id","string","0");
|
||||
$cn=Dossier::connect();
|
||||
if ($p_search=='by_card')
|
||||
{
|
||||
$data_operation=new Filter_Data_Currency_Card($cn,$from_date,$to_date,$currency_code,$card);
|
||||
}
|
||||
elseif ($p_search=='by_accounting')
|
||||
{
|
||||
$data_operation=new Filter_Data_Currency_Accounting($cn,$from_date,
|
||||
$to_date,$currency_code,$from_account,$to_account);
|
||||
}
|
||||
elseif ($p_search=="by_category")
|
||||
{
|
||||
$data_operation=new Filter_Data_Currency_Card_Category($cn,$from_date,$to_date,
|
||||
$currency_code,$card_category_id);
|
||||
}
|
||||
elseif ($p_search=="all")
|
||||
{
|
||||
$data_operation=new Data_Currency_Operation ($cn,$from_date,$to_date,$currency_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("PROC67 Invalid parameter");
|
||||
}
|
||||
|
||||
$print_operation_currency=new Print_Operation_Currency($data_operation);
|
||||
return $print_operation_currency;
|
||||
}
|
||||
/**
|
||||
* @brief Return array of data
|
||||
* @brief return Data_Currency_Operation with a possible filter
|
||||
* @return type
|
||||
*/
|
||||
function get_date()
|
||||
public function getData_operation()
|
||||
{
|
||||
$aArray=$this->cn->get_array("select jr_id,
|
||||
j_date,
|
||||
j_montant,
|
||||
oc_amount,
|
||||
j_poste,
|
||||
jr_comment,
|
||||
jr_internal,
|
||||
jr_pj_number,
|
||||
currency_id,
|
||||
currency_rate,
|
||||
currency_rate_ref,
|
||||
f_id
|
||||
from jrnx
|
||||
join jrn on (jr_grpt_id=jrnx.j_grpt)
|
||||
join operation_currency oc using (j_id)
|
||||
where
|
||||
j_poste >= $1
|
||||
and j_poste <= $2
|
||||
and j_date >= to_date($3 ,'DD.MM.YYYY')
|
||||
and j_date <=to_date($4 ,'DD.MM.YYYY')
|
||||
and currency_id = $5
|
||||
order by j_poste,j_date
|
||||
",[$this->from_account,$this->to_account,$this->from_date,$this->to_date,$this->currency_id]);
|
||||
return $aArray;
|
||||
return $this->data_operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return Data_Currency_Operation with a possible filter
|
||||
* @return type
|
||||
*/
|
||||
public function setData_operation($data_operation)
|
||||
{
|
||||
$this->data_operation=$data_operation;
|
||||
}
|
||||
/**
|
||||
* @brief Display in HTML
|
||||
* @return string
|
||||
*/
|
||||
function export_html()
|
||||
{
|
||||
{
|
||||
$aData=$this->data_operation->get_data();
|
||||
if ( empty ($aData)){
|
||||
return h2(_("Aucune donnée"),'class="error"');
|
||||
}
|
||||
$date=_("Date");
|
||||
$accounting=_("Poste comptable");
|
||||
$card_qcode=_("Fiche");
|
||||
$receipt=_("Pièce");
|
||||
$internal=_("Internal");
|
||||
$comment=_("Libellé");
|
||||
$amount=_("Montant");
|
||||
$amount_currency=_("Mont. Devise");
|
||||
$rate_ref=_("Taux de référence");
|
||||
$rate=_("Taux utilisé");
|
||||
$currency=_("Devise");
|
||||
$r=<<<EOF
|
||||
<table class="result">
|
||||
<tr>
|
||||
<th>{$date}</th>
|
||||
<th>{$accounting}</th>
|
||||
<th>{$card_qcode}</th>
|
||||
<th>{$receipt}</th>
|
||||
<th>{$comment}</th>
|
||||
<th>{$internal}</th>
|
||||
<th>{$currency}</th>
|
||||
<th>{$amount}</th>
|
||||
<th>{$rate}</th>
|
||||
<th>{$rate_ref}</th>
|
||||
<th>{$amount_currency}</th>
|
||||
</tr>
|
||||
|
||||
EOF;
|
||||
$nb_data=count($aData);
|
||||
for ($i=0;$i<$nb_data;$i++)
|
||||
{
|
||||
$r.="<tr>";
|
||||
$r.=td($aData[$i]['j_date']);
|
||||
$r.=td($aData[$i]['j_poste']);
|
||||
$r.=td($aData[$i]['fiche_qcode']);
|
||||
$r.=td($aData[$i]['jr_pj_number']);
|
||||
$r.=td($aData[$i]['jr_comment']);
|
||||
$r.="<td>";
|
||||
$r.=HtmlInput::detail_op($aData[$i]['jr_id'], $aData[$i]['jr_internal']);
|
||||
$r.="</td>";
|
||||
$r.=td($aData[$i]['currency_code_iso']);
|
||||
$r.=td(nbm($aData[$i]['j_montant'],2));
|
||||
$r.=td(round($aData[$i]['currency_rate'],4));
|
||||
$r.=td(round($aData[$i]['currency_rate_ref'],4));
|
||||
$r.=td(nbm($aData[$i]['oc_amount'],2));
|
||||
$r.="</tr>";
|
||||
}
|
||||
$r.="</table>";
|
||||
return $r;
|
||||
|
||||
}
|
||||
function export_csv()
|
||||
/**
|
||||
* @brief Output in CSV
|
||||
*/
|
||||
function export_csv(Noalyss_CSV $export)
|
||||
{
|
||||
$aData=$this->data_operation->get_data();
|
||||
|
||||
}
|
||||
function export_pdf()
|
||||
{
|
||||
$date=_("Date");
|
||||
$accounting=_("Poste comptable");
|
||||
$card_qcode=_("Fiche");
|
||||
$receipt=_("Pièce");
|
||||
$internal=_("Internal");
|
||||
$comment=_("Libellé");
|
||||
$amount=_("Montant");
|
||||
$amount_currency=_("Mont. Devise");
|
||||
$rate_ref=_("Taux de référence");
|
||||
$rate=_("Taux utilisé");
|
||||
$currency=_("Devise");
|
||||
|
||||
$export->write_header(array ($date,
|
||||
$accounting,
|
||||
$card_qcode,
|
||||
$receipt,
|
||||
$comment,
|
||||
$currency,
|
||||
$internal,
|
||||
$amount,
|
||||
$rate,
|
||||
$rate_ref,
|
||||
$amount_currency));
|
||||
$nb_data=count($aData);
|
||||
for ($i=0;$i<$nb_data;$i++)
|
||||
{
|
||||
$export->add($aData[$i]['j_date']);
|
||||
$export->add($aData[$i]['j_poste']);
|
||||
$export->add($aData[$i]['fiche_qcode']);
|
||||
$export->add($aData[$i]['jr_pj_number']);
|
||||
$export->add($aData[$i]['jr_comment']);
|
||||
$export->add($aData[$i]['jr_internal']);
|
||||
$export->add($aData[$i]['currency_code_iso']);
|
||||
$export->add(nbm($aData[$i]['j_montant'],2),"number");
|
||||
$export->add(round($aData[$i]['currency_rate'],4),"number");
|
||||
$export->add(round($aData[$i]['currency_rate_ref'],4),"number");
|
||||
$export->add(nbm($aData[$i]['oc_amount'],2),"number");
|
||||
$export->write();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
||||
|
|
@ -113,7 +113,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
|
|||
if ( ! defined ("SYSINFO_DISPLAY")) {
|
||||
define ("SYSINFO_DISPLAY",TRUE);
|
||||
}
|
||||
define ("DBVERSION",156);
|
||||
define ("DBVERSION",157);
|
||||
define ("MONO_DATABASE",25);
|
||||
define ("DBVERSIONREPO",19);
|
||||
define ('NOTFOUND','--not found--');
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@ if (!defined('ALLOWED'))
|
|||
|
||||
/**
|
||||
* @file
|
||||
* @brief export currency in CSV
|
||||
* @brief export currency operation in CSV see PCUR01
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/class/print_operation_currency.class.php';
|
||||
?>
|
||||
$http=new HttpInput();
|
||||
$export=new Noalyss_Csv(_('devise_export'));
|
||||
$export->send_header();
|
||||
$print_operation_currency=Print_Operation_Currency::build($http->get("search_type"));
|
||||
$print_operation_currency->export_csv($export);
|
||||
|
|
@ -22,40 +22,183 @@
|
|||
if (!defined('ALLOWED'))
|
||||
die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/class/print_operation_currency.class.php';
|
||||
|
||||
require_once NOALYSS_INCLUDE."/lib/select_box.class.php";
|
||||
/**
|
||||
* @file
|
||||
* @brief show all the operation in currency by accounting
|
||||
*/
|
||||
$http=new HttpInput();
|
||||
$action=$http->get("action","string","no");
|
||||
$print_operation_currency=new Print_Operation_Currency($cn);
|
||||
if ( $action == "print")
|
||||
{
|
||||
$print_operation_currency->from_request();
|
||||
}
|
||||
$from_date=new IDate("from_date",$print_operation_currency->getFrom_date());
|
||||
$to_date=new IDate("to_date",$print_operation_currency->getTo_date());
|
||||
|
||||
$from_account=new IPoste("from_account",$print_operation_currency->getFrom_account());
|
||||
|
||||
$to_account=new IPoste("to_account",$print_operation_currency->getTo_account());
|
||||
|
||||
$from_account->name('from_account');
|
||||
$search_type=$http->request("search_type","string","all");
|
||||
$print_operation_currency=Print_Operation_Currency::build($search_type);
|
||||
|
||||
|
||||
$from_date=new IDate("from_date",$print_operation_currency->getData_operation()->getFrom_date());
|
||||
$to_date=new IDate("to_date",$print_operation_currency->getData_operation()->getTo_date());
|
||||
|
||||
$from_account=new IPoste("from_account",$http->request("from_account", "string", ""));
|
||||
|
||||
$to_account=new IPoste("to_account",$http->request("to_account", "string", ""));
|
||||
|
||||
$from_account->name='from_account';
|
||||
$from_account->set_attribute('gDossier',Dossier::id());
|
||||
$from_account->set_attribute('jrn',0);
|
||||
$from_account->set_attribute('account','from_account');
|
||||
|
||||
$to_account->name('to_account');
|
||||
$to_account->name='to_account';
|
||||
$to_account->set_attribute('gDossier',Dossier::id());
|
||||
$to_account->set_attribute('jrn',0);
|
||||
$to_account->set_attribute('account','to_account');
|
||||
|
||||
$acc_currency=new Acc_Currency($cn);
|
||||
$selCurrency=$acc_currency->select_currency();
|
||||
$selCurrency->selected=$print_operation_currency->getCurrency();
|
||||
$selCurrency->selected=$print_operation_currency->getData_operation()->getCurrency_id();
|
||||
|
||||
|
||||
|
||||
if (DEBUGNOALYSS > 1) {
|
||||
echo "print_operation"; var_dump($print_operation_currency->getData_operation());
|
||||
}
|
||||
|
||||
$msg["all"]=_("Aucun filtre");
|
||||
$msg["by_card"]=_("Par fiche");
|
||||
$msg["by_accounting"]=_("Par poste comptable");
|
||||
$msg["by_category"]=_("Par catégorie de fiche");
|
||||
$select_box=new Select_Box("filter_type",$msg[$search_type]);
|
||||
$select_box->add_javascript(_("Aucun filtre"),"show_currency_type_search('all')",true);
|
||||
$select_box->add_javascript(_("Par fiche"),"show_currency_type_search('card_id')",true);
|
||||
$select_box->add_javascript(_("Par poste comptable"),"show_currency_type_search('account_id')",true);
|
||||
$select_box->add_javascript(_("Par catégorie de fiche"),"show_currency_type_search('card_category_div_id')",true);
|
||||
?>
|
||||
<form method="get">
|
||||
<div class="content">
|
||||
<script>
|
||||
function show_currency_type_search(p_div)
|
||||
{
|
||||
let aDiv=["card_category_div_id","card_id","account_id"];
|
||||
|
||||
aDiv.forEach(a=>$(a).hide());
|
||||
let showelt=document.getElementById(p_div);
|
||||
if ( showelt) {
|
||||
showelt.show();
|
||||
}
|
||||
|
||||
$('search_type').value="all";
|
||||
|
||||
|
||||
|
||||
if ( p_div == 'card_category_div_id')
|
||||
{ $('search_type').value="by_category";}
|
||||
|
||||
if ( p_div == 'card_id')
|
||||
{ $('search_type').value="by_card";}
|
||||
if ( p_div == 'account_id')
|
||||
{ $('search_type').value="by_accounting";}
|
||||
|
||||
$('select_boxfilter_type').hide();
|
||||
if ( document.getElementById("select_box_contentfilter_type")) {
|
||||
document.getElementById("select_box_contentfilter_type").hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
<form method="get" action="<?=NOALYSS_URL?>/do.php" onsubmit="waiting_box();return true;">
|
||||
|
||||
<div class="form-group ">
|
||||
<label for="from_date"><?=_("Depuis")?></label>
|
||||
<?=$from_date->input()?>
|
||||
|
||||
<label for="to_date"><?=_("jusque")?></label>
|
||||
<?=$to_date->input()?>
|
||||
|
||||
<label for="currency_code"><?=_("Devise")?></label>
|
||||
<?=$selCurrency->input()?>
|
||||
<?=$select_box->input()?>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
<div id="account_id" style="display:<?=($search_type=="by_accounting")?"block":"none"?>"><!-- comment -->
|
||||
<div class="form-group">
|
||||
<label for="from_account"><?=_("plage de postes comptables")?></label>
|
||||
<?=$from_account->input()?>
|
||||
|
||||
<label for="to_account"><?=_("jusque")?></label>
|
||||
<?=$to_account->input()?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="card_id" style="display:<?=($search_type=="by_card")?"block":"none"?>"><!-- comment -->
|
||||
<div class="form-group">
|
||||
<label for="card"><?=_("Fiche")?></label>
|
||||
<?php
|
||||
// --- card
|
||||
$card = new ICard("card");
|
||||
$card->set_attribute("typecard","all");
|
||||
$card->value=$http->request("card","string","");
|
||||
$card->extra='all';
|
||||
echo $card->input();
|
||||
echo $card->search();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="card_category_div_id" style="display:<?=($search_type=="by_category")?"block":"none"?>"><!-- comment -->
|
||||
<div class="form-group">
|
||||
<label for="card_category_id"><?=_("Fiche")?></label>
|
||||
<?php
|
||||
// --- card_category
|
||||
$card_category=new ISelect ("card_category_id");
|
||||
$card_category->value=$cn->make_array("select fd_id , fd_label from fiche_def order by fd_label");
|
||||
$card_category->selected=$http->request("card_category_id","number",0);
|
||||
?>
|
||||
<?=$card_category->input()?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?=HtmlInput::hidden("action","print")?>
|
||||
<?=HtmlInput::hidden("search_type",$search_type)?>
|
||||
<?=HtmlInput::hidden("ac",$http->request("ac"))?>
|
||||
<?=Dossier::hidden()?>
|
||||
<?=HtmlInput::submit(uniqid(), _("Afficher"))?>
|
||||
</form>
|
||||
<hr><!-- comment -->
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $action !=="print") { return;}
|
||||
///----- There is something to print here
|
||||
|
||||
|
||||
?>
|
||||
<div class="content" style="margin-top:1rem;margin-bottom: 1rem;">
|
||||
<?php
|
||||
try
|
||||
{
|
||||
if (DEBUGNOALYSS > 1) {
|
||||
echo "SQL = ".$print_operation_currency->getData_operation()->build_SQL();
|
||||
}
|
||||
echo $print_operation_currency->export_html();
|
||||
|
||||
}
|
||||
catch (Exception $exc)
|
||||
{
|
||||
echo h2($exc->getMessage(),'class="error"');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="content" style="margin-top:1rem;margin-bottom: 1rem;">
|
||||
<form method="get" id="export_csv" onsubmit="download_document_form(this);return false;" style="display:inline">
|
||||
<?=HtmlInput::hidden("ac", $http->request("ac"))?>
|
||||
<?=HtmlInput::hidden("gDossier", $http->request("gDossier","number"))?>
|
||||
<?=HtmlInput::hidden("act", "CSV:pcur01")?>
|
||||
<?=HtmlInput::array_to_hidden(["from_date","to_date","search_type","from_account","to_account","card","card_category_id","p_currency_code"],$_REQUEST)?>
|
||||
|
||||
<?=HtmlInput::submit(uniqid(),_("Export CSV"))?>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -24,4 +24,3 @@ values ('CSV:pcur01','Export Devise CSV','export_pcur01_csv.php','PR'),
|
|||
insert into version (val,v_description) values (157,'new feature Currency search');
|
||||
commit ;
|
||||
|
||||
commit;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
export PGCLUSTER=10/main
|
||||
DOSSIER_TEST=rel70dossier25
|
||||
FILE_TEST=dossiertest210204-1402.sql
|
||||
FILE_TEST=dossiertest210418-1503.sql
|
||||
|
||||
dropdb $DOSSIER_TEST
|
||||
createdb $DOSSIER_TEST
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ $g_parameter = new Noalyss_Parameter_Folder($g_connection);
|
|||
$_SESSION[SESSION_KEY.'g_user']='admin';
|
||||
$_SESSION[SESSION_KEY.'g_pass']='phpcompta';
|
||||
$_SESSION[SESSION_KEY.'g_pagesize']='50';
|
||||
$_SESSION[SESSION_KEY.'csv_fieldsep']='0';
|
||||
$_SESSION[SESSION_KEY.'csv_decimal']='1';
|
||||
$_SESSION[SESSION_KEY.'csv_encoding']='utf8';
|
||||
$g_user=new User($g_connection);
|
||||
|
||||
require_once __DIR__.'/facility.class.php';
|
||||
|
|
|
|||
208
unit-test/include/class/print_operation_currencyTest.php
Normal file
208
unit-test/include/class/print_operation_currencyTest.php
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief test cprint_currency01.inc.php and, Print_Operation_Currency
|
||||
*/
|
||||
|
||||
class Print_Operation_CurrencyTest extends TestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
include 'global.php';
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Test Filter_Data_Currency_Card_Category
|
||||
* @covers Filter_Data_Currency_Card_Category
|
||||
*/
|
||||
function testFilter_data_currency_card_categoryTest()
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$from_date='01.01.2000';
|
||||
$to_date='01.01.2099';
|
||||
$currency_id=0;
|
||||
$card_category=4;
|
||||
$object=new Filter_Data_Currency_Card_Category($cn,
|
||||
$from_date,
|
||||
$to_date,
|
||||
$currency_id,
|
||||
$card_category);
|
||||
$sql=$object->SQL_Condition();
|
||||
|
||||
$this->assertContains(" and jrnx.f_id in ( select f_id from fiche where fd_id=$4)",$sql);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),29,"operation in EURO");
|
||||
|
||||
|
||||
$object->setCurrency_id(1);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),3,"operations in Dollars");
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Test Data_Currency_Operation
|
||||
* @covers Data_Currency_Operation
|
||||
*/
|
||||
function testData_currency_operationTest()
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$from_date='01.01.2000';
|
||||
$to_date='01.01.2099';
|
||||
$currency_id=0;
|
||||
|
||||
$object=new Data_Currency_Operation($cn,
|
||||
$from_date,
|
||||
$to_date,
|
||||
$currency_id
|
||||
);
|
||||
$sql=$object->SQL_Condition();
|
||||
|
||||
$this->assertContains("where jrn.currency_id = $1 and",$sql);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),142,"operation in EURO");
|
||||
|
||||
|
||||
$object->setCurrency_id(1);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),21,"operations in Dollars");
|
||||
}
|
||||
/**
|
||||
* @brief test Filter_Data_Currency_Card
|
||||
* @covers Filter_Data_Currency_Card
|
||||
*/
|
||||
function testFilter_data_currency_cardTest()
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$from_date='01.01.2000';
|
||||
$to_date='01.01.2099';
|
||||
$currency_id=0;
|
||||
$card='FOURNI';
|
||||
$object=new Filter_Data_Currency_Card($cn,
|
||||
$from_date,
|
||||
$to_date,
|
||||
$currency_id,
|
||||
$card);
|
||||
$sql=$object->SQL_Condition();
|
||||
|
||||
$this->assertContains("and f_id=$4",$sql);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),4,"operation in EURO");
|
||||
|
||||
|
||||
$object->setCurrency_id(1);
|
||||
$object->setCard("FOURNI1");
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(count($array),3,"operations in Dollars");
|
||||
}
|
||||
/**
|
||||
* @brief test Filter_Data_Currency_Card_Accounting
|
||||
* @covers Filter_Data_Currency_Card_Accounting
|
||||
*/
|
||||
function testFilter_data_currency_accounting()
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$from_date='01.01.2000';
|
||||
$to_date='01.01.2099';
|
||||
$currency_id=0;
|
||||
$from_poste='40';
|
||||
$to_poste='450';
|
||||
$object=new Filter_Data_Currency_Accounting($cn,
|
||||
$from_date,
|
||||
$to_date,
|
||||
$currency_id,
|
||||
$from_poste,
|
||||
$to_poste);
|
||||
|
||||
$sql=$object->SQL_Condition();
|
||||
$this->assertContains("and j_poste >= $4 and j_poste <= $5",$sql);
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(72,count($array),"operation in EURO");
|
||||
|
||||
|
||||
$object->setCurrency_id(1);
|
||||
|
||||
$array=$object->get_data();
|
||||
$this->assertEquals(10,count($array),"operations in Dollars");
|
||||
}
|
||||
function testPrint_operation_currency()
|
||||
{
|
||||
$_REQUEST['from_date']='01.01.2000';
|
||||
$_REQUEST['to_date']='01.01.2099';
|
||||
$_REQUEST['p_currency_code']=0;
|
||||
$_REQUEST['from_account']='40';
|
||||
$_REQUEST['to_account']='450';
|
||||
$_REQUEST['card']='FOURNI1';
|
||||
$_REQUEST['search_type']='by_accounting';
|
||||
|
||||
$print_operation=Print_Operation_Currency::build("by_accounting");
|
||||
$array=$print_operation->getData_operation()->get_data();
|
||||
$export=new Noalyss_CSV("test");
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_accounting.html",
|
||||
Noalyss\Facility::page_start().$print_operation->export_html());
|
||||
ob_start();
|
||||
$print_operation->export_csv($export);
|
||||
$csv=ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_accounting.csv",
|
||||
$csv);
|
||||
|
||||
$this->assertEquals(72,count($array),"by_accounting operation in EURO");
|
||||
|
||||
$_REQUEST['p_currency_code']=1;
|
||||
$print_operation=Print_Operation_Currency::build("by_card");
|
||||
$array=$print_operation->getData_operation()->get_data();
|
||||
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_card.html",
|
||||
Noalyss\Facility::page_start().$print_operation->export_html());
|
||||
ob_start();
|
||||
$print_operation->export_csv($export);
|
||||
$csv=ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_card.csv",
|
||||
$csv);
|
||||
|
||||
|
||||
|
||||
$this->assertEquals(3,count($array),"by_card operation in USD");
|
||||
|
||||
$print_operation=Print_Operation_Currency::build("all");
|
||||
$array=$print_operation->getData_operation()->get_data();
|
||||
$this->assertEquals(count($array),21,"all operations in Dollars");
|
||||
ob_start();
|
||||
$print_operation->export_csv($export);
|
||||
$csv=ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_all.csv",
|
||||
$csv) ;
|
||||
|
||||
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_all.html",
|
||||
Noalyss\Facility::page_start().$print_operation->export_html());
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue