Merge pull request #38613 from aspangaro/23_fixclosure

FIX Accountancy - Closure - Income and deficit accounts should not prevent the closing process if they contain data
This commit is contained in:
Alexandre SPANGARO 2026-06-08 22:19:55 +02:00 committed by GitHub
commit b81a2efdd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -352,6 +352,16 @@ class BookKeeping extends CommonObject
}
$sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features
// Allow duplicates in incomes or loss statements
$accountProfit = getDolGlobalString('ACCOUNTING_RESULT_PROFIT');
$accountLoss = getDolGlobalString('ACCOUNTING_RESULT_LOSS');
if (($accountProfit && $this->numero_compte === trim($accountProfit)) ||
($accountLoss && $this->numero_compte === trim($accountLoss))) {
// If the account being processed corresponds to the “Profit” or “Loss” constant, the detection is bypassed
$sql .= " AND 1 = 2";
}
$resql = $this->db->query($sql);
if ($resql) {
@ -477,7 +487,9 @@ class BookKeeping extends CommonObject
$result = -3;
$error++;
$this->error = 'BookkeepingRecordAlreadyExists';
dol_syslog(__METHOD__.' '.$this->error, LOG_WARNING);
$this->errors[] = $langs->trans('WarningBookkeepingRecordAlreadyExists', $this->doc_type, $this->fk_doc, $this->fk_docdet);
dol_syslog(get_class($this).":: create duplicate record detected: doc_type={$this->doc_type}, doc_ref={$this->doc_ref}, fk_doc={((int) $this->fk_doc)}, fk_docdet={((int) $this->fk_docdet)}", LOG_WARNING);
}
} else {
$result = -5;