hledger_connector 0.6.1 copy "hledger_connector: ^0.6.1" to clipboard
hledger_connector: ^0.6.1 copied to clipboard

A library to connect with the hledger plain text accounting system https://hledger.org/.

A dart library to connect with the hledger plain text accounting system.

After releasing this version I will port the whole library to Python because I want to make it (and other software that will utilize this lib) available to a larger variety of operating systems. Please watch my GitHub profile for new repositories.

Please contact me if you need more features. Bugs will continue to be fixed.

License #

This work is provided under the terms of the MIT license. Please take a look at the LICENSE file for the full text.

Features #

  • Generate and read journal entries
    • a date and an optional description,
    • transactions between two or more accounts,
    • preceding or following units
    • simple conversion transactions.
  • Write them to file or read them from a file.
  • Creates a new journal files if necessary.
  • Transform a Transaction from and to a string without any file access. To send it over the net or save it in a database for example.
  • Add a warning if a journal contains an ignored feature.

Planned features #

  • Filter a List of Transactions by account names, dates etc.

List #

Supported features according to the data formats page on hledger.org.

Feature Supported Future dev?
Basic transaction βœ… Supported
Symbols in double quotes ❌ Not Supported πŸ—’οΈ On request
Tag πŸ‘» Ignored πŸ—’οΈ On request
Pending status ❌ Not Supported πŸ—’οΈ On request
Cleared status ❌ Not Supported πŸ—’οΈ On request
(code) ❌ Not Supported πŸ—’οΈ On request
Description as PAYEE | NOTE ΒΉ πŸ‘» Ignored πŸ—’οΈ On request
Complex commodity symbol ❌ Not Supported πŸ—’οΈ On request
Per unit cost ❌ Not Supported πŸ—’οΈ On request
Total cost ❌ Not Supported πŸ—’οΈ On request
Cost basis ❌ Not Supported πŸ—’οΈ On request
Balance assertion ❌ Not Supported πŸ—’οΈ On request
Virtual postings ❌ Not Supported πŸ—’οΈ On request
comment πŸ‘» Ignored πŸ—’οΈ On request
Secondary date ² ❌ Not Supported ❌ Won't implement
Block comment ❌ Not Supported πŸ—’οΈ On request
account directive ❌ Not Supported πŸ—’οΈ On request
Gain postings ❌ Not Supported πŸ—’οΈ On request
alias directive ❌ Not Supported πŸ—’οΈ On request
commodity directive ❌ Not Supported πŸ—’οΈ On request
decimal-mark directive ❌ Not Supported πŸ—’οΈ On request
payee directive ❌ Not Supported πŸ—’οΈ On request
tag directive ❌ Not Supported πŸ—’οΈ On request
Market price directive ❌ Not Supported πŸ—’οΈ On request
include directive ❌ Not Supported πŸ—’οΈ On request
Periodic transaction ❌ Not Supported πŸ—’οΈ On request
apply account ❌ Not Supported πŸ—’οΈ On request
Default commodity ❌ Not Supported πŸ—’οΈ On request
Default year ❌ Not Supported πŸ—’οΈ On request
Other ledger directives ❌ Not Supported πŸ—’οΈ On request
  1. Is part of description
  2. Is deprecated by hledger
  • 'πŸ‘» Ignored' means: The content of this element will be silently dropped if present in a journal. It cannot be added to a Transaction record.
  • '❌ Not Supported' means: This element will cause an error.

Usage #

The following Dart record structure

import 'package:hledger_connector/hledger_connector.dart';

var transaction = Transaction(
  description: 'Example transaction',
  date: DateTime(2026, 1, 1),
  postings: [
    Posting(
      account: 'assets:cash',
      amount: Amount(value: -5, symbol: PrecedingSymbol(r'$')),
    ),
    Posting(
      account: 'expenses:food',
      amount: Amount(value: 5, symbol: PrecedingSymbol(r'$')),
    ),
  ],
);

final writeResult = addTransaction(transaction, 'example.journal');

adds the following transaction to the journal:

2026-01-01 Example transaction
    assets:cash    $-5.0
    expenses:food   $5.0

You can read the information back with

final readResult = readTransactions('example.journal');

if (readResult is Ok<List<Transaction>>) {
  final transaction = readResult.value.first;
}

The transaction variable contains the record structure that you just wrote to disk.

For more usage examples, see the example/ directory.

Contact #

If you have any questions just drop a message at mail@centaurus22.de.

0
likes
160
points
113
downloads

Documentation

API reference

Publisher

verified publishercentaurus22.de

Weekly Downloads

A library to connect with the hledger plain text accounting system https://hledger.org/.

Repository (GitHub)
View/report issues

Topics

#accounting #tracking #finance #journal #plain-text

Funding

Consider supporting this project:

www.paypal.com

License

MIT (license)

More

Packages that depend on hledger_connector