I suggest to create a bug report in our Issue Tracker and attach HAL code that is causing compile errors. Just looking at your code I don't see anything wrong with it so it likely should be investigated.
Actually a new version of this bug is SL>>Reports>>Periodic customer statement "accumulates" amounts
Not sure why it was duplicated, I clicked "submit"only once....