From f872585ea26cba4d86dcc11dd2798798e3ba1d87 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 8 Jun 2022 01:02:02 +0200 Subject: [PATCH 1/3] Fix #21150 - Regression Can't insert manual lines Fix #21150 - Regression Can not insert manual lines for automatically created transactions to the general ledger, this was possible before. --- .../accountancy/class/bookkeeping.class.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5f3def1d3ee..dc4c4992bc0 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1722,6 +1722,38 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { + // Add an empty line when transaction is validated to permit to add new line manually + if ($mode != "_tmp") { + $line = new BookKeepingLine(); + + $line->id = $obj->rowid; + + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->amount; + $line->amount = $obj->amount; + $line->sens = $obj->sens; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $obj->date_creation; + $line->date_modification = $obj->date_modification; + $line->date_export = $obj->date_export; + $line->date_validation = $obj->date_validation; + + $this->linesmvt[] = $line; + } while ($obj = $this->db->fetch_object($result)) { $line = new BookKeepingLine(); From 0641b661183654eaf57e498df590a1410581c125 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 8 Jun 2022 01:39:53 +0200 Subject: [PATCH 2/3] Clean code --- .../accountancy/class/bookkeeping.class.php | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dc4c4992bc0..000ac06f3c6 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1725,33 +1725,6 @@ class BookKeeping extends CommonObject // Add an empty line when transaction is validated to permit to add new line manually if ($mode != "_tmp") { $line = new BookKeepingLine(); - - $line->id = $obj->rowid; - - $line->doc_date = $this->db->jdate($obj->doc_date); - $line->doc_type = $obj->doc_type; - $line->doc_ref = $obj->doc_ref; - $line->fk_doc = $obj->fk_doc; - $line->fk_docdet = $obj->fk_docdet; - $line->thirdparty_code = $obj->thirdparty_code; - $line->subledger_account = $obj->subledger_account; - $line->subledger_label = $obj->subledger_label; - $line->numero_compte = $obj->numero_compte; - $line->label_compte = $obj->label_compte; - $line->label_operation = $obj->label_operation; - $line->debit = $obj->debit; - $line->credit = $obj->credit; - $line->montant = $obj->amount; - $line->amount = $obj->amount; - $line->sens = $obj->sens; - $line->code_journal = $obj->code_journal; - $line->journal_label = $obj->journal_label; - $line->piece_num = $obj->piece_num; - $line->date_creation = $obj->date_creation; - $line->date_modification = $obj->date_modification; - $line->date_export = $obj->date_export; - $line->date_validation = $obj->date_validation; - $this->linesmvt[] = $line; } while ($obj = $this->db->fetch_object($result)) { From 7a20b3dceccdc5476b4b4ffec00ee60067b49575 Mon Sep 17 00:00:00 2001 From: bagtaib Date: Wed, 8 Jun 2022 15:35:07 +0200 Subject: [PATCH 3/3] FIX #21140 Conflicts: htdocs/societe/class/societe.class.php --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3d1637019e9..7c5773363c4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -890,7 +890,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_buy"; $sql .= ", accountancy_code_sell"; } - $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; + $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".((int) $this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null");