Report

IFRS weighted-average cost basis report

The IFRS weighted-average cost basis report report.

For stocks, a line for each buy, sell, split and return of capital with the running quantity, the weighted-average cost per share, the cost of what was sold and the realized gain or loss, in the report currency and with the effect of exchange rates. It is for cost basis by weighted average, as IFRS and some tax regimes require; it is not for FIFO, LIFO or specific-lot methods, and it is not made for options. Each report also ends with notes saying so. In GnuCash: Reports ▸ Experimental ▸ IFRS weighted-average cost basis report.

The options that matter are General/Report's currency, the dates, and the accounts the report reads: General/Stock Account, Proceeds Account, Dividend Account, Fees Account and Cap Gains Account.

Examples

Example: with a copy of the reports/ifrs-cost-basis example book open as book.gnucash, at 2024-03-15T12:00:00Z.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"report.run","params":{"report":"IFRS weighted-average cost basis report","options":{"General":{"Report's currency":"CAD","Proceeds Account":"a0000000000000000000000000000005","Fees Account":"a000000000000000000000000000000d","Start Date":{"absolute":"2019-01-01"},"End Date":{"absolute":"2021-01-01"}}}}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "title": "Average-Cost (Basis) Report: From 01/01/19 to 01/01/21. Report-currency CAD",
    "sections": [
      {
        "blocks": [
          {
            "kind": "table",
            "rows": [
              "…",
              "…",
              {
                "role": "data",
                "cells": [
                  {
                    "display": "03/18/20",
                    "…": "…"
                  },
                  {
                    "text": "Sell SPY",
                    "…": "…"
                  },
                  {
                    "display": "-75. SPY",
                    "…": "…"
                  },
                  {
                    "display": "75. SPY",
                    "…": "…"
                  },
                  "…"
                ],
                "…": "…"
              },
              "…"
            ],
            "…": "…"
          },
          "…"
        ],
        "…": "…"
      },
      "…"
    ],
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash report.run '{"report":"IFRS weighted-average cost basis report","options":{"General":{"Report'\''s currency":"CAD","Proceeds Account":"a0000000000000000000000000000005","Fees Account":"a000000000000000000000000000000d","Start Date":{"absolute":"2019-01-01"},"End Date":{"absolute":"2021-01-01"}}}}'

It prints:

{
  "title": "Average-Cost (Basis) Report: From 01/01/19 to 01/01/21. Report-currency CAD",
  "sections": [
    {
      "blocks": [
        {
          "kind": "table",
          "rows": [
            "…",
            "…",
            {
              "role": "data",
              "cells": [
                {
                  "display": "03/18/20",
                  "…": "…"
                },
                {
                  "text": "Sell SPY",
                  "…": "…"
                },
                {
                  "display": "-75. SPY",
                  "…": "…"
                },
                {
                  "display": "75. SPY",
                  "…": "…"
                },
                "…"
              ],
              "…": "…"
            },
            "…"
          ],
          "…": "…"
        },
        "…"
      ],
      "…": "…"
    },
    "…"
  ],
  "…": "…"
}

MCP tool call

Tool call:

{"name":"report.run","arguments":{"report":"IFRS weighted-average cost basis report","options":{"General":{"Report's currency":"CAD","Proceeds Account":"a0000000000000000000000000000005","Fees Account":"a000000000000000000000000000000d","Start Date":{"absolute":"2019-01-01"},"End Date":{"absolute":"2021-01-01"}}}}}

Result:

{
  "structuredContent": {
    "title": "Average-Cost (Basis) Report: From 01/01/19 to 01/01/21. Report-currency CAD",
    "sections": [
      {
        "blocks": [
          {
            "kind": "table",
            "rows": [
              "…",
              "…",
              {
                "role": "data",
                "cells": [
                  {
                    "display": "03/18/20",
                    "…": "…"
                  },
                  {
                    "text": "Sell SPY",
                    "…": "…"
                  },
                  {
                    "display": "-75. SPY",
                    "…": "…"
                  },
                  {
                    "display": "75. SPY",
                    "…": "…"
                  },
                  "…"
                ],
                "…": "…"
              },
              "…"
            ],
            "…": "…"
          },
          "…"
        ],
        "…": "…"
      },
      "…"
    ],
    "…": "…"
  }
}

Template GUID: 15d5b744176c4625a703720338725291 · Script: standard/ifrs-cost-basis.rhai

Options

General

  • Start Date (date, default {"relative":"start-accounting-period"}): Start of reporting period.
  • End Date (date, default {"relative":"end-accounting-period"}): End of reporting period.
  • Report name (string, default "IFRS weighted-average cost basis report"): Enter a descriptive name for this report.
  • Stylesheet (multichoice, default "Default"): Select a stylesheet for the report.
  • Add options summary (multichoice, default "never"): Add summary of options.
  • Report's currency (currency, default "CURRENCY::USD"): Select the currency to display the values of this report in.
  • Stock Account (accountSel, default null): Stock Account
  • Proceeds Account (accountSel, default null): Proceeds Account
  • Dividend Account (accountSel, default null): Dividend Account
  • Fees Account (accountSel, default null): Fees Account
  • Cap Gains Account (accountSel, default null): Cap Gains Account
  • Action field filter for fees (string, default "Fee"): This string will be used to compare with the split action field to detect capitalized fees on stock activity
  • Format monetary cells (boolean, default true): Check this option to show cells with currency
  • Alternative row-style for shorts (boolean, default true): Check this option to use alternate style for shorts. Disable to use alternate style every other row
  • Capitalise purchase commissions (boolean, default true): Check this option to capitalise purchase commissions in cumulative average cost and gain/loss after commission