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:
commit
b81a2efdd7
1 changed files with 13 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue