There were a few issues:
* we didn't always take the last statement as a reference: if we had
two statement the same day, we needed to take the last one. Adding the
`id` in the ORDER BY actually also improves the performances (4s to
2.5s on the test database for all journals)
* If there is no statement, we didn't display the balance at all because
`statement.first_line_index` is NULL, therefore the `>=` operator
returned NULL and the condition was falsy
opw-3268956
opw-3269493
opw-3268950
opw-3270450
opw-3270143
and many more...
closesodoo/odoo#118368
X-original-commit: 5c4fb4cd15a371c0648ae4aee160f9f858b89445
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>