GNOME Bugzilla – Bug 334775
Sale of partial lot of stock causes Balance Sheet to report wrong information and be unbalanced
Last modified: 2018-06-29 20:59:48 UTC
Please describe the problem: Selling a partial lot of stock for a price different than what was paid for it, causes the Balance Sheet to report an incorrect amount for Unrealized Gains, resulting in an apparent imbalance that cannot be corrected without selling the remainder of shares of that stock account. Steps to reproduce: 1. Enter a transaction for 200 shares of stock purchased at $10 a share. 2. Sell 100 of those shares for $20 a share. 2. Observe the balance sheet. Actual results: If the amounts above are used, the Balance Sheet shows an Unrealized Gain of $333.33, instead of $1000.00, as it should. Errors will occur with any amount and price, though, as far as I can tell. Expected results: A correct Unrealized Gain and a balanced Balance Sheet Does this happen every time? Yes. Other information: This is the source for a small GnuCash file that demonstrates this error. <?xml version="1.0"?> <gnc-v2> <gnc:count-data cd:type="book">1</gnc:count-data> <gnc:book version="2.0.0"> <book:id type="guid">8b26e5979abf3d956511a7c5840a63d9</book:id> <gnc:count-data cd:type="commodity">1</gnc:count-data> <gnc:count-data cd:type="account">18</gnc:count-data> <gnc:count-data cd:type="transaction">2</gnc:count-data> <gnc:commodity version="2.0.0"> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> <cmdty:name>Digital Datawack</cmdty:name> <cmdty:fraction>10000</cmdty:fraction> </gnc:commodity> <gnc:pricedb version="1"> <price> <price:id type="guid">97676c5a4acb70b7670bce9f5d1df469</price:id> <price:commodity> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> </price:commodity> <price:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </price:currency> <price:time> <ts:date>2006-03-17 00:00:00 -0500</ts:date> </price:time> <price:source>user:price-editor</price:source> <price:type>last</price:type> <price:value>20000000/1000000</price:value> </price> <price> <price:id type="guid">6dfe39095bf1bc6a436a8de01fce70a6</price:id> <price:commodity> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> </price:commodity> <price:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </price:currency> <price:time> <ts:date>2006-03-16 00:00:00 -0500</ts:date> </price:time> <price:source>user:price-editor</price:source> <price:type>last</price:type> <price:value>20000000/1000000</price:value> </price> <price> <price:id type="guid">8b667be437f27b42f107fda2212a3635</price:id> <price:commodity> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> </price:commodity> <price:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </price:currency> <price:time> <ts:date>2006-03-15 00:00:00 -0500</ts:date> </price:time> <price:source>user:price-editor</price:source> <price:type>last</price:type> <price:value>20000000/1000000</price:value> </price> <price> <price:id type="guid">a281036f91fc77fffef55b5f3dd31400</price:id> <price:commodity> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> </price:commodity> <price:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </price:currency> <price:time> <ts:date>2006-03-14 00:00:00 -0500</ts:date> </price:time> <price:source>user:price-editor</price:source> <price:type>last</price:type> <price:value>10000000/1000000</price:value> </price> </gnc:pricedb> <gnc:account version="2.0.0"> <act:name>Assets</act:name> <act:id type="guid">17e18fa79cf039d4616207eeec4cc305</act:id> <act:type>ASSET</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Assets</act:description> </gnc:account> <gnc:account version="2.0.0"> <act:name>Investments</act:name> <act:id type="guid">682c84d17038d45a86667d43c93cccbd</act:id> <act:type>ASSET</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Investments</act:description> <act:parent type="guid">17e18fa79cf039d4616207eeec4cc305</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Brokerage Account</act:name> <act:id type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:id> <act:type>BANK</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Brokerage Account</act:description> <act:parent type="guid">682c84d17038d45a86667d43c93cccbd</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Bond</act:name> <act:id type="guid">ed265c9616c7fd63186910bc5eab7bf0</act:id> <act:type>STOCK</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Bond</act:description> <act:parent type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>DWAK</act:name> <act:id type="guid">efafc52e39520c02ebe43358949b6294</act:id> <act:type>STOCK</act:type> <act:commodity> <cmdty:space>NASDAQ</cmdty:space> <cmdty:id>DWAK</cmdty:id> </act:commodity> <act:commodity-scu>10000</act:commodity-scu> <act:slots> <slot> <slot:key>placeholder</slot:key> <slot:value type="string">false</slot:value> </slot> <slot> <slot:key>notes</slot:key> <slot:value type="string"></slot:value> </slot> <slot> <slot:key>tax-related</slot:key> <slot:value type="integer">1</slot:value> </slot> </act:slots> <act:parent type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Stock</act:name> <act:id type="guid">c062cbdf7eb17a38d07324b8b617d2cc</act:id> <act:type>STOCK</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Stock</act:description> <act:parent type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Market Index</act:name> <act:id type="guid">95d152077b37af7acefd435661c55630</act:id> <act:type>MUTUAL</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Market Index</act:description> <act:parent type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Mutual Fund</act:name> <act:id type="guid">99621e86237607faa67e177ccfd49614</act:id> <act:type>MUTUAL</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Mutual Fund</act:description> <act:parent type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Income</act:name> <act:id type="guid">974d4fa95c9275c601e4f1bbbaf5c92d</act:id> <act:type>INCOME</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Income</act:description> </gnc:account> <gnc:account version="2.0.0"> <act:name>Capital Gains</act:name> <act:id type="guid">81005e5e75cbb49277fb4290d9b4aea8</act:id> <act:type>INCOME</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:slots> <slot> <slot:key>placeholder</slot:key> <slot:value type="string">false</slot:value> </slot> <slot> <slot:key>notes</slot:key> <slot:value type="string"></slot:value> </slot> <slot> <slot:key>tax-related</slot:key> <slot:value type="integer">1</slot:value> </slot> </act:slots> <act:parent type="guid">974d4fa95c9275c601e4f1bbbaf5c92d</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Dividend Income</act:name> <act:id type="guid">dabf91b5155aa240bab99292e6356a51</act:id> <act:type>INCOME</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Dividend Income</act:description> <act:parent type="guid">974d4fa95c9275c601e4f1bbbaf5c92d</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Interest Income</act:name> <act:id type="guid">93ed95efbc7df6eddeedd9fd2aea1df7</act:id> <act:type>INCOME</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Interest Income</act:description> <act:parent type="guid">974d4fa95c9275c601e4f1bbbaf5c92d</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Bond Interest</act:name> <act:id type="guid">240fc2ba90eac9e9ce360a467ee3f1f7</act:id> <act:type>INCOME</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Bond Interest</act:description> <act:parent type="guid">93ed95efbc7df6eddeedd9fd2aea1df7</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Expenses</act:name> <act:id type="guid">2498f85d6ec9adf70ffe276e4cfe0c3a</act:id> <act:type>EXPENSE</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Expenses</act:description> </gnc:account> <gnc:account version="2.0.0"> <act:name>Commissions</act:name> <act:id type="guid">5fdec698d8917ac124e27617c5c9c216</act:id> <act:type>EXPENSE</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:description>Commissions</act:description> <act:parent type="guid">2498f85d6ec9adf70ffe276e4cfe0c3a</act:parent> </gnc:account> <gnc:account version="2.0.0"> <act:name>Equity</act:name> <act:id type="guid">9c850b4a3fe9f0c65ef001f0a5eae9cf</act:id> <act:type>EQUITY</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:slots> <slot> <slot:key>placeholder</slot:key> <slot:value type="string">false</slot:value> </slot> <slot> <slot:key>notes</slot:key> <slot:value type="string"></slot:value> </slot> </act:slots> </gnc:account> <gnc:account version="2.0.0"> <act:name>Opening Balances</act:name> <act:id type="guid">85c17a59b8106044a9bd9f6766cc8cbe</act:id> <act:type>EQUITY</act:type> <act:commodity> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </act:commodity> <act:commodity-scu>100</act:commodity-scu> <act:slots> <slot> <slot:key>placeholder</slot:key> <slot:value type="string">false</slot:value> </slot> <slot> <slot:key>notes</slot:key> <slot:value type="string"></slot:value> </slot> </act:slots> <act:parent type="guid">9c850b4a3fe9f0c65ef001f0a5eae9cf</act:parent> </gnc:account> <gnc:transaction version="2.0.0"> <trn:id type="guid">23ae87b68dafa6eaa47223bcfff2760c</trn:id> <trn:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </trn:currency> <trn:date-posted> <ts:date>2006-03-15 00:00:00 -0500</ts:date> </trn:date-posted> <trn:date-entered> <ts:date>2006-03-15 22:50:32 -0500</ts:date> </trn:date-entered> <trn:description></trn:description> <trn:splits> <trn:split> <split:id type="guid">5b0186c464027176dfec0539d230f36e</split:id> <split:reconciled-state>n</split:reconciled-state> <split:value>199500/100</split:value> <split:quantity>199500/100</split:quantity> <split:account type="guid">bc19f8bc9b9e88da75c2cc43375f1aa9</split:account> </trn:split> <trn:split> <split:id type="guid">c313603f0cb6b2edca2c8106675429dd</split:id> <split:reconciled-state>n</split:reconciled-state> <split:value>500/100</split:value> <split:quantity>500/100</split:quantity> <split:account type="guid">5fdec698d8917ac124e27617c5c9c216</split:account> </trn:split> <trn:split> <split:id type="guid">f58ac3879cd69ed17c02f690ea74be7c</split:id> <split:reconciled-state>n</split:reconciled-state> <split:value>100000/100</split:value> <split:quantity>0/10000</split:quantity> <split:account type="guid">efafc52e39520c02ebe43358949b6294</split:account> </trn:split> <trn:split> <split:id type="guid">9b925e2315ff5b563489742fb935ec88</split:id> <split:action>Sell</split:action> <split:reconciled-state>n</split:reconciled-state> <split:value>-200000/100</split:value> <split:quantity>-1000000/10000</split:quantity> <split:account type="guid">efafc52e39520c02ebe43358949b6294</split:account> </trn:split> <trn:split> <split:id type="guid">4c7591e06aca9f2037a4c4fa4006986a</split:id> <split:reconciled-state>n</split:reconciled-state> <split:value>-100000/100</split:value> <split:quantity>-100000/100</split:quantity> <split:account type="guid">81005e5e75cbb49277fb4290d9b4aea8</split:account> </trn:split> </trn:splits> </gnc:transaction> <gnc:transaction version="2.0.0"> <trn:id type="guid">0fdeb0d1829c7bb0ae85272ec6ffd3c9</trn:id> <trn:currency> <cmdty:space>ISO4217</cmdty:space> <cmdty:id>USD</cmdty:id> </trn:currency> <trn:date-posted> <ts:date>2006-03-14 00:00:00 -0500</ts:date> </trn:date-posted> <trn:date-entered> <ts:date>2006-03-15 22:26:41 -0500</ts:date> </trn:date-entered> <trn:description>Inital shares</trn:description> <trn:splits> <trn:split> <split:id type="guid">211f2595b863b3a9e32cdc9e34f4408e</split:id> <split:action>Buy</split:action> <split:reconciled-state>n</split:reconciled-state> <split:value>200000/100</split:value> <split:quantity>2000000/10000</split:quantity> <split:account type="guid">efafc52e39520c02ebe43358949b6294</split:account> </trn:split> <trn:split> <split:id type="guid">8b79c8d6c6e0938acc8b5630676ef778</split:id> <split:reconciled-state>n</split:reconciled-state> <split:value>-200000/100</split:value> <split:quantity>-200000/100</split:quantity> <split:account type="guid">85c17a59b8106044a9bd9f6766cc8cbe</split:account> </trn:split> </trn:splits> </gnc:transaction> </gnc:book> </gnc-v2> <!-- Local variables: --> <!-- mode: xml --> <!-- End: -->
Created attachment 61370 [details] A small GnuCash file that demonstrates the bug
Development on Gnucash 1.8.x has stopped; nothing will be fixed there. However, in the 1.9.x/upcoming 2.0.0 series there will be functions to deal with this. Apart from this, the same issue has already been reported, so further discussion should be added to that other bug report. *** This bug has been marked as a duplicate of 131623 ***
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=334775. Please update any external references or bookmarks.