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.
- 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