#ledger #format #format-file #csv #accounting #ledger-cli #convert

bin+lib okane

CLI tool to support Ledger (https://www.ledger-cli.org/) equivalent syntax files

14 releases (8 breaking)

0.10.0 Jul 5, 2024
0.8.0 Feb 3, 2024
0.7.0 Nov 16, 2023
0.6.0 Apr 14, 2023
0.1.0 Nov 26, 2021

#29 in Finance

Download history 48/week @ 2024-03-28 24/week @ 2024-04-04 150/week @ 2024-05-09 13/week @ 2024-05-16 5/week @ 2024-05-23 89/week @ 2024-07-04 5/week @ 2024-07-11

94 downloads per month

MIT license

335KB
9K SLoC

okane

CircleCI crates.io

Okane is a plain text accounting software developed with Rust, influenced by ledger-cli.

This tool supports various commands:

  • balance to get the current balance of the accounts.
  • register to get the history of the accounts.
  • accounts to list all accounts in the file.
  • format to format given Ledger file into organized format.
  • import to convert various source including CSV, ISO Camt053 XML into Ledger format.
  • primitive to hold commands that are not so useful but good for debugging.

Note balance, register are still work-in-progress, and the UX would change drastically.

How to use

Disclaimer: This software is still in early phase, subject to any kind of change.

Follows syntax page for the supported syntax.

Install

Up until now no binary release is provided, so you need to run cargo install to install the tool.

$ cargo install okane

Query the file

Similar to Ledger, you can use similar commands.

$ okane accounts /path/to/file.ledger
$ okane balance /path/to/file.ledger
$ okane registry /path/to/file.ledger [optional account]

Format the file

$ okane format ~/ledger/account.ledger

This command currently prints the formatted output into standard output. In future in-place format would be provided, also to emit diffs to be used as Git hook.

Import CSV or ISO Camt053 XML files

First you need to write YAML file to control import behavior. We'll assume those are placed under ~/ledger/. The format of YAML is (sorry) not documented, but you can see tests/testdata directory as example configurations.

Then run the okane import command with logging and redirecting to /dev/null. This way you can dry-run and check its output.

$ RUST_LOG=info okane import --config ~/ledger/import.yml ~/ledger/input_file.csv > /dev/null

After iterating over the logs and modifying YAML file, you can redirect the standard output to the ledger file.

$ RUST_LOG=info okane import --config ~/ledger/import.yml ~/ledger/input_file.csv >> ~/ledger/output_path.ledger

Tips: You probably don't want to handle all the entries, rather should aim to cover 80-90% of entries initially.

License

This tool is licensed under MIT lisence.

Dependencies

~17MB
~345K SLoC