--- Alias: ["Personal Accounting"] Tag: ["πŸ€–", "πŸ’²", "πŸ’»", "πŸ“²"] Date: 2021-08-19 DocType: "Confidential" Hierarchy: "Root2" TimeStamp: 2021-08-19 location: [51.514678599999996, -0.18378583926867909] CollapseMetaTable: true --- Parent:: [[@Finances]] --- ^Top   ```button name Save type command action Save current file id Save ``` ^button-hLedgerSave   # hLedger   ```ad-abstract title: Summary collapse: open This note describes the workings of plain text accounting through hLedger ```   ```toc style: number ```   ---   ### Documentation   [Plain text Accounting](https://plaintextaccounting.org/) [hledger](https://hledger.org/create-a-journal.html) [Ledger manual](https://www.ledger-cli.org/3.0/doc/ledger3.html#index-account_002c-alias) [Ledger helpers](https://github.com/ledger/ledger/wiki/Entering-transactions-with-ledgerhelpers-GUI-apps) [Ledger help](https://github.com/ledger/ledger/wiki/Entering-data)   ---   ### hLedger   Plain Text Accounting is accessible through command-line clients like hledger. Installation is simple: ```ad-command ~~~bash brew install hledger ~~~ ``` Some extensions may be required for certain functionalities to work and will be documented accordingly.   #### Structure The structure of the tool and resulting file is rather simple. The tool offers two main functionalities: 1. **Import data** hLedger allows for direct links to your bank or manual entries into the ledger. 2. **Reports on aggregated data** A suite of reports is available to visualise financial data The underlying database is a (collection of) file(s) readable through classic text editors with a list of the transactions made during the period.   #### Initialisation At start of the year/period in any given file, a certain number of initialisations need to be made: 1. **Initialise top-level accounts** ```ad-code ~~~ account 'name of account' ~~~ ``` 2. **Currencies used** ```ad-code ~~~ commodity 'layout + number format' ~~~ ``` 2. **Opening balances** ```ad-code ~~~ 'Date' set initial 'account name' account balance 'account name'(+optional nesting -> :'sub-account') {+ 2 spaces min} 'amount' equity:opening balances ~~~ ```   #### Accounts 1. **Aliasing** Aliases can be defined for simplifying writing/reading accounts. ```ad-code ~~~bash alias a=assets alias c=a:Cash ~~~ ``` Flags can be used in reports: > [!command] > β€”recursive-aliases –> expand recursive aliases > β€”no-aliases –> does not expand aliases   #### Transactions [[#^Top|TOP]] hLedger allows for three methods for entering transactions: 1. **Through command-line** This method is well-guided with hLedger: ```ad-command ~~~bash hledger add -f 'journalname' ~~~ ``` The function will then prompt the user for appropriate entries. 2. **Manually into the .journal file** Open the .journal file and manually enter transactions with the following format: ```ad-code ~~~ (date) 'transaction name' 'account 1' {2+ spaces} (amount) 'account 2' {2+ spaces} !(amount) ~~~ ``` 3. **Import** ```ad-command title: Import from Note ~~~bash hledger import -f 'journalname' 'filename' ~~~ ``` ```ad-note title: CSV Import hLedger requires a certain level of customisation to import .csv. Instructions can be found [here](https://hledger.org/import-csv.html) ``` 4. **Recurring transactions** [Recurring transactions](https://hledger.org/hledger.html#periodic-transactions) do not really form part of hledger or plaintextaccounting per se. The below code helps to understand how recurring budgets can be declared: ```ad-code ~~~ ~ monthly (or other periodicity) (optional 'from') (account 1):(sub-account 1) {2+ spaces} (amount) (account 2):(sub-account 2) ~~~ ``` In order to create recurring transactions, scripts need to be written and cronjobs set. Find below an outline of the process.   Create a `.sh` file with the below code: ```ad-code ~~~sh #!/bin/sh LEDGER_RECURRING='/Volumes/Computer Vault/Wealth/Compta/.journal.ledger' cat >> $LEDGER_RECURRING <stats: account stats (number of transactions, ccy, exchange rates, etc...) 2. print: transaction history 3. aregister: transaction history in a particular account 4. cashflow: summary of cashflows per asset account & ccy 5. balance: show account balances   #### Other commands [[#^Top|TOP]] ```ad-example title: Specific tasks [Error checking](https://hledger.org/checking-for-errors.html) ```   ### Tasks & Further steps   ```ad-question title: To explore - [!] Tax - [!] Financial forecasting ``` - [x] [[hLedger]]: Tax for Investments βœ… 2022-01-22 - [x] [[hLedger]]: Financial forecasting βœ… 2022-01-22 - [S] :heavy_dollar_sign: [[hLedger]]: Update Price file %%done_del%% πŸ” every 3 months on the 1st Friday πŸ“… 2023-04-07 - [S] :heavy_dollar_sign: [[hLedger]]: Update current ledger %%done_del%% πŸ” every 3 months on the 1st Friday πŸ“… 2023-04-07