From 0582653a679d0da3399f399ed39d634d46c99d57 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 10:55:03 +0100 Subject: [PATCH 1/5] FIX : get multicurrency infos of propal when create order from propal with "WORKFLOW_PROPAL_AUTOCREATE_ORDER" conf --- htdocs/commande/class/commande.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 54e50baa9f7..2e20567e4c5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1355,6 +1355,27 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($conf->multicurrency->enabled)) { + if (!empty($object->multicurrency_code)) { + $this->multicurrency_code = $object->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($object->multicurrency_tx)) { + $this->multicurrency_tx = $object->multicurrency_tx; + } + + 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_commande); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + } + // get extrafields from original line $object->fetch_optionals(); From 3b9d39c1d2fae893b272532167353a64ba866ba1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 21 Dec 2022 10:00:26 +0000 Subject: [PATCH 2/5] Fixing style errors. --- htdocs/commande/class/commande.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2e20567e4c5..12054c3ccb8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1355,7 +1355,7 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) if (!empty($conf->multicurrency->enabled)) { if (!empty($object->multicurrency_code)) { $this->multicurrency_code = $object->multicurrency_code; @@ -1364,16 +1364,16 @@ class Commande extends CommonOrder $this->multicurrency_tx = $object->multicurrency_tx; } - 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_commande); - } else { - $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - } - if (empty($this->fk_multicurrency)) { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + 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_commande); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } } // get extrafields from original line From a48d1ae8e392cc2b2ad9d9c324983d1e6193c1b1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 12:31:24 +0100 Subject: [PATCH 3/5] FIX : multicurrency_tx and not currency_tx --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0d7cf53a5d..4f3d9230899 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2929,8 +2929,8 @@ if ($action == 'create') { $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (!empty($conf->multicurrency->enabled)) { - $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); - $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); } //Replicate extrafields From 69b0cf9bcfeeab25166131128b3f229477255771 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 14:05:54 +0100 Subject: [PATCH 4/5] FIX : include class multicurrency --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 12054c3ccb8..d56eeb2af0e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1281,6 +1281,7 @@ class Commande extends CommonOrder { global $conf, $hookmanager; + dol_include_once('/multicurrency/class/multicurrency.class.php'); dol_include_once('/core/class/extrafields.class.php'); $error = 0; From 2c7e0afabd7c04cbde50fcd9734edc75ac60cb35 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 17:17:33 +0100 Subject: [PATCH 5/5] FIX : travis --- htdocs/commande/class/commande.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d56eeb2af0e..33de271b45d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1366,7 +1366,9 @@ class Commande extends CommonOrder } 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_commande); + $tmparray = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date_commande); + $this->fk_multicurrency = $tmparray[0]; + $this->multicurrency_tx = $tmparray[1]; } else { $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); }