entries Package

models Module

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

Transactions itemize Account balance changes.

Transactions are grouped by Entries and Events. Entries group Transactions by date while Events group by specific events.

Transactons can be related to Entries through the journal_entry, bankspend_entry or bankreceive_entry attributes, or through the main_transaction attribute of the BankReceivingEntry or BankSpendingEntry models. Transactions may only be related to Entries through one of these ways, never multiple ones.

journal_entry

The JournalEntry this Transaction belongs to, if any.

bankspend_entry

The BankSpendingEntry this Transaction belongs to, if any.

bankreceive_entry

The BankReceivingEntry this Transaction belongs to, if any.

account

The Account this Transaction is charged to.

detail

Information about the specific charge.

balance_delta

The change in balance this Transaction represents. A positive value indicates a Credit while a negative value is a Debit.

event

The Event this Transaction is related to, if any.

reconciled

Whether or not this Transaction has been marked as Reconciled.

date

The datetime.date of the Transaction. By default, this is automatically pulled from the related Entry when the Transaction is saved.

clean()[source]

Prevent relations to a void BankSpendingEntry.

get_absolute_url(*moreargs, **morekwargs)[source]

Return a URL to the related Entry’s detail page.

get_entry_number()[source]

Return the related Entry’s number.

get_final_account_balance()[source]

Return the Account's value balance after the Transaction has occured.

This is accomplished by subtracting the balance_delta of all newer Transactions balance.

Note

The value balance is not the same as credit/debit balance. For Assets, Liabilities and Equity Accounts, a debit balance means a positive value balance instead of the normal negative value balance.

Returns:The Account's post-transaction value balance.
Return type:Decimal
get_initial_account_balance()[source]

Return the value balance of the Account from before the Transaction occured.

Returns:The Account's pre-transaction value balance.
Return type:Decimal
get_journal_entry()[source]

Return the related Entry.

get_memo()[source]

Return the related Entry’s memo.

save(pull_date=True, *args, **kwargs)[source]

Pull the date from the related Entry before saving.

class entries.models.BaseJournalEntry(*args, **kwargs)[source]

Journal Entries group Transactions by discrete points in time.

For example, a set of transfers, a check being deposited, stipends being paid.

Journal Entries ensure that Transactions are balanced, that there is an equal amount of credits for every debit.

Note

This class is an abstract class to prevent multi-table inheritance.

See also

Module entries.views
Views related to showing, creating and editing Entries.
date

The date the entry occured.

memo

A short description of the Entry.

comments

Any additional comments about the Entry.

created_at

The date and time the Entry was created.

updated_at

The date and time the Entry was last updated. Defaults to created_at.

get_absolute_url()[source]

Return a link to the Entry’s detail page.

get_edit_url()[source]

Return an edit link to the Entry’s edit page.

get_number()[source]

Return the number of the Entry.

in_fiscal_year()[source]

Determines whether the BaseJournalEntry.date is in the current FiscalYear.

Returns True if there is no current FiscalYear.

Returns:Whether or not the date is in the current FiscalYear.
Return type:bool
class entries.models.JournalEntry(*args, **kwargs)[source]

A concrete class of the BaseJournalEntry model.

get_absolute_url(*moreargs, **morekwargs)

Return a link to the Entry’s detail page.

save(*args, **kwargs)[source]

Save all related Transactions after saving.

class entries.models.BankSpendingEntry(*args, **kwargs)[source]

Holds information about a Check or ACH payment for a Bank Account. The main_transaction is linked to the Bank Account.

Bank Spending Entries credit the Bank Account (via the main_transaction) while debiting all related Transactions.

check_number

The number of the Check, if applicable. An ACH Payment should have no check_number and ach_payment value of True will cause the check_number to be set to None. This value must be unique with respect to the main_transaction's account attribute.

ach_payment

A boolean representing if this BankSpendingEntry is an ACH Payment or not. If this is True the check_number will be set to None.

payee

An optional Payee for the BankSpendingEntry.

void

A boolean representing whether this BankSpendingEntry is void. If this value switches from False to True, all of this BankSpendingEntry's Transactions will be deleted and it’s main_transaction will have it’s balance_delta set to 0. Switching void back to False will simply allow transactions to be saved again, it will not recreate any previouse Transactions.

main_transaction

The Transaction that links this BankSpendingEntry with it’s Bank Account.

clean()[source]

Only a check_number or an ach_payment must be entered, not both.

The check_number must be unique per BankSpendingEntry.main_transaction Account.

get_absolute_url(*moreargs, **morekwargs)[source]

Return a link to the Entry’s detail page.

get_edit_url()[source]

Return the Entry’s edit URL.

get_number[source]

Return the formatted check_number or ##ACH##.

save(*args, **kwargs)[source]

Delete related Transactions if void, update Transaction dates.

class entries.models.BankReceivingEntry(*args, **kwargs)[source]

Holds information about receiving money for a Bank Account. The main_transaction is linked to the Bank Account.

Bank Receiving Entries debit the Bank Account (via the main_transaction) while crediting all related Transactions.

payor

The Person or Company making the payment.

main_transaction

The Transaction that links this BankSpendingEntry with it’s Bank Account.

get_absolute_url(*moreargs, **morekwargs)[source]

Return the Entry’s detail page.

get_edit_url()[source]

Return the Entry’s edit page.

get_number[source]

Return the Entry’s formatted number.

save(*args, **kwargs)[source]

Set the date’s of all related Transactions.

managers Module

class entries.managers.TransactionManager[source]

A Custom Manager for the Transaction Model.

Note

Using this Manager as a Model’s default Manager will cause this Manager to be used when the Model is accessed through Related Fields.

get_query_set()[source]

Return a caching.base.CachingQuerySet.

get_totals(net_change=False)[source]

Calculate debit and credit totals for the respective Queryset.

Groups and Sums the default Queryset by positive/negative balance_delta. Totals default to 0 if no corresponding Transaction is found.

Optionally:
  • Returns the Net Change(credits + debits) with the totals.
Parameters:
  • query (Q) – Optional Q query used to filter Manager’s Queryset.
  • net_change (bool) – Calculate the difference between debits and credits.
Returns:

Debit and credit sums and optionally the net_change.

Return type:

tuple

class entries.managers.TransactionQuerySet(*args, **kw)[source]

A wrapper for the caching.base.CachingQuerySet.

The methods of this class mimic the TransactionManager class. This allows the chaining of our custom methods. For example:

Transaction.objects.filter(id__gt=500).get_totals()
get_totals(net_change=False)[source]

See TransactionManager.get_totals().

forms Module

class entries.forms.BankReceivingForm(*args, **kwargs)[source]

A form for the BankReceivingEntry model.

clean_amount()[source]

Negate the amount field.

BankReceivingEntries debit their bank Account> so a positive amount should become a debit and vice versa.

entries.forms.BankReceivingTransactionFormSet

A FormSet of Transactions for use with BankReceivingEntries, derived from the BaseBankTransactionFormSet.

alias of TransactionFormFormSet

class entries.forms.BankSpendingForm(*args, **kwargs)[source]

A form for the BankSpendingEntry model.

entries.forms.BankSpendingTransactionFormSet

A FormSet of Transactions for use with BankSpendingEntries, derived from the BaseBankTransactionFormSet.

alias of TransactionFormFormSet

class entries.forms.BankTransactionForm(*args, **kwargs)[source]

A form for entry of Bank Transactions.

Bank Transactions do not have a credit and debit field, instead they have only an amount. Whether this amount is a credit or debit depends on if the Transaction is related to a models.BankSpendingEntry or a models.BankSpendingEntry.

clean()[source]

Set the balance_delta to the entered amount.

class entries.forms.BaseBankForm(*args, **kwargs)[source]

A Base form for common elements between the BankSpendingForm and the BankReceivingForm.

The account and amount fields be used to create the Entries main_transaction.

account

The Bank Account the Entry is for.

amount

The total amount this Entry represents.

clean()[source]

Cleaning the BaseBankForm will modify or create the BankSpendingEntry.main_transaction or BankReceivingEntry.main_transaction.

The main_transaction will not be saved until this form’s save method is called.

save(*args, **kwargs)[source]

Saving the BaseBankFormForm will save both the BaseBankForm and the BankSpendingEntry.main_transaction or BankReceivingEntry.main_transaction.

class entries.forms.BaseBankTransactionFormSet(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)[source]

An InlineFormSet used to validate it’s form’s amounts balance with the self.entry_form‘s amount.

Note

The self.entry_form attribute must be set by the view instantiating this form.

clean()[source]

Checks that the Transactions’ amounts balance the Entry’s amount.

class entries.forms.BaseEntryForm(*args, **kwargs)[source]

An abstraction of General and Bank Entries.

clean_date()[source]

The date must be in the Current FiscalYear.

class entries.forms.BaseTransactionFormSet(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)[source]

A FormSet that validates that a set of Transactions is balanced.

clean()[source]

Checks that debits and credits balance out.

class entries.forms.JournalEntryForm(*args, **kwargs)[source]

A form for JournalEntries.

class entries.forms.TransactionForm(*args, **kwargs)[source]

A form for Transactions.

It splits the balance_delta field into a credit and debit field. A debit results in a negative balance_delta and a credit results in a positive balance_delta.

clean()[source]

Make sure only a credit or debit is entered and set it to the balance_delta.

entries.forms.TransactionFormSet

A FormSet for Transactions, derived from the BaseTransactionFormSet.

alias of TransactionFormFormSet

class entries.forms.TransferForm(*args, **kwargs)[source]

A form for Transfer Entries, a specialized JournalEntry.

Transfer Entries move a discrete amount between two Accounts. The source is debited while the destination is credited.

source

The Account to remove the amount from.

destination

The Account to move the amount to.

amount

The amount of currency to transfer between Accounts.

detail

Any additional details about the charge.

clean()[source]

Ensure that the source and destination Accounts are not the same.

entries.forms.TransferFormSet

A FormSet for Transfer Transactions, derived from the TransferForm.

alias of TransferFormFormSet

views Module

entries.views.add_bank_entry(request, *args, **kwargs)[source]

Add, Edit or Delete a BankSpendingEntry or BankReceivingEntry.

A journal_type of CD corresponds to BankSpendingEntries while a journal_type of CR corresponds to BankReceivingEntries

If there is no BankSpendingEntry or BankReceivingEntry with an id of the entry_id parameter, a new BankSpendingEntry or BankReceivingEntry will be created.

If the request contains POST data, either validate and save the data or delete the JournalEntry and all related Transactions, depending on if a submit or delete is sent.

Parameters:
  • entry_id (int) – The id of the Entry to edit. If None then a new entry will be created.
  • journal_type (str) – The bank journal of the Entry(CD or CR).
  • template_name (str) – The template to use.
Returns:

HTTP response containing a JournalEntryForm, a TransactionFormSet and a journal_type of GJ.

Return type:

HttpResponse or ~django.http.HttpResponseRedirect

entries.views.add_journal_entry(request, *args, **kwargs)[source]

Add, Edit or Delete a JournalEntry.

If there is no JournalEntry with an id of the entry_id parameter, a new JournalEntry will be created.

If the request contains POST data, either validate and save the data or delete the JournalEntry and all related Transactions, depending on if a submit or delete is sent.

Parameters:
  • entry_id (int) – The id of the Entry to edit. If None then a new entry will be created.
  • template_name (str) – The template to use.
Returns:

HTTP response containing a JournalEntryForm, a TransactionFormSet and a journal_type of GJ.

Return type:

HttpResponse or HttpResponseRedirect

entries.views.add_transfer_entry(request, *args, **kwargs)[source]

Add a Transfer Entry, a specialized JournalEntry.

Transfer Entries are JournalEntries where a discrete amount is being transfered from one account to another.

Normally, JournalEntries require that the Credit and Debit totals are equal. Transfer Entries require that every single Credit charge is balanced with an equal Debit charge.

Transfer Entries do not have their own class, they use the JournalEntry model.

Parameters:template_name (str) – The template to use.
Returns:HTTP response containing a JournalEntryForm, a TransferFormSet and a verbose_journal_type of Transfer Entry.
Return type:HttpResponse
entries.views.journal_ledger(request, template_name='entries/journal_ledger.html')[source]

Display a list of Journal Entries.

Parameters:template_name (str) – The template to use.
Returns:HTTP response containing JournalEntry instances as context.
Return type:HttpResponse
entries.views.show_bank_entry(request, entry_id, journal_type)[source]

Display the details of a BankSpendingEntry or BankReceivingEntry.

Parameters:
  • entry_id (int) – The id of the Entry to display.
  • journal_type (str) – The bank journal of the Entry(CD or CR).
  • template_name (str) – The template to use.
Returns:

HTTP response containing the Entry instance and additional details as context.

Return type:

HttpResponse

entries.views.show_journal_entry(request, entry_id, template_name='entries/entry_detail.html')[source]

Display the details of a JournalEntry.

Parameters:
  • entry_id (int) – The id of the JournalEntry to display.
  • template_name (str) – The template to use.
Returns:

HTTP response containing the JournalEntry instance and additional details as context.

Return type:

HttpResponse