Fix credit, debit and balance computation on SQLite

issue3877
review8271002
(grafted from 2510104559a7deeb9e39e798a991961072d1064a)

--HG--
branch : 2.4
extra : source : 2510104559a7deeb9e39e798a991961072d1064a