Coder Social home page Coder Social logo

pacioli's Introduction

About

Author: Massimo Di Pierro <[email protected]>
License: BSD <http://opensource.org/licenses/BSD-3-Clause>
Created on: 2013-02-20

This program is named after Luca Pacioli (1445โ€“1517), inventor of accounting and double-entry bookkeeping. Pacioli maintained that business people must insist on justice, honour, and truth.

The program contains three parts:

An implementation of double-entry bookkeeping

  • Assets, Liabilities, Equity, Income, Expenses
  • Computations of Balance Sheet and Profit/Losses
  • Automatic computation FIFO capital-gains
  • API
  • Scenario analysis (WORK IN PROGRESS)

Functions to read and write a general ledger in the beancount format

  • list of accounts
  • support for ofx records
  • transactions with multiple postings
  • tags
  • checks
  • support for multiple files and partial output

Reporting

  • The output of the program is in HTML
  • Reporting in Latex/PDF (can be improved)
  • Reporting in JSON (WORKM IN PROGRESS)
  • Charting

This program uses a single file to store the input ledger. This is only appropriate for small bussinesses. Our benchmark indicates that the program requires 0.0004 seconds/transactions. Therefore if a business processes about 1000 transaction/day, the system can process one year of trasactions in about 2 minutes. Additional time is required to generate reports.

!!Attention!!

This program is usable but:

  • It is a work in progress.
  • It may need more testing.
  • We plan to add feature.
  • We may break the API. The documentation is incomplete.
  • I am not an accountant

Help

./pacioli.py -h

Example

Consider a simple business that buys wood and sells wood toys.

; file: toystore.ledger
; define your accounts
@defaccount De Assets:Cash
@defaccount De Assets:AccountsReceivable
@defaccount Cr Liabilities:Loan
@defaccount Cr Liabilities:AccountPayable
@defaccount Cr Equity:Opening-Balances
@defaccount De Income:ToySale
@defaccount De Income:Capital-Gains
@defaccount Cr Expense:ShippingCosts
@defaccount Cr Expense:Monthly:LoanInterest

; put initial money in cash account
@pad   2013-01-01 Assets:Cash Equity:Opening-Balances
@check 2013-01-01 Assets:Cash 2000 USD

; transactions
2013-01-01 * Receive a loan
    Assets:Cash                   +10000 USD
    Liabilities:Loan              -10000 USD

2013-02-01 * Pay load interest
    Assets:Cash                   -300 USD
    Liabilities:Loan              +125 USD
    Expense:Monthly:LoanInterest           ; automatically computed as 300-125 = 275 USD

2013-03-01 * buy wood
    Expense:ShippingCosts          500 USD
    Assets:Cash                            ; automatically computes as -(9*1000+500) USD

@begintag client-0001
2013-04-01 * first toy sale (cash transaction)
    Income:ToySale                -230 USD ; $230 from client #0001
    Assets:Cash                            ; automatically computed as 230 USD
@endtag client-0001

@check 2013-04-01 Assets:Cash     2430 USD ; 2000+10000-9*1000-500+230 = 2430 USD

; read more about AccountsReceivable
; http://www.investopedia.com/terms/a/accountsreceivable.asp

@begintag client-0002
2013-04-02 * second toy sale (invoice)
    Income:ToySale                -230 USD ; $230 billed to client #0001
    Assets:AccountsReceivable              ; automatically computed as 230 USD

2013-04-10 * second toy sale (payment received after one week)
    Assets:AccountsReceivable     -230 USD ; $230 received from client #0001
    Assets:Cash                            ; automatically computed as 230 USD
@endtag client-0002

@check 2013-04-10 Assets:Cash     2660 USD ; 2000+10000-9*1000-500+230*2 = 2460 USD

Run it with

./pacioli.py -B -i toystore.ledger > toystore.balance

The output will be in toystore.ledger.output and toystore.balance

banchmark: 4.11e-04 sec/transaction
Assets                        : 2660.0 USD
Assets:AccountsReceivable     : 0.0 USD
Assets:Cash                   : 2660.0 USD
Equity                        : -2000.0 USD
Equity:Opening-Balances       : -2000.0 USD
Expense                       : 675.0 USD
Expense:Monthly               : 175.0 USD
Expense:Monthly:LoanInterest  : 175.0 USD
Expense:ShippingCosts         : 500.0 USD
Expenses                      : 
Income                        : -460.0 USD
Income:Capital-Gains          : 
Income:ToySale                : -460.0 USD
Liabilities                   : -9875.0 USD
Liabilities:AccountPayable    : 
Liabilities:Loan              : -9875.0 USD

More docs?

Most of the documentation about ledger and beancount applies to pacioli.

Why?

So why pacioli.py when we have beancount? I mostly made it for myself. I wanted to rewrite beancount from scratch to understand it. The result (pacioli) performs the same functions but it is much smaller (~800 lines of code). I believe pacioli has better API. I have plans to turn it into a web application and integrate it with d3.js. Beancount is GPL. Pacioli is BSD.

API

Pacioli can be used programmatically:

>>> from pacioli import *
>>> p = Pacioli()
>>> p.add_account('Assets:Cash','De','USD')
>>> p.add_account('Equity','Cr','USD')
>>> p.ledger.append(Transaction('2008-10-20','info',postings=[
...     Posting('Assets:Cash',amount=Amount(100,'USD')),
...     Posting('Equity')]))
>>> p.ledger.sort()
>>> p.save('test.ledger')
>>> p.run()
>>> p.report()
>>> p.dump_html('folder')
>>> p.dump_latex('folder/report.latex')
>>> assert p.accounts['Assets'].wallet['USD'] == +100
>>> assert p.accounts['Equity'].wallet['USD'] == -100

Web server

Pacioli uses Tornado to serve the genarated documents:

./pacioli.py -i demo.ledger -w 8080

The generated documents are just static html files therefore they can served using other server.

Latex

Pacioli generates also a <input.ledger>.output/<input.ledger>.latex file. You can process it with

./pacioli.py -i demo.ledger
cd demo.ledger.output
pdflatex demo.ledger.latex
open demo.ledger.pdf

Other files

Pacioli includes the file demo.ledger which we stole from beancount and we used for testing purposes. It also includes a demo.ledger.output generated from this example.

Pacioli also includes a gaap.lendger (GAAP = General Accepted Accounting Practices) which you can customized and use for your business.

License

BSD v3

pacioli's People

Contributors

mdipierro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pacioli's Issues

ValueError: need more than 2 values to unpack

hank@shelob ~/repos/pacioli $ python pacioli.py -i eriktest.ledger
Traceback (most recent call last):
  File "pacioli.py", line 913, in <module>
    if __name__=='__main__': main()
  File "pacioli.py", line 903, in main
    p.run()
  File "pacioli.py", line 445, in run
    item.run(self)
  File "pacioli.py", line 207, in run
    (m,v,a) = fifo[0]
ValueError: need more than 2 values to unpack

Input:

@defaccount De Assets:Investments:UTrade           USD
@defaccount De Assets:Investments:UTrade:AAPL      AAPL
@defaccount De Expenses:Financial:Commissions
@defaccount De Assets:Cash                         USD
@defaccount Cr Income:Investments:Capital-Gains

2008-01-01 * Transferring money to brokerage account for better investment.
  Assets:Cash                        -10000.00 USD
  Assets:Investments:UTrade

2008-01-08 * Buy AAPL
  Assets:Investments:UTrade:AAPL    30 AAPL @ 100 USD
  Expenses:Financial:Commissions    9.95 USD
  Assets:Investments:UTrade

2008-01-08 * Buy More AAPL
  Assets:Investments:UTrade:AAPL    50 AAPL @ 120 USD
  Expenses:Financial:Commissions    9.95 USD
  Assets:Investments:UTrade

2008-02-28 * Sell off AAPL
  Assets:Investments:UTrade:AAPL    -40 AAPL @ 140 USD
  Expenses:Financial:Commissions               9.95 USD
  Assets:Investments:UTrade
  (Income:Investments:Capital-Gains)           BOOK AAPL

2008-02-29 * Sell off AAPL
  Assets:Investments:UTrade:AAPL    -40 AAPL @ 160 USD
  Expenses:Financial:Commissions               9.95 USD
  Assets:Investments:UTrade
  (Income:Investments:Capital-Gains)           BOOK AAPL

FIFO Capital Gains

So, I have a simple ledger:

@defaccount De Assets:Investments:UTrade           USD
@defaccount De Assets:Investments:UTrade:AAPL      AAPL
@defaccount De Expenses:Financial:Commissions
@defaccount De Assets:Cash                         USD
@defaccount Cr Income:Investments:Capital-Gains

2008-01-01 * Transferring money to brokerage account for better investment.
  Assets:Cash                        -10000.00 USD
  Assets:Investments:UTrade

2008-01-08 * Buy AAPL
  Assets:Investments:UTrade:AAPL    30 AAPL @ 100 USD
  Expenses:Financial:Commissions    9.95 USD
  Assets:Investments:UTrade

2008-01-08 * Buy More AAPL
  Assets:Investments:UTrade:AAPL    50 AAPL @ 120 USD
  Expenses:Financial:Commissions    9.95 USD
  Assets:Investments:UTrade

2008-02-28 * Sell off AAPL
  Assets:Investments:UTrade:AAPL    -40 AAPL @ 140 USD
  Expenses:Financial:Commissions               9.95 USD
  Assets:Investments:UTrade
  (Income:Investments:Capital-Gains)           BOOK AAPL

I expect the capital gain to be $1400 (30 shares sold at $40 profit each, 10 shares sold at a $20 profit each). Instead, I get this:

Assets                                  : 40.0 AAPL, -3429.85 USD
Assets:Cash                             : -10000.00 USD
Assets:Investments                      : 40.0 AAPL, 6570.15 USD
Assets:Investments:UTrade               : 40.0 AAPL, 6570.15 USD
Assets:Investments:UTrade:AAPL          : 40.0 AAPL
Equity                                  :
Expenses                                : 29.85 USD
Expenses:Financial                      : 29.85 USD
Expenses:Financial:Commissions          : 29.85 USD
Income                                  : -1600.0 USD
Income:Investments                      : -1600.0 USD
Income:Investments:Capital-Gains        : -1600.0 USD
Liabilities                             :

So, it seems like the gain is calculated incorrectly. Please advise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.