Task #448 : delete unused currency

This commit is contained in:
Dany De Bontridder 2018-05-11 19:53:09 +02:00
parent 1096958e3d
commit 694c9769c3

View file

@ -82,6 +82,18 @@ class V_Currency_Last_Value_SQL extends Data_SQL
public function delete()
{
/* check if currency is used */
$is_used = $this->cn->get_value("select count(*) from jrn where currency_id=$1",[$this->currency_id]);
/* if not used , we can delete it */
if ( $is_used <> 0 ) { throw new Exception (_("Devise utilisée")); }
// We cannot delete EUR
if ( $this->currency_id == -1 ) {
throw new Exception(_("EUR ne peut pas être effacé"));
}
$this->cn->exec_sql("delete from currency_history where currency_id=$1",[$this->currency_id]);
$this->cn->exec_sql("delete from currency where id=$1",[$this->currency_id]);
}