Support including open accounting entries in reports

This is optional and crontrolled by a checkbox. Currently only for
balance and results reports.

In doing this, also restructure the get_balance_query function to use
more query generation and less hardcoded strings, as it became completely
unreadable after trying to merge this in. And generally format it for
better readability.
Add ability to view open entries in ledger report as well

Open items are indicated with an asterisk after the amount.