In this article
The Calculate sales data dialog allows you to calculate the realized gain or loss resulting from the sale of an investment and, when required, create the related accounting transactions.
The dialog provides two main functions:
- Calculate the Sale Result – Click Calculate profit or loss to preview the realized gain or loss based on the data entered in the dialog or automatically retrieved from the accounting file. No accounting transactions are created. This function can also be used without starting from the sale transaction row in the Transactions table.
- Create the Sales Record – Click Create sales record to create the accounting transactions required to complete the sale recording. To use this function, start from the sale transaction row in the Transactions table that records the net proceeds from the investment sale.
Start from the Sale Transaction Row
When creating the sales record, the program needs to identify the transaction to be completed with the additional entries required to record the sale, such as charges, realized gains or losses, and exchange rate differences. Therefore, you must start from the transaction row that records the net proceeds from the investment sale.
If this row already includes:
- Item (security ID)
- Quantity
- Unit Price (Market Price)
- Exchange Rate (for multi-currency accounting)

The dialog retrieves this information automatically. Otherwise, you need to enter the missing information in the dialog.
The sale transaction row is the only row that must be entered manually. Once this row is available, the program can automatically create the additional entries required to complete the sale recording.
How to use the dialog
When you execute this command, a dialog titled Calculate book profit/loss on sale opens.

Enter or review the information required for the sale:
- Security Data:
- Id (ISIN): Select the security from the dropdown.
- Type: Displays whether the security is a Stock or a Bond.
- Quantity/Nominal Value: Enter the quantity or nominal value of the investment being sold.
- Current Price: Enter the price per unit at which the investment is being sold.
- Current Exchange Rate: For investments denominated in a foreign currency, enter the exchange rate applicable to the transaction.
- Bank Charges: Enter any bank charges related to the sale. If no amount is entered, the corresponding transaction is not created.
- Other Charges: Enter any additional costs related to the sale. If no amount is entered, the corresponding transaction is not created.
- Accrued Interests: For bonds, enter any accrued interest related to the sale. This field is enabled only for bonds.
- Results Preview: Once the required data is entered, click Calculate profit or loss to generate a preview showing:
- Actual Quantity: The quantity held before the sale.
- Book Value per Unit: The current book value per unit of the investment.
- Total Book Value: The book value of the investment quantity being sold.
- Total at Current Price: The value of the investment quantity being sold at the entered Current Price.
- Book Profit/Loss: The difference between the book value and the sale value.
- Exchange Rate Profit/Loss: For investments denominated in a foreign currency, the gain or loss resulting from exchange rate differences.
Amounts are displayed using the number of decimal places defined for the corresponding columns in the Transactions table.
When you enter an amount in the dialog, make sure to use the local number format (for example, “1'234.56” in Switzerland), as this is the format expected by the program.
Recording the Sale
Once you are satisfied with the preview, click Create sales record to create the accounting entries required to complete the sale recording. The program displays a confirmation dialog showing the entries to be added or modified, allowing you to review them before applying the changes.

- Upon confirmation, the program updates the accounting records with the new or modified entries.
- If the quantity is zero or the calculated profit/loss is zero, no transaction is created.
- The program adds a transaction identifier to the ExternalReference column of both the original sale row and any newly created rows. This prevents duplicate entries if the command is run multiple times on the same sale row.
- If the program detects an existing record for this sale, it will ask whether you want to overwrite it.
This procedure helps ensure that investment sales are correctly recorded while allowing you to review the accounting entries before they are applied.

In the example shown in the image, placeholder accounts are used. These are used when the corresponding accounts have not been defined in the Accounts Settings dialog.
The extension uses a neutral number (±123.00) in the Quantity column when recording the realized gain or loss. A neutral quantity does not change the quantity held but allows the amount of the realized gain or loss to be associated with the investment and its corresponding unit value to be shown in the Unit Price column. This is especially useful for investment funds and ETFs.
Error Messages
- Items table not found: The Items table is not present in the accounting file.
- Add the Items table to your file.
- Asset: XXX not foun: The selected Asset does not exist in the Items table.
- Asset: XXX without assigned Asset Account: No Asset Account has been assigned to this Asset in the Items table.
- Define an account in the Asset Account column for the Asset in the Items table.
- Asset: XXX without assigned type: No Asset Type has been defined for this Asset.
- The selected row does not contain the Asset ID: The selected row does not contain a valid Asset ID. To create the sales record, the selected row must contain the ID of an Asset defined in the Items table.
- The selected row does not contain a valid sale Quantity: The selected row does not contain a valid quantity for an investment sale. The sale quantity must be negative. Check that the quantity is preceded by a minus sign (-) and that you have selected a sale row rather than a purchase row.
- The selected row in the Transactions table is not correct: The selected row does not correspond to the investment sale row required to create the sales record.
- The selected row in the Transactions table is not valid: The selected row in the Transactions table is not a valid transaction row.