Entering an investment sale transaction is done in a similar way to entering a buy transaction (see Section 9.5.2, “Buying New Shares”) except the amount entered in the Shares column is negative and the proceeds of the transaction is entered in the Sell column. The net proceeds from the sale should be transferred from the shares account to your bank or brokerage account.
For information on handling commissions and the use of Net
Pricing or Gross Pricing, please see
Section 9.5.2.1, “Handling Commissions and Fees”. If you will be recording a capital gain or loss on the
sale, please see Chapter 11, Capital Gains and Chapter 16, Depreciation for
more information on this topic. To use the GnuCash
Automatic Calculation of Capital
Gain or Loss Using Lots feature, please see Section 9.7.2, “Selling Shares with Automatic Calculation of Capital Gain or Loss Using Lots”
otherwise continue to the next section.
Note | |
---|---|
In order for |
In the schemes of transaction splits presented below, the following symbols are used:
There are 2 ways of manually recording the capital gain or loss. The capital gain/loss can be combined with the sale in one transaction or it can be entered in a separate transaction.
This has the advantage that all parts of the sale event are kept together. This is not compatible with using scrubbing (see Section 9.7.2, “Selling Shares with Automatic Calculation of Capital Gain or Loss Using Lots”). If you may in future use scrubbing on a specific security, save some work later by entering the capital gain/loss splits in a separate transaction now.
When the capital gain/loss splits are combined with the sale splits in one transaction, there are 2 splits for the security account in the same transaction, so the transaction must be entered with the security register in Auto-Split Ledger or Transaction Journal view. One of the splits for the security account is for the sale and the other is for the capital gain or loss. The security account split for the capital gain or loss must be entered with 0 number of shares and 0 price per share to stop the automatic recalculation of these fields.
Account for the profit or loss as coming from an Income:Capital Gains or Expenses:Capital Loss account.
Table 9.1. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Combined, Gross Pricing
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Bank ABC | NET_SALE | |||
Assets:Stock:SYMBOL | 0 | 0 | GROSS_PROFIT | (Loss) |
Expenses:Commission | COMMISSION | |||
Assets:Stock:SYMBOL | −NUM_SHARES | GROSS_SELL_PRICE | GROSS_SALE | |
Income:Capital Gains | (Loss) | GROSS_PROFIT |
Example 9.1. Sale of Shares with Profit, Manual Profit/Loss Calculation, Sale & Profit Combined, Gross Pricing
In this example, we will use the AMZN account created in Section 9.4.2, “Example Stock Account”.
You bought 100 shares of AMZN for $20 per share, then later sell them all for $36 per share with a commission of $75. The split transaction scheme is as follows:
Table 9.2. Selling Shares Split Scheme, Sale & Gain Combined, Gross Pricing
Account | Shares | Price | Buy | Sell |
Assets:Bank ABC | 3525.00 | |||
Assets:Brokerage Account:Stock:AMZN | 0 | 0 | 1600.00 | |
Expenses:Commission | 75.00 | |||
Assets:Brokerage Account:Stock:AMZN | −100 | 36.00 | 3600.00 | |
Income:Capital Gain (Long Term):AMZN | 1600.00 |
Note | |
---|---|
In the above screenshot, it appears there are 2 transactions for Mar. 21, 2006. This is because the register is in Auto-Split Ledger view and there are 2 splits for the register account in the 1 transaction. Transaction Journal view may be clearer. Refer to Section 2.9.3, “Simple vs. Split Transactions”. As there are 2 splits for the register account in the sale transaction, this transaction must be entered in Auto-Split Ledger or Transaction Journal view. It cannot be entered in Basic Ledger view. |
Table 9.3. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Combined, Net Pricing
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Bank ABC | NET_SALE | |||
Assets:Stock:SYMBOL | 0 | 0 | NET_PROFIT | (Loss) |
Assets:Stock:SYMBOL | −NUM_SHARES | NET_SELL_PRICE | NET_SALE | |
Income:Capital Gains | (Loss) | NET_PROFIT |
Example 9.2. Sale of Shares with Profit, Manual Profit/Loss Calculation, Sale & Profit Combined, Net Pricing
In this example, we will use the AMZN account created in Section 9.4.2, “Example Stock Account”.
You bought 100 shares of AMZN for $20 per share (including commissions), then later sell them all for $36 per share with a commission of $75. The split transaction scheme is as follows:
Table 9.4. Selling Shares Split Scheme, Sale & Gain Combined, Net Pricing
Account | Shares | Price | Buy | Sell |
Assets:Bank ABC | 3525.00 | |||
Assets:Brokerage Account:Stock:AMZN | 0 | 0 | 1525.00 | |
Assets:Brokerage Account:Stock:AMZN | −100 | 35.25 | 3525.00 | |
Income:Capital Gain (Long Term):AMZN | 1525.00 |
This is required if using scrubbing to calculate and create capital gain/loss transactions automatically. Otherwise scrubbing will not detect them and will create an incorrectly valued capital gain/loss transaction.
Table 9.5. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Separate Transactions, Sale Transaction
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Bank ABC | NET_SALE | |||
Expenses:Commission | COMMISSION | |||
Assets:Stock:SYMBOL | −NUM_SHARES | GROSS_SELL_PRICE | GROSS_SALE |
Table 9.6. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Separate Transactions, Capital Gain/Loss Transaction
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Stock:SYMBOL | 0 | 0 | GROSS_PROFIT | (Loss) |
Income:Capital Gains | (Loss) | GROSS_PROFIT |
Example 9.3. Sale of Shares with Profit, Manual Profit/Loss Calculation, Sale & Profit Separated, Gross Pricing
In this example, we will use the AMZN account created in Section 9.4.2, “Example Stock Account”.
You bought 100 shares of AMZN for $20 per share and commissions $20, then later sell them all for $36 per share with a commission of $75. The split transaction scheme is as follows:
Table 9.7. Selling Shares Split Scheme, Sale Transaction, Gross Pricing
Account | Shares | Price | Buy | Sell |
Assets:Bank ABC | 3525.00 | |||
Expenses:Commission | 75.00 | |||
Assets:Brokerage Account:Stock:AMZN | −100 | 36.00 | 3600.00 |
Table 9.8. Selling Shares Split Scheme, Gain Transaction, Gross Pricing
Account | Shares | Price | Buy | Sell |
Assets:Brokerage Account:Stock:AMZN | 0 | 0 | 1600.00 | |
Income:Capital Gain (Long Term):AMZN | 1600.00 |
Figure 9.21. Selling Shares for Gain Where the Sale and Gain are Recorded in Separate Transactions, in Transaction Journal View
Table 9.9. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Separate Transactions, Sale Transaction
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Bank ABC | NET_SALE | |||
Assets:Stock:SYMBOL | −NUM_SHARES | NET_SELL_PRICE | NET_SALE |
Table 9.10. Selling Shares Split Scheme, Sale and Capital Gain/Loss Are Separate Transactions, Capital Gain/Loss Transaction
Account | Number of Shares | Share Price | Total Buy | Total Sell |
Assets:Stock:SYMBOL | 0 | 0 | NET_PROFIT | (Loss) |
Income:Capital Gains | (Loss) | NET_PROFIT |
Example 9.4. Sale of Shares with Profit, Manual Profit/Loss Calculation, Sale & Profit Separated, Net Pricing
In this example, we will use the AMZN account created in Section 9.4.2, “Example Stock Account”.
You bought 100 shares of AMZN for $20 per share (including commissions), then later sell them all for $36 per share with a commission of $75. In the split transaction scheme is as follows:
Table 9.11. Selling Shares Split Scheme, Sale Transaction, Net Pricing
Account | Shares | Price | Buy | Sell |
Assets:Bank ABC | 3525.00 | |||
Assets:Brokerage Account:Stock:AMZN | −100 | 35.25 | 3525.00 |
Table 9.12. Selling Shares Split Scheme, Gain Transaction, Net Pricing
Account | Shares | Price | Buy | Sell |
Assets:Brokerage Account:Stock:AMZN | 0 | 0 | 1525.00 | |
Income:Capital Gain (Long Term):AMZN | 1525.00 |
Figure 9.22. Selling Shares for Gain Where the Sale and Gain are Recorded in Separate Transactions, in Transaction Journal View
Wikipedia includes the following definition of a lot:
a set of goods for sale together in an auction; or a quantity of a financial instrument
GnuCash
has a built-in lot management facility that can be used to keep track of capital gains or
losses resulting from security sales. Buy and sell transactions are put into lots for the
purpose of calculating the cost of the sale. More specifically, a lot is used to link
particular buy and sell transaction splits. Lots can be automatically or manually created
and linked. Capital gain or loss can be automatically calculated and transaction(s)
created for the difference between the sale value and the cost of the securities sold.
GnuCash
refers to this process as scrubbing.
The term scrub is used because security accounts need to be cleaned after sales to ensure the difference between the cost paid for securities, and value received from selling them, is accounted for as capital gain or loss. If the capital gain/loss is not correct, the bottom line total debits will not balance to total credits. To see the , select → → .
Note | |
---|---|
If you make an error, you can delete the lot(s) and capital gain/loss transaction(s) and retry. Ensure you delete the lot, or at least unlink sale transactions from the lot, before you delete a capital gain/loss transaction. Otherwise, the Lots in Account screen will recreate the capital gain/loss transaction when you select the lot. |
If you are not familiar with FIFO, LIFO or Average costing, please see Wikipedia FIFO and LIFO accounting and Average cost method.
If you are not familiar with the difference between GnuCash
transactions and splits, please see
Section 2.9.3, “Simple vs. Split Transactions”.
The GnuCash
lot management facility can be a useful feature, reducing manual calculation, especially
if dividends have been reinvested over years and there are many different costs involved.
It can automatically link buy transactions to sell transactions using
FIFO cost method and one can manually link specific buy transactions to
sell transactions in order to use LIFO. Advanced Portfolio Report basis
costs and gains/losses will agree with the costs and gain/loss transactions created by
scrubbing if either the FIFO or LIFO cost methods
are used.
The Lots in Account SSSS window, where SSSS is a security account, is used to manually or automatically link security transaction splits to lots and create capital gain/loss transactions to account for the difference between the costs of buying a security and the value received by selling it.
To open the Lots in Account window, open the security account register, then select → .
Refer to the Help Manual, Chapter 8 Tools & Assistants, Lots in Account for details of the Lots in Account screen elements.
Using the lot management facility for the automatic calculation of capital gain or loss typically follows these steps:
Before using this feature, ensure you have read Section 9.7.2.8, “Considerations”.
This functionality allows the manual linking of specific buy and sell transactions. It may be used in the case where a user wishes to use a different cost method than the automatic linking method (FIFO). Effectively, if one wishes the cost basis and capital gains in the Advanced Portfolio Report to be consistent with the capital gains transactions created by scrubbing, manual lot creation only needs to be used when using LIFO or “sale of designated lots” (the same thing for securities as far as US personal tax law is concerned). This is because the scrub function can automatically do FIFO linking so there is no need to do it manually and scrubbing cannot be used for average costing. See Example 9.5, “Manual Lot Creation and Linking”.
Note | |
---|---|
Do not do this unless you are using FIFO or LIFO to cost sales. See Section 9.7.2.8, “Considerations”. |
GnuCash
can automatically calculate and create security sale capital gain/loss transactions. Lots are
used to link buy transaction splits with sell transaction splits so the correct cost of
the securities sold can be determined. GnuCash
will use any existing lots, and create new
lots for any buy transaction splits not already linked to a lot. Buy and sell transaction
splits are linked to lots using FIFO method.
See:
The capital gain/loss transaction(s) created by scrubbing uses an automatically created generic
Orphaned Gains-CCC account (where CCC is the security currency)
because GnuCash
doesn't know which capital gain or loss account should be used. After
scrubbing, the user should edit the Orphaned Gains-CCC transaction
split to re-assign the income account to a more meaningful income (or expense) gain or
loss account (for example, Income:Capital Gain (Long Term):IBM).
See Example 9.9, “Changing the Orphaned Gains-CCC to Gain/Loss Account”.
Running a Trial Balance report (
→ → ) after creating capital gain/loss transactions, is a basic check that capital gains/losses are correctly accounting for the difference between the cost paid for securities, and value received from selling them. At the end of the report, total debits should equal total credits.Tip | |
---|---|
A Trial Balance may not balance due to some other problem. To determine if the cause of an imbalance is from incorrectly accounting for capital gain/loss:
|
There are some points that should be considered before using the lot management facility.
GnuCash
implements only the First In/ First Out (FIFO) cost method when
automatically linking buy transactions to sell transactions. That means the oldest
securities are always sold first. The Last In First Out (LIFO) cost
method may be used by manually linking the most recent buy security splits to the sell
split before scrubbing.
The Advanced Portfolio Report does not use lot information when calculating costs, just the security transaction splits. It calculates the cost basis and gains or losses using the selected Basis calculation method report option (Average, FIFO or LIFO). If one wishes the Advanced Portfolio Report costs and gains/losses to be consistent with the capital gain/loss transactions created by scrubbing, the same cost model must be used in both places.
Scrubbing does not recognize commissions or fees so makes no allowance for them in the calculation of gain or loss. Therefore you must use Net Pricing rather than Gross Pricing if you wish to use scrubbing. See Section 9.5.2.1, “Handling Commissions and Fees”.
Scrubbing does not recognize capital gain/loss transaction splits if they have been manually entered as part of the sale transaction. Therefore ensure previous sales are recorded as 2 transactions:
Table 9.13. Transaction 1 dealing with value received and the reduction of the number of shares
Account | Tot Shares | (Unit) Price | Buy (Debit) | Sell (Credit) |
Brokerage or Bank | Debit | |||
Security | −NumSold | SaleUnitPrice | SaleValue |
Table 9.14. Transaction 2 capital gain/loss (loss in this example)
Account | Tot Shares | (Unit) Price | Buy (Debit) | Sell (Credit) |
Capital Loss | Debit | |||
Security | 0 | 0 | Credit |
The automatic capital gains calculations can handle straightforward buy, sell, and return of capital transactions but any transaction that affect the number of shares, even simple splits, will cause it to produce wrong answers so those cases must be handled manually.
Example 9.5. Manual Lot Creation and Linking
Here is an example of selling part of a security holding using the LIFO method.
In this example, the most recent buy transaction (dated Jul. 1, 2016, a reinvested
dividend), is linked to a lot, along with the sell transaction, and the GnuCash
scrub
function is used to calculate capital gain or loss and create the capital gain/loss
transaction.
Open the security account's register.
Ensure all previous capital gain/loss transactions are separate transactions to the sell transactions which record the reduction in the number of shares and the value received.
Select Lots in Account SSSS window where SSSS is the security account.
→ to open theCreate a new lot using the
button. Initially this lot is not linked to any buy or sell split.Highlight the new lot in the Lots in This Account panel.
Highlight the buy split (dated Jul. 1, 2016) of the security to be sold in the Splits free panel.
Click the >> button to link the buy split with the highlighted lot. The split moves from the Splits free panel to the Splits in Lot panel.
Repeat the previous 2 steps for any other buy splits that should be included in the lot (in this example, there is only 1 buy split in the sale).
Highlight the sell split in the Splits free panel.
Click the >> button to link the sell split with the highlighted lot.
Check the lot Balance is as expected. In this example the lot balance should be zero as the number of securities sold in the lot, is matched with the same number of security buys.
Figure 9.26. Selling Shares - Capital Gains - Lots before scrubbing a single lot, after manual linking
Click the not the button.)
button (The Lots in Account window has not changed after using the Scrub button so no example screen image is supplied.
Close the Lots in Account SSSS window and return to the security account register.
Figure 9.27. Selling Shares - Capital Gains - Register after manual linking and scrubbing a single lot
Continue to Section 9.7.2.6, “Change Orphaned Gains-CCC to Gain/Loss Account”.
Example 9.6. Automatic Creation of Capital Gain Or Loss Transactions
Create the capital gains transaction by following these steps:
Open the security account's register.
Ensure any previous manually entered capital gain/loss transaction splits have been entered in separate transactions to the the sell transactions.
Select Lots in Account SSSS window where SSSS is the security account.
→ to open theIf using LIFO, use the above procedure Section 9.7.2.4, “Manual Lot Creation and Linking” to create a lot for each sell transaction, link the lot with the sell transaction and each of the buy transactions that make up the sale.
Click the Scrub Account button which:
Creates lots for any buy transactions that are not already linked to a lot and links them to sell transactions splits using the FIFO method. As a transaction split can only be linked to 1 lot, if a sell transaction needs to be linked to multiple lots, the sell transaction split is itself split into multiple subsplits. In the case of multiple subsplits, it is possible to have different splits from the same transaction in both the Splits free and Splits in lot panels.
Continue to Section 9.7.2.6, “Change Orphaned Gains-CCC to Gain/Loss Account”.
Example 9.7. Automatic Creation of Capital Gain Or Loss Transactions, 2 Sales at Once
Here is an example of FIFO scrubbing without manual lot creation. In this example, the transactions for 2 sales are scrubbed at once but usually scrubbing would be performed after each sale. One reason for scrubbing 2 sales at once, could be because there were multiple sales on the same day.
Select Lots in Account SSSS window where SSSS is the security account.
→ to open theClick the Scrub Account button.
Note | |
---|---|
After using the Scrub Account button only the last lot is shown, so the above image is after the Lots in Account window has been closed and reopened so all the lots show. |
Close the Lots in Account SSSS window and return to the security account register.
Note | |
---|---|
The security splits in the sell transactions have been split into subsplits, one subsplit per lot, and a capital gain transaction has been created for each security subsplit of each sell transaction. |
Continue to Section 9.7.2.6, “Change Orphaned Gains-CCC to Gain/Loss Account”.
Example 9.8. Automatic Creation of Capital Gain Or Loss Transactions - After a Simple Stock Split
Here is an example of FIFO scrubbing without manual lot creation/linking, where the Stock Split Assistant has been used for a simple stock split. In this example, 100 shares of security XYZ were bought for $10.00 each, there was a simple 2 for 1 stock split for zero cost (so the holding was then 200 shares @ $5.00 each), then all 200 shares were sold for $6.00 each.
The above screenshots show that scrubbing created:
2 capital gain transactions (one for each lot) on the date of the sale:
Total gain $200 is correct. Whether the gain is a single long-term one or one each of long-term and short-term or whether there's even a distinction depends on the user's tax jurisdiction and the way the split is structured. If the user needs help figuring it out they should consult a professional.
Example 9.9. Changing the Orphaned Gains-CCC to Gain/Loss Account
Close the Lots in Account SSSS window if open and return to the security account register.
Find each new Realized Gain/Loss transaction in the security account register (they will have the same date as the sell transactions).
Edit the Orphaned Gains-CCC transaction split to re-assign the income account to a more meaningful income (or expense) gain or loss account (for example, Income:Capital Gain (Long Term):IBM).
Tip | |
---|---|
You may like to split the capital gain/loss into taxable and non taxable parts if that is in accord with your tax laws. |