diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7818ab2fb11..a3b0810efc6 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -663,7 +663,7 @@ abstract class CommonInvoice extends CommonObject * conditions and billing date. * * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. - * @return integer Date limite de reglement si ok, <0 si ko + * @return integer Date limit of payment if OK, <0 if KO */ public function calculate_date_lim_reglement($cond_reglement = 0) { @@ -674,6 +674,9 @@ abstract class CommonInvoice extends CommonObject if (!$cond_reglement) { $cond_reglement = $this->cond_reglement_id; } + if (!$cond_reglement) { + return $this->date; + } $cdr_nbjour = 0; $cdr_type = 0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2e766fb5cdc..bc0c7b9e232 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3069,16 +3069,17 @@ class FactureFournisseur extends CommonInvoice $object->fk_facture_source = 0; $object->date_creation = ''; $object->date_validation = ''; - $object->date = (empty($this->date) ? '' : $this->date); - $object->date_echeance = ''; + $object->date = (empty($this->date) ? dol_now() : $this->date); $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { + if (getDolGlobalInt('MAIN_DONT_KEEP_NOTE_ON_CLONING') == 1) { $object->note_private = ''; $object->note_public = ''; } + $object->date_echeance = $object->calculate_date_lim_reglement(); + // Loop on each line of new invoice foreach ($object->lines as $i => $line) { if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts