hledger_connector 0.3.0 copy "hledger_connector: ^0.3.0" to clipboard
hledger_connector: ^0.3.0 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.

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.
  • Returns a Success when everything has worked correctly or an Error which contains an error message.

Planned features #

  • Filter a List of Transactions by account names, dates etc.
  • Write a list of Transactions with one file access instead one access for every Transaction.
  • Transform a Transaction from and to a string without any file access for example to send it over the net or save it in a database.
  • Add a warning if a journal contains an ignored feature.

List #

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

Feature Supported Future dev?
Basic transaction โœ… Supported
Tag ๐Ÿ‘ป Ignored ๐Ÿ—’๏ธ On request
Group values by spaces โŒ Not Supported ๐Ÿ—’๏ธ 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),
  subTransactions: [
    SubTransaction(
      account: 'assets:cash',
      amount: Amount(value: -5, unit: r'$')
    ),
    SubTransaction(
      account: 'expenses:food',
      amount: Amount(value: 5, unit: r'$')
    )
]);

final writeResult = addTransaction(transaction, 'test.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('test.journal');

if (readResult is Success) {
  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
100
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