Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - Update Accounting closure with missing too many A-Nouveau #30039

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

// Class
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
Expand Down Expand Up @@ -327,7 +328,7 @@ public function create(User $user, $notrigger = false)
$this->piece_num = 0;

// First check if line not yet already in bookkeeping.
// Note that we must include 'doc_type - fk_doc - numero_compte - label' to be sure to have unicity of line (because we may have several lines
// Note that we must include 'doc_type - fk_doc - numero_compte - label - montant - compte tiers - label compte tiers' to be sure to have unicity of line (because we may have several lines
// with same doc_type, fk_doc, numero_compte for 1 invoice line when using localtaxes with same account)
// WARNING: This is not reliable, label may have been modified. This is just a small protection.
// The page that make transfer make the test on couple (doc_type - fk_doc) only.
Expand All @@ -341,6 +342,9 @@ public function create(User $user, $notrigger = false)
}
$sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'";
$sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'";
$sql .= " AND montant = '".((float) $this->montant)."'";
Copy link
Member

@eldy eldy Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you introduce this lines, it means you want to remove the protection.
Without the protection, it will be possible to have duplicate line with same
doc_type, doc id, entity, account number and account label
This protection is not very good because we should have a protection on
doc_type, doc id, entity, account number. But it is better than nothing.
I don't see the use cases when we need to have duplicates on this 4 fields. Can you provide an example of values for this 4 parameters and the use case that explain why we need to be able to insert such duplicate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eldy You were right

$sql .= " AND subledger_account = '".$this->db->escape($this->subledger_account)."'";
$sql .= " AND subledger_label = '".$this->db->escape($this->subledger_label)."'";
$sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features

$resql = $this->db->query($sql);
Expand Down
Loading