{"id":17130663,"url":"https://github.com/dtrai2/gnucash-to-beancount","last_synced_at":"2025-03-24T04:46:01.090Z","repository":{"id":239059027,"uuid":"798350702","full_name":"dtrai2/gnucash-to-beancount","owner":"dtrai2","description":"This project can convert GnuCash into a new beancount file.","archived":false,"fork":false,"pushed_at":"2024-05-17T19:34:03.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T13:21:40.958Z","etag":null,"topics":["beancount","gnucash","plaintext-accounting"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtrai2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-09T15:48:14.000Z","updated_at":"2024-11-10T12:04:35.000Z","dependencies_parsed_at":"2024-05-17T20:39:16.355Z","dependency_job_id":"6b7cb639-d3ec-4b95-93eb-b3444053a421","html_url":"https://github.com/dtrai2/gnucash-to-beancount","commit_stats":null,"previous_names":["dtrai2/gnucash-csv-to-beancount","dtrai2/gnucash-to-beancount"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtrai2%2Fgnucash-to-beancount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtrai2%2Fgnucash-to-beancount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtrai2%2Fgnucash-to-beancount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtrai2%2Fgnucash-to-beancount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtrai2","download_url":"https://codeload.github.com/dtrai2/gnucash-to-beancount/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245212172,"owners_count":20578440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beancount","gnucash","plaintext-accounting"],"created_at":"2024-10-14T19:12:55.864Z","updated_at":"2025-03-24T04:46:01.066Z","avatar_url":"https://github.com/dtrai2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gnucash to Beancount\n\nThis project can convert a [Gnucash](https://github.com/Gnucash/gnucash) sql file into a new\n[beancount](https://github.com/beancount/beancount) file.\nIt is not intended to continuously import gnucash data into an existing beancount ledger, as this\nscript will also add plugins and beancount options to the beginning of the file.\nThis project started with the intention to convert a gnucash csv export, but it turned out that the\ncsv exported from gnucash is not quite reliable.\nRead more about that at in the section [Unreliable Export](#unreliable-gnucash-csv-export).\nBecause of that I refactored it to use the [piecash](https://pypi.org/project/piecash/) library.\nWith that it has the same goal as the already existing repository from\n[henriquebastos/gnucash-to-beancount](https://github.com/henriquebastos/gnucash-to-beancount).\nThe implementation in this repository does offer few configuration options though.\n\nOne downside I have encountered sofar are stock splits.\nThose are currently not supported and have to be added manually to the output by following the\nofficial documentation\n[Beancount Stock Splits](https://beancount.github.io/docs/trading_with_beancount.html#stock-splits).\nLuckily those splits don't happen too often.\n\n## Prerequisite\n\nYour gnucash file must be in a sql format.\nI implemented it with a sqlite3 file, which was saved by GnuCash v5.4.\nIf your current genucash file is not in the right format it is always possible to just save it\nas a sqlite3 file.\n\n## Install\n\nTo install `gnucash to beancount` simply use `pip`:\n\n```bash\npip install g2b\n```\n\nTest with `g2b --version` if the installation was successful.\n\n## Usage\n\n### Create Configuration for g2b\n\nIn order for a successful conversion you need to create a `yaml` configuration file.\nAn example would look like this:\n\n```yaml\nconverter:\n  loglevel: INFO\ngnucash:  # here you can specify details about your gnucash export\n  default_currency: EUR\n  thousands_symbol: \".\"\n  decimal_symbol: \",\"\n  reconciled_symbol: \"b\"\n  not_reconciled_symbol: \"n\"\n  account_rename_patterns:  # Here you can rename accounts that might not align with the beancount format\n    - [\"OpenBalance\", \"Equity:Opening-Balance\"]\n    - [\"Money@[Bank]\", \"Assets:Money at Bank\"]\n  non_default_account_currencies:  # Here you have to name all accounts that deviate from the default currency\n    Assets:Cash:Wallet: \"NZD\"\nbeancount:  # here you can add beancount options, plugins and events that should be added to output file\n  flag_postings: false  # if false, will set all transactions automatically to '*' (default: true)\n  options:\n    - [\"title\", \"Exported GnuCash Book\"]  # options should be key value pairs\n    - [\"operating_currency\", \"EUR\"]\n  plugins:\n    - \"beancount.plugins.check_commodity\"  # plugins can be named directly\n    - \"beancount.plugins.coherent_cost\"\n    - \"beancount.plugins.nounused\"\n    - \"beancount.plugins.auto\"\n  events:\n    2024-05-05: type description string  # optional events that should be added to the output, the\n                                         # first space is used to split between space and description\nfava:  # optional configuration specific to fava\n  commodity-precision: 3  # set the render precision of values for the fava web-frontend\n```\n\n## Execute g2b\n\nOnce you created the needed configuration file you can call:\n\n```bash\ng2b -i book.gnucash -c config.yaml -o my.beancount\n```\n\nThe script will, at the end, automatically call beancount to parse and verify the export, such\nthat you know if the conversion was successful or not.\n\n## Limitations\n\nCurrently, this project can not deal with stock splits.\nThose will not be added to the beancount output and have to be added manually.\nTo do that follow the official\n[Documentation](https://beancount.github.io/docs/trading_with_beancount.html#stock-splits).\n\n## Unreliable Gnucash CSV Export\n\nWhile starting out with CSV exports I found the following issues that kept me from\nprogressing with the CSV exports.\n\n- The gnucash csv export does not offer reliable currency information.\n  Transaction with values like `100 $` cannot be properly understood as it, for example, could be\n  USD or NZD.\n  An offical bug report is open since 2017:\n  [gnucash bug - use ISO 4217 currency symbols in output](https://bugs.gnucash.org/show_bug.cgi?id=791651).\n- The `Rate/Price` value is sometimes added to the wrong posting in transactions with multiple\n  currencies.\n  Because of that it wasn't easily recognizable how to convert which prices.\n- And probably the most severe issue: Some transactions were completely missing inside the export.\n  As I couldn't figure out why I decided to use the `piecash` library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtrai2%2Fgnucash-to-beancount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtrai2%2Fgnucash-to-beancount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtrai2%2Fgnucash-to-beancount/lists"}