BookKeeper
BookKeeper is a low-level library you can use to implement more complicated double-entry accounting applications. It has a very basic chart of accounts and facilities for making journal entries, closing accounting periods and generating data structures suitable for creating an income statement and balance sheet. It's up to you to define a more compliex chart of accounts and implement the flows of money through the system.
Blackground
You should have a basic knowledge of accounting to use BookKeeper. If you don't, start with the great Accounting for Developers tutorials from the good folks at subledger.com.
Suitability
Don't use BookKeeper to manage real money. It's not thorougly tested and I'm not an accountant. If you're managing real money, try SubLedger.
Note: I have no relationship with subledger at all. I just really like their tutorial.
Live Demo
(Comming soon)
Install
npm install bookkeeper --save-dev
or
git clone https://github.com/adamcarheden/bookkeeper.git
Usage
Basic
basic.js
var BookKeeper = default var coa = // Period (2016 below) is an arbitrary value that you choosevar period = '2017' coa var cash = coaassetsvar sales = coaincomevar supplies = coaexpensesvar incomeSummary = coaincomevar retainedEarnings = coaequity period period console/*-= Chart Of Accounts (Before close) =-GeneralLedger $ 200.00 Assets $ 50.00 Cash $ 50.00 Liabilities $ 0.00 Equity $ 0.00 Retained Earnings $ 0.00 Income $ 100.00 Sales $ 100.00 Income Summary $ 0.00 Expenses $ 50.00 supplies $ 50.00 Changes to Equity $ 0.0*/console/*-= General Ledger (Before close) =- Debits Credits AccountMade a sale $100.00 Cash $100.00 Sales Bought supplies $50.00 supplies $50.00 Cash*/periodconsole/*-= Income Statement =-Income $ 100.00 Sales $ 100.00 Income Summary $ 0.00 Expenses $ 50.00 supplies $ 50.00 Profit/(Loss): $ 50.00 Changes to Equity $ 0.00*/console/*-= Balance Sheet =-Assets $ 50.00 Cash $ 50.00 Liabilities $ 0.00 Net Worth $ 50.00 Equity $ 50.00 Retained Earnings $ 50.00*/console/*-= Chart Of Accounts (After close) =-GeneralLedger $ 100.00 Assets $ 50.00 Cash $ 50.00 Liabilities $ 0.00 Equity $ 50.00 Retained Earnings $ 50.00 Income $ 0.00 Sales $ 0.00 Income Summary $ 0.00 Expenses $ 0.00 supplies $ 0.00 Changes to Equity $ 0.00*/console/*-= General Ledger (After close) =- Debits Credits AccountMade a sale $100.00 Cash $100.00 Sales Bought supplies $50.00 supplies $50.00 Cash Close sales $100.00 Sales $100.00 Income Summary Close supplies $50.00 Income Summary $50.00 supplies Close income summary $50.00 Income Summary $50.00 Retained Earnings*/// For programmers thinking thinking "for a simple example, this ain't so simple",// don't blame me, I didn't invent accounting.// For accountants thinking "No, no that's all wrong", stop being pedantic.// Accounting need not be that complicated.
Complex example
complex.js
var BookKeeper = default var coa = // http://accountinginfo.com/study/inventory/inventory-110.htm // Equityvar ownersEquity = coaequityvar retainedEarnings = coaequityvar draw = coachangesToEquity// Assetsvar cash = coaassetsvar inventory = coaassetsvar ar = coaassets// Liabilitiesvar ap = coaliabilitieslet loan = amount: 20000 apr: 0065 payments: 5 * 12var loanPayable = coaliabilities// Incomevar sales = coaincomevar incomeSummary = coaincome// Expensesvar rent = coaexpensesvar interest = coaexpensesvar cogs = coaexpenses // Open the businessvar p0 = '0' // An arbitrary name for the period. BookKeeper itself doesn't use this at present coa {} // A function to close the period. (optional). It's called automatically if you access the income statement or balance sheet.p0p0console/*-= Opening Balance =-Assets $ 30,000.00 Cash $ 30,000.00 Inventory of Widgets $ 0.00 Acconts Receivable $ 0.00 Liabilities $ 20,000.00 Accounts Payable $ 0.00 Bank Loan (60 months @ 6.5%) $ 20,000.00 Net Worth $ 10,000.00 Equity $ 10,000.00 Owner's Equity $ 10,000.00 Retained Earnings $ 0.00 */ var p1 = '1' coa// Make somethingp1// Sell somethinglet profitMargin = 03let sale = 7000let merch = sale * 1-profitMarginp1sale = 3000merch = sale * 1-profitMarginp1// Pay billsp1// http://homeguides.sfgate.com/calculate-principal-interest-mortgage-2409.htmllet pInt = loanapr / 12let payment = Math / 100let intr = Math / 100let principal = Math / 100p1p1// Take some profitsp1 // Close the booksvar { if cashbalance < 0 throw `You're bankrupt` p1 p1 if incomeSummarybalance > 0 // Profit! p1 else if incomeSummarybalance < 0 // Loss :( p1 if drawbalance > coaequitybalance throw `Company policy doesn't allow you to take a loan from the business.` p1 }p1consoleconsole/*-= Income Statement =-Income $ 10,000.00 Sales $ 10,000.00 Income Summary $ 0.00 Expenses $ 8,608.33 Rent $ 1,500.00 Interest Expense $ 108.33 Cost of Goods Sold $ 7,000.00 Profit/(Loss): $ 1,391.67 Changes to Equity $ 1,000.00 Owner's Draw $ 1,000.00*/console/*-= Balance Sheet =-Assets $ 30,108.68 Cash $ 22,108.68 Inventory of Widgets $ 1,000.00 Acconts Receivable $ 7,000.00 Liabilities $ 19,717.01 Accounts Payable $ 0.00 Bank Loan (60 months @ 6.5%) $ 19,717.01 Net Worth $ 10,391.67 Equity $ 10,391.67 Owner's Equity $ 10,000.00 Retained Earnings $ 391.67*/console/*GeneralLedger $ 60,217.36 Assets $ 30,108.68 Cash $ 22,108.68 Inventory of Widgets $ 1,000.00 Acconts Receivable $ 7,000.00 Liabilities $ 19,717.01 Accounts Payable $ 0.00 Bank Loan (60 months @ 6.5%) $ 19,717.01 Equity $ 10,391.67 Owner's Equity $ 10,000.00 Retained Earnings $ 391.67 Income $ 0.00 Sales $ 0.00 Income Summary $ 0.00 Expenses $ 0.00 Rent $ 0.00 Interest Expense $ 0.00 Cost of Goods Sold $ 0.00 Changes to Equity $ 0.00 Owner's Draw $ 0.00*/
Chart of Accounts
The BookKeeper ChartOfAccounts object contains the following accounts by default:
Name | Normal Balance |
---|---|
assets | Debit |
liabilities | Credit |
equity | Credit |
income | Credit |
expenses | Debit |
changesToEquity | Debit |
Assets, liabilities and equity end up on the balance sheet. Income, expenses and changes equity (investments and withdrawl of profits) end up on the income statement.
Period End
Prior to generating a period's financial statements you must close that period. Closing a period means:
- All temporary accounts (income, expenses and changes to equity) must have a zero balance. This usually means a journal entry to transfer the balance to a balance sheet account.
- No additional journal entries may be made for that period.
You need not provide a closing function. Bookkeeper has a built-in one that does the right thing with it's default accounts. However, the whole point of accounting is a more granular tracking of how money flows through your business so you probably want to provide your own closing function that meets your reporting needs.
Roadmap
Bookkeepr does what I want it to, so I have no plans to develop it further in the near future. It could use dates in the journal entries that auto-map to some predefined periods though. A more thorough unit testing regime would also probably be a good idea. PRs welcome.
Current State
Alpha. It seems to work but has somewhat sparse unit testing. Also, I'm not an accountant, so "seems to work" for me is not necessarily GAAP compliant.
Contributing
git clone https://github.com/adamcarheden/bookkeeper.gitcd bookkeepernpm installnpm run buildnpm run testnpm run examples
PRs welcome.