hledger_connector 0.3.0
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 |
- 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),
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.