Wrong balance when splitting account into children accounts

Has someone already created new children accounts to fit accountant chart of account?

=> Account 6226 split into 62260, 62261, 62262…

The problem is that I have already some lines in the parent account (here 6226) and even if it is balanced, the final balance is wrong as the moves are accounted twice: those of the parent and those of the children.

Example:

The final balance is still at 4599.52 even if its lines have been transferred to children accounts.

Can force closing the parent account fix it? Would it have side effects?

The problem is because you have some moves in the parent account. You move the parent moves into the children accounts and then close the parent account to avoid creating new moves on the parent.

After that the balance will be corect.

I did credit the parent account and debit the children. Is that what you mean?

By doing so, I end up with a parent account with as many debit amount as credit, as shown in my previous screenshot. Looks good except that its final balance takes into account children.

Now, I cannot close (by the user interface) the parent account since there still lives original moves. Should I force close by SQL query hoping to get a correct balance?

I do not understand why you say that the balance is wrong. For me the numbers look correct. The debit/credit are always only for the account and the balance is cumulateur with the children.

Once an account has moves, you can no more close it. At best you deactivate it by setting an end date but it will require to end also its children accounts.
This could be an improvement to add a way to prevent to use an account for future move.

In the last column, the final balance of the parent is also the sum of the final balance of the children.

The consequence is that the grand balance at the very bottom right is not zero. Which is not what we expect a balance to be.

But the balance accumulate the balance of its children. Nothing wrong here.

So in your opinion it is OK not to have a grand balance not equal to zero at the bottom?

At the bottom of what?
The balance of the root is zero.

Last column, last row (not shown in my screenshot).

Next to the cumulated credit which is correctly the same as cumulated debit (of all the accounts).

The start balance is zero, yes.

In other words, the “grand final balance” is not equal to cumulated debit minus cumulated credit.

Hum it seems you are looking at the general ledger and not the chart of accounts.

I can see that as it is a flat structure that using the balance of the account (which is designed for the tree structure) may not be the best option.
We should probably have a contextual flag to calculate the account balance for flat structure.

I filled General Ledger balance must not include children balance (#14294) · Issues · Tryton / Tryton · GitLab

I think we can just use the “End Date”.

Sorry about not clarifying. By moving I mean you should use an sql query to update the moves accounts where the parent is used and use a children for it. After running such query you will be able to close the account and the balance will show as you expect.

Such operation can corrupt the data if for example a fiscal year has been closed, the deferral values may be no more correct.

And I consider the need for specifying the chart of account by adding new children as the need evolves is a legitimate use case.

So touching SQL db for that should be prohibited from a user point of view, in my opinion.

By the way, I may have noticed duplicate moves exported to the general ledger report, due to the same dual scan of the tree structure. But I will check again when I get back on Tryton!

My bad, the general ledger report is correct. No duplicate move in parent account. Every thing is correct on that side.

When trying to set an End Date to the parent account (in the future or in the past), I get the following error (in French):

La valeur « 62260 - Honoraires comptables, 62261 - Honoraires juridiques, 62262 - Honoraires AGO » du champ « Enfants » sur l'enregistrement « 6226 - Honoraires » de « Compte » n'est pas valide selon son domaine.

If you set an end date to the parent, you must also set it also to its children.
So end date is not a solution. So there is only the closing of the account but instead of being a boolean it should be based on a date.

Is it allowed to close an account containing move lines once the fiscal year is closed?

So that one has just to wait…

Not for now because it checks for any line, but it could be