I have been through a few bad transactions turned up by in imbalanced trial balance in Gnucash, but this one stumps me. It seems to be different from the others.

I have used the method posted a while back by @onetrudragongirl to a similar question I asked here. This allowed me to track down the date and eventually the transaction that was causing the problem.

This transaction was the sale of 7 shares of a stock. So, experimenting, I deleted that transaction and the trial balance .... balances.

Easy, I thought: just add the transaction back. But the trial balance goes out of whack by exactly the same amount. Thinking it was a faulty price database entry, I deleted that date's price for that stock, but that did nothing.

Note that when out of balance, the unrealized gain amount with the transaction and without the transaction is exactly the difference in the trial balance with the transaction present. Now, you would indeed expect the unrealized gain to go down when a stock is sold: it's now a realized gain. But why doesn't something show up on the other side to balance it out? Something indeed shows up in the transaction: cash is debited (increased) on sale of the stock, but for some reason, the trial balance is still out of balance (before deleting the transaction).

I've tried some weird things, like selling 1, 2, 3, 4, and 5 shares instead of all 7. Hey, that works. But sell 6 or 7 and it's out of balance.

I tried selling 10 shares of some other stock on that date. Perfect balance.

I even tried deleting the purchase of the stock some months earlier. That, too, puts everything in balance, even without deleting the sale (so it sorta looks like I sold short, I guess at this point.) But as soon as I put that BUY transaction back, the trial balance goes out of balance again.

I deleted all the transactions in the account, deleted the account, and added it back. No joy. As soon as I put those transactions back in, the TB was out of balance.

I tried putting in made-up transactions in that account. So long as the $ amount of the sale matches the $ amount of the buy, TB balances. I always forced the transaction to 7 shares, though. For example, if I buy 7 shares for $1k and sell 7 shares for $1k, it balances. If I sell 7 shares for $1200, it's exactly $200 out of balance.

I do not know how to resolve this.

  • Sounds like you aren't marking the implied 'income' / 'gain' from selling shares for higher than you bought them. Dec 12, 2022 at 14:29
  • 2
    Have you already reviewed this: gnucash.org/docs/v4/C/gnucash-guide/invest-sell1.html
    – Hart CO
    Dec 12, 2022 at 15:06
  • 1
    While this question is about accounting, the software and use case does relate to investing from an individual perspective. Voting to re-open. Dec 12, 2022 at 17:02
  • 2
    OK; thanks to @HartCO 's reference, I might have this. I assigned a lot for the two 7 shs transactions, buy/sell, then ran scrub on the account. This gave me a bunch of Orphan gain/loss transactions, which I then sorted into the appropriate gain/loss accounts. Refresh on the TB and... Success! Thank you so much for pointing me in the right direction.
    – fbicknel
    Dec 12, 2022 at 17:51


Browse other questions tagged .