accounts Package

models Module

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

Holds information on Accounts.

get_balance()[source]

Returns the value balance for the Account.

The Account model stores the credit/debit balance in the balance field. This method will convert the credit/debit balance to a value balance for Account.type where a debit increases the Account's value, instead of decreasing it(the normal action).

The Current Year Earnings Account does not source it’s balance field but instead uses the Sum of all Accounts with type of 4 to 8.

See also

flip_balance() method for more information on value balances.

Returns:The Account’s current value balance.
Return type:decimal.Decimal
get_balance_by_date[source]

Calculate the Account's balance at the end of a specific date.

For the Current Year Earnings Account, Transactions from all Accounts with type of 4 to 8 will be used.

Parameters:date (datetime.date) – The day whose balance should be returned.
Returns:The Account’s balance at the end of the specified date.
Return type:decimal.Decimal
get_balance_change_by_month(date)[source]

Calculates the Accounts net change in balance for the month of the specified date.

For the Current Year Earnings Account, Transactions from all Accounts with type of 4 to 8 will be used.

Parameters:date (datetime.date) – The month to calculate the net change for.
Returns:The Account’s net balance change for the specified month.
Return type:decimal.Decimal
class accounts.models.BaseAccountModel(*args, **kwargs)[source]

Abstract class storing common attributes of Headers and Accounts.

Subclasses must implement the _calculate_full_number and _get_change_tree methods.

clean()[source]

Set the type and calculate the full_number.

The type attribute will be inherited from the parent and the full_number will be calculated if the object has an id.

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

Renumber Headers or Accounts when deleted.

get_full_number()[source]

Retrieve the Full Number from the model field.

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

Resave Headers or Accounts if the parent has changed.

This method first checks to see if the parent attribute has changed. If so, it will cause the object and all related objects(the change_tree) to be saved once the pending changes have been saved.

class accounts.models.Header(*args, **kwargs)[source]

Groups Accounts Together.

get_account_balance()[source]

Traverse child Headers and Accounts to generate the current balance.

Returns:The Value Balance of all Accounts and Headers under this Header.
Return type:decimal.Decimal
class accounts.models.HistoricalAccount(*args, **kwargs)[source]

A model for Archiving Historical Account Data. It stores an Account's balance (for Assets, Liabilities and Equities) or net_change (for Incomes and Expenses) for a certain month in a previous Fiscal Years.

Hard data is stored in additon to a link back to the originating Account.

Note

This model is automatically generated by the add_fiscal_year() view.

Note

This model does not inherit from the BaseAccountModel because it has no parent attribute and cannot inherit from MPTTModel.

account

The Account this HistoricalAccount was generated for. The HistoricalAccount will remain even if the Account is deleted.

number

The Account number, formatted as type-num must be unique with respect to date.

name

The Account’s name, must be unique with respect to date.

type

The Account’s type, chosen from TYPE_CHOICES.

amount

The end-of-month balance for HistoricalAccounts with type 1-3, and the net change for HistoricalAccounts with type 4-8. This field represents the credit/debit amount not the value amount. To retrieve the value amount for a HistoricalAccount use the get_amount() method.

date

A datetime.date object representing the 1st day of the Month and Year the archive was created.

flip_balance[source]

Determines whether the HistoricalAccount.amount should be flipped based on the HistoricalAccount.type.

For example, debits(negative HistoricalAccount.amount) increase the value of Assets, Expenses, Cost of Sales and Other Expenses, while decreasing the value of all other Account Types.

In essence, this method will return True if the credit/debit amount needs to be negated(multiplied by -1) to display the value amount, and False if the credit/debit amount is the displayable value amount.

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

The default URL for a HistoricalAccount points to the listing for the date's month and year.

get_amount[source]

Calculates the flipped/value balance or net_change for Asset, Cost of Sales, Expense and Other Expense HistoricalAccounts.

The amount field for HistoricalAccounts represents the credit/debit amounts but debits for Asset, Cost of Sales, Expense and Other Expenses represent a positive value instead of a negative value. This function returns the value amount of these accounts instead of the debit/credit amount. E.g., a negative(debit) amount will be returned as a positive value amount.

If the HistoricalAccount is not one of these types, the HistoricalAccounts normal amount will be returned.

Returns:The value amount for the HistoricalAccount
Return type:decimal.Decimal

managers Module

class accounts.managers.AccountManager[source]

A Custom Manager for the Account Model.

This class inherits from the CachingTreeManager.

active()[source]

This method will return a Querset containing all Active Accounts.

get_banks()[source]

This method will return a Queryset containing any Bank Accounts.

forms Module

views Module

signals Module

accounts.signals.transaction_delete(sender, instance, **kwargs)[source]

Refund Transaction before deleting from database.

accounts.signals.transaction_postsave(sender, instance, **kwargs)[source]

Change Account Balance on Save.

accounts.signals.transaction_presave(sender, instance, **kwargs)[source]

Refund Account balances if updating a Transaction.