diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f9bb52ff088..6ec3f776cf0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1341,7 +1341,7 @@ if (empty($reshook)) { } } - // NOTE: Pb with situation invoice + // NOTE: Pb with situation invoice when INVOICE_USE_SITUATION=1 (legacy mode) // NOTE: fields total on situation invoice are stored as cumulative values on total of lines (bad) but delta on invoice total // NOTE: fields total on credit note are stored as delta both on total of lines and on invoice total (good) // NOTE: fields situation_percent on situation invoice are stored as cumulative values on lines (bad) @@ -3317,6 +3317,7 @@ if (empty($reshook)) { } if (GETPOST('all_progress') != "") { $all_progress = GETPOSTINT('all_progress'); + if ($all_progress > 100) $all_progress = 100; foreach ($object->lines as $line) { if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { $percent = $line->getAllPrevProgress($object->id); @@ -3328,7 +3329,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'warnings'); $result = -1; } else { - $object->update_percent($line, GETPOSTINT('all_progress'), false); + $object->update_percent($line, $all_progress, false); } } $object->update_price(1); @@ -6822,7 +6823,7 @@ if ($action == 'create') { } // Create next situation invoice - if ($usercancreate && ($object->type == 5) && ($object->status == 1 || $object->status == 2)) { + if ($usercancreate && ($object->type == Facture::TYPE_SITUATION) && ($object->status == 1 || $object->status == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { print ''.$langs->trans('CreateNextSituationInvoice').''; } elseif (!$object->is_last_in_cycle()) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2b56ead9b18..d6baacd4cb1 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -2418,5 +2418,5 @@ abstract class CommonInvoiceLine extends CommonObjectLine /** * @var float Situation advance percentage (default 100 for standard invoices) */ - public $situation_percent; + public $situation_percent = 100; }