diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 649b7b0c093..686f714827a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -463,11 +463,17 @@ class Facture extends CommonInvoice $this->status = self::STATUS_DRAFT; $this->statut = self::STATUS_DRAFT; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { - list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + if (!empty($this->multicurrency_code)) { + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate of multicurrency_code only if not using original rate) + if (empty($this->multicurrency_tx)) { + // If original rate is not set, we take a default value from date + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + } else { + // original rate multicurrency_tx and multicurrency_code are set, we use them + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } } else { - $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + $this->fk_multicurrency = 0; } if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency;