ledger package

Submodules

ledger.admin module

class ledger.admin.AccountAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

balance()[source]
list_display = ('pk', 'handle', 'currency', <function AccountAdmin.balance>)
list_filter = ('currency',)
property media
class ledger.admin.TransactionAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

inlines = (<class 'ledger.admin.TransferInline'>,)
list_display = ('pk', 'currency', 'description')
property media
class ledger.admin.TransferInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

property media
model

alias of ledger.models.Transfer

ledger.apps module

class ledger.apps.LedgerConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'ledger'

ledger.models module

class ledger.models.Account(*args, **kwargs)[source]

Bases: django.db.models.base.Model

An Account is an accounting account on which sums can be debited or credited by a Transfer. Each Account is addressable by a unique handle.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

currency

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_balance()[source]
handle

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
transfer_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ledger.models.Transaction(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A Transaction represents a single accounting journal entry that groups together one or more debits and credits on Accounts as represented by Transfers.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

currency

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ledger.models.TransactionManager object>
transfer_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ledger.models.TransactionManager(*args, **kwargs)[source]

Bases: django.db.models.manager.Manager

add_transaction(currency, transfers)[source]

Add a single Transaction where ‘currency’ is the Transaction currency, and ‘transfers’ is a list of data to create Transfer objects with keys ‘account’, ‘amount’ and ‘description’. The ‘account’ is an Account.handle. The Account is created if it doesn’t exist. The amounts of all Transfers must add up to a zero. Returns the created Transaction.

class ledger.models.Transfer(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A Transfer is a single debit or a credit on an Account. Multiple Transfers are grouped together by a Transaction to form a single accounting journal entry. Positive amounts represent debits and negative amounts credits.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

account

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

account_id
amount

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
transaction

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

transaction_id

ledger.tests module

ledger.views module