Order payable/receivable lines by maturity date or move date
I think the best is to have an order method for maturity date that use a COALESCE with the move date.
The same should be done in the window of get_payable_receivable_balance
.
Ref: https://discuss.tryton.org/t/payable-receivable-lines-balance-always-increasing/6684