@seneca/ledger
v0.6.4
Published
Ledger business logic plugin for the Seneca platform.
Readme

A Seneca.js plugin
@seneca/ledger
|
| This open source module is sponsored and supported by Voxgig. |
| ---------------------------------------------------- | --------------------------------------------------------------------------------------- |
Ledger business logic plugin for the Seneca platform.
Install
$ npm install @seneca/ledgerQuick Example
// Setup
const seneca = Seneca().use('promisify').use('entity').use('ledger')
await seneca.ready()
// Create an account
await seneca.post('biz:ledger,create:account', {
account: { oref: 'o0', path: 'Asset', name: 'Cash', normal: 'debit' },
})
// Get an account
await seneca.post('biz:ledger,get:account', { aref: 'o0/Asset/Cash' })
// List accounts
await seneca.post('biz:ledger,list:account', { org_id: 'o0' })
// Update an account
await seneca.post('biz:ledger,update:account', {
aref: 'o0/Asset/Cash',
account: { custom_field: 'value' },
})
// Create a book (accounting period)
await seneca.post('biz:ledger,create:book', {
book: { oref: 'o0', name: 'Q1', start: 20220101, end: 20220331 },
})
// Get a book
await seneca.post('biz:ledger,get:book', { bref: 'o0/Q1/20220101' })
// List books
await seneca.post('biz:ledger,list:book', { oref: 'o0' })
// Update a book
await seneca.post('biz:ledger,update:book', {
bref: 'o0/Q1/20220101',
book: { end: 20220331 },
})
// Create a journal entry (double-entry: debit + credit)
await seneca.post('biz:ledger,create:entry', {
bref: 'o0/Q1/20220101',
daref: 'o0/Asset/Cash',
caref: 'o0/Income/Sales',
val: 100,
desc: 'Jan Sales',
date: 20220131,
})
// List entries
await seneca.post('biz:ledger,list:entry', {
oref: 'o0',
bref: 'o0/Q1/20220101',
})
// Balance an account
await seneca.post('biz:ledger,balance:account', {
aref: 'o0/Asset/Cash',
bref: 'o0/Q1/20220101',
})
// Close an account (zero balance and optionally carry forward to target book)
await seneca.post('biz:ledger,close:account', {
aref: 'o0/Asset/Cash',
bref: 'o0/Q1/20220101',
target_bref: 'o0/Q2/20220401',
})
// Close a book (close all accounts and mark book as closed)
await seneca.post('biz:ledger,close:book', {
bref: 'o0/Q1/20220101',
target_bref: 'o0/Q2/20220401',
})
// Export account to CSV
await seneca.post('biz:ledger,export:account,format:csv', {
aref: 'o0/Asset/Cash',
bref: 'o0/Q1/20220101',
})
// Export book to CSV (all accounts summary)
await seneca.post('biz:ledger,export:book,format:csv', {
bref: 'o0/Q1/20220101',
})More Examples
See test/ for more usage examples.
Motivation
A Seneca.js plugin.
Support
If you're using this module and need help, you can:
- Post a github issue
- Tweet to @senecajs
- Ask on the Gitter
API
Options
None.
Action Patterns
- balance:account,biz:ledger
- balance:book,biz:ledger
- biz:ledger,close:account
- biz:ledger,close:book
- biz:ledger,create:account
- biz:ledger,create:book
- biz:ledger,create:entry
- biz:ledger,export:account,format:csv
- biz:ledger,export:book,format:csv
- biz:ledger,get:account
- biz:ledger,get:book
- biz:ledger,list:account
- biz:ledger,list:book
- biz:ledger,list:balance
- biz:ledger,list:entry
- biz:ledger,update:account
- biz:ledger,update:book
- biz:ledger,void:entry
Action Descriptions
« balance:account,biz:ledger »
No description provided.
« balance:book,biz:ledger »
No description provided.
« biz:ledger,close:account »
No description provided.
« biz:ledger,close:book »
No description provided.
« biz:ledger,create:account »
No description provided.
« biz:ledger,create:book »
No description provided.
« biz:ledger,create:entry »
No description provided.
« biz:ledger,export:account,format:csv »
No description provided.
« biz:ledger,export:book,format:csv »
No description provided.
« biz:ledger,get:account »
No description provided.
« biz:ledger,get:book »
No description provided.
« biz:ledger,list:account »
No description provided.
« biz:ledger,list:book »
No description provided.
« biz:ledger,list:balance »
No description provided.
« biz:ledger,list:entry »
No description provided.
« biz:ledger,update:account »
No description provided.
« biz:ledger,update:book »
No description provided.
« biz:ledger,void:entry »
No description provided.
Contributing
The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
Running tests
npm run testBackground
Part of the Senecajs org.
