Recalculate gl account balances

This will repost the GL accounts with the transactions from all periods.

Execute this query in PGAdmin

UPDATE gl_accounts
SET last_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}',
this_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}',
next_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}',
foreign_last_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}',
foreign_this_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}',
foreign_next_year = '{0.00,0,0,0,0,0,0,0.00,0,0,0,0,0}';

UPDATE gl_accounts AS a SET
last_year = r.last_year,
this_year = r.this_year,
next_year = r.next_year,
foreign_last_year = r.frn_last_year,
foreign_this_year = r.frn_this_year,
foreign_next_year = r.frn_next_year
FROM gl_reallocate_balances() AS r
WHERE a.division = r.division
AND a.account_no = r.account_no
AND a.currency = r.currency