Created attachment 373229 [details] Example xml database Scrubbing seems to ignore Return of Capital Transactions (Shares 0, Price 0). The capital gain/loss transactions created seems to ignore the RoC transactions. For example: Date $Spent $Received 02/08/2016 Buy Stock1 500 @ $1.00 500 03/08/2016 Return of Capital 100 30/08/2016 Sell 100 @ $1.50 150 30/09/2016 Sell 400 @ $2.00 800 ---- ---- Total 500 1050 Ie Gain is 550 30/08/2016 Realised Gain created by scrub 50 WRONG s/b 150 - (100 * 400/500) = 70 30/09/2016 Realised Gain created by scrub 400 WRONG s/b 800 - (400 * 400/500) = 480 --- 550 This causes the Trial Balance the be out by the value of the RoC. Manually correcting the gains fixes the TB. I have attached a sample database showing the problem.