diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 82015cd539a..3936dc3e824 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -450,7 +450,19 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - header("Location: " . $backtopage . "?sortfield=t.piece_num&sortorder=asc" . ($type ? '&type='.$type : '')); + // Retrieve the actual final part number (not the temporary number) + $piece_num = $object->piece_num; + + $linkEntry = ''.$langs->trans('NumMvts').': '.(int) $piece_num.''; + setEventMessages($langs->trans('RecordSaved').' - '.$linkEntry, null, 'mesgs', '', 1); + + if (getDolGlobalInt('ACCOUNTANCY_VALID_REDIRECT_TO_CARD')) { + // Redirection to the validated entry record + header("Location: ".$_SERVER["PHP_SELF"]."?piece_num=".(int) $piece_num); + } else { + // Default behavior: return on journal view + header("Location: ".$backtopage."?sortfield=t.piece_num&sortorder=asc".($type ? '&type='.$type : '')); + } exit; } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 603424c4ba7..303d0883cb2 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2258,6 +2258,9 @@ class BookKeeping extends CommonObject $error++; } + // Store the new piece_num so caller can use it after transformTransaction() + $this->piece_num = $next_piecenum; + if (!$error) { // Delete if there is an empty line $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0"; diff --git a/htdocs/accountancy/class/bookkeepingtemplateline.class.php b/htdocs/accountancy/class/bookkeepingtemplateline.class.php index df470a812c7..1f418afe9d6 100644 --- a/htdocs/accountancy/class/bookkeepingtemplateline.class.php +++ b/htdocs/accountancy/class/bookkeepingtemplateline.class.php @@ -132,6 +132,11 @@ class BookkeepingTemplateLine extends CommonObject */ public $subledger_label; + /** + * @var ?string label operation + */ + public $operation_label; + /** * @var string Debit amount (stored as string for precision) */