The General Journal Reports page was failing with "invalid input syntax
for integer" on ar.invnumber. This field is type but it is cast to
integer in the query. I had, perhaps foolishly, set it to 2010-03-08 on
one of my invoices, causing the cast to fail. The query is a union of
queries on gl, ar and ap and each of gl.reference, ar.invnumber and
ap.invnumber were cast to int, despite all being text fields and all
being compared with LIKE in the where clauses.
With this change the casts to int are removed and the report is
generated without error.