What double-entry accounting libraries are available for Java?
-
No responses so far, so does this mean that there aren't any? – Derek Mahar Sep 03 '10 at 22:21
-
1It seems that there may be an opportunity here for a small open source project. – Derek Mahar Sep 14 '10 at 21:17
-
The small open source project is ready and available as a library from the Central Repository: mvnrepository.com/artifact/com.yanimetaxas/bookkeeping Enjoy! – Yani Sep 23 '18 at 01:45
8 Answers
I did write a library for myself, but since it was for a really trivial application, I don't know if it would suit a general purpose accounting need.
It has an interface like:
ledger.newPosting(new Date(), "Received $10 from Anne")
.debit("Cash:Anne", 1000)
.credit("Dues Received", 1000)
.post();
int cashBalance = ledger.getAccount("Cash").getTrialBalance();
assertEquals(-1000, cashBalance);
int anneBalance = ledger.getAccount("Cash:Anne").getTrialBalance();
assertEquals(-1000, anneBalance);
int duesBalance = ledger.getAccount("Dues Received").getTrialBalance();
assertEquals(1000, duesBalance);
Is this the kind of thing you're looking for? Anyone else actually INTERESTED in this code? I wrote it generically, but never published it because I didn't think anyone would want something this trivial.

- 429
- 3
- 8
-
I think this is a step in the right direction. According to your sample code, a posting to a ledger requires one or more debits and credits and I assume these must balance for the posting to be successful. The trial balance is also a valid double-entry accounting concept. I'm familiar with the concept of posting to a ledger, but I think I prefer the term transaction over posting (or maybe you could post a transaction to the ledger). – Derek Mahar May 16 '11 at 14:49
-
1Does your library support the relationship between asset, liability, and equity accounts? These are key concepts in accounting (http://en.wikipedia.org/wiki/Accounting_equation). – Derek Mahar May 16 '11 at 14:51
-
1@Derek: I didn't explicitly link asset, liability and equity accounts (as I said: it was for a trivial personal application), but I am familiar with them. I am sure it wouldn't be too hard to model. For posting, if it was unbalanced, it would throw an exception. Because the code was responsible for entering transactions, an unbalanced transaction was a bug in my code. Dunno what one would do for a real system. Is one allowed to post unbalanced transactions? And yeah, just rename Posting to Transaction. I used Posting because that's the term I was more familiar with. – CodeSlinger Jul 18 '11 at 18:05
-
Have you published the source code to your library to any repositories? – Derek Mahar Jul 19 '11 at 16:35
-
@Derek: No, I haven't. Have any suggestions on what I should do with it? I could just mail you the tarball. :-) – CodeSlinger Jul 19 '11 at 17:23
-
8
There's a Swedish project called fribok.org (free (as in GNU free) accounting). It's an application too, but might be componentized and contain what you look for (given that GPL is a viable option for you).

- 988
- 1
- 10
- 17
How about jLedger - Java Business Accounting API?
Citing the project's home page: "This is a Java Business Accounting API that consist of invoicing, general ledger, stock/inventory control and other business API that will assist java developer to build a business software with ease."
Note, however, that this project releases the software under the GNU GPL v2 license, not the Apache license that's usually associated with Java-related projects.
GNU GPL is a copyleft license and libraries licensed under it may not be appropriate for internally developed or commercial software.

- 845
- 9
- 8
-
1A quick look at the jLedger site on SourceForge reveals that the jLedger project hasn't seen an update since it's 1.1 Beta release in September 2009. – Derek Mahar Apr 16 '13 at 22:10
There is this more recent implementation using JTA and Spring. As it states:
The Double-entry bookkeeping concept implemented with Spring 4, the Java Transaction API and the H2 database in embedded mode

- 8,575
- 10
- 55
- 80
-
This API is updated and is available as a library from the Central Repository: https://mvnrepository.com/artifact/com.yanimetaxas/bookkeeping – Yani Sep 23 '18 at 01:34
-
1JMoney is more an application than a library. I was thinking of a Java library that would enable a client application to record transactions that conform to the balance sheet equation (see http://en.wikipedia.org/wiki/Accounting_equation). The transaction "record" would be some in-memory representation that an application could store to the file system or to a relational database. These alternative storage options need not be the responsibility of the library, however. The focus of the library would be to correctly represent basic double-entry accounting transactions. – Derek Mahar Sep 05 '10 at 05:46
Well, I am not aware of any such libraries. Personally me thinks that double entry accounting framework would boil down to couple of interfaces and minimal code to ensure equation invariants. Hence no libs for that: try to bite a relevant code snippet from JMoney or something like that... ;)

- 4,182
- 4
- 26
- 41
-
5What would make it interesting is if it had support for the different accounting plans/schemes used throughout the world, e.g. EU BAS 97, EU BAS 2003 which are popular in Sweden and I would guess within EU... :-) Also you could imagine support balance sheet reports, profits reports, closing of books etc. There is a lot more to double accounting than just keeping the accounts balanced. – Christoffer Soop Sep 07 '10 at 06:19
-
1oh, these details of course make a lot of difference... reporting feels for me more like a complete application, not a framework. as for the plans/schemes - this might be a good idea for a library, but this would be a pain to implement and test... – Anton Kraievyi Oct 13 '10 at 04:57
The best I have seen is a jPos module called minigl which is part of jpos-ee., The jPOS framework is used widely in many production grade deployments. I have personally used in at scale on some high-profile projects.
You will need to get up to speed on jpos-ee, a very solid java framework for all things payment and fintech related. It is worth the learning curve as if you are asking about ledgers you are probably going to have other needs which are likely already addressed in the jPos codebase.

- 1
I just wrote a java library for accounting. The beauty of my library is that it uses a 4GL to do the credits, debits and ledgers. You can also import other functions to handle inventory, payroll and things like that. Fetal Libraries

- 1
- 2