hledger_connector 0.6.1
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 |
- Is part of description
- 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.