Hello Paul,
I tried to repeat the manually what your routine I guess it does and I wasn't able to experience the behaviour you described.
I can only guess the reason is the custom HAL
Sorry for not being more helpful.
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....