django的复式记账模块
swingtix-bookkeeper的Python项目详细描述
最初为SwingTix开发的double-entry bookkeeping系统。
你好,世界
你需要一个django项目。如果你手边没有,你可以做一个空的 django tutorial的第一步。之后, 编辑<;yourproject>;/settings.py将“swingtix.bookkeeper”添加到已安装的应用程序并运行:
$ python manage.py syncdb
然后您就可以开始使用shell进行探索:
$ python manage.py shell
首先,我们创建几个帐户:
>>> from swingtix.bookkeeper.models import BookSet, Account >>> book = BookSet(description="my book") >>> book.save() >>> revenue = Account(bookset=book, name="revenue", positive_credit=True) >>> revenue.save() >>> bank = Account(bookset=book, name="bank", positive_credit=False) >>> bank.save() >>> expense = Account(bookset=book, name="expense", positive_credit=False) >>> expense.save()
然后您可以使用它们:
>>> book = BookSet.objects.get(description="my book") >>> revenue = book.get_account("revenue") >>> bank = book.get_account("bank") >>> expense = book.get_account("expense") #Someone pays you can advance. Yay! >>> bank.debit(120.00, revenue, "our first sale") (<AccountEntry: 120 >, <AccountEntry: -120 >) #but now you have to do some work. The local coffee shop has free wifi.. >>> bank.credit(2.20, expense, "coffee") (<AccountEntry: -2 >, <AccountEntry: 2 >) >>> bank.balance() Decimal('117.80') >>> expense.balance() Decimal('2.20') >>> revenue.balance() Decimal('120.00')