Payable/Receivable lines balance always increasing

I am wondering if I have my payment methods configured wrong, or if this is a bug.

In payment methods i put my bank account in both credit and debit.
I also tested this with demo, where I put the cash account in credit and debit of the payment method used to pay the invoice.

I relate from party – relate → payable/receivable lines.
Then I sort by reconciliation to get the moves in the right order.

Here is an example of the list I get:

Maturity Date Amount Payable/Receivable Balance Move/Record Name Move Origin Move Origin/Record Name Reconciliation/Record Name
-18643.97 0 83 Invoice 12796 33
2022-09-09 18643.97 18643.97 42 Invoice 12796 33
-18643.97 18643.97 406 Invoice 12934 195
2022-12-03 18643.97 37287.94 343 Invoice 12934 195
-18643.97 37287.94 709 Invoice 13067 344
2023-03-09 18643.97 55931.91 650 Invoice 13067 344
-18643.97 55931.91 1149 Invoice 13226 525
2023-06-08 18643.97 74575.88 1079 Invoice 13226 525
-18643.97 74575.88 1432 Invoice 13315 624
2023-07-31 18643.97 93219.85 1290 Invoice 13315 624
-18643.97 93219.85 1639 Invoice 13400 718
2023-09-24 18643.97 111863.82 1577 Invoice 13400 718
-18643.97 111863.82 1737 Invoice 13443 760
2023-10-15 18643.97 130507.79 1709 Invoice 13443 760

Note the balance, it is always going up.
Also tested this on demo, same result.

Is this the expected behavior, a misconfiguration or a bug?

PS: These invoices have been paid using the pay button on the invoices.

IMHO it looks ok. The sort order is a little bit irritating, because the payment line is on top of the line to pay. E.g. reconciliation 33 should be ordered like this:

Amount      Balance    Move
 18643.97   18643.97   Move 42
-18643.97   0          Move 83

It is probably obvious, but I should point out that in this case I checked the reconciled check-box to get the full history of this party.

I guess I could have sorted by move number, which would have been more intuitive in this case. The right way would have been to sort by effective date, but there is no such field. But this is not my issue.

My issue is that this is a customer who has all their invoices paid (thus the number in the reconciliation field of every record), yet the Balance at 2023-10-15 is 130507.79, while there is no unpaid invoice/line for this customer, and the customer only ever order 18643.97.

I would have expected to see the balance to 18643.97 and after the payment back to 0 in each of the lines.

I think the problem is that we order by maturity date, move date and id in the view but also to compute the accumulate balance.
But all move lines do not have a maturity date (like payments) so they are put at the end. I think it will be cleared if you left the original order.

See Order payable/receivable lines by maturity date or move date (#12722) · Issues · Tryton / Tryton · GitLab

Now I understood that the sorting and the computation of the balance are actually the same problem.