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 Accounting Closure Duplicates, Subledger accounts, Account Labels and more... Update bookkeeping.class.php #32194

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

josett225
Copy link
Contributor

FIX I did further testing and investigation and I fixed the following issues that stop doing a full closure without duplicate lines generated by an unclean database :

- different label_compte with same account number
- removing label_compte is raising an issue and the code in the line around 2770 $bookkeeping->label_compte = $obj->label_compte;
- different subledger_label with same subledger_account
- empty versus null values for subledger_label and subledger_account
- opening_balance is 0 as it creates a bookkeeping entry for now.  

See other comments here on this draft: #30653
See also Fix required here : FIX - Update Accounting closure with missing too many A-Nouveau #30039)](#30039)

FIX I did further testing and investigation and I fixed the following issues that stop doing a full closure without duplicate lines generated by an unclean database :

    - different label_compte with same account number
    - removing label_compte is raising an issue and the code in the line around 2770 $bookkeeping->label_compte = $obj->label_compte;
    - different subledger_label with same subledger_account
    - empty versus null values for subledger_label and subledger_account
    - opening_balance is 0 as it creates a bookkeeping entry for now.  

FIX - Update Accounting closure with missing too many A-Nouveau Dolibarr#30039)
@josett225 josett225 changed the title FIX Accounting Closure Duplicates, Last account Labels and more... Update bookkeeping.class.php FIX Accounting Closure Duplicates, Subledger accounts, Account Labels and more... Update bookkeeping.class.php Dec 1, 2024
if ($separate_auxiliary_account) {
$sql .= ' ,t.subledger_account, t.subledger_label';
$sql .= " , NULLIF(t.subledger_account, '')";
Copy link
Member

Choose a reason for hiding this comment

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

Adding a function call into a group by is strange. DoesYour fix work if you replace this with
$sql .= ", subledger_account";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @eldy

It does not work if you remove the NULLIF function. We still get duplicates.
Here are some screenshots with and without:

SQLDIFFWITHOUTISNULLINGROUP
SQLDIFFWITHISNULLINGROUP

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Dec 3, 2024
@josett225
Copy link
Contributor Author

Hi @eldy
Just answered in your comment.

@eldy
Copy link
Member

eldy commented Dec 5, 2024

@aspangaro is this patch looks ok for you ?

@aspangaro
Copy link
Member

It looks pretty good to me, and completes my patch for the sub-accounts section.

I'll do a few tests and confirm that.

@josett225
Copy link
Contributor Author

josett225 commented Dec 7, 2024

Hi @aspangaro and @eldy
To work correctly the PR #30039 has to be validated also.
Could you please validate it or do you want me to add it to this PR and I cancel the other one

@eldy
Copy link
Member

eldy commented Dec 8, 2024

Hi @aspangaro and @eldy
To work correctly the PR #30039 has to be validated also.
Could you please validate it or do you want me to add it to this PR and I cancel the other one

Yes please, close old one and merge it into one request (this pr), so it will be easier to follow all the changes of the fix...

This will help to better and understand and follow this fix
@@ -2732,23 +2736,38 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->doc_ref = $fiscal_period->label;
Copy link
Member

Choose a reason for hiding this comment

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

I still have an interrogation with this replacement.
Why $fiscal_period->label instead of $new_fiscal_period->label ? Done on prupose ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @eldy
Yes it is done on purpose.

Let's assume we are reporting AN from 2023 to 2024.
doc_ref has to get the value $fiscal_period->label (e.g. ANNEE 2023) and label_operation is getting the $new_fiscal_period->label (e.g. ANNEE 2024).

In some Accounting software the values are RAN (Report A-Nouveau) for doc_ref and the label_operation is A.N. au 01/01/2024

I followed what was already there in term of labelling maybe done by @aspangaro

I found a small bug in the meantime as for the income, I did not change it for the income AN report.

I will change it as soon as you validate it.

@alexandre-janniaux
Copy link
Contributor

Just so that I follow correctly, this is still about fixing the option where the details of the RAN are merged in a single transaction per subaccount, not yet the new feature where the details of the RAN would be integrated one by one into the AN journal (which would actually duplicates the operation label/account I guess) ?

@josett225
Copy link
Contributor Author

josett225 commented Dec 9, 2024

Yes this is correct for now this is a balance mode with subledgers. Doing it in a more detailed view requires a bit more of work as there are several issues as taking in consideration the 'lettrage' for e.g. and some other aspects. I am working right now with 2 accounting experts as my first version I did was a bit incomplete. I used the label and amount to avoid duplicates but it was not perfect at all. So this is requiring a bit more of work.

@eldy eldy merged commit 492505a into Dolibarr:19.0 Dec 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants