Fix due date for supplier invoice not correctly set on clone

This commit is contained in:
Laurent Destailleur 2023-02-21 12:14:34 +01:00
parent 3a561d78b9
commit a64c41c4ba
2 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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