# **Django Ledger**
# **Miguel Sanda**
# **Sep 28, 2025**
## **CONTENTS:**
|**1**|**Django Ledger**|**Django Ledger**||**3**|
|---|---|---|---|---|
||1.1|A Double Entry Accounting Engine for Django . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||3|
||1.2|Key Features . . . . . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|3|
||1.3|Getting Involved . . . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|3|
||1.4|Who Should Contribute? . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|4|
|**2**|**Installation**|||**5**|
||2.1|Adding Django Ledger to an existing project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||5|
|||2.1.1
Add django_ledger to INSTALLED_APPS in you new Django Project. . . . . . . . . . . . .||5|
|||2.1.2
Add Django Ledger Context Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . .||5|
|||2.1.3
Perform database migrations: . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|5|
|||2.1.4
Run your project: . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|6|
||2.2|Deprecated behavior setting (v0.8.0+) . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|6|
||2.3|Setting Up Django Ledger for Development|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|6|
|**3**|**How**|** To Set Up Django Ledger for Development**|** using Docker**|**9**|
|**4**|**Run**|** Test Suite**||**11**|
|**5**|**Screenshots**|||**13**|
|**6**|**Financial Statements Screenshots**|||**17**|
|**7**|**API**|** Quickstart**||**21**|
||7.1|Get Your Entity Administrator UserModel|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|21|
||7.2|Get or Create an Entity Model . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|22|
||7.3|Chart of Accounts
. . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|22|
|||7.3.1
Create a Default Chart of Accounts|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|22|
||7.4|Populate Entity with Random Data (Optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||22|
|||7.4.1
Defne a Start Date for Transactions|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|22|
|||7.4.2
EntityModel has now a Default Chart of Accounts . . . . . . . . . . . . . . . . . . . . . . .||23|
||7.5|Chart of Accounts (CoA) . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|23|
|||7.5.1
Django Ledger support multiple chart of accounts.
. . . . . . . . . . . . . . . . . . . . . .||23|
||7.6|Accounts . . . . . . . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|23|
|||7.6.1
Default CoA Accounts . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|23|
|||7.6.2
Get CoA Accounts by CoA Model|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|23|
|||7.6.3
Get CoA Accounts by CoA Model UUID
. . . . . . . . . . . . . . . . . . . . . . . . . . .||23|
|||7.6.4
Get CoA Accounts by CoA Model Slug . . . . . . . . . . . . . . . . . . . . . . . . . . . .||24|
|||7.6.5
Get Accounts With Codes and CoA|Model . . . . . . . . . . . . . . . . . . . . . . . . . . .|24|
|||7.6.6
Create Account Model
. . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|24|
||7.7|Basic Django Ledger Usage . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|25|
**i**
|||7.7.1|Create a Library . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|25|
|---|---|---|---|---|---|---|---|
|||7.7.2|Create and Register a BluePrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||||25|
|||7.7.3|Get a Cursor . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|25|
|||7.7.4|Dispatch Some Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||||25|
|||7.7.5|Commit Your Instructions|||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|26|
||7.8|Customers
. . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
|||7.8.1|Get Customers
. . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
|||7.8.2|Create Customers . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
||7.9|Vendors . . . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
|||7.9.1|Get Vendors . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
|||7.9.2|Create Vendor . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|27|
||7.10|Invoices . . . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
|||7.10.1|Get Invoices . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
|||7.10.2|Create Invoice . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
|||7.10.3|Add Items to Invoices|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
||7.11|Bills . . . . . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
|||7.11.1|Get Bills . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|28|
|||7.11.2|Create Bill . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|29|
|||7.11.3|Add Items to Bills . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|29|
||7.12|Purchase Orders
. . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|29|
|||7.12.1|Get Purchase Orders|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|29|
|||7.12.2|Create Purchase Order||.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|29|
|||7.12.3|Add Items to Purchase|Orders
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|||29|
||7.13|Estimates/Contracts
. . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|30|
|||7.13.1|Get Estimates/Contracts|||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|30|
|||7.13.2|Create Estimate . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|30|
|||7.13.3|Add Items to Estimates||.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|30|
||7.14|Bank Accounts . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|31|
|||7.14.1|Get Bank Accounts .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|31|
|||7.14.2|Create Bank Account|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|31|
||7.15|Items . . . . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|31|
|||7.15.1|Unit of Measures . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|31|
|||7.15.2|Expenses
. . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|32|
|||7.15.3|Services . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|32|
|||7.15.4|Products . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|32|
|||7.15.5|Inventory
. . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|33|
||7.16|Financial Statement PDF Reports||||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|33|
|||7.16.1|Set Up . . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|33|
|||7.16.2|Balance Sheet . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|33|
|||7.16.3|Income Statement . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|33|
|||7.16.4|Cash Flow Statement|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|34|
|||7.16.5|All Financial Statements||Data in a single Call . . . . . . . . . . . . . . . . . . . . . . . . .||34|
|**8**|**IO Engine**||||||**35**|
||8.1|IO Middleware . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|35|
||8.2|IO Context . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|35|
||8.3|IO Library
. . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|35|
||8.4|IO Core . . . . . . . . . . . .||.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|40|
|||8.4.1|Key Features: . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|40|
|||8.4.2|Classes: . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|41|
|||8.4.3|Functions: . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|41|
|||8.4.4|Error Handling: . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|41|
|||8.4.5|Supported Features: .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|41|
|||8.4.6|Notes: . . . . . . . .|.|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|42|
**ii**
||8.5|Account Roles . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|58|
|---|---|---|---|---|---|
||8.6|Financial Ratios
. . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|58|
||8.7|Random Data Generation||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|58|
|**9**|**Models**||||**61**|
||9.1|Model Dependency Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|||61|
||9.2|Database Fields . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|61|
||9.3|Entity Model . . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|61|
||9.4|Entity Unit Model
. . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|83|
||9.5|Account Model . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|85|
|||9.5.1
AccountModel|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|85|
|||9.5.2
Account Types|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|85|
|||9.5.3
Double Entry Accounting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|||85|
|||9.5.4
Chart of Accounts||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|85|
|||9.5.5
Account Roles .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|86|
||9.6|Ledger Model
. . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|96|
||9.7|Transaction Model . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|101|
||9.8|Journal Entry Model . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|108|
||9.9|Bank Account Model . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|123|
||9.10|Chart of Accounts Model||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|124|
|||9.10.1
Chart Of Accounts||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|125|
||9.11|Default Chart of Accounts||. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|131|
|||9.11.1
Default Chart of|Accounts Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .||132|
||9.12|Receipt Model . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|134|
||9.13|Item Model . . . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|141|
||9.14|Bill Model . . . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|152|
||9.15|Estimate Model . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|167|
||9.16|Purchase Order Model .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|181|
||9.17|Invoice Model
. . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|192|
||9.18|Customer Model . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|207|
||9.19|Vendor Model
. . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|211|
||9.20|MixIns . . . . . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|214|
||9.21|Signals . . . . . . . . .|.|. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .|224|
|**10**|** Indices and tables**||||**225**|
|**Python**||** Module Index**|||**227**|
|**Index**|||||**229**|
**iii**
**iv**
**Django Ledger**
sphinx-quickstart on Mon Jan 6 19:38:59 2020. You can adapt this file completely to your liking, but it should at least contain the root _toctree_ directive.
Created and developed by Miguel Sanda.
**==> picture [468 x 171] intentionally omitted <==**
**CONTENTS:**
**1**
**Django Ledger**
**2**
**CONTENTS:**
**CHAPTER ONE**
## **DJANGO LEDGER**
## **1.1 A Double Entry Accounting Engine for Django**
Django Ledger is a powerful financial management system built on the Django Web Framework. It offers a simplified API for handling complex accounting tasks in financially driven applications.
Created and developed by Miguel Sanda.
FREE Get Started Guide | Join our Discord | Documentation | QuickStart Notebook
## **1.2 Key Features**
- • High-level API
- • Double entry accounting
- • Hierarchical Chart of Accounts
- • Financial statements (Income Statement, Balance Sheet, Cash Flow)
- • Purchase Orders, Sales Orders, Bills, and Invoices
- • Financial ratio calculations
- • Multi-tenancy support
- • Ledgers, Journal Entries & Transactions
- • OFX & QFX file import
- • Closing Entries
- • Inventory management
- • Unit of Measures
- • Bank account information
- • Django Admin integration
- • Built-in Entity Management UI
## **1.3 Getting Involved**
All pull requests are welcome, as long as they address bugfixes, enhancements, new ideas, or add value to the project in any shape or form.
Please refrain from submitting pull requests that focus solely on code linting, auto-generated code, refactoring, or similar cosmetic non-value add changes.
**3**
**Django Ledger**
- • **Feature Requests/Bug Reports** : Open an issue in the repository
- • **For software customization, advanced features and consulting services** : Contact us or email msanda@arrobalytics.com
- • **Contribute** : See our contribution guidelines
## **1.4 Who Should Contribute?**
We’re looking for contributors with:
- • Python and Django programming skills
- • Finance and accounting expertise
- • Interest in developing a robust accounting engine API
If you have relevant experience, especially in accounting, we welcome your pull requests or direct contact.
**4**
**Chapter 1. Django Ledger**
**CHAPTER TWO**
## **INSTALLATION**
Django Ledger is a Django application. If you haven’t, you need working knowledge of Django and a working Django project before you can use Django Ledger. A good place to start is here.
Make sure you refer to the django version you are using.
The easiest way to start is to use the zero-config Django Ledger starter template. See details here. Otherwise, you may create your project from scratch.
## **2.1 Adding Django Ledger to an existing project.**
## **2.1.1 Add django_ledger to INSTALLED_APPS in you new Django Project.**
```
INSTALLED_APPS = [
...,
''
django_ledger,
...,
]
```
## **2.1.2 Add Django Ledger Context Preprocessor**
`TEMPLATES = [ { 'OPTIONS': { 'context_processors': [ ' ' ... , 'django_ledger.context.django_ledger_context'` _`# Add this line to a`_ `␣` _˓→_ _`context_processors list..`_ `], }, }, ]`
## **2.1.3 Perform database migrations:**
```
python manage.py migrate
```
• Add URLs to your project’s **urls.py** :
**5**
**Django Ledger**
```
from django.urls import include, path
```
```
urlpatterns = [
```
```
...,
path('ledger/', include('django_ledger.urls', namespace='django_ledger')),
...,
]
```
## **2.1.4 Run your project:**
```
python manage.py runserver
```
- • Navigate to Django Ledger root view assigned in your project urlpatterns setting ( typically http://127.0.0.1:8000/ledger if you followed this installation guide).
- • Use your superuser credentials to login.
## **2.2 Deprecated behavior setting (v0.8.0+)**
Starting with version v0.8.0, Django Ledger introduces the DJANGO_LEDGER_USE_DEPRECATED_BEHAVIOR setting to control access to deprecated features and legacy behaviors.
- • Default: False (deprecated features are disabled by default)
- • To temporarily keep using deprecated features while you transition, set this to True in your Django settings.
## **2.3 Setting Up Django Ledger for Development**
Django Ledger comes with a basic development environment already configured under **dev_env/** folder not to be used for production environments. If you want to contribute to the project perform the following steps:
- 1. Navigate to your projects directory.
- 2. Clone the repo from github and CD into project.
```
git clone https://github.com/arrobalytics/django-ledger.git && cd django-ledger
```
- 3. Install PipEnv, if not already installed:
```
pip install -U pipenv
```
- 4. Create virtual environment.
## `pipenv install`
If using a specific version of Python you may specify the path.
```
pipenv install --python PATH_TO_INTERPRETER
```
- 5. Activate environment.
```
pipenv shell
```
- 6. Apply migrations.
**6**
**Chapter 2. Installation**
**Django Ledger**
```
python manage.py migrate
```
7. Create a Development Django user.
```
python manage.py createsuperuser
```
8. Run development server.
```
python manage.py runserver
```
**2.3. Setting Up Django Ledger for Development**
**7**
**Django Ledger**
**8**
**Chapter 2. Installation**
**CHAPTER THREE**
# **HOW TO SET UP DJANGO LEDGER FOR DEVELOPMENT USING**
## **DOCKER**
- 1. Navigate to your projects directory.
- 2. Give executable permissions to entrypoint.sh
## `sudo chmod +x entrypoint.sh`
- 3. Add host ‘0.0.0.0’ into ALLOWED_HOSTS in settings.py.
- 4. Build the image and run the container.
## `docker compose up --build`
- 5. Add Django Superuser by running command in seprate terminal
```
docker ps
```
Select container id of running container and execute following command
```
docker exec -it containerId /bin/sh
python manage.py createsuperuser
```
- 6. Navigate to http://0.0.0.0:8000/ on browser.
**9**
**Django Ledger**
**10**
**Chapter 3. How To Set Up Django Ledger for Development using Docker**
**CHAPTER FOUR**
**RUN TEST SUITE**
After setting up your development environment you may run tests. `python manage.py test django_ledger`
**11**
**Django Ledger**
**12**
**Chapter 4. Run Test Suite**
**13**
**Django Ledger**
## **CHAPTER FIVE**
## **SCREENSHOTS**
**Chapter 5. Screenshots**
**14**
**Django Ledger**
**==> picture [468 x 411] intentionally omitted <==**
**15**
**Django Ledger**
**==> picture [468 x 335] intentionally omitted <==**
**16**
**Chapter 5. Screenshots**
**17**
**Django Ledger**
**CHAPTER SIX**
## **FINANCIAL STATEMENTS SCREENSHOTS**
**18**
**Chapter 6. Financial Statements Screenshots**
**Django Ledger**
**==> picture [469 x 607] intentionally omitted <==**
**19**
**Django Ledger**
**20**
**Chapter 6. Financial Statements Screenshots**
**CHAPTER SEVEN**
## **API QUICKSTART**
```
import os
from datetime import date, datetime
from decimal import Decimal
from random import randint, choices, random
from zoneinfo import ZoneInfo
import django
# for easier visualization it is recommended to use pandas to render data...
# if pandas is not installed, you may install it with this command: pip install -U pandas
# pandas is not a dependecy of django_ledger...
import pandas as pd
from django.core.exceptions import ObjectDoesNotExist
# Set your django settings module if needed...
'''
os.environ[DJANGO_SETTINGS_MODULE] = 'dev_env.settings
# if using jupyter notebook need to set DJANGO_ALLOW_ASYNC_UNSAFE as "true"
'''
os.environ[DJANGO_ALLOW_ASYNC_UNSAFE] = 'true
# change your working directory as needed...
''
os.chdir(../)
```
```
django.setup()
```
```
from django_ledger.models.entity import EntityModel
from django_ledger.models.items import ItemModel
from django_ledger.models.invoice import InvoiceModel
from django_ledger.models.bill import BillModel
from django_ledger.models.estimate import EstimateModel
from django.contrib.auth import get_user_model
from django_ledger.io import roles, DEBIT, CREDIT
from django_ledger.io.io_library import IOBluePrint, IOLibrary
```
## **7.1 Get Your Entity Administrator UserModel**
```
# change this to your preferred django username...
MY_USERNAME = 'ceo_user'
MY_PASSWORD = 'NeverUseMe|VeryInsecure!'
UserModel = get_user_model()
```
(continues on next page)
**21**
**Django Ledger**
(continued from previous page)
```
try:
user_model = UserModel.objects.get(username__exact=MY_USERNAME)
except:
user_model = UserModel(username=MY_USERNAME)
user_model.set_password(MY_PASSWORD)
user_model.save()
```
## **7.2 Get or Create an Entity Model**
```
ENTITY_NAME = 'One Big Company, LLC'
entity_model = EntityModel.create_entity(
name=ENTITY_NAME,
admin=user_model,
use_accrual_method=True,
fy_start_month=1
)
```
```
entity_model
```
## **7.3 Chart of Accounts**
## **7.3.1 Create a Default Chart of Accounts**
• Newly created EntityModel do not have a default Code of Accounts yet.
```
entity_model.has_default_coa()
```
```
default_coa_model = entity_model.create_chart_of_accounts(
assign_as_default=True,
commit=True,
coa_name='My QuickStart CoA'
)
```
```
default_coa_model
```
```
entity_model.default_coa == default_coa_model
```
## **7.4 Populate Entity with Random Data (Optional)**
## **7.4.1 Define a Start Date for Transactions**
```
START_DTTM = datetime(year=2022, month=10, day=1, tzinfo=ZoneInfo('UTC'))
```
- • This action will populate the EntityModel with random data.
- • It will populate a Code of Accounts using a default pre-defined list.
- • This approach is for illustration, educational and testing purposes, not encouraged for new production entities.
**22**
**Chapter 7. API Quickstart**
**Django Ledger**
```
entity_model.populate_random_data(start_date=START_DTTM)
```
## **7.4.2 EntityModel has now a Default Chart of Accounts**
```
entity_model.has_default_coa()
```
```
default_coa_model = entity_model.get_default_coa()
default_coa_model
```
## **7.5 Chart of Accounts (CoA)**
- • A Chart of Accounts is a user-defined list of accounts.
- • Each Entity Model must have at least one default Chart of Accounts.
## **7.5.1 Django Ledger support multiple chart of accounts.**
```
another_coa_model = entity_model.create_chart_of_accounts(
```
```
assign_as_default=False,
commit=True,
coa_name='My Empty Chart of Accounts'
)
```
```
another_coa_model
```
## **7.6 Accounts**
## **7.6.1 Default CoA Accounts**
```
default_coa_accounts_qs = entity_model.get_default_coa_accounts()
pd.DataFrame(default_coa_accounts_qs)
```
## **7.6.2 Get CoA Accounts by CoA Model**
```
coa_accounts_by_coa_model_qs = entity_model.get_coa_accounts(coa_model=default_coa_model)
pd.DataFrame(coa_accounts_by_coa_model_qs)
```
No Accounts yet on this CoA...
```
coa_accounts_by_coa_model_qs = entity_model.get_coa_accounts(coa_model=another_coa_model)
pd.DataFrame(coa_accounts_by_coa_model_qs)
```
## **7.6.3 Get CoA Accounts by CoA Model UUID**
• May pass UUID instance instead of ChartOF AccountsModel...
`coa_accounts_by_coa_uuid_qs = entity_model.get_coa_accounts(coa_model=default_coa_model.` _˓→_ `uuid)`
```
pd.DataFrame(coa_accounts_by_coa_uuid_qs)
```
**7.5. Chart of Accounts (CoA)**
**23**
**Django Ledger**
## **7.6.4 Get CoA Accounts by CoA Model Slug**
• If string is passed, will lookup by slug...
`coa_accounts_by_coa_slug_qs = entity_model.get_coa_accounts(coa_model=default_coa_model.` _˓→_ `slug) pd.DataFrame(coa_accounts_by_coa_slug_qs)`
## **7.6.5 Get Accounts With Codes and CoA Model**
• Assumes default CoA if no coa_model is passed...
`coa_accounts_by_codes_qs = entity_model.get_accounts_with_codes(code_list=['1010', '1050` _˓→_ `']) pd.DataFrame(coa_accounts_by_codes_qs)`
Empty ChartOfAccountModel...
```
coa_accounts_by_codes_qs = entity_model.get_accounts_with_codes(
code_list=['1010', '1050'],
coa_model=another_coa_model
)
```
```
pd.DataFrame(coa_accounts_by_codes_qs)
```
**Get All Accounts at Once**
```
coa_qs, coa_map = entity_model.get_all_coa_accounts()
```
A dictionary, CoA Model -> Account List.
```
coa_map
```
```
pd.DataFrame(coa_map[default_coa_model])
```
```
pd.DataFrame(coa_map[another_coa_model])
```
## **7.6.6 Create Account Model**
• Creating AccountModel into empty “another_coa_model”...
```
account_model = entity_model.create_account(
coa_model=another_coa_model,
code=f'1{str(randint(10000, 99999))}',
role=roles.ASSET_CA_INVENTORY,
name='A cool account created from the EntityModel API!',
balance_type=roles.DEBIT,
active=True)
```
```
account_model
```
```
another_coa_accounts_qs = entity_model.get_coa_accounts(coa_model=another_coa_model)
pd.DataFrame(another_coa_accounts_qs)
```
**24**
**Chapter 7. API Quickstart**
**Django Ledger**
## **7.7 Basic Django Ledger Usage**
- • The LedgerModel name is whatever your heart desires.
• Examples:
**–** A month. **–** A customer.
**–** A vendor.
**–** A project.
• The more ledgers are created, the more segregation and control over transactions is possible.
```
ledger_model = entity_model.create_ledger(name='My October 2023 Ledger', posted=True)
```
## **7.7.1 Create a Library**
```
library = IOLibrary(name='quickstart-library')
```
## **7.7.2 Create and Register a BluePrint**
```
@library.register
def sale_blueprint(
sale_amount,
contribution_margin_percent: float,
description: str = None
) -> IOBluePrint:
blueprint = IOBluePrint()
cogs_amount = (1 - contribution_margin_percent) * sale_amount
blueprint.debit(account_code='1010', amount=sale_amount, description=description)
blueprint.credit(account_code='4010', amount=sale_amount, description=description)
blueprint.credit(account_code='1200', amount=cogs_amount, description=description)
blueprint.debit(account_code='5010', amount=cogs_amount, description=description)
return blueprint
```
## **7.7.3 Get a Cursor**
```
cursor = library.get_cursor(entity_model=entity_model, user_model=user_model)
```
## **7.7.4 Dispatch Some Instructions**
```
''
cursor.dispatch(sale_blueprint,
ledger_model='ledger-test-1',
sale_amount=120.345,
contribution_margin_percent=0.25,
description='so cool')
''
cursor.dispatch(sale_blueprint,
ledger_model='ledger-test-1',
sale_amount=12.345,
contribution_margin_percent=0.2,
description='so cool')
```
(continues on next page)
**7.7. Basic Django Ledger Usage**
**25**
**Django Ledger**
```
''
cursor.dispatch(sale_blueprint,
ledger_model=ledger_model,
sale_amount=34.455,
contribution_margin_percent=0.13,
description='so cool')
''
cursor.dispatch(sale_blueprint,
ledger_model='ledger-test-12',
sale_amount=90.43,
contribution_margin_percent=0.17,
description='so cool')
```
(continued from previous page)
## **7.7.5 Commit Your Instructions**
Not recommended to post both ledger and journal entries. Posted transactions will immediately hit the books. **result** contains resulting ledger models, journal entries and transactions fro the committed
```
result = cursor.commit(
post_new_ledgers=True,
post_journal_entries=True,
je_timestamp='2023-12-02 12:00'
)
```
```
# result
```
**Get Financial Statement Report Data fro Ledger Model**
Balance Sheet
```
bs_data = ledger_model.digest_balance_sheet(
to_date=date(2023, 12, 31),
entity_slug=entity_model
)
```
```
bs_data.get_balance_sheet_data()
```
Income Statement
```
is_data = ledger_model.digest_income_statement(
from_date=date(2023, 1, 1),
to_date=date(2023, 12, 31),
entity_slug=entity_model
```
```
)
```
```
is_data.get_income_statement_data()
```
Cash Flow Statement
```
cfs_data = ledger_model.digest_cash_flow_statement(
from_date=date(2023, 1, 1),
to_date=date(2023, 12, 31),
entity_slug=entity_model
)
```
(continues on next page)
**26**
**Chapter 7. API Quickstart**
**Django Ledger**
(continued from previous page)
```
cfs_data.get_cash_flow_statement_data()
```
All Statements in a Single Call
```
fin_digest = ledger_model.digest_financial_statements(
from_date=date(2023, 1, 1),
to_date=date(2023, 12, 31),
entity_slug=entity_model
)
```
```
statement_data = fin_digest.get_financial_statements_data()
```
```
statement_data['balance_sheet']
```
```
statement_data['income_statement']
```
```
statement_data['cash_flow_statement']
```
## **7.8 Customers**
## **7.8.1 Get Customers**
```
customer_qs = entity_model.get_customers()
pd.DataFrame(customer_qs.values())
```
## **7.8.2 Create Customers**
```
customer_model = entity_model.create_customer(customer_model_kwargs={
'customer_name': 'Mr. Big',
'description': 'A great paying customer!',
})
```
## **7.9 Vendors**
## **7.9.1 Get Vendors**
```
vendor_qs = entity_model.get_vendors()
pd.DataFrame(vendor_qs.values())
```
## **7.9.2 Create Vendor**
```
vendor_model = entity_model.create_vendor(vendor_model_kwargs={
'vendor_name': 'ACME LLC',
'description': 'A Reliable Vendor!'
})
```
**7.8. Customers**
**27**
**Django Ledger**
## **7.10 Invoices**
## **7.10.1 Get Invoices**
```
invoices_qs = entity_model.get_invoices()
pd.DataFrame(invoices_qs.values())
```
## **7.10.2 Create Invoice**
```
invoice_model = entity_model.create_invoice(
customer_model='C-0000000006',
terms=InvoiceModel.TERMS_NET_30
)
```
```
invoice_model
```
## **7.10.3 Add Items to Invoices**
```
invoices_item_models = invoice_model.get_item_model_qs()
# K= number of items...
K = 6
invoice_itemtxs = {
im.item_number: {
'unit_cost': round(random() * 10, 2),
'quantity': round(random() * 100, 2),
'total_amount': None
} for im in choices(invoices_item_models, k=K)
}
# Choose operation ITEMIZE_APPEND to append itemtxs...
invoice_itemtxs = invoice_model.migrate_itemtxs(itemtxs=invoice_itemtxs,
commit=True,
operation=InvoiceModel.ITEMIZE_REPLACE)
invoice_itemtxs
```
```
invoice_model.amount_due
```
## **7.11 Bills**
## **7.11.1 Get Bills**
```
bills_qs = entity_model.get_bills()
pd.DataFrame(bills_qs.values())
```
**28**
**Chapter 7. API Quickstart**
**Django Ledger**
## **7.11.2 Create Bill**
```
bill_model = entity_model.create_bill(
vendor_model='V-0000000002',
terms=BillModel.TERMS_NET_60
)
```
```
bill_model
```
## **7.11.3 Add Items to Bills**
```
bill_item_models = bill_model.get_item_model_qs()
K = 6
bill_itemtxs = {
im.item_number: {
'unit_cost': round(random() * 10, 2),
'quantity': round(random() * 100, 2),
'total_amount': None
} for im in choices(bill_item_models, k=K)
}
# Choose operation ITEMIZE_APPEND to append itemtxs...
bill_itemtxs = bill_model.migrate_itemtxs(itemtxs=bill_itemtxs,
commit=True,
operation=BillModel.ITEMIZE_REPLACE)
bill_itemtxs
```
```
bill_model.amount_due
```
## **7.12 Purchase Orders**
## **7.12.1 Get Purchase Orders**
```
purchase_orders_qs = entity_model.get_purchase_orders()
pd.DataFrame(purchase_orders_qs.values())
```
## **7.12.2 Create Purchase Order**
```
po_model = entity_model.create_purchase_order()
```
## **7.12.3 Add Items to Purchase Orders**
```
po_item_models = po_model.get_item_model_qs()
K = 6
po_itemtxs = {
```
(continues on next page)
**7.12. Purchase Orders**
**29**
**Django Ledger**
(continued from previous page)
```
im.item_number: {
'unit_cost': round(random() * 10, 2),
'quantity': round(random() * 100, 2),
'total_amount': None
} for im in choices(po_item_models, k=K)
}
# Choose operation ITEMIZE_APPEND to append itemtxs...
po_itemtxs = po_model.migrate_itemtxs(itemtxs=po_itemtxs,
commit=True,
operation=EstimateModel.ITEMIZE_REPLACE)
po_itemtxs
```
```
po_model.po_amount
```
## **7.13 Estimates/Contracts**
## **7.13.1 Get Estimates/Contracts**
```
estimates_qs = entity_model.get_estimates()
pd.DataFrame(estimates_qs.values())
```
## **7.13.2 Create Estimate**
```
estimate_model = entity_model.create_estimate(
estimate_title='A quote for new potential customer!',
customer_model='C-0000000009',
contract_terms=EstimateModel.CONTRACT_TERMS_FIXED
)
```
## **7.13.3 Add Items to Estimates**
```
estimate_item_models = estimate_model.get_item_model_qs()
```
```
K = 6
estimate_itemtxs = {
im.item_number: {
'unit_cost': round(random() * 10, 2),
'unit_revenue': round(random() * 20, 2),
'quantity': round(random() * 100, 2),
'total_amount': None
} for im in choices(estimate_item_models, k=K)
}
# Choose operation ITEMIZE_APPEND to append itemtxs...
estimate_itemtxs = estimate_model.migrate_itemtxs(itemtxs=estimate_itemtxs,
commit=True,
```
(continues on next page)
**30**
**Chapter 7. API Quickstart**
**Django Ledger**
_˓→_ `REPLACE) estimate_itemtxs`
(continued from previous page) `operation=EstimateModel.ITEMIZE_`
```
estimate_model.get_cost_estimate()
```
```
estimate_model.get_revenue_estimate()
```
```
estimate_model.get_profit_estimate()
```
```
estimate_model.get_gross_margin_estimate(as_percent=True)
```
## **7.14 Bank Accounts**
## **7.14.1 Get Bank Accounts**
```
bank_accounts_qs = entity_model.get_bank_accounts()
pd.DataFrame(bank_accounts_qs.values())
```
## **7.14.2 Create Bank Account**
```
bank_account_model = entity_model.create_bank_account(name='A big bank account!',
account_type='checking')
```
## **7.15 Items**
## **7.15.1 Unit of Measures**
**Get Unit of Measures**
```
uom_qs = entity_model.get_uom_all()
pd.DataFrame(uom_qs.values())
```
## **Create a UOM**
```
uom_model_ft = entity_model.create_uom(
name='Linear Feet',
unit_abbr='lin-ft'
)
```
## **Get Some UoMs**
```
uom_model_unit = uom_qs.get(unit_abbr__exact='unit')
uom_model_man_hr = uom_qs.get(unit_abbr__exact='man-hour')
```
**7.14. Bank Accounts**
**31**
**Django Ledger**
## **7.15.2 Expenses**
**Get Expense Items**
```
expenses_qs = entity_model.get_items_expenses()
pd.DataFrame(expenses_qs.values())
```
## **Create Expense Item**
```
expense_item_model = entity_model.create_item_expense(
name='Premium Pencils',
uom_model=uom_model_unit,
expense_type=ItemModel.ITEM_TYPE_MATERIAL
)
```
```
expense_item_model.is_expense()
```
## **7.15.3 Services**
## **Get Service Items**
```
services_qs = entity_model.get_items_services()
pd.DataFrame(services_qs.values())
```
## **Create Service Item**
```
service_model = entity_model.create_item_service(
name='Yoga Class',
uom_model=uom_model_man_hr
)
```
```
service_model.is_service()
```
## **7.15.4 Products**
## **Get Product Items**
```
products_qs = entity_model.get_items_products()
pd.DataFrame(products_qs.values())
```
## **Create Product Items**
```
product_model = entity_model.create_item_product(
name='1/2" Premium PVC Pipe',
uom_model=uom_model_ft,
item_type=ItemModel.ITEM_TYPE_MATERIAL
)
```
```
product_model.is_product()
```
**32**
**Chapter 7. API Quickstart**
**Django Ledger**
## **7.15.5 Inventory**
**Get Inventory Items**
```
inventory_qs = entity_model.get_items_inventory()
pd.DataFrame(inventory_qs.values())
```
## **Create Inventory Items**
```
inventory_model = entity_model.create_item_inventory(
name='A Home to Flip!',
uom_model=uom_model_unit,
item_type=ItemModel.ITEM_TYPE_LUMP_SUM
)
```
```
inventory_model.is_inventory()
```
## **7.16 Financial Statement PDF Reports**
## **7.16.1 Set Up**
• Must enable PDF support by installing dependencies via _pipenv_ .
**–** pipenv install –categories pdf
## **7.16.2 Balance Sheet**
`bs_report = entity_model.get_balance_sheet_statement( to_date=date(2022, 12, 31), save_pdf=True, filepath='./' )` _`# save_pdf=True saves the PDF report in the project` '_ _`s BASE_DIR. # filename and filepath may also be specified... # will raise not implemented error if PDF support is not enabled...`_
**Balance Sheet Statement Raw Data**
```
bs_report.get_report_data()
```
## **7.16.3 Income Statement**
`ic_report = entity_model.get_income_statement( from_date=date(2022, 1, 1), to_date=date(2022, 12, 31), save_pdf=True, filepath='./' )` _`# save_pdf=True saves the PDF report in the project` '_ _`s BASE_DIR. # filename and filepath may also be specified... # will raise not implemented error if PDF support is not enabled...`_
**7.16. Financial Statement PDF Reports**
**33**
**Django Ledger**
## **Income Statement Raw Data**
```
ic_report.get_report_data()
```
## **7.16.4 Cash Flow Statement**
`cf_report = entity_model.get_cash_flow_statement( from_date=date(2022, 1, 1), to_date=date(2022, 12, 31), save_pdf=True, filepath='./' )` _`# save_pdf=True saves the PDF report in the project` '_ _`s BASE_DIR. # filename and filepath may also be specified...`_
**Cash Flow Statement Raw Data**
```
cf_report.get_report_data()
```
## **7.16.5 All Financial Statements Data in a single Call**
`reports = entity_model.get_financial_statements( user_model=user_model, from_date=date(2022, 1, 1), to_date=date(2022, 12, 31), save_pdf=True, filepath='./' )` _`# save_pdf=True saves the PDF report in the project` '_ _`s BASE_DIR. # filename and filepath may also be specified...`_
```
reports.balance_sheet_statement.get_report_data()
```
```
reports.income_statement.get_report_data()
```
```
reports.cash_flow_statement.get_report_data()
```
**34**
**Chapter 7. API Quickstart**
**CHAPTER EIGHT**
## **IO ENGINE**
## **8.1 IO Middleware**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
## **Contributions to this module:**
- • Miguel Sanda
## **8.2 IO Context**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
## **Contributions to this module:**
• Miguel Sanda
`exception django_ledger.io.io_context.IODigestValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **8.3 IO Library**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
## **Contributions to this module:**
• Miguel Sanda
This module contains classes and functions used to document, dispatch and commit new transaction into the database.
- `class django_ledger.io.io_library.IOBluePrint(` _name: str | None = None_ , _precision_decimals: int = 2_ `)` This class documents instructions required to assemble and dispatch transactions into the ledger.
**Parameters**
- • `name` ( _`str, optional`_ ) – The human-readable name of the IOBluePrint instance.
- • `precision_decimals` ( _`int`_ ) – The number of decimals to use when balancing transactions. Defaults to 2.
**35**
**Django Ledger**
`commit(` _entity_model:_ EntityModel, _user_model_ , _ledger_model: str |_ LedgerModel _| UUID | None = None_ , _je_timestamp: str | datetime | date | None = None_ , _post_new_ledgers: bool = False_ , _post_journal_entries: bool = False_ , _**kwargs_ `)` _→_ Dict
Commits the blueprint transactions to the database.
**Parameters**
- • `entity_model` ( `EntityModel` ) – The entity model instance where transactions will be committed.
- • `user_model` ( _`UserModel`_ ) – The user model instance executing transactions to check for permissions.
- • `ledger_model` ( _`Optional[Union[str,`_ `LedgerModel` _`, UUID]]`_ ) – The ledger model instance identifier to be used for the transactions. If none, a new ledger will be created.
- • `je_timestamp` ( _`date or datetime or str, optional`_ ) – The date and/or time to be used for the transactions. If none, localtime will be used.
- • `post_new_ledgers` ( _`bool`_ ) – If True, newly created ledgers will be posted. Defaults to False.
- • `post_journal_entries` ( _`bool`_ ) – If True, newly created journal entries will be posted. Defaults to False.
- • `kwargs` – Keyword arguments passed to the IO Library.
**Returns**
A dictionary containing the resulting models of the transactions.
**Return type**
Dict
`credit(` _account_code: str_ , _amount: float | Decimal_ , _description: str = None_ `)`
Registers a CREDIT to the specified account..
**Parameters**
- • `account_code` ( _`str`_ ) – The account code to use for the transaction.
- • `amount` ( _`float or Decimal`_ ) – The amount of the transaction.
- • `description` ( _`str`_ ) – Description of the transaction.
`debit(` _account_code: str_ , _amount: float | Decimal_ , _description: str = None_ `)`
Registers a DEBIT to the specified account.
**Parameters**
- • `account_code` ( _`str`_ ) – The account code to use for the transaction.
- • `amount` ( _`float or Decimal`_ ) – The amount of the transaction.
- • `description` ( _`str`_ ) – Description of the transaction.
`get_name(` _entity_model:_ EntityModel `)` _→_ str
Determines the name of the blueprint if none provided.
**Parameters**
`entity_model` ( `EntityModel` ) – The EntityModel instance where the resulting blueprint transactions will be stored.
**Returns**
The name of the blueprint.
**36**
**Chapter 8. IO Engine**
**Django Ledger**
## **Return type**
str
`exception django_ledger.io.io_library.IOBluePrintValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
`class django_ledger.io.io_library.IOCursor(` _io_library_ , _entity_model:_ EntityModel, _user_model_ , _mode:_ IOCursorMode _= IOCursorMode.PERMISSIVE_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ `)`
Represents a Django Ledger cursor capable of dispatching transactions to the database. The Cursor class is responsible for coordinating the creation of new ledgers, journal entries and transactions It is a low level interface to the IOBlueprint and IOLibrary classes.
## **Parameters**
- • `io_library` ( `IOLibrary` ) – The IOLibrary class that contains all the necessary instructions to dispatch the transactions.
- • `entity_model` ( `EntityModel` ) – The EntityModel instance that will be used for the new transactions.
- • `user_model` ( _`UserModel`_ ) – The UserModel instance that will be used for the new transactions. Used for read permissions of QuerySets.
- • `coa_model` ( `ChartOfAccountModel` _`or UUID or str.`_ ) – The ChartOfAccountModel instance that contains the accounts to be used for transactions. Instance, UUID or slug can be sued to retrieve the model.
- `commit(` _je_timestamp: str | datetime | date | None = None_ , _je_description: str | None = None_ , _post_new_ledgers: bool = False_ , _post_journal_entries: bool = False_ , _**kwargs_ `)`
Commits the compiled blueprint transactions into the database. This action is irreversible and if journal entries are posted, the books will be immediately impacted by the new transactions. It is encouraged NOT to post anything until the transaction is reviews for accuracy.
## **Parameters**
- • `je_timestamp` ( _`Optional[Union[datetime, date, str]]`_ ) – The date or timestamp used for the committed journal entries. If none, localtime will be used.
- • `je_description` ( _`Optional[str]`_ ) – The description of the journal entries. If none, no description will be used.
- • `post_new_ledgers` ( _`bool`_ ) – If a new ledger is created, the ledger model will be posted to the database.
- • `post_journal_entries` ( _`bool`_ ) – If new journal entries are created, the journal entry models will be posted to the database.
- • `kwargs` – Additional keyword arguments passed to the IO commit_txs function.
`compile_instructions()` _→_ Dict
Compiles the blueprint instructions into Journal Entries and Transactions to be committed to the ledger.
**Returns** A dictionary containing the compiled instructions.
**Return type** Dict
**8.3. IO Library**
**37**
**Django Ledger**
`dispatch(` _name_ , _ledger_model: str |_ LedgerModel _| UUID | None = None_ , _**kwargs_ `)`
Stages the instructions to be processed by the IOCursor class. This method does not commit the transactions into the database.
**Parameters**
- • `name` ( _`str`_ ) – The registered blueprint name to be staged.
- • `ledger_model` ( _`Optional[Union[str,`_ `LedgerModel` _`, UUID]]`_ ) – Optional ledger model identifier to house the transactions associated with the blueprint. If none is provided, a new ledger model will be created.
- • `kwargs` – The keyword arguments to be passed to the blueprint function.
`get_account_model_qs()` _→ AccountModelQuerySet_
Determines the AccountModelQuerySet associated with the Chart of Accounts specified.
**Return type** _AccountModelQuerySet_
`get_ledger_model_qs()` _→ LedgerModelQuerySet_
Determines the ledger model queryset associated with the entity model and user model provided.
**Return type** _LedgerModelQuerySet_
`is_committed()` _→_ bool
Determines if the IOCursor instance has committed the transactions into the database. A cursor can only commit transactions once.
**Returns**
True if committed, False otherwise.
**Return type** bool
`resolve_account_model_qs(` _codes: Set[str]_ `)` _→ AccountModelQuerySet_
Resolves the final AccountModelQuerySet associated with the given account codes used by the blueprint.
**Parameters** `codes` ( _`List[str]`_ ) – List of codes used during the execution of the blueprint. **Returns** The resolved AccountModelQuerySet associated with the given codes.
**Return type** _AccountModelQuerySet_
`resolve_ledger_model_qs()` _→ LedgerModelQuerySet_
Resolves the final LedgerModelQuerySet associated with the provided ledger model identifiers used by the blueprints.
**Returns**
The resolved LedgerModelQuerySet associated with the given ledger model identifiers.
**Return type** _LedgerModelQuerySet_
`class django_ledger.io.io_library.IOCursorMode(` _*values_ `)`
**38**
**Chapter 8. IO Engine**
**Django Ledger**
`exception django_ledger.io.io_library.IOCursorValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
`class django_ledger.io.io_library.IOLibrary(` _name: str_ `)`
The IO Library is a centralized interface for documenting commonly used operations. The library will register and document the blueprints and their instructions so that they can be dispatched from anywhere in the application.
**Parameters**
`name` ( _`str`_ ) – The human-readable name of the library (i.e. PayRoll, Expenses, Rentals, etc...)
## `IO_CURSOR_CLASS`
alias of _`IOCursor`_
`get_blueprint(` _name: str_ `)` _→_ Callable
Retrieves a blueprint by name.
**Parameters**
`name` ( _`str`_ ) – The name of the blueprint to retrieve.
## **Return type**
## Callable
- `get_cursor(` _entity_model:_ EntityModel, _user_model_ , _mode:_ IOCursorMode _= IOCursorMode.PERMISSIVE_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ `)` _→ IOCursor_
Creates a cursor instance for associated with the library, entity and user model.
## **Parameters**
- • `entity_model` ( `EntityModel` ) – The entity model instance where transactions will be committed.
- • `user_model` ( _`UserModel`_ ) – The user model instance executing the transactions.
- • `coa_model` ( `ChartOfAccountModel` _`or UUID or str, optional`_ ) – The ChartOfAccountsModel instance or identifier used to determine the AccountModelQuerySet used for the transactions.
- • `mode` ( `IOCursorMode` ) – The Mode of the cursor instance. Defaults to IOCursorMode.PERMISSIVE.
## **Return type**
## _IOCursor_
`exception django_ledger.io.io_library.IOLibraryError(` _message_ , _code=None_ , _params=None_ `)`
`class django_ledger.io.io_library.TransactionInstructionItem(` _account_code: str_ , _amount: Decimal | float_ , _tx_type: str_ , _description: str | None_ , _account_model:_ AccountModel _| None = None_ `)`
A class to represent a transaction instruction used during the development of transaction blueprints. `account_code` The account code of the AccountModel as a String. **Type** str
**8.3. IO Library**
**39**
**Django Ledger**
```
amount
```
The transaction amount as a Decimal value. Will be rounded to the nearest decimal place.
**Type** Decimal
```
tx_type
```
A choice of ‘debit’ or ‘credit’ transaction.
**Type** str
```
description
```
Description of the transaction.
**Type** str
```
account_model
```
The resolved account model for the transaction. Not to be modified. Defaults to None.
**Type**
_AccountModel_
## **8.4 IO Core**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
This module serves as a core component of the Django Ledger framework, providing an optimized interface and utilities for handling financial transactions, journal entries, and generating financial statements. It is designed to allow efficient interaction with the database, minimizing Python’s memory usage by emphasizing database-level aggregations while enforcing proper accounting principles.
## **8.4.1 Key Features:**
1. 1. **Transaction and Journal Management** : - Provides capabilities for creating, validating, and balancing transactions at the database level. - Supports integration of Closing Entries as optimizations for financial data aggregation.
1. 2. **Validation Utilities** : - Validates transaction balances, timestamps, and input data for minimal errors. - Ensures consistency with Django Ledger configurations, such as handling timezone-awareness and closing dates.
1. 3. **Database Interaction** : - Aggregation and querying of financial data at the database layer to improve memory efficiency. - Implements advanced filtering options for transactions based on attributes like activity, account roles, business units, and time periods. - Leverages Closing Entries as “checkpoints” to minimize aggregation workload on large datasets.
## 4. **Financial Statement Reports:**
• Offers functionalities to generate financial statements, including:
- • Balance Sheet
- • Income Statement
- • Cash Flow Statement
- • Supports PDF generation for these reports (if PDF support is enabled).
**40**
**Chapter 8. IO Engine**
**Django Ledger**
1. 5. **Extensibility** : - Implements a layered architecture with reusable mixins ( _IODatabaseMixIn_ , _IOReportMixIn_ , _IOMixIn_ ) that allow developers to customize behavior for specific use cases or extend functionality when needed.
1. 6. **Middleware and Ratios** : - Includes middleware support for handling roles, financial groups, and ratios as additional processing layers for generated reports.
## **8.4.2 Classes:**
- • _IOResult_ : A data carrier class for managing aggregated transaction and account balance data during digest operations.
- • _IODatabaseMixIn_ : Handles database interactions for aggregating transaction data efficiently and applying accounting rules.
- • _IOReportMixIn_ : Offers methods for generating financial reports, including support for PDF output (if enabled).
- • _IOMixIn_ : Combines database operations and reporting features into a single reusable mixin for comprehensive I/O management.
## **8.4.3 Functions:**
- • **Utility Functions:**
- **–** _diff_tx_data()_ : Validates whether the credits and debits for a given transaction dataset are balanced.
- **–** _check_tx_balance()_ : Ensures transaction datasets are corrected to be balanced if requested.
- **–** _validate_io_timestamp()_ : Ensures that input dates or timestamps are valid and timezone-aware.
- **–** _get_localtime()_ , _get_localdate()_ : Retrieve local time or local date based on Django’s timezone settings.
- **–** _validate_dates()_ : Validates and parses _from_date_ and _to_date_ inputs.
## • **Digest Operations:**
- **–** _database_digest()_ : Processes and aggregates transactions directly in the database with support for filters such as activity, role, and period.
- **–** _python_digest()_ : Applies additional processing and group-by operations on transaction data after database-level aggregation.
- **–** _digest()_ : A unified entry point for performing database digests and Python-level post-processing, with options to process roles, groups, ratios, and financial statements.
- • **Report Data Generation:**
- **–** _get_balance_sheet_statement()_ , _get_income_statement()_ , _get_cash_flow_statement()_ : Generate specific financial statements, with optional PDF output.
- **–** _get_financial_statements()_ : Generate all key financial statements together (Balance Sheet, Income Statement, Cash Flow Statement).
## **8.4.4 Error Handling:**
- • **Custom Exceptions** : - _IOValidationError_ : Raised for input validation errors during transaction or journal entry processing.
## **8.4.5 Supported Features:**
• Database-level transaction aggregation for performance optimization.
- • Timezone-aware operations for timestamp handling.
**8.4. IO Core**
**41**
**Django Ledger**
- • Modular architecture leveraging mixins for different components.
- • Middleware for advanced role processing and financial grouping.
- • Optional PDF generation using settings from Django Ledger.
## **8.4.6 Notes:**
- • Ensure _DJANGO_LEDGER_PDF_SUPPORT_ENABLED_ is properly configured to enable PDF output in financial reports.
- • Closing Entries play a critical role in improving aggregation times for entities with significant transactions.
- • The module is designed to work seamlessly with Django’s ORM and custom models through utilities provided in the Django Ledger framework.
## `class django_ledger.io.io_core.IODatabaseMixIn`
- Mix-in class for database interactions and aggregation for IO models.
This class is designed to encapsulate several common behaviors for models related to database queries and aggregations in the context of IO operations such as transactions, ledger models, and entity models. It facilitates the derivation of specific models, validation of query parameters, and execution of data aggregation queries with flexible filtering and grouping options.
## `TRANSACTION_MODEL_CLASS`
Specifies the Django model class for transactions. If None, a lazy loader will be used to determine the model dynamically.
## **Type**
NoneType or Type
## `JOURNAL_ENTRY_MODEL_CLASS`
Specifies the Django model class for journal entries. If None, a lazy loader will be used to determine the model dynamically.
**Type**
NoneType or Type
## `STAGED_TRANSACTION_MODEL_CLASS`
Specifies the Django model class for staged transactions. If None, a lazy loader will be used to determine the model dynamically.
## **Type**
NoneType or Type
## `static aggregate_balances(` _k_ , _g_ `)`
Aggregates balances from grouped data, providing a summarized representation of account attributes and their balances over a specified period. The function is used to compile essential details such as account identifiers, roles, activity, and balance, summarizing them for further processing or presentation.
## **Parameters**
- • `k` ( _`tuple`_ ) – A tuple consisting of grouped key values. Expected structure: - The first element represents the account UUID. - The second element represents the unit UUID. - The third and fourth elements represent the period year and month, respectively. - The sixth element represents the transaction type.
- • `g` ( _`iterable`_ ) – An iterable of grouped account data, typically containing dictionaries with detailed account properties and their respective balance information.
**42**
**Chapter 8. IO Engine**
**Django Ledger**
## **Returns**
A dictionary containing the aggregated balance information and related attributes, structured with the following keys: - ‘account_uuid’ - ‘coa_slug’ - ‘unit_uuid’ - ‘unit_name’ - ‘activity’ - ‘period_year’ - ‘period_month’ - ‘role_bs’ - ‘role’ - ‘code’ - ‘name’ - ‘balance_type’ - ‘tx_type’ - ‘balance’
## **Return type**
dict
`commit_txs(` _je_timestamp: str | datetime | date_ , _je_txs: List[Dict]_ , _je_posted: bool = False_ , _je_ledger_model=None_ , _je_unit_model=None_ , _je_desc=None_ , _je_origin=None_ , _force_je_retrieval: bool = False_ , _**kwargs_ `)`
Commits a set of financial transactions to a journal entry, after performing validation checks. Validations include ensuring balanced transactions, ensuring timestamp integrity, and verifying relationships between models. This method creates or retrieves a journal entry based on the provided details and assigns the given transactions accordingly, supporting conditional posting.
## **Parameters**
- • `je_timestamp` ( _`str or datetime or date`_ ) – The timestamp for the journal entry. Validates against entity’s closed periods and is required to be in a valid format.
- • `je_txs` ( _`list of dict`_ ) – A list of transactions to be committed, each represented as a dictionary. Each transaction should include keys such as ‘account’, ‘amount’, ‘tx_type’, and ‘description’.
- • `je_posted` ( _`bool, optional`_ ) – Whether the created or retrieved journal entry should be marked as posted after verification. Defaults to False.
- • `je_ledger_model` ( _`object, optional`_ ) – An optional instance of LedgerModel used for validating ledger associations. If not provided, defaults to the current ledger model.
- • `je_unit_model` ( _`object, optional`_ ) – An optional instance of EntityUnitModel used for validating entity unit associations with transactions.
- • `je_desc` ( _`str, optional`_ ) – A description for the journal entry. Defaults to None if not provided.
- • `je_origin` ( _`str, optional`_ ) – Specifies the origin or source of the journal entry. Defaults to None.
- • `force_je_retrieval` ( _`bool, optional`_ ) – Whether to force retrieval of an existing journal entry with the given timestamp instead of creating a new one. Defaults to False.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments that may be required for handling specific customization details during journal entry creation or retrieval.
## **Returns**
A tuple containing the journal entry model (je_model) and a list of transaction models (txs_models) created or associated with the journal entry.
## **Return type**
tuple
**Raises**
_`IOValidationError`_ – Raised for various validation errors including invalid timestamps, attempting to commit on locked or closed ledgers, association errors with ledger or entity models, and inability to retrieve a required journal entry.
**8.4. IO Core**
**43**
**Django Ledger**
- `database_digest(` _entity_slug: str | None = None_ , _unit_slug: str | None = None_ , _from_date: datetime | date | None = None_ , _to_date: datetime | date | None = None_ , _by_activity: bool = False_ , _by_tx_type: bool = False_ , _by_period: bool = False_ , _by_unit: bool = False_ , _activity: str | None = None_ , _role: str = typing.Optional[str]_ , _accounts: str | List[str] | Set[str] | None = None_ , _posted: bool = True_ , _exclude_zero_bal: bool = True_ , _use_closing_entry: bool = False_ , _**kwargs_ `)` _→ IOResult_
Aggregates transaction data based on the provided parameters to generate a digest of financial entries. This method is designed to work with various models (EntityModel, EntityUnitModel, LedgerModel) and processes transactions, including handling closing entries to optimize database queries. The resulting data can be customized based on specific filters or aggregation criteria, such as activity, transaction type, or time periods.
## **Parameters**
- • `entity_slug` ( _`Optional[str]`_ ) – The identifier for the entity. Used to filter transactions for a specific entity in cases where the model operates at the entity level.
- • `unit_slug` ( _`Optional[str]`_ ) – The identifier for the unit. Valid when filtering transactions for a specific unit within an entity.
- • `user_model` ( _`Optional[UserModel]`_ ) – The user model instance. Represents the user context in which the transaction filtering applies.
- • `from_date` ( _`Optional[Union[date, datetime]]`_ ) – The starting date for filtering transactions. Aggregates data from the given date if specified.
- • `to_date` ( _`Optional[Union[date, datetime]]`_ ) – The ending date for filtering transactions. Aggregates data up to this date if specified.
- • `by_activity` ( _`bool`_ ) – Determines whether results should be aggregated by activity. Defaults to False.
- • `by_tx_type` ( _`bool`_ ) – Indicates if results should be grouped by transaction type. Defaults to False.
- • `by_period` ( _`bool`_ ) – Determines if results should be grouped by time period (e.g., months). Defaults to False.
- • `by_unit` ( _`bool`_ ) – Indicates whether transactions should be grouped by entity unit. Defaults to False.
- • `activity` ( _`Optional[str]`_ ) – A specific activity identifier to filter results. If provided, only transactions related to this activity will be included.
- • `role` ( _`Optional[str]`_ ) – A specific role to filter transactions by. Transactions matching this role will be included in the aggregation.
- • `accounts` ( _`Optional[Union[str, List[str], Set[str]]]`_ ) – Specifies accounts to filter by. Can be a single account or a list/set of accounts. Filters transactions associated with the provided accounts.
- • `posted` ( _`bool`_ ) – Indicates whether to filter transactions that are posted (committed). Defaults to True.
- • `exclude_zero_bal` ( _`bool`_ ) – If True, transactions with zero-balance amounts will be excluded. Defaults to True.
- • `use_closing_entry` ( _`bool`_ ) – Specifies whether closing entries should be used to optimize database aggregation. If not provided, the value is determined by the system-global setting.
**44**
**Chapter 8. IO Engine**
**Django Ledger**
- • `kwargs` ( _`dict`_ ) – Additional parameters that can be passed for extended flexibility or customization when filtering and processing transactions.
## **Returns**
An object containing the aggregated results, filtered transaction querysets, and metadata such as database query bounds or details about closing entry matches.
## **Return type**
_IOResult_
- `digest(` _entity_slug: str | None = None_ , _unit_slug: str | None = None_ , _to_date: str | datetime | date | None = None_ , _from_date: str | datetime | date | None = None_ , _accounts: Set[str] | List[str] | None = None_ , _role: Set[str] | List[str] | None = None_ , _activity: str | None = None_ , _signs: bool = True_ , _process_roles: bool = False_ , _process_groups: bool = False_ , _process_ratios: bool = False_ , _process_activity: bool = False_ , _equity_only: bool = False_ , _by_period: bool = False_ , _by_unit: bool = False_ , _by_activity: bool = False_ , _by_tx_type: bool = False_ , _balance_sheet_statement: bool = False_ , _income_statement: bool = False_ , _cash_flow_statement: bool = False_ , _use_closing_entry: bool | None = None_ , _**kwargs_ `)` _→_ IODigestContextManager
Processes financial data and generates various financial statements, ratios, or activity digests based on the provided arguments. The method applies specific processing pipelines, such as role processing, grouping, ratio computation, activity-based operations, or generating financial statements like balance sheet, income statement, and cash flow statement.
## **Parameters**
- • `entity_slug` ( _`Optional[str]`_ ) – The slug identifier for the entity to process the financial data for.
- • `unit_slug` ( _`Optional[str]`_ ) – The slug identifier for the specific unit of the entity to filter the data for.
- • `to_date` ( _`Optional[Union[date, datetime, str]]`_ ) – The upper limit of the date range for which the data will be processed. Can be a _date_ , _datetime_ , or ISO 8601 formatted _str_ .
- • `from_date` ( _`Optional[Union[date, datetime, str]]`_ ) – The lower limit of the date range for which the data will be processed. Can be a _date_ , _datetime_ , or ISO 8601 formatted _str_ .
- • `user_model` ( _`Optional[UserModel]`_ ) – A user model instance to filter data or apply user-specific permissions during processing.
- • `accounts` ( _`Optional[Union[Set[str], List[str]]]`_ ) – A collection of account identifiers to filter the financial data to process.
- • `role` ( _`Optional[Union[Set[str], List[str]]]`_ ) – A collection of roles used to filter or organize the data during processing.
- • `activity` ( _`Optional[str]`_ ) – Specific activity identifier to filter or process the data for.
- • `signs` ( _`bool, default=True`_ ) – If _True_ , account roles with predefined signs will be applied to the financial data.
- • `process_roles` ( _`bool, default=False`_ ) – If _True_ , processes account roles and organizes financial data accordingly.
- • `process_groups` ( _`bool, default=False`_ ) – If _True_ , processes and organizes the financial data into predetermined account groups.
- • `process_ratios` ( _`bool, default=False`_ ) – If _True_ , computes and processes financial ratios for the provided data.
**8.4. IO Core**
**45**
**Django Ledger**
- • `process_activity` ( _`bool, default=False`_ ) – If _True_ , specific activity-based computation or segregation will be executed.
- • `equity_only` ( _`bool, default=False`_ ) – Processes only equity-specific accounts if set to _True_ .
- • `by_period` ( _`bool, default=False`_ ) – Organizes or groups the output by accounting periods if _True_ .
- • `by_unit` ( _`bool, default=False`_ ) – Organizes or processes data specific to each unit when set to _True_ .
- • `by_activity` ( _`bool, default=False`_ ) – Groups or segregates the processed data by activity when _True_ .
- • `by_tx_type` ( _`bool, default=False`_ ) – Groups or organizes the result by transaction type when _True_ .
- • `balance_sheet_statement` ( _`bool, default=False`_ ) – If _True_ , prepares a balance sheet statement as part of the processing.
- • `income_statement` ( _`bool, default=False`_ ) – If _True_ , generates an income statement as part of the processed result.
- • `cash_flow_statement` ( _`bool, default=False`_ ) – If _True_ , prepares a cash flow statement based on the provided data.
- • `use_closing_entry` ( _`Optional[bool]`_ ) – Specifies whether to account for closing entries in the financial statement computation.
- • `**kwargs` – Additional named arguments that can be passed to adjust the behavior of specific processing modules or middleware.
## **Returns**
A context manager instance containing the processed financial data and results, including financial statements, ratios, or any activity digest generated as per the input parameters.
**Return type** IODigestContextManager
## `get_entity_model_from_io()`
Retrieves the entity model associated with the current instance.
This method determines the type of the current model instance and retrieves the corresponding entity model if applicable. If the instance itself is an EntityModel, it returns itself. If the instance is a ledgerModel or EntityUnitModel model, the associated entity model is retrieved from its attributes.
## **Returns**
**entity** – Retrieves the associated entity model if the instance is a ledger or entity unit model.
## **Return type**
_EntityModel_
## `get_journal_entry_model()`
Retrieves the class model for journal entries. If the _JOURNAL_ENTRY_MODEL_CLASS_ attribute is set, it returns its value. Otherwise, it dynamically loads and returns the journal entry model using the _lazy_loader_ .
**Returns** The journal entry model class, either explicitly defined in _JOURNAL_ENTRY_MODEL_CLASS_ or loaded dynamically. **Return type** Type
**46**
**Chapter 8. IO Engine**
**Django Ledger**
## `get_staged_transaction_model()`
Retrieve the staged transaction model class used for handling imported transactions.
The method checks whether a specific transaction model class is explicitly set via the _STAGED_TRANSACTION_MODEL_CLASS_ attribute. If set, it returns that class as the transaction model. If not set, it falls back to a default transaction model obtained from the _lazy_loader.get_txs_model()_ method.
**Returns**
The transaction model class defined in _STAGED_TRANSACTION_MODEL_CLASS_ or the default transaction model provided by _lazy_loader.get_staged_txs_model()_ .
**Return type**
type
## `get_transaction_model()`
Retrieve the transaction model class used for handling transactions.
The method checks whether a specific transaction model class is explicitly set via the _TRANSACTION_MODEL_CLASS_ attribute. If set, it returns that class as the transaction model. If not set, it falls back to a default transaction model obtained from the _lazy_loader.get_txs_model()_ method.
**Returns**
The transaction model class defined in _TRANSACTION_MODEL_CLASS_ or the default transaction model provided by _lazy_loader.get_txs_model()_ .
**Return type**
type
```
is_entity_model()
```
Check if the instance is an EntityModel.
**Returns**
True if the instance is an entity model, False otherwise.
**Return type** bool
## `is_entity_unit_model()`
Checks if the current instance is an EntityUnitModel.
**Returns**
_True_ if the object is an instance of the entity unit model; _False_ otherwise.
**Return type** bool
## `is_ledger_model()`
Checks if the current instance is a LedgerModel.
**Returns**
True if the instance is of type ledger model, False otherwise.
**Return type** bool
`python_digest(` _entity_slug: str | None = None_ , _unit_slug: str | None = None_ , _to_date: str | datetime | date | None = None_ , _from_date: str | datetime | date | None = None_ , _equity_only: bool = False_ , _activity: str = None_ , _role: Set[str] | List[str] | None = None_ , _accounts: Set[str] | List[str] | None = None_ , _signs: bool = True_ , _by_unit: bool = False_ , _by_activity: bool = False_ , _by_tx_type: bool = False_ , _by_period: bool = False_ , _use_closing_entry: bool = False_ , _force_queryset_sorting: bool = False_ , _**kwargs_ `)` _→ IOResult_
**8.4. IO Core**
**47**
**Django Ledger**
Computes and returns the digest of transactions for a given entity, unit, and optional filters such as date range, account role, and activity. The digest includes aggregated balances by specified group-by keys.
## **Parameters**
- • `user_model` ( _`Optional[UserModel]`_ ) – The user model to be used for the computation. Defaults to None.
- • `entity_slug` ( _`Optional[str]`_ ) – The slug representing the entity to compute the digest for. Defaults to None.
- • `unit_slug` ( _`Optional[str]`_ ) – The slug representing the unit within the entity. Defaults to None.
- • `to_date` ( _`Optional[Union[date, datetime, str]]`_ ) – The end date for the transaction filter. Defaults to None.
- • `from_date` ( _`Optional[Union[date, datetime, str]]`_ ) – The start date for the transaction filter. Defaults to None.
- • `equity_only` ( _`bool`_ ) – Whether to compute results only for earnings-related accounts. Defaults to False.
- • `activity` ( _`str`_ ) – An optional activity filter for transactions. Defaults to None.
- • `role` ( _`Optional[Union[Set[str], List[str]]]`_ ) – The account roles to include in the digest. Defaults to None.
- • `accounts` ( _`Optional[Union[Set[str], List[str]]]`_ ) – A list or set of specific accounts to include. Defaults to None.
- • `signs` ( _`bool`_ ) – Whether to adjust the signs for the account balances based on balance type and account role. Defaults to True.
- • `by_unit` ( _`bool`_ ) – Whether to group the results by unit. Defaults to False.
- • `by_activity` ( _`bool`_ ) – Whether to group the results by activity. Defaults to False.
- • `by_tx_type` ( _`bool`_ ) – Whether to group the results by transaction type. Defaults to False.
- • `by_period` ( _`bool`_ ) – Whether to group the results by period (year and month). Defaults to False.
- • `use_closing_entry` ( _`bool`_ ) – Whether to include closing entries in the computation. Defaults to False.
- • `force_queryset_sorting` ( _`bool`_ ) – Whether to force sorting of the transaction queryset. Defaults to False.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments passed to the computation.
## **Returns**
An object containing the transaction queryset, grouped and aggregated account balances, and other relevant digest information.
## **Return type**
_IOResult_
## `class django_ledger.io.io_core.IOMixIn`
Provides input and output functionalities by mixing in database and reporting environments.
This class is a mixin that combines functionalities from IODatabaseMixIn and IOReportMixIn. It is designed to integrate database input/output operations with report generation features seamlessly.
**48**
**Chapter 8. IO Engine**
**Django Ledger**
## `class django_ledger.io.io_core.IOReportMixIn`
Provides functionality for generating and managing financial reports.
This mixin class facilitates the generation, processing, and management of various financial statements, including balance sheet statements, income statements, and cash flow statements. Reports can be created in multiple formats, such as plain data representation or as PDF files. The class integrates support for financial data digestion and report serialization, including saving PDF reports to specified file paths. Common use cases include generating summarized financial data for reporting purposes and outputting them in PDF format.
## `PDF_REPORT_ORIENTATION`
Indicates the orientation of the generated PDF reports (‘P’ for portrait, ‘L’ for landscape).
**Type**
str
## `PDF_REPORT_MEASURE_UNIT`
Specifies the measurement unit used in the PDF reports (e.g., ‘mm’, ‘cm’).
**Type**
str
## `PDF_REPORT_PAGE_SIZE`
Defines the size of the pages in the generated PDF reports (e.g., ‘Letter’, ‘A4’).
**Type**
str
## `ReportTuple`
A tuple structure containing three fields: _balance_sheet_statement_ , _income_statement_ , and _cash_flow_statement_ . Each field represents a respective financial report.
**Type**
namedtuple
`class ReportTuple(` _balance_sheet_statement_ , _income_statement_ , _cash_flow_statement_ `)`
## `balance_sheet_statement`
Alias for field number 0
```
cash_flow_statement
```
Alias for field number 2
```
income_statement
```
Alias for field number 1
`digest_balance_sheet(` _to_date: date | datetime_ , _user_model: User | None = None_ , _txs_queryset: QuerySet | None = None_ , _**kwargs: Dict_ `)` _→_ IODigestContextManager
Digest the balance sheet for a specific time period, user, and optionally a specific set of transactions. Returns a context manager for digesting the specified balance sheet data.
## **Parameters**
- • `to_date` ( _`Union[date, datetime]`_ ) – The date till which the balance sheet needs to be digested, including transactions occurring on this date.
- • `user_model` ( _`Optional[UserModel], optional`_ ) – The model instance representing the user whose balance sheet is to be digested. This can be _None_ to indicate no specific user.
**8.4. IO Core**
**49**
**Django Ledger**
- • `txs_queryset` ( _`Optional[QuerySet], optional`_ ) – A queryset containing specific transactions to be included in the calculation. If not provided, all transactions up to _to_date_ will be considered.
- • `kwargs` ( _`Dict`_ ) – Additional keyword arguments that can be used for the digestion process. Allows flexible filtering or additional specifications.
- **Returns**
A context manager for handling the digestion process of the balance sheet.
## **Return type**
IODigestContextManager
`digest_cash_flow_statement(` _from_date: date | datetime_ , _to_date: date | datetime_ , _user_model: User | None = None_ , _txs_queryset: QuerySet | None = None_ , _**kwargs_ `)` _→_
IODigestContextManager
Generates a digest of the cash flow statement for a specified date range, user model, and optional transaction query set. This method utilizes an internal digest mechanism to compile and return the cash flow statement context.
**Parameters**
- • `from_date` ( _`Union[date, datetime]`_ ) – The start date of the period for the cash flow statement.
- • `to_date` ( _`Union[date, datetime]`_ ) – The end date of the period for the cash flow statement.
- • `user_model` ( _`Optional[UserModel]`_ ) – The user model instance for which the digest is generated. If None, the default user model is used.
- • `txs_queryset` ( _`Optional[QuerySet]`_ ) – An optional queryset of transactions to include in the digest. If None, defaults to all transactions within the date range.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments passed to the digest function.
**Returns**
Context manager providing the digested cash flow statement.
## **Return type**
IODigestContextManager
`digest_financial_statements(` _from_date: date | datetime_ , _to_date: date | datetime_ , _user_model: User | None = None_ , _**kwargs_ `)` _→_ IODigestContextManager
Digest financial statements within a given date range, allowing optional customization through _kwargs_ . The method processes and provides access to balance sheet statements, income statements, and cash flow statements for the specified date range. Results are encapsulated in an IODigestContextManager for ease of management.
The function provides flexibility to include a user model for domain-specific processing needs while ensuring support for both date and datetime objects.
**Parameters**
- • `from_date` ( _`date or datetime`_ ) – The starting date of the range for which financial statements are to be processed.
- • `to_date` ( _`date or datetime`_ ) – The ending date of the range for which financial statements are to be processed.
- • `user_model` ( _`Optional[UserModel], default=None`_ ) – A user model instance that allows for context-specific processing during the digestion of financial statements.
**50**
**Chapter 8. IO Engine**
**Django Ledger**
- • `kwargs` ( _`dict`_ ) – Additional optional parameters that may be used to further customize the processing of financial statements.
**Returns**
Represents the context manager containing the digested financial statements for the specified date range.
**Return type** IODigestContextManager
`digest_income_statement(` _from_date: date | datetime_ , _to_date: date | datetime_ , _user_model: User | None = None_ , _txs_queryset: QuerySet | None = None_ , _**kwargs_ `)` _→_ IODigestContextManager
Digest the income statement within the specified date range and optionally filter by user and transaction queryset.
This method generates a digest context manager for the income statement, allowing granular control over the data derived within the requested range and applying any additional filters provided. It supports optional user and transaction queryset filters for tailored data processing.
**Parameters**
- • `from_date` ( _`Union[date, datetime]`_ ) – The starting date for filtering the income statement.
- • `to_date` ( _`Union[date, datetime]`_ ) – The ending date for filtering the income statement.
- • `user_model` ( _`Optional[UserModel], optional`_ ) – An optional user model instance to filter income statement data by a specific user.
- • `txs_queryset` ( _`Optional[QuerySet], optional`_ ) – An optional transaction queryset to filter the income statement by specific transaction records.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments for customization or requirements in the income statement digest generation process.
**Returns**
A context manager containing the processed income statement data.
**Return type**
IODigestContextManager
`get_balance_sheet_statement(` _to_date: date | datetime_ , _subtitle: str | None = None_ , _filepath: Path | None = None_ , _filename: str | None = None_ , _user_model: User | None = None_ , _save_pdf: bool = False_ , _**kwargs_ `)` _→_ IODigestContextManager
Generates a balance sheet statement with an option to save it as a PDF file.
This method fetches and processes financial data to create a balance sheet statement using the provided date range, user model, and additional optional settings. It supports generating a PDF output for the balance sheet if configured. The class responsible for PDF generation is dynamically loaded, allowing modularity and flexibility.
Note that PDF generation functionality is dependent on the presence of the _DJANGO_LEDGER_PDF_SUPPORT_ENABLED_ flag. If the flag is not enabled, the method raises an exception.
**Parameters**
- • `to_date` ( _`Union[date, datetime]`_ ) – The end date for the balance sheet report. The data will be considered up to this date for the financial statement.
**8.4. IO Core**
**51**
**Django Ledger**
- • `subtitle` ( _`Optional[str], default=None`_ ) – An optional subtitle for the generated report. This can be used to include additional context or descriptions in the report.
- • `filepath` ( _`Optional[Path], default=None`_ ) – Specifies the directory path where the PDF file should be saved. If not provided, a default directory is used based on application settings.
- • `filename` ( _`Optional[str], default=None`_ ) – Name of the file to save the PDF report. Defaults to an automatically generated filename if not provided.
- • `user_model` ( _`Optional[UserModel], default=None`_ ) – The user context associated with the balance sheet report. Includes permissions or specific user-related data.
- • `save_pdf` ( _`bool, default=False`_ ) – A flag indicating whether the balance sheet should be saved as a PDF. If True, the method generates and stores the PDF in the specified location.
- • `**kwargs` – Additional keyword arguments required for generating the balance sheet. It may include filtering, formatting, or any other relevant parameters.
## **Returns**
The context manager object handling the generated balance sheet, either in memory or in saved PDF format. If the _save_pdf_ option is enabled, the PDF report is saved at the specified location.
## **Return type**
- IODigestContextManager
`get_cash_flow_statement(` _from_date: date | datetime_ , _to_date: date | datetime_ , _subtitle: str | None = None_ , _filepath: Path | None = None_ , _filename: str | None = None_ , _user_model: User | None = None_ , _save_pdf: bool = False_ , _**kwargs_ `)`
Generates a cash flow statement report within a specified date range and provides an option to save the report as a PDF file. The method retrieves financial data, processes it into a structured cash flow statement, and uses a PDF report generator to create the report.
## **Parameters**
- • `from_date` ( _`Union[date, datetime]`_ ) – The start date for the cash flow statement.
- • `to_date` ( _`Union[date, datetime]`_ ) – The end date for the cash flow statement.
- • `subtitle` ( _`Optional[str], default=None`_ ) – Subtitle text for the report.
- • `filepath` ( _`Optional[Path], default=None`_ ) – The directory path where the PDF report will be saved. Defaults to the base directory if not provided.
- • `filename` ( _`Optional[str], default=None`_ ) – The name of the PDF report file. If not provided, a default name is generated.
- • `user_model` ( _`Optional[UserModel], default=None`_ ) – The user model instance, optionally used for filtering or customization of the report content.
- • `save_pdf` ( _`bool, default=False`_ ) – Flag to save the generated report as a PDF file.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments that are passed to the _digest_cash_flow_statement_ method for further customization or additional processing.
## **Returns**
An instance of the cash flow statement report class, either saved as a PDF if _save_pdf_ is True or ready for further processing or display.
## **Return type**
CashFlowStatementReport
**52**
**Chapter 8. IO Engine**
**Django Ledger**
## **Raises**
_`IOValidationError`_ – If PDF support is not enabled in the system’s Django ledger configuration.
`get_financial_statements(` _from_date: date | datetime_ , _to_date: date | datetime_ , _dt_strfmt: str = '%Y%m%d'_ , _user_model: User | None = None_ , _save_pdf: bool = False_ , _filepath: Path | None = None_ , _**kwargs_ `)` _→ ReportTuple_
Generates financial statements for a specified date range, optionally saving them as PDF files. This method consolidates the balance sheet, income statement, and cash flow statement for the given dates. If PDF saving is enabled, the financial statements will be saved to the specified path or the application’s base directory. The results are returned as a tuple containing the reports.
## **Parameters**
- • `from_date` ( _`Union[date, datetime]`_ ) – The start date for the financial statements.
- • `to_date` ( _`Union[date, datetime]`_ ) – The end date for the financial statements.
- • `dt_strfmt` ( _`str`_ ) – The string format used for the filenames of the generated PDF reports. Defaults to ‘%Y%m%d’.
- • `user_model` ( _`Optional[UserModel], optional`_ ) – The user model instance, if applicable. Defaults to None.
- • `save_pdf` ( _`bool, optional`_ ) – Determines whether to save the generated financial statements as PDF files. Defaults to False.
- • `filepath` ( _`Optional[Path], optional`_ ) – The directory path where the PDF files will be saved. If not provided, the files will be saved in the application’s base directory. Defaults to None.
• `**kwargs` – Additional keyword arguments for customizing financial statement generation.
## **Returns**
- A named tuple containing the generated balance sheet, income statement, and cash flow statement as objects.
## **Return type**
_ReportTuple_
**Raises**
_`IOValidationError`_ – Raised if PDF support is not enabled in the application configuration.
`get_income_statement(` _from_date: date | datetime_ , _to_date: date | datetime_ , _subtitle: str | None = None_ , _filepath: Path | None = None_ , _filename: str | None = None_ , _user_model: User | None = None_ , _txs_queryset: QuerySet | None = None_ , _save_pdf: bool = False_ , _**kwargs_ `)`
Generates an income statement report for a specific time period and allows optional PDF saving functionality. The function utilizes configurations, user-provided parameters, and transactions data to create an income statement report, which can either be returned as a report object or saved as a PDF on the filesystem.
## **Parameters**
- • `from_date` ( _`date or datetime`_ ) – The starting date of the income statement period. Must be provided.
- • `to_date` ( _`date or datetime`_ ) – The ending date of the income statement period. Must be provided.
- • `subtitle` ( _`str, optional`_ ) – An optional subtitle for the income statement report.
**8.4. IO Core**
**53**
**Django Ledger**
- • `filepath` ( _`Path, optional`_ ) – The directory path where the PDF report should be saved, if _save_pdf_ is set to True.
- • `filename` ( _`str, optional`_ ) – The filename for the PDF report. If not provided, a default filename is generated.
- • `user_model` ( _`UserModel, optional`_ ) – A user model instance, providing additional context or filtering for the income statement generation.
- • `txs_queryset` ( _`QuerySet, optional`_ ) – A queryset containing transactions data to be included in the income statement report. If not provided, transactions may be automatically determined by other parameters or configurations.
- • `save_pdf` ( _`bool`_ ) – Indicates whether the generated income statement should be saved as a PDF file. Defaults to False.
• `**kwargs` – Additional optional keyword arguments for further customization or filtering.
**Raises**
_`IOValidationError`_ – Raised if PDF support is not enabled in the configuration. The error provides a message suggesting installing PDF support.
## **Returns**
A configured instance of the IncomeStatementReport class, representing the generated income statement report. If _save_pdf_ is True, the report will also be saved as a PDF file at the specified location.
## **Return type**
IncomeStatementReport
`class django_ledger.io.io_core.IOResult(` _db_from_date: date | None = None_ , _db_to_date: date | None = None_ , _ce_match: bool = False_ , _ce_from_date: date | None = None_ , _ce_to_date: date | None = None_ , _accounts_digest: List[Dict] | None = None_ `)`
Represents the input-output result schema for data aggregation and processing.
This class encapsulates details related to database aggregation, closing entry lookup parameters, and the final dataset used for evaluation. It also provides utility to check bounded date constraints for closing entry lookups.
## `db_from_date`
The starting date for database aggregation queries.
**Type** Optional[date]
```
db_to_date
```
The ending date for database aggregation queries. **Type** Optional[date]
## `ce_match`
Indicates whether closing entry matches are applicable.
**Type** bool
```
ce_from_date
```
The starting date for closing entry lookups.
**Type** Optional[date]
**54**
**Chapter 8. IO Engine**
**Django Ledger**
## `ce_to_date`
The ending date for closing entry lookups.
**Type**
Optional[date]
## `txs_queryset`
The final queryset used for evaluation, typically containing processed transaction data.
## `accounts_digest`
A summary or aggregation of account balances derived from the processed data.
**Type**
Optional[List[Dict]]
`exception django_ledger.io.io_core.IOValidationError(` _message_ , _code=None_ , _params=None_ `)`
`django_ledger.io.io_core.check_tx_balance(` _tx_data: list_ , _perform_correction: bool = False_ `)` _→_ bool
Checks the validity of a list of transactions and optionally corrects the balance discrepancy if any. The function assesses whether the total balance from the transactions satisfies the predefined tolerance settings. If _perform_correction_ is enabled, it adjusts the transactions iteratively to correct discrepancies.
**Parameters**
- • `tx_data` ( _`list`_ ) – A list of transaction data where each transaction contains information such as amount and type (‘debit’ or ‘credit’).
- • `perform_correction` ( _`bool, optional`_ ) – A flag indicating whether to attempt to correct balance discrepancies in the transaction data. Defaults to False.
## **Returns**
- Returns True if the transactions are valid and satisfy the balance tolerance (with or without correction). Returns False otherwise.
## **Return type**
## bool
`django_ledger.io.io_core.diff_tx_data(` _tx_data: list_ , _raise_exception: bool = True_ `)`
Calculates the difference between credits and debits in a transaction dataset and validates if the transactions are in balance. Supports both dictionary-like data and _TransactionModel_ objects.
The function checks whether the provided transaction data is in balance by comparing the sum of credits and debits. If they are not in balance, the function optionally raises an exception when the discrepancy exceeds the defined tolerance limit. It also indicates whether the transaction data is modeled using _TransactionModel_ .
## **Parameters**
- • `tx_data` ( _`list`_ ) – A list of transactions, which can either be dictionaries or instances of _TransactionModel_ . Each transaction must have an _amount_ field and a _tx_type_ field. The _tx_type_ should be either ‘credit’ or ‘debit’.
- • `raise_exception` ( _`bool, optional`_ ) – Whether to raise an exception if the transactions are not balanced and the difference exceeds the defined tolerance value. Defaults to True.
## **Returns**
## **A tuple containing the following:**
1. 1. _IS_TX_MODEL_ (bool): Indicates whether the transaction data uses the _TransactionModel_ .
1. 2. _is_valid_ (bool): Indicates whether the total credits match the total debits within the defined tolerance.
**8.4. IO Core**
**55**
**Django Ledger**
3. _diff_ (float): The difference between the sum of credits and the sum of debits.
**Return type** tuple
## **Raises**
- • `ValidationError` – If the _tx_data_ is neither a list of dictionaries nor a list of _TransactionModel_ instances.
- • `TransactionNotInBalanceError` – If the transactions are not in balance (when _is_valid_ is False), the difference exceeds the maximum tolerance, and _raise_exception_ is True.
`django_ledger.io.io_core.get_localdate()` _→_ date
Fetches the current local date, optionally considering time zone settings.
This function retrieves the current local date. If the global settings indicate the use of time zones ( _USE_TZ_ is True), the date is determined based on the local time zone. Otherwise, the date is based on the system’s local time without any time zone consideration.
## **Returns**
The current local date, adjusted for the time zone setting if applicable.
## **Return type**
## date
`django_ledger.io.io_core.get_localtime(` _tz=None_ `)` _→_ datetime
Retrieve the local time based on the specified timezone.
Determines the local time depending on whether timezone support ( `USE_TZ` ) is enabled in global settings. If timezone support is enabled, it uses the _localtime_ function to obtain the local time according to the provided timezone. If timezone support is disabled, it defaults to the current time with respect to the given timezone.
## **Parameters**
`tz` ( _`timezone or None, optional`_ ) – The timezone to determine the local time. If _None_ , defaults to the system timezone.
## **Returns**
A datetime object representing the calculated local time.
## **Return type**
## datetime
`django_ledger.io.io_core.validate_activity(` _activity: str_ , _raise_404: bool = False_ `)`
Validates the given activity against the list of valid activities and raises appropriate exceptions if it is invalid.
This function checks whether the provided activity is included in the list of valid activities defined within the JournalEntryModel. It raises a ValidationError or Http404 error depending on the value of _raise_404_ if the activity is not valid. If the activity is valid or not provided, it returns the activity unaltered.
## **Parameters**
- • `activity` ( _`str`_ ) – The activity string to validate against the valid activities.
- • `raise_404` ( _`bool, optional`_ ) – Whether to raise an Http404 error instead of ValidationError when the activity is invalid. Default is False.
## **Returns**
The activity string if it is valid.
## **Return type**
str
**Raises**
**56**
**Chapter 8. IO Engine**
**Django Ledger**
- • `ValidationError` – If the activity is invalid and _raise_404_ is False.
- • `Http404` – If the activity is invalid and _raise_404_ is True.
`django_ledger.io.io_core.validate_dates(` _from_date: str | datetime | date | None = None_ , _to_date: str | datetime | date | None = None_ `)` _→_ Tuple[date, date]
Validates and converts the input dates to date objects. This function ensures that the provided _from_date_ and _to_date_ are correctly parsed into _date_ objects. If the dates are given as strings or datetime objects, they will be validated and converted to _date_ objects accordingly.
## **Parameters**
- • `from_date` ( _`str, datetime, date, optional`_ ) – The start date, which can be provided as a string, datetime, or date object. If not provided, it may default depending on the implementation of the _validate_io_timestamp_ function.
- • `to_date` ( _`str, datetime, date, optional`_ ) – The end date, which can be provided as a string, datetime, or date object. If not provided, it may default depending on the implementation of the _validate_io_timestamp_ function.
## **Returns**
A tuple containing the validated _from_date_ and _to_date_ as _date_ objects. The first element is the validated start date, and the second element is the validated end date.
## **Return type**
Tuple[date, date]
`django_ledger.io.io_core.validate_io_timestamp(` _dt: str | date | datetime_ , _no_parse_localdate: bool =_
_True_ `)` _→_ datetime | date | None
Validates and processes a given date or datetime input and returns a processed datetime or date object depending on the parsing and processing results. This function is designed to handle multiple types of inputs including strings, date objects, and datetime objects, while accounting for timezone awareness and other scenarios where inputs may be invalid or improperly formed.
## **Parameters**
- • `dt` ( _`Union[str, date, datetime]`_ ) – The input value to be validated and processed. This can be a string representing a date or datetime, a _date_ object, or a _datetime_ object. If the input is invalid or cannot be parsed, an error will be raised.
- • `no_parse_localdate` ( _`bool, optional`_ ) – A flag to indicate if the local date should be returned directly when the input cannot be parsed or is unavailable. Defaults to True.
## **Returns**
Returns a timezone-aware or naive _datetime_ object that was processed depending on input and timezone settings. May also return a _date_ object in specific scenarios. Returns _None_ if the input is empty or invalid.
## **Return type**
Optional[Union[datetime, date]]
## **Raises**
`InvalidDateInputError` – Raised when the provided string cannot be parsed into a valid _date_ or _datetime_ object.
## **Notes**
- • The function handles both timezone-aware and naive datetime objects, and attempts to make objects timezone-aware when global time zone settings are enabled.
**8.4. IO Core**
**57**
**Django Ledger**
- • String inputs are first attempted to be parsed into _date_ objects before attempting to parse them into _datetime_ objects if the initial attempt fails.
- • When _no_parse_localdate_ is True, the function defaults to returning the local time for cases where parsing is not possible.
## **8.5 Account Roles**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
## **Contributions to this module:**
• Miguel Sanda
`django_ledger.io.roles.validate_roles(` _roles: str | List[str]_ , _raise_exception: bool = True_ `)` _→_ Set[str]
Validates a given role identifier against the valid role available. :param roles: The role or list of roles to validate. :type roles: str or list :param raise_exception: Raises InvalidRoleError if any of the roles provided if not valid. :type raise_exception: bool
**Returns**
A set of the valid roles.
**Return type** set
## **8.6 Financial Ratios**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
Contributions to this module: Miguel Sanda
## **8.7 Random Data Generation**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
Contributions to this module: Miguel Sanda
This is a random data generator module used during the testing of the API and for Educational purposes.
The class EntityDataGenerator will only work on new entities that contain no Transactions. This is with the intention of avoiding unintentional commingling with an actual EntityModel with production data and the data generated randomly.
This class will conveniently create a Chart of Accounts and populate the database will Bills, Invoices and various other Transactions. The user will be able to immediately browse the Entity data by clicking on the newly created entity’s details page.
All data generated is random and fake, not related to any other entity data.
`class django_ledger.io.io_generator.EntityDataGenerator(` _user_model_ , _entity_model:_ EntityModel _| str_ , _start_dttm: datetime_ , _capital_contribution: Decimal_ , _days_forward: int_ , _tx_quantity: int = 25_ `)`
A random data generator for Entity Models. Requires a user to me the entity model administrator.
**58**
**Chapter 8. IO Engine**
**Django Ledger**
`user_model` The Django user model that administers the entity. **Type** UserModel `entity_model` The Entity model to populate. **Type** _EntityModel_
`start_dttm` The start datetime for new transactions. All transactions will be posted no earlier than this date. **Type** datetime
`capital_contribution` The initial capital contribution amount for the Entity Model. This will help fund the entity. **Type** Decimal `days_forward` The number of days to span from the start_dttm for new transactions. **Type** int
`exception django_ledger.io.io_generator.EntityModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
`django_ledger.io.io_generator.random()` _→_ x in the interval [0, 1).
**8.7. Random Data Generation**
**59**
**Django Ledger**
**60**
**Chapter 8. IO Engine**
**CHAPTER NINE**
## **MODELS**
## **9.1 Model Dependency Diagram**
**==> picture [468 x 115] intentionally omitted <==**
## **9.2 Database Fields**
**==> picture [468 x 172] intentionally omitted <==**
## **9.3 Entity Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
The EntityModel represents the Company, Corporation, Legal Entity, Enterprise or Person that engage and operate as a business. EntityModels can be created as part of a parent/child model structure to accommodate complex corporate structures where certain entities may be owned by other entities and may also generate consolidated financial statements.
**61**
**Django Ledger**
Another use case of parent/child model structures is the coordination and authorization of inter-company transactions across multiple related entities. The EntityModel encapsulates all LedgerModel, JournalEntryModel and TransactionModel which is the core structure of Django Ledger in order to track and produce all financials.
The EntityModel must be assigned an Administrator at creation, and may have optional Managers that will have the ability to operate on such EntityModel.
EntityModels may also have different financial reporting periods, (also known as fiscal year), which start month is specified at the time of creation. All key functionality around the Fiscal Year is encapsulated in the EntityReportMixIn.
- `class django_ledger.models.entity.EntityManagementModel(` _*args_ , _**kwargs_ `)`
- EntityManagement Model Base Class From Abstract
- `exception DoesNotExist`
## `exception MultipleObjectsReturned`
- `class django_ledger.models.entity.EntityManagementModelAbstract(` _*args_ , _**kwargs_ `)`
Entity Management Model responsible for manager permissions to read/write.
- `class django_ledger.models.entity.EntityModel(` _*args_ , _**kwargs_ `)`
- Entity Model Base Class From Abstract
- `exception DoesNotExist`
## `exception MultipleObjectsReturned`
- `class django_ledger.models.entity.EntityModelAbstract(` _*args_ , _**kwargs_ `)`
The base implementation of the EntityModel. The EntityModel represents the Company, Corporation, Legal Entity, Enterprise or Person that engage and operate as a business. The base model inherit from the Materialized Path Node of the Django Treebeard library. This allows for complex parent/child relationships between Entities to be tracked and managed properly.
The EntityModel also inherits functionality from the following MixIns:
1. 1. _`SlugNameMixIn`_
1. 2. _`PaymentTermsMixIn`_
1. 3. _`ContactInfoMixIn`_
1. 4. _`CreateUpdateMixIn`_
1. 5. `EntityReportMixIn`
1. 6. `IOMixIn`
`uuid` This is a unique primary key generated for the table. The default value of this field is uuid4().
- **Type** UUID
`name` The name of the Company, Enterprise, Person, etc. used to identify the Entity.
**Type** str
**62**
**Chapter 9. Models**
**Django Ledger**
## `admin`
The Django UserModel that will be assigned as the administrator of the EntityModel.
**Type** UserModel
## `default_coa`
The default Chart of Accounts Model of the Entity. EntityModel can have multiple Chart of Accounts but only one can be assigned as default.
**Type** ChartOfAccounts
```
managers
```
The Django UserModels that will be assigned as the managers of the EntityModel by the admin.
**Type** UserModel
## `hidden`
A flag used to hide the EntityModel from QuerySets. Defaults to False.
**Type** bool
## `accrual_method`
**A flag used to define which method of accounting will be used to produce financial statements.**
• If False, Cash Method of Accounting will be used.
• If True, Accrual Method of Accounting will be used.
**Type** bool
```
fy_start_month
```
An integer that specifies the month that the Fiscal Year starts.
**Type** int
## `picture`
The image or logo used to identify the company on reports or UI/UX.
```
class Meta
```
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`create_account(` _code: str_ , _role: str_ , _name: str_ , _balance_type: str_ , _active: bool = False_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _raise_exception: bool = True_ `)` _→_
_AccountModel_
Creates a new AccountModel for the EntityModel.
**Parameters**
• `code` ( _`str`_ ) – The AccountModel code of the new Account.
**9.3. Entity Model**
**63**
**Django Ledger**
- • `role` ( _`str`_ ) – The choice of role that the new Account belongs to.
- • `name` ( _`str`_ ) – The name of the new Account.
- • `balance_type` ( _`str`_ ) – The balance type of the new account. Possible values are ‘debit’ or ‘credit’.
- • `active` ( _`bool`_ ) – Active status of the new account.
- • `coa_model` ( `ChartOfAccountModel` _`, UUID, str`_ ) – The ChartOfAccountsModel UUID, model instance or slug to pull accounts from. Uses default Coa if not provided.
- • `raise_exception` ( _`bool`_ ) – Raises EntityModelValidationError if ChartOfAccountsModel is not valid for the EntityModel instance.
- **Returns**
The ChartOfAccountModel and AccountModel instance just created.
**Return type**
A tuple of _ChartOfAccountModel_ , _AccountModel_
`create_account_by_kwargs(` _account_model_kwargs: Dict_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _raise_exception: bool = True_ `)` _→_
Tuple[ _ChartOfAccountModel_ , _AccountModel_ ]
Creates a new AccountModel for the EntityModel by passing AccountModel KWARGS. This is a legacy method for creating a new AccountModel for the EntityModel. Will be deprecated in favor of create_account().
**Parameters**
- • `coa_model` ( `ChartOfAccountModel` _`, UUID, str`_ ) – The ChartOfAccountsModel UUID, model instance or slug to pull accounts from. Uses default Coa if not provided.
- • `account_model_kwargs` ( _`dict`_ ) – A dictionary of kwargs to be used to create the new AccountModel instance.
- • `raise_exception` ( _`bool`_ ) – Raises EntityModelValidationError if ChartOfAccountsModel is not valid for the EntityModel instance.
**Returns**
The ChartOfAccountModel and AccountModel instance just created.
**Return type**
A tuple of _ChartOfAccountModel_ , _AccountModel_
`create_bank_account(` _name: str_ , _account_type: str_ , _active=False_ , _account_model:_ AccountModel _| None = None_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _bank_account_model_kwargs: Dict | None = None_ , _commit: bool = True_ `)`
Create a bank account entry for the entity model with specified attributes and validation.
This method creates a new instance of _BankAccountModel_ , validates the given inputs, and saves it to the database if _commit_ is set to True.
**Parameters**
- • `name` ( _`str`_ ) – The name of the bank account to be created.
- • `account_type` ( _`str`_ ) – The account type. It must be one of the valid types defined in _BankAccountModel.VALID_ACCOUNT_TYPES_ .
- • `active` ( _`bool, optional`_ ) – A flag indicating whether the account is active. Defaults to False.
**64**
**Chapter 9. Models**
**Django Ledger**
- • `account_model` ( _`Optional[`_ `AccountModel` _`], optional`_ ) – An optional pre-existing account model instance to link to the bank account.
- • `coa_model` ( _`Optional[Union[`_ `ChartOfAccountModel` _`, UUID, str]], optional`_ ) – The chart of account model or an identifier to filter accounts. Can accept a UUID, string, or _ChartOfAccountModel_ .
- • `bank_account_model_kwargs` ( _`Optional[Dict], optional`_ ) – Additional keyword arguments to initialize the _BankAccountModel_ instance. Defaults to an empty dictionary.
- • `commit` ( _`bool, optional`_ ) – Flag indicating whether to save the created bank account to the database. Defaults to True.
## **Returns**
The newly created and optionally saved instance of the bank account model.
## **Return type**
- _BankAccountModel_
- `create_bill(` _vendor_model:_ VendorModel _| UUID | str_ , _terms: str_ , _date_draft: datetime | date | None = None_ , _xref: str | None = None_ , _cash_account:_ AccountModel _| None = None_ , _prepaid_account:_ AccountModel _| None = None_ , _payable_account:_ AccountModel _| None = None_ , _additional_info: Dict | None = None_ , _ledger_name: str | None = None_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _commit: bool = True_ `)`
Creates a new BillModel for the EntityModel instance. Bill will have DRAFT status.
**Parameters**
- • `vendor_model` ( `VendorModel` _`or UUID or str`_ ) – The VendorModel, VendorModel UUID or VendorModel Number
- • `terms` ( _`str`_ ) – Payment terms of the new BillModel. A choice of BillModel.TERM_CHOICES_VALID
- • `date_draft` ( _`date or datetime`_ ) – Date to use as draft date for the new BillModel.
- • `xref` ( _`str`_ ) – Optional External Reference for the Bill (i.e. Vendor invoice number.)
- • `cash_account` ( `AccountModel` ) – Optional CASH AccountModel associated with the new BillModel. Defaults to CASH default AccountModel role.
- • `prepaid_account` ( `AccountModel` ) – Optional PREPAID AccountModel associated with the new BillModel for accruing purposes. Defaults to PREPAID default AccountModel role.
- • `payable_account` ( `AccountModel` ) – Optional PAYABLE AccountModel associated with the new BillModel for accruing purposes. Defaults to ACCOUNTS PAYABLE default AccountModel role.
- • `additional_info` ( _`Dict`_ ) – Additional user-defined information stored as JSON in the Database.
- • `ledger_name` ( _`str`_ ) – Optional LedgerModel name to be assigned to the BillModel instance.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels
- • `commit` ( _`bool`_ ) – If True, commits the new BillModel in the Database.
## **Returns**
The newly created BillModel in DRAFT state.
**9.3. Entity Model**
**65**
**Django Ledger**
## **Return type**
_BillModel_
`create_chart_of_accounts(` _assign_as_default: bool = False_ , _coa_name: str | None = None_ , _commit: bool = False_ `)` _→ ChartOfAccountModel_
Creates a Chart of Accounts for the Entity Model and optionally assign it as the default Chart of Accounts. EntityModel must have a default Chart of Accounts before being able to transact.
## **Parameters**
- • `coa_name` ( _`str`_ ) – The new CoA name. If not provided will be auto generated based on the EntityModel name.
- • `commit` ( _`bool`_ ) – Commits the transaction into the DB. A ChartOfAccountModel will
- • `assign_as_default` ( _`bool`_ ) – Assigns the newly created ChartOfAccountModel as the EntityModel default_coa.
## **Returns**
The newly created chart of accounts model.
## **Return type**
_ChartOfAccountModel_
`create_customer(` _customer_model_kwargs: Dict_ , _commit: bool = True_ `)` _→ CustomerModel_
Creates a new CustomerModel associated with the EntityModel instance.
## **Parameters**
- • `customer_model_kwargs` ( _`dict`_ ) – The kwargs to be used for the new CustomerModel.
- • `commit` ( _`bool`_ ) – Saves the CustomerModel instance in the Database.
## **Return type**
_CustomerModel_
`classmethod create_entity(` _name: str_ , _use_accrual_method: bool_ , _admin: User_ , _fy_start_month: int_ , _parent_entity=None_ `)`
Convenience Method to Create a new Entity Model. This is the preferred method to create new Entities in order to properly handle potential parent/child relationships between EntityModels.
## **Parameters**
- • `name` ( _`str`_ ) – The name of the new Entity.
- • `use_accrual_method` ( _`bool`_ ) – If True, accrual method of accounting will be used, otherwise Cash Method of accounting will be used.
- • `fy_start_month` ( _`int`_ ) – The month which represents the start of a new fiscal year. 1 represents January, 12 represents December.
- • `admin` ( _`UserModel`_ ) – The administrator of the new EntityModel.
- • `parent_entity` ( `EntityModel` ) – The parent Entity Model of the newly created Entity. If provided, the admin user must also be admin of the parent company.
`create_estimate(` _estimate_title: str_ , _contract_terms: str_ , _customer_model:_ CustomerModel _| UUID | str_ , _date_draft: date | None = None_ , _commit: bool = True_ `)`
Creates a new EstimateModel for the EntityModel instance. Estimate will have DRAFT status.
## **Parameters**
- • `estimate_title` ( _`str`_ ) – A user defined title for the Estimate.
**66**
**Chapter 9. Models**
**Django Ledger**
- • `date_draft` ( _`date`_ ) – Optional date to use as Draft Date. Defaults to localdate() if None.
- • `customer_model` ( `CustomerModel` _`or UUID or str`_ ) – The CustomerModel, CustomerModel UUID or CustomerModel Number
- • `contract_terms` ( _`str`_ ) – A choice of EstimateModel.CONTRACT_TERMS_CHOICES_VALID
- • `commit` ( _`bool`_ ) – If True, commits the new PO in the Database. Defaults to True.
**Returns**
The newly created PurchaseOrderModel in DRAFT state.
**Return type**
_PurchaseOrderModel_
- `create_invoice(` _customer_model:_ VendorModel _| UUID | str_ , _terms: str_ , _cash_account:_ AccountModel _| None = None_ , _prepaid_account:_ AccountModel _| None = None_ , _payable_account:_ AccountModel _| None = None_ , _additional_info: Dict | None = None_ , _ledger_name: str | None = None_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _date_draft: date | None = None_ , _commit: bool = True_ `)`
Creates a new InvoiceModel for the EntityModel instance. Invoice will have DRAFT status.
**Parameters**
- • `customer_model` ( `CustomerModel` _`or UUID or str`_ ) – The CustomerModel, CustomerModel UUID or CustomerModel Number
- • `terms` ( _`str`_ ) – A choice of InvoiceModel.TERM_CHOICES_VALID
- • `cash_account` ( `AccountModel` ) – Optional CASH AccountModel associated with the new InvoiceModel. Defaults to CASH default AccountModel role.
- • `prepaid_account` ( `AccountModel` ) – Optional PREPAID AccountModel associated with the new InvoiceModel for accruing purposes. Defaults to PREPAID default AccountModel role.
- • `payable_account` ( `AccountModel` ) – Optional PAYABLE AccountModel associated with the new InvoiceModel for accruing purposes. Defaults to ACCOUNTS PAYABLE default AccountModel role.
- • `additional_info` ( _`Dict`_ ) – Additional user-defined information stored as JSON in the Database.
- • `ledger_name` ( _`str`_ ) – Optional LedgerModel name to be assigned to the InvoiceModel instance.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels
- • `date_draft` ( _`date`_ ) – Optional date to use as Draft Date. Defaults to localdate() if None.
- • `commit` ( _`bool`_ ) – If True, commits the new BillModel in the Database.
- **Returns**
The newly created InvoiceModel in DRAFT state.
- **Return type**
- _InvoiceModel_
`create_item_expense(` _name: str_ , _expense_type: str_ , _uom_model: UUID |_ UnitOfMeasureModel, _expense_account: UUID |_ AccountModel _| None = None_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _commit: bool = True_ `)` _→ ItemModel_
**9.3. Entity Model**
**67**
**Django Ledger**
Creates a new items of type EXPENSE.
**Parameters**
- • `name` ( _`str`_ ) – The name of the new service.
- • `expense_type` ( _`str`_ ) – The type of expense. A choice of ItemModel.ITEM_TYPE_CHOICES
- • `uom_model` – The UOM UUID or UnitOfMeasureModel of the Service. Will be validated if provided.
- • `expense_account` ( `AccountModel` ) – Optional EXPENSE_OPERATIONAL AccountModel associated with the new Expense Item. Defaults to EXPENSE_OPERATIONAL default AccountModel role.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels.
- • `commit` ( _`bool`_ ) – Commits the ItemModel in the DB. Defaults to True.
**Return type** _ItemModel_
`create_item_inventory(` _name: str_ , _uom_model: UUID |_ UnitOfMeasureModel, _item_type: str_ , _inventory_account: UUID |_ AccountModel _| None = None_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _commit: bool = True_ `)`
Creates a new items of type INVENTORY.
**Parameters**
- • `name` ( _`str`_ ) – The name of the new service.
- • `item_type` ( _`str`_ ) – The type of expense. A choice of ItemModel.ITEM_TYPE_CHOICES
- • `uom_model` – The UOM UUID or UnitOfMeasureModel of the Service. Will be validated if provided.
- • `inventory_account` ( `AccountModel` ) – Optional ASSET_CA_INVENTORY AccountModel associated with the new Expense Item. Defaults to ASSET_CA_INVENTORY default AccountModel role.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels.
- • `commit` ( _`bool`_ ) – Commits the ItemModel in the DB. Defaults to True.
- **Return type** _ItemModel_
`create_item_product(` _name: str_ , _item_type: str_ , _uom_model: UUID |_ UnitOfMeasureModel, _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _commit: bool = True_ `)` _→ ItemModel_
Creates a new items of type PRODUCT.
**Parameters**
- • `name` ( _`str`_ ) – Name of the new service.
- • `item_type` ( _`str`_ ) – The type of product. A choice of ItemModel.ITEM_TYPE_CHOICES
**68**
**Chapter 9. Models**
**Django Ledger**
- • `uom_model` – The UOM UUID or UnitOfMeasureModel of the Service. Will be validated if provided.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels.
- • `commit` ( _`bool`_ ) – Commits the ItemModel in the DB. Defaults to True.
**Returns**
The created Product.
**Return type**
_ItemModel_
`create_item_service(` _name: str_ , _uom_model: UUID |_ UnitOfMeasureModel, _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _commit: bool = True_ `)` _→ ItemModel_
Creates a new items of type SERVICE.
**Parameters**
- • `name` ( _`str`_ ) – Name of the new service.
- • `uom_model` – The UOM UUID or UnitOfMeasureModel of the Service. Will be validated if provided.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional ChartOfAccountsModel to use when fetching default role AccountModels.
- • `commit` ( _`bool`_ ) – Commits the ItemModel in the DB. Defaults to True.
## **Returns**
The created Service.
**Return type**
_ItemModel_
`create_purchase_order(` _po_title: str | None = None_ , _estimate_model=None_ , _date_draft: date | None = None_ , _commit: bool = True_ `)`
Creates a new PurchaseOrderModel for the EntityModel instance. PO will have DRAFT status.
**Parameters**
- • `po_title` ( _`str`_ ) – The user defined title for the new Purchase Order Model.
- • `date_draft` ( _`date`_ ) – Optional date to use as Draft Date. Defaults to localdate() if None.
- • `estimate_model` ( `EstimateModel` ) – The EstimateModel to associate the PO for tracking.
- • `commit` ( _`bool`_ ) – If True, commits the new PO in the Database. Defaults to True.
**Returns**
The newly created PurchaseOrderModel in DRAFT state.
**Return type**
_PurchaseOrderModel_
`create_uom(` _name: str_ , _unit_abbr: str_ , _active: bool = True_ , _commit: bool = True_ `)` _→ UnitOfMeasureModel_
Creates a new Unit of Measure Model associated with the EntityModel instance
## **Parameters**
• `name` ( _`str`_ ) – The user defined name of the new Unit of Measure Model instance.
**9.3. Entity Model**
**69**
**Django Ledger**
- • `unit_abbr` ( _`str`_ ) – The unique slug abbreviation of the UoM model. Will be indexed.
- • `active` ( _`bool`_ ) – Mark this UoM as active.
- • `commit` ( _`bool`_ ) – Saves the model in the DB if True. Defaults to True
**Return type**
_UnitOfMeasureModel_
`create_vendor(` _vendor_model_kwargs: Dict_ , _commit: bool = True_ `)` _→ VendorModel_
Creates a new VendorModel associated with the EntityModel instance.
**Parameters**
- • `vendor_model_kwargs` ( _`dict`_ ) – The kwargs to be used for the new VendorModel.
- • `commit` ( _`bool`_ ) – Saves the VendorModel instance in the Database.
**Return type**
_VendorModel_
`generate_slug(` _commit: bool = False_ , _raise_exception: bool = True_ , _force_update: bool = False_ `)` _→_ str
Convenience method to create the EntityModel slug.
**Parameters**
- • `force_update` ( _`bool`_ ) – If True, will update the EntityModel slug.
- • `raise_exception` ( _`bool`_ ) – Raises ValidationError if EntityModel already has a slug.
- • `commit` ( _`bool`_ ) – If True,
`static generate_slug_from_name(` _name: str_ `)` _→_ str
Uses Django’s slugify function to create a valid slug from any given string.
**Parameters**
`name` ( _`str`_ ) – The name or string to slugify.
**Return type**
The slug as a String.
`get_accounts_url()` _→_ str
The EntityModel Code of Accounts llist import URL.
**Returns**
EntityModel Code of Accounts llist import URL as a string.
**Return type**
str
`get_accounts_with_codes(` _code_list: str | List[str] | Set[str]_ , _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ `)` _→ AccountModelQuerySet_
Fetches the AccountModelQuerySet with provided code list.
**Parameters**
- • `coa_model` ( `ChartOfAccountModel` _`, UUID, str`_ ) – The ChartOfAccountsModel UUID, model instance or slug to pull accounts from. Uses default Coa if not provided.
- • `code_list` ( _`list or str`_ ) – Code or list of codes to fetch.
**Returns**
The requested AccountModelQuerySet with applied code filter.
**70**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
_AccountModelQuerySet_
`get_all_accounts(` _active: bool = True_ , _order_by: Tuple[str] | None = ('code',)_ `)` _→ AccountModelQuerySet_ Fetches all AccountModelQuerySet associated with the EntityModel.
**Parameters**
- • `active` ( _`bool`_ ) – Selects only active accounts.
- • `order_by` ( _`list of strings.`_ ) – Optional list of fields passed to the order_by QuerySet method.
**Returns**
The AccountModelQuerySet of the assigned default CoA.
**Return type**
_AccountModelQuerySet_
`get_all_coa_accounts(` _order_by: Tuple[str] | None = ('code',)_ , _active: bool = True_ `)` _→_ Tuple[ _ChartOfAccountModelQuerySet_ , Dict[ _ChartOfAccountModel_ ,
_AccountModelQuerySet_ ]]
Fetches all the AccountModels associated with the EntityModel grouped by ChartOfAccountModel.
**Parameters**
- • `active` ( _`bool`_ ) – Selects only active accounts.
- • `order_by` ( _`list of strings.`_ ) – Optional list of fields passed to the order_by QuerySet method.
**Returns Tuple** – The ChartOfAccountModelQuerySet and a grouping of AccountModels by ChartOfAccountModel as keys.
**Return type** Tuple[ _ChartOfAccountModelQuerySet_ , Dict[ _ChartOfAccountModel_ , _AccountModelQuerySet_ ]
`get_balance_sheet_url()` _→_ str
The EntityModel Balance Sheet Statement URL.
**Returns** EntityModel Balance Sheet Statement URL as a string.
**Return type**
str
`get_bank_accounts(` _active: bool = True_ `)` _→ BankAccountModelQuerySet_
Fetches a QuerySet of BankAccountModels associated with the EntityModel instance.
**Parameters**
`active` ( _`bool`_ ) – If True, returns only active Bank Accounts. Defaults to True.
**Return type** _BankAccountModelQuerySet_
`get_banks_url()` _→_ str
The EntityModel bank account list URL.
**Returns**
EntityModel bank account list URL as a string.
**9.3. Entity Model**
**71**
**Django Ledger**
## **Return type**
str
```
get_bills()
```
Fetches a QuerySet of BillModels associated with the EntityModel instance.
**Return type**
_BillModelQuerySet_
`get_bills_url()` _→_ str
The EntityModel bill list URL.
**Returns**
EntityModel bill list URL as a string.
**Return type**
str
`get_cashflow_statement_url()` _→_ str
The EntityModel Cashflow Statement URL.
**Returns**
EntityModel Cashflow Statement URL as a string.
## **Return type**
str
`get_coa_accounts(` _coa_model:_ ChartOfAccountModel _| UUID | str | None = None_ , _active: bool = True_ , _locked: bool = False_ , _order_by: Tuple | None = ('code',)_ , _return_coa_model: bool = False_ `)` _→ AccountModelQuerySet_ | Tuple[ _ChartOfAccountModel_ , _AccountModelQuerySet_ ]
Fetches the AccountModelQuerySet for a specific ChartOfAccountModel.
**Parameters**
- • `coa_model` ( `ChartOfAccountModel` _`, UUID, str`_ ) – The ChartOfAccountsModel UUID, model instance or slug to pull accounts from. If None, will use default CoA.
- • `active` ( _`bool`_ ) – Selects only active accounts.
- • `locked` ( _`bool`_ ) – Selects only locked accounts.
- • `order_by` ( _`list of strings.`_ ) – Optional list of fields passed to the order_by QuerySet method.
**Returns**
The AccountModelQuerySet of the assigned default CoA.
**Return type**
_AccountModelQuerySet_
`get_coa_model_qs(` _active: bool = True_ `)`
Fetches the current Entity Model instance Chart of Accounts Model Queryset.
**Parameters**
`active` ( _`bool`_ ) – Returns only active Chart of Account Models. Defaults to True.
**Return type**
_ChartOfAccountModelQuerySet_
**72**
**Chapter 9. Models**
**Django Ledger**
`get_customers(` _active: bool = True_ `)` _→ CustomerModelQueryset_
Fetches the CustomerModel associated with the EntityModel instance.
**Parameters** `active` ( _`bool`_ ) – Active CustomerModel only. Defaults to True.
**Returns**
The EntityModel instance CustomerModelQueryset with applied filters.
**Return type** _CustomerModelQueryset_
`get_customers_url()` _→_ str
The EntityModel customers list URL.
**Returns** EntityModel customers list URL as a string.
**Return type** str
`get_dashboard_url()` _→_ str
The EntityModel Dashboard URL.
**Returns** EntityModel dashboard URL as a string.
**Return type** str
`get_data_import_url()` _→_ str
The EntityModel transaction import URL.
**Returns** EntityModel transaction import URL as a string.
**Return type**
str
`get_default_account_for_role(` _role: str_ , _coa_model:_ ChartOfAccountModel _| None = None_ `)` _→_
_AccountModel_
Gets the given role default AccountModel from the provided CoA. CoA will be validated against the EntityModel instance.
**Parameters**
- • `role` ( _`str`_ ) – The CoA role to fetch the corresponding default Account Model.
- • `coa_model` ( `ChartOfAccountModel` ) – The CoA Model to pull default account from. If not provided, will use EntityModel default CoA.
- **Returns**
The default account model for the specified CoA role.
**Return type**
_AccountModel_
`get_default_coa(` _raise_exception: bool = True_ `)` _→ ChartOfAccountModel_ | None
Fetches the EntityModel default Chart of Account.
**Parameters**
`raise_exception` ( _`bool`_ ) – Raises exception if no default CoA has been assigned.
**9.3. Entity Model**
**73**
**Django Ledger**
## **Returns**
The EntityModel default ChartOfAccount.
**Return type**
_ChartOfAccountModel_
`get_default_coa_accounts(` _active: bool = True_ , _order_by: Tuple[str] | None = ('code',)_ , _raise_exception: bool = True_ `)` _→ AccountModelQuerySet_ | None
Fetches the default AccountModelQuerySet.
**Parameters**
- • `active` ( _`bool`_ ) – Selects only active accounts.
- • `order_by` ( _`list of strings.`_ ) – Optional list of fields passed to the order_by QuerySet method.
- • `raise_exception` ( _`bool`_ ) – Raises EntityModelValidationError if no default_coa found.
**Returns**
The AccountModelQuerySet of the assigned default CoA.
**Return type**
_AccountModelQuerySet_
`get_delete_url()` _→_ str
The EntityModel delete URL.
**Returns** EntityModel delete URL as a string.
**Return type**
str
```
get_estimates()
```
Fetches a QuerySet of EstimateModels associated with the EntityModel instance.
**Return type**
_EstimateModelQuerySet_
`get_income_statement_url()` _→_ str
The EntityModel Income Statement URL.
**Returns** EntityModel Income Statement URL as a string.
**Return type** str
```
get_invoices()
```
Fetches a QuerySet of InvoiceModels associated with the EntityModel instance.
**Return type** _InvoiceModelQuerySet_
`get_invoices_url()` _→_ str The EntityModel invoice list URL.
**Returns** EntityModel invoice list URL as a string.
**Return type**
str
**74**
**Chapter 9. Models**
**Django Ledger**
`get_items_all(` _active: bool = True_ `)` _→ ItemModelQuerySet_
Fetches all EntityModel instance ItemModel’s. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
`get_items_expenses(` _active: bool = True_ `)` _→ ItemModelQuerySet_
Fetches all EntityModel instance ItemModel’s that qualify as Products. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
`get_items_inventory(` _active: bool = True_ `)`
Fetches all EntityModel instance ItemModel’s that qualify as inventory. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
`get_items_inventory_wip(` _active: bool = True_ `)`
Fetches all EntityModel instance ItemModel’s that qualify as work in progress inventory. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
`get_items_products(` _active: bool = True_ `)` _→ ItemModelQuerySet_
Fetches all EntityModel instance ItemModel’s that qualify as Products. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
`get_items_services(` _active: bool = True_ `)` _→ ItemModelQuerySet_
Fetches all EntityModel instance ItemModel’s that qualify as Services. QuerySet selects relevant related fields to avoid additional DB queries for most use cases.
**Parameters**
`active` ( _`bool`_ ) – Filters the QuerySet to active accounts only. Defaults to True.
**Return type**
_ItemModelQuerySet_
**9.3. Entity Model**
**75**
**Django Ledger**
`get_ledgers_url()` _→_ str The EntityModel Ledger List URL. **Returns** EntityModel ledger list URL as a string. **Return type** str `get_manage_url()` _→_ str The EntityModel Manage URL. **Returns** EntityModel manage URL as a string. **Return type** str
```
get_purchase_orders()
```
Fetches a QuerySet of PurchaseOrderModels associated with the EntityModel instance.
**Return type** _PurchaseOrderModelQuerySet_ `get_uom_all()` _→ UnitOfMeasureModelQuerySet_ Fetches the EntityModel instance Unit of Measures QuerySet.
**Return type** _UnitOfMeasureModelQuerySet_ `get_vendors(` _active: bool = True_ `)` _→ VendorModelQuerySet_ Fetches the VendorModels associated with the EntityModel instance.
**Parameters** `active` ( _`bool`_ ) – Active VendorModels only. Defaults to True. **Returns** The EntityModel instance VendorModelQuerySet with applied filters. **Return type** _VendorModelQuerySet_ `get_vendors_url()` _→_ str The EntityModel vendors list URL. **Returns** EntityModel vendors list URL as a string. **Return type** str `has_default_coa()` _→_ bool Determines if the EntityModel instance has a Default CoA. **Returns** True if EntityModel instance has a Default CoA. **Return type** bool
**76**
**Chapter 9. Models**
**Django Ledger**
`static inventory_adjustment(` _counted_qs_ , _recorded_qs_ `)` _→_ defaultdict
Computes the necessary inventory adjustment to update balance sheet.
**Parameters**
- • `counted_qs` ( `ItemTransactionModelQuerySet` ) – Inventory recount queryset from Purchase Order received inventory. See `ItemTransactionModelManager. inventory_count` . Expects ItemTransactionModelQuerySet to be formatted “as values”.
- • `recorded_qs` ( `ItemModelQuerySet` ) – Inventory received currently recorded for each inventory item. See `ItemTransactionModelManager.inventory_count` Expects ItemModelQuerySet to be formatted “as values”.
**Returns**
**A dictionary with necessary adjustments with keys as tuple:**
- 0. item_model_id
- 1. item_model__name
- 2. item_model__uom__name
- **Return type**
- defaultdict
`populate_default_coa(` _activate_accounts: bool = False_ , _force: bool = False_ , _ignore_if_default_coa: bool = True_ , _coa_model:_ ChartOfAccountModel _| None = None_ , _commit: bool = True_ `)` Populates the EntityModel default CoA with the default Chart of Account list provided by Django Ledger or user defined. See DJANGO_LEDGER_DEFAULT_COA setting.
**Parameters**
- • `activate_accounts` ( _`bool`_ ) – Activates all AccountModels for immediate use. Defaults to False.
- • `force` ( _`bool`_ ) – Forces the creation of accounts even if other accounts are present. Defaults to False.
- • `ignore_if_default_coa` ( _`bool`_ ) – Raises exception if EntityModel already has a default CoA. Defaults to True.
- • `coa_model` ( `ChartOfAccountModel` ) – Optional CoA Model to populate. Will be validated against EntityModel if provided.
- • `commit` ( _`bool`_ )
- • `True.` ( _'_ _`Commits the newly created CoA into the Database. Defaults to`_ )
- `recorded_inventory(` _item_qs:_ ItemModelQuerySet _| None = None_ , _as_values: bool = True_ `)` _→_
_ItemModelQuerySet_
Recorded inventory on the books marked as received. PurchaseOrderModel drives the ordering and receiving of inventory. Once inventory is marked as “received” recorded inventory of each item is updated by calling _`update_inventory`_ . This function returns relevant values of the recoded inventory, including Unit of Measures.
**Parameters**
- • `item_qs` ( `ItemModelQuerySet` ) – Pre fetched ItemModelQuerySet. Avoids additional DB Query.
- • `as_values` ( _`bool`_ ) – Returns a list of dictionaries by calling the Django values() QuerySet function.
**9.3. Entity Model**
**77**
**Django Ledger**
**Returns**
The ItemModelQuerySet containing inventory ItemModels with additional Unit of Measure information.
**Return type** _ItemModelQuerySet_
`update_inventory(` _commit: bool = False_ `)` _→_ Tuple[defaultdict, _ItemTransactionModelQuerySet_ , _ItemModelQuerySet_ ]
Triggers an inventory recount with optional commitment of transaction.
**Parameters** `commit` – Updates all inventory ItemModels with the new inventory count.
## **Returns**
**Return a tuple as follows:**
- 0. All necessary inventory adjustments as a dictionary.
- 1. The recounted inventory.
- 2. The recorded inventory on Balance Sheet.
**Return type**
Tuple[defaultdict, _ItemTransactionModelQuerySet_ , _ItemModelQuerySet_ ]
`validate_account_model_for_coa(` _account_model:_ AccountModel, _coa_model:_ ChartOfAccountModel, _raise_exception: bool = True_ `)` _→_ bool
Validates that the AccountModel provided belongs to the CoA Model provided.
**Parameters**
- • `account_model` ( `AccountModel` ) – The AccountModel to validate.
- • `coa_model` ( `ChartOfAccountModel` ) – The ChartOfAccountModel to validate against.
- • `raise_exception` ( _`bool`_ ) – Raises EntityModelValidationError if AccountModel is invalid for the EntityModel and CoA instance.
**Returns**
True if valid, else False.
**Return type**
bool
`validate_chart_of_accounts_for_entity(` _coa_model:_ ChartOfAccountModel, _raise_exception: bool = True_ `)` _→_ bool
Validates the CoA Model against the EntityModel instance.
**Parameters**
- • `coa_model` ( `ChartOfAccountModel` ) – The CoA Model to validate.
- • `raise_exception` ( _`bool`_ ) – Raises EntityModelValidationError if CoA Model is not valid for the EntityModel instance.
**Returns**
True if valid, else False.
**Return type** bool
**78**
**Chapter 9. Models**
**Django Ledger**
`validate_item_qs(` _item_qs:_ ItemModelQuerySet, _raise_exception: bool = True_ `)` _→_ bool
Validates the given ItemModelQuerySet against the EntityModel instance. :param item_qs: The ItemModelQuerySet to validate. :type item_qs: ItemModelQuerySet :param raise_exception: Raises EntityModelValidationError if ItemModelQuerySet is not valid. :type raise_exception: bool
## **Returns**
True if valid, else False.
## **Return type**
## bool
## `class django_ledger.models.entity.EntityModelClosingEntryMixIn`
Closing Entries provide
## `class django_ledger.models.entity.EntityModelFiscalPeriodMixIn`
This class encapsulates the functionality needed to determine the start and end of all financial periods of an EntityModel. At the moment of creation, an EntityModel must be assigned a calendar month which is going to determine the start of the Fiscal Year.
`get_fiscal_quarter_dates(` _year: int_ , _quarter: int_ , _fy_start_month: int = None_ `)` _→_ Tuple[date, date]
Convenience method to get in one shot both, fiscal year quarter start and end dates.
**Parameters**
- • `year` ( _`int`_ ) – The fiscal year associated with the requested start and end date.
- • `quarter` ( _`int`_ ) – The quarter number associated with the requested start and end date.
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
## **Returns**
Both, the date when the requested EntityModel fiscal year quarter start and end date as a tuple. The start date will be first.
## **Return type**
tuple
`get_fiscal_year_dates(` _year: int_ , _fy_start_month: int = None_ `)` _→_ Tuple[date, date]
Convenience method to get in one shot both, fiscal year start and end dates.
## **Parameters**
- • `year` ( _`int`_ ) – The fiscal year associated with the requested start and end date.
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
## **Returns**
Both, the date when the requested EntityModel fiscal year start and end date as a tuple. The start date will be first.
## **Return type**
## tuple
`get_fy_end(` _year: int_ , _fy_start_month: int = None_ `)` _→_ date
The fiscal year ending date of the EntityModel, according to its settings.
**Parameters**
- • `year` ( _`int`_ ) – The fiscal year associated with the requested end date.
**9.3. Entity Model**
**79**
**Django Ledger**
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
**Returns**
The date when the requested EntityModel fiscal year ends.
**Return type** date
`get_fy_for_date(` _dt: date | datetime_ , _as_str: bool = False_ `)` _→_ str | int
Given a known date, returns the EntityModel fiscal year associated with the given date.
**Parameters**
• `dt` ( _`date`_ ) – Date to evaluate.
• `as_str` ( _`bool`_ ) – If True, return date as a string.
**Returns** Fiscal year as an integer or string, depending on as_str parameter.
**Return type** str or date
`get_fy_start(` _year: int_ , _fy_start_month: int | None = None_ `)` _→_ date
The fiscal year start date of the EntityModel, according to its settings.
**Parameters**
- • `year` ( _`int`_ ) – The fiscal year associated with the requested start date.
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
**Returns** The date when the requested EntityModel fiscal year starts. **Return type** date
`get_fy_start_month()` _→_ int
The fiscal year start month represents the month (as an integer) when the assigned fiscal year of the EntityModel starts.
**Returns** An integer representing the month that the fiscal year starts. **Return type** int
**Examples**
• 1 -> January.
• 4 -> April. • 9 -> September.
`get_quarter_end(` _year: int_ , _quarter: int_ , _fy_start_month: int = None_ `)` _→_ date
The fiscal year quarter ending date of the EntityModel, according to its settings.
**Parameters**
• `year` ( _`int`_ ) – The fiscal year associated with the requested end date.
**80**
**Chapter 9. Models**
**Django Ledger**
- • `quarter` ( _`int`_ ) – The quarter number associated with the requested end date.
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
**Returns**
The date when the requested EntityModel quarter ends.
**Return type**
date
`get_quarter_start(` _year: int_ , _quarter: int_ , _fy_start_month: int = None_ `)` _→_ date
The fiscal year quarter starting date of the EntityModel, according to its settings.
**Parameters**
- • `year` ( _`int`_ ) – The fiscal year associated with the requested start date.
- • `quarter` ( _`int`_ ) – The quarter number associated with the requested start date.
- • `fy_start_month` ( _`int`_ ) – Optional fiscal year month start. If passed, it will override the EntityModel setting.
**Returns**
The date when the requested EntityModel quarter starts.
**Return type**
date
`validate_month(` _month: int_ `)`
Validates the month as a valid parameter for other functions. Makes sure that only integers between 1 and 12 are used to refer to a particular month. Prevents injection of invalid values from views into the IOMixIn.
**Parameters**
`month` ( _`int`_ ) – The month number to validate.
**Raises**
`ValidationError` – If month is not valid.
`validate_quarter(` _quarter: int_ `)`
Validates the quarter as a valid parameter for other functions. Makes sure that only integers 1,2,3, or 4 are used to refer to a particular Quarter. Prevents injection of invalid values from views into the IOMixIn.
**Parameters**
`quarter` ( _`int`_ ) – The quarter number to validate.
**Raises**
`ValidationError` – If quarter is not valid.
## `class django_ledger.models.entity.EntityModelManager(` _*args_ , _**kwargs_ `)`
A custom defined EntityModel Manager. This ModelManager uses the custom defined EntityModelQuerySet as default. Inherits from the Materialized Path Node Manager to include the necessary methods to manage tree-like models. This Model Manager keeps track and maintains a root/parent/child relationship between Entities for the purposes of producing consolidated financial statements.
**Examples**
```
>>> user = request.user
>>> entity_model_qs = EntityModel.objects.for_user(user_model=user)
```
**9.3. Entity Model**
**81**
**Django Ledger**
`for_user(` _user_model_ , _authorized_superuser: bool = False_ `)`
This QuerySet guarantees that Users do not access or operate on EntityModels that don’t have access to. This is the recommended initial QuerySet.
**Parameters**
- • `user_model` – The Django User Model making the request.
- • `authorized_superuser` – Allows any superuser to access the EntityModel. Default is False.
## **Returns**
**A filtered QuerySet of EntityModels that the user has access. The user has access to an Entity if:**
- 1. Is the Administrator.
2. Is a manager.
## **Return type**
_EntityModelQuerySet_
`get_queryset()` _→ EntityModelQuerySet_
Sets the custom queryset as the default.
`class django_ledger.models.entity.EntityModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
A custom defined EntityModel QuerySet. Inherits from the Materialized Path Node QuerySet Class from Django Treebeard.
`hidden()` _→ EntityModelQuerySet_
A QuerySet of all hidden EntityModel.
**Returns**
A filtered QuerySet of hidden EntityModels only.
**Return type**
_EntityModelQuerySet_
`visible()` _→ EntityModelQuerySet_
A Queryset of all visible EntityModel.
**Returns**
A filtered QuerySet of visible EntityModels only.
## **Return type**
_EntityModelQuerySet_
`exception django_ledger.models.entity.EntityModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
`class django_ledger.models.entity.EntityStateModel(` _*args_ , _**kwargs_ `)`
Entity State Model Base Class from Abstract.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.entity.EntityStateModelAbstract(` _*args_ , _**kwargs_ `)`
**82**
**Chapter 9. Models**
**Django Ledger**
## **9.4 Entity Unit Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
An EntityUnit is a logical, user-defined grouping assigned to JournalEntryModels, helping to segregate business operations into distinct components. Examples of EntityUnits may include departments (e.g., Human Resources, IT), office locations, real estate properties, or any other labels relevant to the business.
EntityUnits are self-contained entities, meaning that double-entry accounting rules apply to all transactions associated with them. When an Invoice or Bill is updated, the migration process generates the corresponding Journal Entries for each relevant unit. This allows invoices or bills to split specific items into different units, with the migration process allocating costs to each unit accordingly.
**Key advantages of EntityUnits:**
- 1. EntityUnits can generate their own financial statements, providing deeper insights into the specific operations of the business.
- 2. EntityUnits can be assigned to specific items on Bills and Invoices, offering flexibility to track inventory, expenses, or income associated with distinct business units.
`class django_ledger.models.unit.EntityUnitModel(` _*args_ , _**kwargs_ `)`
Base Model Class for EntityUnitModel
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.unit.EntityUnitModelAbstract(` _*args_ , _**kwargs_ `)`
Base implementation of the EntityUnitModel.
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
```
slug
```
A unique, indexed identifier for the EntityUnitModel instance used in URLs and queries.
**Type** str
```
entity
```
The EntityModel associated with this EntityUnitModel.
**Type**
_EntityModel_
```
document_prefix
```
A predefined prefix automatically incorporated into JournalEntryModel document numbers. Max Length
- 3. May be user defined. Must be unique for the EntityModel.
**Type** str
```
active
```
Active EntityUnits may transact. Inactive units are considered archived. Defaults to True.
**9.4. Entity Unit Model**
**83**
**Django Ledger**
## **Type**
bool
```
hidden
```
Hidden Units will not show on drop down menus on the UI. Defaults to False.
## **Type**
bool
```
class Meta
```
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`create_entity_unit_slug(` _name: str | None = None_ , _force: bool = False_ , _add_suffix: bool = True_ , _k: int = 5_ `)` _→_ str
Automatically generates a EntityUnitModel slug. If slug is present, will not be replaced. Called during the clean() method.
**Parameters**
- • `force` ( _`bool`_ ) – Forces generation of new slug if already present.
- • `name` ( _`str`_ ) – The name used to create slug. If none, the unit name will be used.
- • `add_suffix` ( _`bool`_ ) – Adds a random suffix to the slug. Defaults to True.
- • `k` ( _`int`_ ) – Length of the suffix if add_suffix is True. Defaults to 5.
- **Returns**
The EntityUnitModel slug, regardless if generated or not.
**Return type**
str
`get_dashboard_url()` _→_ str
The dashboard URL of the EntityModelUnit.
**Returns**
The EntityModelUnit instance dashboard URL.
## **Return type**
str
`class django_ledger.models.unit.EntityUnitModelManager(` _*args_ , _**kwargs_ `)`
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)`
Filter the queryset based on the provided entity model, its slug, or its UUID.
Provides functionality to filter entities within a queryset by comparing either an EntityModel instance, its slug, or its UUID. This method also handles optional deprecated behavior for filtering by the ‘user_model’ for backward compatibility.
**Parameters**
- • `entity_model` ( `EntityModel` _`| str | UUID`_ ) – An entity filter criterion that could be a specific EntityModel instance, a string representing the entity slug, or a UUID corresponding to the entity.
**84**
**Chapter 9. Models**
**Django Ledger**
- • `**kwargs` ( _`dict, optional`_ ) – Additional keyword arguments. If the ‘user_model’ parameter is provided, a deprecation warning is issued, and the functionality temporarily delegates to legacy behavior based on the value of ‘DJANGO_LEDGER_USE_DEPRECATED_BEHAVIOR’.
**Returns** A queryset filtered based on the provided entity criteria.
**Return type** QuerySet
**Raises** _`EntityUnitModelValidationError`_ – Raised when the _entity_model_ parameter does not match any of the accepted types (EntityModel, str, or UUID) and fails validation.
## `get_queryset()`
Sets the custom queryset as the default.
`class django_ledger.models.unit.EntityUnitModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
`exception django_ledger.models.unit.EntityUnitModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.5 Account Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
## **9.5.1 AccountModel**
The AccountModel is a fundamental component of the Django Ledger system, responsible for categorizing and organizing financial transactions related to an entity’s assets, liabilities, and equity.
## **9.5.2 Account Types**
In accordance with accounting principles, each AccountModel must be classified as either:
1. 1. **DEBIT-type balance account**
## 2. **CREDIT-type balance account**
The account type determines how transactions affect the account’s balance.
## **9.5.3 Double Entry Accounting**
The AccountModel is crucial in implementing double entry accounting systems:
- • For DEBIT-type accounts: - A DEBIT increases the balance - A CREDIT decreases the balance
- • For CREDIT-type accounts: - A CREDIT increases the balance - A DEBIT decreases the balance
## **9.5.4 Chart of Accounts**
Users have the flexibility to adopt a chart of accounts that best suits their EntityModel. Django Ledger provides a default Chart of Accounts when creating a new EntityModel, which can be customized as needed.
**9.5. Account Model**
**85**
**Django Ledger**
## **9.5.5 Account Roles**
All AccountModels must be assigned a role from the _ACCOUNT_ROLES_ function in _django_ledger.io.roles_ . Roles serve several purposes:
- 1. Group accounts into common namespaces
- 2. Provide consistency across user-defined fields
- 3. Enable accurate generation of financial statements
- 4. Facilitate financial ratio calculations
`class django_ledger.models.accounts.AccountModel(` _*args_ , _**kwargs_ `)`
Base Account Model from Account Model Abstract Class
```
exception DoesNotExist
```
```
exception MultipleObjectsReturned
```
`class django_ledger.models.accounts.AccountModelAbstract(` _*args_ , _**kwargs_ `)`
Abstract class representing an Account Model.
```
BALANCE_TYPE
```
List of choices for the balance type of the account. Options include ‘Credit’ and ‘Debit’.
**Type** list `uuid` Unique identifier for each account instance.
**Type** UUIDField
`code` Code representing the account, constrained by length and specific validation rules.
**Type** CharField
`name` Name of the account, constrained by length.
**Type** CharField
`role` Role associated with the account, with specific predefined choices.
**Type** CharField
`role_default` Flag indicating if this account is the default for its role.
**Type** BooleanField
`balance_type` Type of balance the account holds, must be either ‘debit’ or ‘credit’.
**86**
**Chapter 9. Models**
**Django Ledger**
**Type** CharField
```
locked
```
Indicates whether the account is locked.
**Type** BooleanField
`active` Indicates whether the account is active.
**Type** BooleanField
`coa_model` Reference to the associated ChartOfAccountModel.
**Type** ForeignKey
```
class Meta
```
`activate(` _commit: bool = True_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Checks if the Account Model instance can be activated, then Activates the AccountModel instance. Raises exception if AccountModel cannot be activated.
**Parameters**
- • `commit` ( _`bool, optional`_ ) – If True, commit the changes to the database by calling the save method.
- • `raise_exception` ( _`bool, optional`_ ) – If True, raises an AccountModelValidationError if the account cannot be activated.
- • `kwargs` ( _`dict`_ ) – Additional parameters that can be passed for further customization.
## `alt_str()`
Returns a formatted string representation of the object.
The formatted string includes the code, name, role, and balance type of the object. The role is converted to uppercase for consistency, and the balance type is displayed as is. This method provides a concise textual representation for quick identification or display.
**Returns**
A formatted string in the format ‘code: name (ROLE/BALANCE_TYPE)’.
**Return type** str
```
can_activate()
```
Determines if the object can be activated.
**Returns** True if the object is inactive, otherwise False.
**Return type**
bool
## `can_deactivate()`
Determine if the object can be deactivated.
Checks if the _active_ attribute is set to _True_ .
**9.5. Account Model**
**87**
**Django Ledger**
**Returns** True if the object is currently active and can be deactivated, otherwise False. **Return type** bool
`can_transact()` _→_ bool Determines if a transaction can be performed based on multiple conditions.
**Returns**
• _bool_ – True if all conditions are met, enabling a transaction; False otherwise.
• _Conditions_
• _1. The chart of accounts (coa_model) must be active._ • _2. The entity must not be locked._
• _3. The entity itself must be active._
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
## `property coa_slug`
Property that retrieves the _coa_slug_ attribute from the object. If the attribute is not found, it fetches the _slug_ attribute from the _coa_model_ .
`_coa_slug` Cached value of the _coa_slug_ if it exists. **Type** str `coa_model` Object containing the _slug_ attribute that serves as a fallback when __coa_slug_ is not present. **Type** Any **Returns** The value of __coa_slug_ if defined, or the _slug_ attribute from _coa_model_ if __coa_slug_ is not available. **Return type** str
`classmethod create_account(` _name: str_ , _role: bool_ , _balance_type: str_ , _is_role_default: bool = False_ , _locked: bool = False_ , _active: bool = False_ , _**kwargs_ `)`
Create a new AccountModel instance, managing parent/child relationships properly.
This convenience method ensures correct creation of new accounts, handling the intricate logic needed for maintaining hierarchical relationships between accounts.
## **Parameters**
- • `name` ( _`str`_ ) – Name of the new account entity.
- • `role` ( _`str`_ ) – Role assigned to the account.
- • `balance_type` ( _`str`_ ) – Type of balance associated with the account. Must be either ‘debit’ or ‘credit’.
**88**
**Chapter 9. Models**
**Django Ledger**
- • `is_role_default` ( _`bool, optional`_ ) – Indicates if the account should be the default for its role. Only one default account per role is allowed. Defaults to False.
- • `locked` ( _`bool, optional`_ ) – Flags the account as locked. Defaults to False.
- • `active` ( _`bool, optional`_ ) – Flags the account as active. Defaults to True.
- • `**kwargs` ( _`dict, optional`_ ) – Additional attributes for account creation.
## **Returns**
The newly created _AccountModel_ instance.
## **Return type**
_AccountModel_
`deactivate(` _commit: bool = True_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Checks if the Account Model instance can be de-activated, then De-activates the AccountModel instance. Raises exception if AccountModel cannot be de-activated.
**Parameters**
- • `commit` ( _`bool, optional`_ ) – If True, commit the changes to the database by calling the save method.
- • `raise_exception` ( _`bool, optional`_ ) – If True, raises an AccountModelValidationError if the account cannot be activated.
- • `kwargs` ( _`dict`_ ) – Additional parameters that can be passed for further customization.
## `property entity_slug`
Retrieve the slug value associated with the entity.
This property method returns the value of the private attribute ‘_entity_slug’ for the current instance. The purpose of the slug is typically to provide a URL-friendly string representing the entity.
**Returns**
The value of the ‘_entity_slug’ attribute.
**Return type**
Any
```
generate_random_code()
```
Generates a random code for the account adding a prefix 1-6 depending on account role.
**Raises** _`AccountModelValidationError`_ – If the account role is not assigned before code generation.
**Returns** A randomly generated code prefixed with a role-based prefix.
**Return type**
str
```
get_account_move_choice_queryset()
```
Retrieves a filtered queryset of account models that the current Account Model instance can be a child of.
The queryset is filtered based on the specified role and its hierarchical parent roles. Account models with a UUID matching the current instance’s UUID are excluded from the results.
**Returns**
A filtered set of account models suitable for moving the current instance under.
**9.5. Account Model**
**89**
**Django Ledger**
## **Return type** QuerySet
## `get_code_prefix()` _→_ str
Returns the code prefix based on the account type.
This method determines the account type by calling the respective account type methods and returns the corresponding code prefix based on Accounting best practices..
**Returns**
The code prefix for the account type. The possible values are: ‘1’ for assets, ‘2’ for liabilities, ‘3’ for capital, ‘4’ for income, ‘5’ for cost of goods sold (COGS), ‘6’ for expenses.
**Return type** str
**Raises** _`AccountModelValidationError`_ – If the account role does not match any of the predefined categories.
## `get_html_pixel_indent()`
Calculates the pixel indentation for HTML elements based on the depth attribute for UI purposes
**Returns**
The calculated pixel indentation as a string with ‘px’ suffix.
**Return type** str
`get_root_role()` _→_ str
Returns the root role corresponding to the account type.
**Returns**
The root role corresponding to the account type.
**Return type** str **Raises**
_`AccountModelValidationError`_ – If no valid role match is found for the account’s role.
`is_active()` _→_ bool
Determines if the current instance is active.
**Returns** True if the instance is active, otherwise False **Return type** bool
`is_asset()` _→_ bool
Determines if the current Account Model role of the instance is considered an asset.
**Returns**
True if the role is part of the GROUP_ASSETS, False otherwise.
**Return type** bool
`is_capital()` _→_ bool
Checks if the current Account Model role is in the capital group.
**90**
**Chapter 9. Models**
**Django Ledger**
**Returns** True if the role is in GROUP_CAPITAL, otherwise False. **Return type** bool `is_coa_root()` Check if the current Account Model role is ‘ROOT_COA’. **Returns** True if the role is ‘ROOT_COA’, False otherwise. **Return type** bool `is_cogs()` _→_ bool Determines if the role of the object is part of the GROUP_COGS. **Returns** True if the object’s role is part of the GROUP_COGS, False otherwise. **Return type** bool `is_credit()` Checks if the Account Model has a CREDIT balance type. **Returns** True if account has a CREDIT balance, else False. **Return type** bool `is_debit()` _→_ bool Checks if the account has a DEBIT balance type. **Returns** True if account has a DEBIT balance, else False. **Return type** bool `is_expense()` _→_ bool Checks if the current Account Model _role_ is categorized under _GROUP_EXPENSES_ . **Parameters** `None` **Returns** True if _role_ is in _GROUP_EXPENSES_ , otherwise False. **Return type** bool `is_income()` _→_ bool Determines whether the current Account Model role belongs to the income group. **Parameters** `self` ( _`object`_ ) – The instance of the class containing attribute ‘role’. **Returns** True if the role is in the GROUP_INCOME list, False otherwise.
**9.5. Account Model**
**91**
**Django Ledger**
## **Return type**
bool
```
is_indented()
```
Check if the current depth level is greater than 2.
**Returns**
True if the depth is greater than 2, False otherwise.
**Return type**
bool
`is_liability()` _→_ bool
Determines if the current Account Model role is considered a liability.
**Returns**
True if the role is part of GROUP_LIABILITIES, otherwise False.
**Return type**
bool
## `is_locked()` _→_ bool
Determines if the current object is locked.
**Returns**
True if the object is locked, False otherwise.
**Return type** bool
## `is_root_account()`
Checks if the current user’s role belongs to the ROOT_GROUP.
**Returns**
True if the role is in the ROOT_GROUP, False otherwise
**Return type**
bool
```
property role_bs:str
```
Returns the principal role of the account on the balance sheet.
The principal role can be one of the following: - ‘asset’ - ‘liability’ - ‘equity’
**Returns**
A string representing the principal role of the account on the balance sheet.
**Return type**
str
`class django_ledger.models.accounts.AccountModelManager(` _*args_ , _**kwargs_ `)`
AccountModelManager class provides methods to manage and retrieve AccountModel objects. It inherits from MP_NodeManager for tree-like model implementation.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _coa_model:_ ChartOfAccountModel _| str | UUID | None = None_ , _**kwargs_ `)` _→ AccountModelQuerySet_
Filters the queryset for an entity and, optionally, a chart of account (COA) model.
The method refines the queryset based on the provided _entity_model_ and, optionally, the _coa_model_ . If a deprecated _user_model_ is specified in keyword arguments, a warning is issued. The method supports _EntityModel_ , _str_ , and _UUID_ types for both _entity_model_ and _coa_model_ . A validation error is raised for unsupported types.
**92**
**Chapter 9. Models**
**Django Ledger**
## **Parameters**
- • `entity_model` ( _`Union[` '_ _`EntityModel` '_ _`, str, UUID]`_ ) – The entity model used for filtering the queryset. Could be an instance of _EntityModel_ , a string (slug), or a UUID.
- • `coa_model` ( _`Optional[Union[` '_ _`ChartOfAccountModel` '_ _`, str, UUID]], optional`_ ) – The COA model used for filtering the queryset. Can be an instance of _ChartOfAccountModel_ , a string (slug), or a UUID. If None, default Entity ChartOfAccounts is used. Defaults to None.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments. A deprecated argument _user_model_ can be passed for backward compatibility.
**Returns**
A queryset filtered by the input entity model and, optionally, the chart of account model.
**Return type** _AccountModelQuerySet_ **Raises** _`AccountModelValidationError`_ – If an invalid type is passed for either _entity_model_ or _coa_model_ .
**Warns DeprecationWarning** – If the _user_model_ parameter is passed in the keyword arguments and the application relies on deprecated behavior.
- `get_queryset()` _→ AccountModelQuerySet_
Retrieve and return the default AccountModel QuerySet.
The query set is ordered by the ‘path’ field and uses ‘select_related’ to reduce the number of database queries by retrieving the related ‘coa_model’.
**Returns** An instance of AccountModelQuerySet ordered by ‘path’ and prefetching related ‘coa_model’.
**Return type** _AccountModelQuerySet_
`class django_ledger.models.accounts.AccountModelQuerySet(` _model=None_ , _query=None_ , _using=None_ , _hints=None_ `)`
Custom QuerySet for AccountModel inheriting from MP_NodeQuerySet.
`active()` _→ AccountModelQuerySet_
Filters the queryset to include only active items.
**Returns** A filtered queryset containing only the items marked as active. **Return type** _AccountModelQuerySet_
`can_transact()` _→ AccountModelQuerySet_
Filter the queryset to include only accounts that can accept new transactions.
**Returns** A QuerySet containing the filtered results. **Return type** QuerySet
**9.5. Account Model**
**93**
**Django Ledger**
## `cash()` _→ AccountModelQuerySet_
Retrieve accounts that are of type ASSET_CA_CASH.
`expenses()` _→ AccountModelQuerySet_
Retrieve a queryset containing expenses filtered by specified roles.
This method filters the expenses based on roles defined in the _GROUP_EXPENSES_ constant. It ensures that only the relevant expenses associated with the specified roles are included in the queryset.
## **Returns**
A queryset consisting of expenses filtered according to the roles in _GROUP_EXPENSES_ .
## **Return type**
_AccountModelQuerySet_
`for_bill()` _→ AccountModelQuerySet_
Retrieves only available and unlocked AccountModels for a specific EntityModel, specifically for the creation and management of Bills. Roles within the ‘GROUP_BILL’ context include: ASSET_CA_CASH, ASSET_CA_PREPAID, and LIABILITY_CL_ACC_PAYABLE.
## **Returns**
A QuerySet of the requested EntityModel’s chart of accounts.
## **Return type**
_AccountModelQuerySet_
`for_invoice()` _→ AccountModelQuerySet_
Retrieves available and unlocked AccountModels for a specific EntityModel, specifically for the creation and management of Invoices.
This method ensures that only relevant accounts are pulled, as defined under the roles in _GROUP_INVOICE_ . These roles include: ASSET_CA_CASH, ASSET_CA_RECEIVABLES, and LIABILITY_CL_DEFERRED_REVENUE.
**Returns**
A QuerySet containing the AccountModels relevant for the specified EntityModel and the roles defined in _GROUP_INVOICE_ .
## **Return type**
_AccountModelQuerySet_
`for_user(` _user_model_ `)` _→ AccountModelQuerySet_
## **Parameters**
`user_model` ( _`UserModel`_ ) – The user model instance to use for filtering.
## **Returns**
The filtered queryset based on the user’s permissions. Superusers get the complete queryset whereas other users get a filtered queryset based on their role as admin or manager in the entity.
## **Return type**
_AccountModelQuerySet_
`gb_bs_role()` _→ AccountModelQuerySet_
Groups accounts by Balance Sheet Bucket and then further groups them by role.
## **Returns**
A list where each element is a tuple. The first element of the tuple is the BS bucket, and the second element is a list of tuples where each sub-tuple contains a role display and a list of accounts that fall into that role within the BS bucket.
**94**
**Chapter 9. Models**
**Django Ledger**
## **Return type** List[Tuple]
`inactive()` _→ AccountModelQuerySet_
Filters and returns queryset entries where the active field is set to False.
## **Returns**
A queryset containing entries with active=False.
## **Return type**
_AccountModelQuerySet_
`is_coa_root()` _→ AccountModelQuerySet_
Retrieves the Chart of Accounts (CoA) root node queryset.
A Chart of Accounts Root is a foundational element indicating the primary node in the account hierarchy. This method filters the queryset to include only the Chart of Accounts (CoA) root node.
## **Return type**
_AccountModelQuerySet_
`is_role_default()` _→ AccountModelQuerySet_
Filter the queryset to include only entries where _role_default_ is set to True, excluding entries marked as ‘coa_root’.
## **Returns**
Filtered queryset with _role_default_ set to True and excluding ‘coa_root’ entries.
## **Return type**
_AccountModelQuerySet_
`locked()` _→ AccountModelQuerySet_
Filters the queryset to include only locked AccountModels.
## **Returns**
A queryset containing only the objects with locked set to True.
## **Return type**
_AccountModelQuerySet_
`not_coa_root()` _→ AccountModelQuerySet_
Exclude AccountModels with ROOT_GROUP role from the QuerySet.
## **Returns**
A QuerySet excluding users with role in ROOT_GROUP.
## **Return type**
_AccountModelQuerySet_
`unlocked()` _→ AccountModelQuerySet_
Returns a filtered list of items where the ‘locked’ attribute is set to False.
## **Returns**
A queryset of items with ‘locked’ attribute set to False
## **Return type**
_AccountModelQuerySet_
`with_roles(` _roles: List | str_ `)` _→ AccountModelQuerySet_
Filter the accounts based on the specified roles. This method helps to retrieve accounts associated with a particular role or a list of roles.
**9.5. Account Model**
**95**
**Django Ledger**
For example, to get all accounts categorized under the role “asset_ppe_build” (which might include fixed assets like Buildings), you can utilize this method.
**Parameters**
`roles` ( _`Union[List[str], str]`_ ) – The role or a list of roles to filter the accounts by. If a single string is provided, it is converted into a list containing that role.
**Returns**
A QuerySet of accounts filtered by the provided roles.
**Return type**
_AccountModelQuerySet_
`exception django_ledger.models.accounts.AccountModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.6 Ledger Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
The LedgerModel is the heart of Django Ledger. It is a self-contained unit of accounting that implements a doubleentry accounting system capable of creating and managing transactions into the ledger and producing any financial statements. In essence, an EntityModel is made of a collection of LedgerModels that drive the whole bookkeeping process. Each LedgerModel is independent and they can operate as an individual or as a group.
Each LedgerModel encapsulates a collection of JournalEntryModels, which in turn hold a collection of TransactionModels. LedgerModels can be used to represent any part of the EntityModel and can be extended to add additional functionality and custom logic that drives how transactions are recorded into the books. One example of this is the LedgerWrapperMixIn (see django_ledger.models.mixins.LedgerWrapperMixIn), which is the foundation of LedgerModel abstractions such as the BillModel, InvoiceModel, PurchaseOrderModel and EstimateModel. Extending the LedgerModel can add additional functionality necessary to implement industry-specific functionality to almost anything you can think of. Examples: Farming Equipment, Real Estate, Investment Portfolio, etc.
Also, the LedgerModel inherits functionality from the all mighty IOMixIn (see django_ledger.io.io_mixin.IOMixIn), which is the class responsible for making accounting queries to the Database in an efficient and performing way. The digest() method executes all necessary aggregations and optimizations in order to push as much work to the Database layer as possible in order to minimize the amount of data being pulled for analysis into the Python memory.
The Django Ledger core model follows the following structure: EntityModel -< LedgerModel -< JournalEntryModel -< TransactionModel
`class django_ledger.models.ledger.LedgerModel(` _*args_ , _**kwargs_ `)`
Base LedgerModel from Abstract.
```
exception DoesNotExist
```
```
exception MultipleObjectsReturned
```
- `class django_ledger.models.ledger.LedgerModelAbstract(` _*args_ , _**kwargs_ `)`
Base implementation of the LedgerModel.
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4(). **Type** UUID
**96**
**Chapter 9. Models**
**Django Ledger**
```
name
```
Human-readable name of the LedgerModel. Maximum 150 characters. **Type** str `ledger_xid` A unique user-defined identifier for the LedgerModel. Unique for the Entity Model. **Type** str `entity` The EntityModel associated with the LedgerModel instance. **Type** _EntityModel_ `posted` Determines if the LedgerModel is posted. Defaults to False. Mandatory. **Type** bool `locked` Determines if the LedgerModel is locked. Defaults to False. Mandatory. **Type** bool `hidden` Determines if the LedgerModel is hidden. Defaults to False. Mandatory. **Type** bool `can_hide()` _→_ bool Determines if the LedgerModel can be hidden. **Returns** True if can be hidden, else False. **Return type** bool `can_lock()` _→_ bool Determines if the LedgerModel can be locked. **Returns** True if can be locked, else False. **Return type** bool `can_post()` _→_ bool Determines if the LedgerModel can be marked as posted. **Returns** True if can be posted, else False. **Return type** bool
**9.6. Ledger Model**
**97**
**Django Ledger**
## `can_unhide()` _→_ bool
Determines if the LedgerModel can be un-hidden.
**Returns** True if can be un-hidden, else False.
**Return type** bool
## `can_unlock()` _→_ bool
Determines if the LedgerModel can be un-locked.
**Returns** True if can be un-locked, else False.
**Return type**
bool
## `can_unpost()` _→_ bool
Determines if the LedgerModel can be un-posted.
**Returns** True if can be un-posted, else False.
**Return type**
bool
`get_absolute_url()` _→_ str
Determines the absolute URL of the LedgerModel instance. Results in additional Database query if entity field is not selected in QuerySet.
**Returns** URL as a string.
**Return type**
str
## `get_create_url()` _→_ str
Determines the update URL of the LedgerModel instance. Results in additional Database query if entity field is not selected in QuerySet.
**Returns** URL as a string.
**Return type**
str
## `get_list_url()` _→_ str
Determines the list URL of the LedgerModel instances. Results in additional Database query if entity field is not selected in QuerySet.
**Returns** URL as a string.
**Return type**
str
## `get_update_url()` _→_ str
Determines the update URL of the LedgerModel instance. Results in additional Database query if entity field is not selected in QuerySet.
**98**
**Chapter 9. Models**
**Django Ledger**
**Returns**
URL as a string.
**Return type**
str
`is_hidden()` _→_ bool
Determines if the LedgerModel instance is hidden.
**Returns** True if hidden, else False.
**Return type** bool
`is_locked()` _→_ bool
Determines if the LedgerModel instance is locked.
**Returns** True if locked, else False.
**Return type**
bool
`is_posted()` _→_ bool
Determines if the LedgerModel instance is posted.
**Returns** True if posted, else False.
**Return type**
bool
`lock(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Locks the LedgerModel.
**Parameters**
- • `commit` ( _`bool`_ ) – If True, saves the LedgerModel instance instantly. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises LedgerModelValidationError if locking not allowed.
`post(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
- Posts the LedgerModel.
**Parameters**
- • `commit` ( _`bool`_ ) – If True, saves the LedgerModel instance instantly. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises LedgerModelValidationError if posting not allowed.
`unlock(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
- Un-locks the LedgerModel.
**Parameters**
`commit` ( _`bool`_ ) – If True, saves the LedgerModel instance instantly. Defaults to False.
`unpost(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Un-posts the LedgerModel.
## **Parameters**
- • `commit` ( _`bool`_ ) – If True, saves the LedgerModel instance instantly. Defaults to False.
**9.6. Ledger Model**
**99**
**Django Ledger**
- • `raise_exception` ( _`bool`_ ) – Raises LedgerModelValidationError if un-posting not allowed.
`class django_ledger.models.ledger.LedgerModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined LedgerModelManager that implements custom QuerySet methods related to the LedgerModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ LedgerModelQuerySet_
Returns a QuerySet of LedgerModels associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
**Returns** A Filtered LedgerModelQuerySet.
**Return type** _LedgerModelQuerySet_
`get_queryset()` _→ LedgerModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
`class django_ledger.models.ledger.LedgerModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
Custom QuerySet for filtering LedgerModel instances based on specific fields.
Provides predefined filtering methods to simplify working with ledger data. These filters allow querying for entries that are locked, unlocked, posted, unposted, hidden, visible, or current.
```
locked()
```
Filters instances based on the ‘locked’ attribute set to _True_ .
`unlocked()` Filters instances based on the ‘locked’ attribute set to _False_ .
`posted()` Filters a queryset to include only posted entries with ‘posted’ set to _True_ .
`unposted()` Filters a queryset to include only unposted entries with ‘posted’ set to _False_ .
`hidden()` Filters a queryset to include only items marked as hidden.
`visible()` Filters out hidden items from the queryset.
`current()` Filters the queryset to include items where the earliest timestamp comes after the entity’s last closing date or is null.
`hidden()` _→ LedgerModelQuerySet_ Filters the queryset to include only objects marked as hidden.
**Returns** A filtered queryset containing only objects with the _hidden_ attribute set to True.
**100**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
_LedgerModelQuerySet_
`locked()` _→ LedgerModelQuerySet_
Filters instances based on the ‘locked’ attribute.
This method returns a new instance where the ‘locked’ attribute is set to _True_ .
## **Returns**
A new instance filtered with the attribute ‘locked’ set to _True_ .
**Return type**
_LedgerModelQuerySet_
`posted()` _→ LedgerModelQuerySet_
Filters a queryset to include only posted entries.
## **Returns**
A new queryset instance containing only objects with the _posted_ field set to True.
## **Return type**
_LedgerModelQuerySet_
`unlocked()` _→ LedgerModelQuerySet_
Filters and returns an instance where the _locked_ attribute is set to _False_ .
## **Returns**
A new or modified instance of the object with the filter applied.
**Return type**
_LedgerModelQuerySet_
`unposted()` _→ LedgerModelQuerySet_
Filters a queryset or a similar iterable-like object to include only items that have the attribute _posted_ set to _True_ . This method returns a new instance containing the filtered results.
**Returns**
A new instance containing only the filtered results with _posted_ set to True.
**Return type**
_LedgerModelQuerySet_
`visible()` _→ LedgerModelQuerySet_
Filters out hidden items from the queryset.
Ensures that only items with the _hidden_ attribute set to _False_ are included in the returned queryset.
## **Returns**
A queryset containing only visible items.
## **Return type**
_LedgerModelQuerySet_
`exception django_ledger.models.ledger.LedgerModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.7 Transaction Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
**9.7. Transaction Model**
**101**
**Django Ledger**
The TransactionModel serves as the foundational accounting entity where all financial transactions are recorded. Every transaction must be associated with a JournalEntryModel, which represents a collection of related transactions. This strict association ensures that standalone TransactionModels—or orphan transactions—do not exist, a constraint enforced at the database level.
Each transaction performs either a CREDIT or a DEBIT operation on the designated AccountModel, upholding standard accounting principles. The TransactionModel API integrates the IOMixIn, a critical component for generating financial statements. This mixin facilitates efficient querying and aggregation directly at the database level, eliminating the need to load all TransactionModels into memory. This database-driven approach significantly improves performance and simplifies the process of generating accurate financial reports.
The TransactionModel, together with the IOMixIn, is essential for ensuring seamless, efficient, and reliable financial statement production in the Django Ledger framework.
`class django_ledger.models.transactions.TransactionModel(` _*args_ , _**kwargs_ `)`
Base Transaction Model From Abstract.
## `exception DoesNotExist`
## `exception MultipleObjectsReturned`
`class django_ledger.models.transactions.TransactionModelAbstract(` _*args_ , _**kwargs_ `)`
Abstract base model class for representing financial transactions in a ledger system.
This class defines the structure and behavior of transactions in a generic ledger system, including attributes such as transaction type, associated account, amount, description, and status flags for cleared and reconciled state. It also includes methods and properties to facilitate queries and determine transaction type.
```
uuid
```
Unique identifier of the transaction.
**Type** UUID
```
tx_type
```
Type of the transaction, either ‘credit’ or ‘debit’.
**Type** str
```
journal_entry
```
Reference to the associated JournalEntryModel instance for this transaction.
**Type** ForeignKey
`account` Reference to the associated account in the Chart of Accounts.
**Type** ForeignKey
## `amount`
Monetary amount for the transaction. Must be a non-negative value.
**Type** Decimal
## `description`
Description of the transaction.
**102**
**Chapter 9. Models**
**Django Ledger**
**Type** str, optional
```
cleared
```
Indicates if the transaction has been cleared. Defaults to False.
**Type**
bool
```
reconciled
```
Indicates if the transaction has been reconciled. Defaults to False.
**Type**
bool
## `objects`
Custom manager for managing transaction models.
**Type**
_TransactionModelManager_
```
property coa_id
```
Returns the Chart of Accounts (COA) ID associated with the current object.
The property attempts to retrieve the COA ID value stored internally, if it exists. If the internal value is not set and the _account_ attribute is not _None_ , the COA ID is obtained from the _account.coa_model_id_ attribute. Otherwise, it will return _None_ .
**Returns** The COA ID if it exists, otherwise _None_ .
**Return type**
Any or None
`is_credit()` _→_ bool
Check if the transaction is of type ‘credit’.
This method evaluates whether the transaction type of the current instance matches the ‘credit’ transaction type.
**Returns** True if the transaction type is ‘credit’, False otherwise.
**Return type**
bool
`is_debit()` _→_ bool
Determines if the transaction type is a debit.
This method checks whether the transaction type of the current instance is set to a debit type.
**Returns**
True if the transaction type is debit, otherwise False.
**Return type**
bool
`class django_ledger.models.transactions.TransactionModelManager(` _*args_ , _**kwargs_ `)`
A custom manager for _TransactionModel_ designed to add helper methods for querying and filtering _TransactionModel_ objects efficiently based on use cases like user permissions, associated entities, ledgers, journal entries, and more.
**9.7. Transaction Model**
**103**
**Django Ledger**
This manager leverages _TransactionModelQuerySet_ for complex query construction and integrates advanced filtering options based on user roles, entities, and other relationships.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ TransactionModelQuerySet_
Filters transactions for a specific entity, optionally scoped to a specific user.
**Parameters**
`entity_model` ( _`Union[`_ `EntityModel` _`, str, UUID]`_ ) – Identifier for the entity. This can be an _EntityModel_ object, a slug (str), or a UUID.
**Returns**
A queryset containing transactions associated with the specified entity.
**Return type** _TransactionModelQuerySet_
**Notes**
• If _user_model_ is provided, only transactions accessible by the user are included.
• Supports flexible filtering by accepting different forms of _entity_slug_ .
`get_queryset()` _→ TransactionModelQuerySet_
Retrieves the base queryset for _TransactionModel_ , annotated and pre-loaded with commonly used related fields.
**Returns**
A custom queryset with essential annotations and relationships preloaded.
**Return type** _TransactionModelQuerySet_
## `class django_ledger.models.transactions.TransactionModelQuerySet(` _model=None_ , _query=None_ ,
_using=None_ , _hints=None_ `)`
A custom QuerySet class tailored for _TransactionModel_ objects. It includes a collection of methods to efficiently and safely retrieve and filter transactions from the database based on common use cases.
`for_accounts(` _account_list: List[_ AccountModel _| str | UUID]_ `)` _→ TransactionModelQuerySet_
Filters transactions based on the accounts they are associated with.
**Parameters**
`account_list` ( _`list of str or`_ `AccountModel` ) – A list containing account codes (strings) or _AccountModel_ instances. Transactions will be filtered to match these accounts.
**Returns** A QuerySet filtered for transactions associated with the specified accounts.
**Return type**
_TransactionModelQuerySet_
`for_activity(` _activity_list: str | List[str] | Set[str]_ `)` _→ TransactionModelQuerySet_
Filters transactions based on their associated activity or activities.
**Parameters** `activity_list` ( _`str or list of str`_ ) – A single activity or a list of activities to filter transactions by.
**Returns**
A QuerySet filtered for transactions linked to the specified activity or activities.
**104**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
_TransactionModelQuerySet_
`for_bill(` _bill_model:_ BillModel _| str | UUID_ `)` _→ TransactionModelQuerySet_
Filters transactions for a specific bill under a given entity.
**Parameters**
`bill_model` ( _`Union[`_ `BillModel` _`, str, UUID]`_ ) – The bill model or its UUID to filter by.
**Returns**
A queryset containing transactions related to the specified bill.
**Return type**
_TransactionModelQuerySet_
`for_invoice(` _invoice_model:_ InvoiceModel _| str | UUID_ `)` _→ TransactionModelQuerySet_
Filters transactions for a specific invoice under a given entity.
**Parameters** `invoice_model` ( _`Union[`_ `InvoiceModel` _`, str, UUID]`_ ) – The invoice model or its UUID to filter by.
**Returns**
A queryset containing transactions related to the specified invoice.
**Return type**
_TransactionModelQuerySet_
`for_journal_entry(` _je_model_ `)` _→ TransactionModelQuerySet_
Filters transactions for a specific journal entry under a given ledger and entity.
**Parameters** `je_model` ( _`Union[`_ `JournalEntryModel` _`, UUID]`_ ) – The journal entry model or its UUID to filter by.
**Returns**
A queryset containing transactions associated with the given journal entry.
**Return type**
_TransactionModelQuerySet_
`for_ledger(` _ledger_model:_ LedgerModel _| UUID | str_ `)` _→ TransactionModelQuerySet_
Filters transactions for a specific ledger under a given entity.
**Parameters** `ledger_model` ( _`Union[`_ `LedgerModel` _`, UUID]`_ ) – The ledger model or its UUID to filter by.
**Returns**
A queryset containing transactions associated with the given ledger and entity.
**Return type**
_TransactionModelQuerySet_
`for_roles(` _role_list: str | List[str] | Set[str]_ `)` _→ TransactionModelQuerySet_
Fetches a QuerySet of TransactionModels which AccountModel has a specific role.
**Parameters**
`role_list` ( _`str or list`_ ) – A string or list of strings representing the roles to be used as filter.
**9.7. Transaction Model**
**105**
**Django Ledger**
**Returns**
Returns a TransactionModelQuerySet with applied filters.
**Return type**
_TransactionModelQuerySet_
`for_unit(` _unit_slug: str |_ EntityUnitModel `)` _→ TransactionModelQuerySet_
Filters transactions based on their associated entity unit.
**Parameters**
`unit_slug` ( _`str or`_ `EntityUnitModel` ) – A string representing the slug of the entity unit or an _EntityUnitModel_ instance.
**Returns**
A QuerySet filtered for transactions linked to the specified unit.
**Return type**
_TransactionModelQuerySet_
`for_user(` _user_model_ `)` _→ TransactionModelQuerySet_
Filters transactions accessible to a specific user based on their permissions.
**Parameters**
`user_model` ( _`UserModel`_ ) – The user object for which the transactions should be filtered.
**Returns**
- • _TransactionModelQuerySet_ – A queryset containing transactions filtered by the user’s access level.
- • _Description_
- • _———–_
- • **–** Returns all _TransactionModel_ objects for superusers.
- • _- For regular users, it filters transactions where_ –
- **–** The user is an admin of the entity associated with the ledger in the transaction.
- **–** The user is a manager of the entity associated with the ledger in the transaction.
`from_date(` _from_date: str | date | datetime_ `)` _→ TransactionModelQuerySet_
Filters transactions occurring on or after a specific date or timestamp.
If _from_date_ is a naive datetime (no timezone), it is assumed to be in local time based on Django settings.
**Parameters**
`from_date` ( _`str, date, or datetime`_ ) – The minimum date or timestamp for filtering. When using a date (not datetime), the filter is inclusive (e.g., “2022-12-20” includes all transactions from that day).
## **Returns**
A QuerySet filtered to include transactions from the specified date or timestamp onwards.
**Return type**
_TransactionModelQuerySet_
`is_closing_entry()` _→ TransactionModelQuerySet_
Filters transactions that are part of a closing journal entry.
**Returns**
A QuerySet with transactions where the _journal_entry__is_closing_entry_ field is True.
**106**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
_TransactionModelQuerySet_
`not_closing_entry()` _→ TransactionModelQuerySet_
Filters transactions that are _not_ part of a closing journal entry.
**Returns**
A QuerySet with transactions where the _journal_entry__is_closing_entry_ field is False.
## **Return type**
_TransactionModelQuerySet_
`posted()` _→ TransactionModelQuerySet_
Retrieves transactions that are part of a posted journal entry and ledger.
A transaction is considered “posted” if: - It belongs to a journal entry marked as _posted_ . - Its associated journal entry is part of a ledger marked as _posted_ .
## **Returns**
A QuerySet containing only transactions that meet the “posted” criteria.
**Return type**
_TransactionModelQuerySet_
`to_date(` _to_date: str | date | datetime_ `)` _→ TransactionModelQuerySet_
Filters transactions occurring on or before a specific date or timestamp.
If _to_date_ is a naive datetime (no timezone), it is assumed to be in local time based on Django settings.
**Parameters**
`to_date` ( _`str, date, or datetime`_ ) – The maximum date or timestamp for filtering. When using a date (not datetime), the filter is inclusive (e.g., “2022-12-20” includes all transactions from that day).
## **Returns**
A QuerySet filtered to include transactions up to the specified date or timestamp.
## **Return type**
_TransactionModelQuerySet_
`exception django_ledger.models.transactions.TransactionModelValidationError(` _message_ ,
_code=None_ , _params=None_ `)`
`django_ledger.models.transactions.transactionmodel_presave(` _instance:_ TransactionModel,
_**kwargs_ `)`
Pre-save validation for the TransactionModel instance.
This function is executed before saving a _TransactionModel_ instance, ensuring that certain conditions are met to maintain data integrity.
The function performs the following validations: 1. **Account Transactionality** :
If the _bypass_account_state_ flag is not provided or set to _False_ , it verifies whether the associated account can process transactions by calling _instance.account.can_transact()_ . If the account cannot process transactions, the save operation is interrupted to prevent invalid data.
1. 2. **Journal Entry Lock** : If the associated journal entry ( _instance.journal_entry_ ) is locked, the transaction cannot be modified. The save process is halted if the journal entry is marked as locked.
## **Parameters**
**9.7. Transaction Model**
**107**
**Django Ledger**
- • `instance` ( `TransactionModel` ) – The _TransactionModel_ instance that is about to be saved.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments, such as the optional _bypass_account_state_ .
## **Raises**
_`TransactionModelValidationError`_ – Raised in the following scenarios: - **Account Transactionality Failure** : When _bypass_account_state_ is _False_ or not provided, and the associated account ( _instance.account_ ) cannot process transactions. The exception contains a message identifying the account.
- **Locked Journal Entry** : When the associated journal entry ( _instance.journal_entry_ ) is locked, preventing modification of any related transactions. The error message describes the locked journal entry constraint.
## **9.8 Journal Entry Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
A Journal Entry (JE) is the foundation of all double entry accounting and financial data of any EntityModel. A JE encapsulates a collection of TransactionModel, which must contain two transactions at a minimum. Each transaction must perform a DEBIT or a CREDIT to an AccountModel. The JE Model performs additional validation to make sure that the sum of all DEBITs and the sum of all CREDITs are equal to keep the books balanced.
A JE by default will be un-posted, which means that simply creating a JE will have no effect on the EntityModel books. This behavior allows for constant refinement and persistence of JEs in the database without any impact on the books. Only Journal Entries contained within a _POSTED_ LedgerModel (see LedgerModel for documentation) will have an impact in the EntityModel finances.
The JournalEntryModel also carries an optional EntityUnitModel, which are logical user-defined labels which help segregate the different financial statements into different business operations (see EntityUnitModel for documentation). Examples of EntityModelUnits are offices, departments, divisions, etc. _The user may request financial statements by unit_ .
All JEs automatically generate a sequential Journal Entry Number, which takes into consideration the Fiscal Year of the JournalEntryModel instance. This functionality enables a human-readable tracking mechanism which helps with audits. It is also searchable and indexed to support quick searches and queries.
The JournalEntryModel is also responsible for validating the Financial Activity involved in the operations of the business. Whenever an account with ASSET_CA_CASH role is involved in a Journal Entry (see roles for more details), the JE is responsible for programmatically determine the kind of operation for the JE (Operating, Financing, Investing).
- `class django_ledger.models.journal_entry.ActivityEnum(` _*values_ `)`
- Represents the database prefixes used for different types of accounting activities.
```
OPERATING
```
Prefix for a Journal Entry categorized as an Operating Activity.
**Type** str
```
INVESTING
```
Prefix for a Journal Entry categorized as an Investing Activity.
**Type**
str
## `FINANCING`
Prefix for a Journal Entry categorized as a Financing Activity.
**108**
**Chapter 9. Models**
**Django Ledger**
## **Type**
str
`class django_ledger.models.journal_entry.JournalEntryModel(` _*args_ , _**kwargs_ `)`
- Journal Entry Model Base Class From Abstract
## `exception DoesNotExist`
## `exception MultipleObjectsReturned`
- `class django_ledger.models.journal_entry.JournalEntryModelAbstract(` _*args_ , _**kwargs_ `)`
Abstract base model for handling journal entries in the bookkeeping system.
```
uuid
```
A unique identifier (primary key) for the journal entry, generated using uuid4().
**Type** UUID
## `je_number`
A human-readable, unique, alphanumeric identifier for the journal entry (e.g., Voucher or Document Number). Includes the fiscal year as a prefix for organizational purposes.
**Type**
str
## `timestamp`
The date of the journal entry, used for financial statements. This timestamp applies to associated transactions.
**Type** datetime
## `description`
An optional user-defined description for the journal entry.
**Type** str
## `entity_unit`
A reference to a logical and self-contained structure within the _EntityModel_ . Provides context for the journal entry. See _EntityUnitModel_ documentation for details.
**Type** _EntityUnitModel_
## `activity`
Indicates the nature of the activity associated with the journal entry. Must be one of the predefined _ACTIVITIES_ (e.g., Operating, Financing, Investing) and is programmatically determined.
**Type** str
## `origin`
Describes the origin or trigger for the journal entry (e.g., reconciliations, migrations, auto-generated). Max length: 30 characters.
**Type** str
**9.8. Journal Entry Model**
**109**
**Django Ledger**
## `posted`
Determines whether the journal entry has been posted (affecting the books). Defaults to _False_ .
**Type** bool
```
locked
```
Indicates whether the journal entry is locked, preventing further modifications. Defaults to _False_ .
**Type** bool
```
ledger
```
A reference to the LedgerModel associated with this journal entry. This field is mandatory.
**Type**
_LedgerModel_
```
is_closing_entry
```
Indicates if the journal entry is a closing entry. Defaults to _False_ .
**Type**
bool
`can_delete()` _→_ bool
Checks if the journal entry can be deleted.
`can_edit()` _→_ bool
Checks if the journal entry is editable.
`can_generate_je_number()` _→_ bool
Checks if a Journal Entry Number can be generated.
**Returns**
True if the Journal Entry can generate a JE number, otherwise False.
**Return type**
bool
- `can_lock()` _→_ bool
Determines if the journal entry can be locked.
`can_post(` _ignore_verify: bool = True_ `)` _→_ bool
Determines if the journal entry can be posted.
`can_unlock()` _→_ bool
Checks if the journal entry can be unlocked.
- `can_unpost()` _→_ bool
Checks if the journal entry can be un-posted.
`clean(` _verify: bool = False_ , _raise_exception: bool = True_ , _txs_qs:_ TransactionModelQuerySet _| None = None_ `)` _→_ Tuple[ _TransactionModelQuerySet_ , bool]
Cleans the JournalEntryModel instance, optionally verifying it and generating a Journal Entry (JE) number if required.
**Parameters**
- • `verify` ( _`bool, optional`_ ) – If True, attempts to verify the JournalEntryModel during the cleaning process. Default is False.
**110**
**Chapter 9. Models**
**Django Ledger**
- • `raise_exception` ( _`bool, optional`_ ) – If True, raises an exception when the instance fails verification. Default is True.
- • `txs_qs` ( `TransactionModelQuerySet` _`, optional`_ ) – A pre-fetched TransactionModelQuerySet. If provided, avoids additional database queries. The provided queryset is validated against the JournalEntryModel instance.
**Returns**
A tuple containing: - The validated TransactionModelQuerySet for the JournalEntryModel instance. - A boolean indicating whether the instance passed verification.
**Return type** Tuple[ _TransactionModelQuerySet_ , bool]
**Raises** _`JournalEntryValidationError`_ – If the instance has a timestamp in the future and is posted, or if verification fails and _raise_exception_ is True.
`delete(` _**kwargs_ `)`
Deletes the JournalEntryModel instance, ensuring it is allowed to be deleted.
**Parameters** `**kwargs` ( _`dict`_ ) – Additional arguments passed to the parent delete method.
**Raises**
_`JournalEntryValidationError`_ – If the instance is not eligible for deletion.
```
property entity_last_closing_date:
```
```
date | None
```
Retrieves the last closing date for an entity, if available.
This property returns the date of the most recent closing event associated with the entity. If no closing date exists, the result will be None.
**Returns**
The date of the last closing event, or None if no closing date is available.
**Return type** Optional[date]
```
property entity_model:
```
```
EntityModel
```
Provides access to the _EntityModel_ related to the JournalEntryModel.
**Returns**
The _EntityModel_ instance linked to the instance LedgerModel.
**Return type** _EntityModel_
```
property entity_slug
```
Retrieves the unique slug associated with the entity.
The property first attempts to return the value stored in the __entity_slug_ attribute if it exists. If __entity_slug_ is not set, it falls back to the _ledger.entity.slug_ attribute.
**Returns**
The slug value from __entity_slug_ if available, or _ledger.entity.slug_ otherwise.
**Return type** str
**9.8. Journal Entry Model**
**111**
**Django Ledger**
`generate_activity(` _txs_qs:_ TransactionModelQuerySet _| None = None_ , _raise_exception: bool = True_ , _force_update: bool = False_ `)` _→_ str | None
Generates the activity for the Journal Entry model based on its transactions.
**Parameters**
- • `txs_qs` ( _`Optional[`_ `TransactionModelQuerySet` _`], default None`_ ) – Queryset of TransactionModel instances for validation. If None, transactions are queried.
- • `raise_exception` ( _`bool, default True`_ ) – Determines whether exceptions are raised during processing.
- • `force_update` ( _`bool, default False`_ ) – Forces the regeneration of activity even if it exists.
**Returns** Generated activity or None if not applicable.
**Return type** Optional[str]
`generate_je_number(` _commit: bool = False_ `)` _→_ str
Generates the Journal Entry number in an atomic transaction.
**Parameters** `commit` ( _`bool, default False`_ ) – Saves the generated JE number in the database.
**Returns** The generated or existing JE number.
**Return type** str
`get_absolute_url()` _→_ str
Generates the URL to view the details of the journal entry.
**Returns**
The absolute URL for the journal entry details.
**Return type** str
`get_action_lock_url()` _→_ str
Generates the URL used to mark the journal entry as locked.
**Returns** The generated URL for marking the journal entry as locked.
**Return type** str
`get_action_post_url()` _→_ str Generates the URL used to mark the journal entry as posted.
**Returns** The generated URL for marking the journal entry as posted.
**Return type** str
## `get_action_unlock_url()` _→_ str
Generates the URL used to mark the journal entry as unlocked.
**112**
**Chapter 9. Models**
**Django Ledger**
**Returns**
The generated URL for marking the journal entry as unlocked.
**Return type** str
`get_action_unpost_url()` _→_ str
Generates the URL used to mark the journal entry as unposted.
**Returns**
The generated URL for marking the journal entry as unposted.
**Return type**
str
`classmethod get_activity_from_roles(` _role_set: List[str] | Set[str]_ , _validate: bool = False_ , _raise_exception: bool = True_ `)` _→_ str | None
Determines the financial activity type (e.g., operating, investing, financing) based on a set of account roles.
**Parameters**
- • `role_set` ( _`Union[List[str], Set[str]]`_ ) – The set of roles to analyze.
- • `validate` ( _`bool, optional`_ ) – If True, validates the roles before analysis. Defaults to False.
- • `raise_exception` ( _`bool, optional`_ ) – If True, raises an exception if multiple activities are detected. Defaults to True.
**Returns**
The detected activity name, or None if no activity type is matched.
**Return type** Optional[str]
**Raises** _`JournalEntryValidationError`_ – If multiple activities are detected and _raise_exception_ is True.
`get_activity_name()` _→_ str | None
Gets the name of the activity associated with this journal entry.
The activity indicates its categorization based on GAAP (e.g., operating, investing, financing).
**Returns** The activity name if defined, otherwise None.
**Return type** Optional[str]
`get_delete_message()` _→_ str
Generates a confirmation message for deleting the JournalEntryModel instance.
**Returns**
A confirmation message including the Journal Entry number and Ledger name.
**Return type**
str
`get_detail_txs_url()` _→_ str
Generates the URL to view transaction details of the journal entry.
**9.8. Journal Entry Model**
**113**
**Django Ledger**
**Returns**
The URL for transaction details of the journal entry.
**Return type** str
`get_detail_url()` _→_ str
Generates the detail URL for the journal entry.
**Returns** The URL for updating or viewing journal entry details.
**Return type** str
`get_entity_last_closing_date()` _→_ date | None
Retrieves the last closing date for the entity associated with the Journal Entry.
**Returns** The last closing date if one exists, otherwise None.
**Return type** Optional[date]
`get_entity_unit_name(` _no_unit_name: str = ''_ `)` _→_ str Retrieves the name of the entity unit associated with the Journal Entry.
**Parameters** `no_unit_name` ( _`str`_ ) – The fallback name to return if no unit is associated. **Returns** The name of the entity unit, or the fallback provided.
**Return type** str
`get_journal_entry_create_url()` _→_ str
Constructs the URL to create a new journal entry associated with a specific ledger and entity.
**Returns** The URL to create a journal entry. **Return type** str
`get_journal_entry_list_url()` _→_ str
Constructs the URL to access the list of journal entries associated with a specific ledger and entity.
**Returns** The URL for the journal entry list. **Return type** str `get_lock_url()` _→_ str Generates the URL to mark the journal entry as locked. **Returns** The URL for locking the journal entry. **Return type** str
**114**
**Chapter 9. Models**
**Django Ledger**
`get_post_url()` _→_ str
Generates the URL to mark the journal entry as posted.
**Returns** The URL for posting the journal entry.
**Return type** str
`get_transaction_queryset(` _select_accounts: bool = True_ `)` _→ TransactionModelQuerySet_
Retrieves the _TransactionModelQuerySet_ associated with this _JournalEntryModel_ instance.
**Parameters** `select_accounts` ( _`bool, optional`_ ) – If True, prefetches the related _AccountModel_ for each transaction. Defaults to True.
**Returns** A queryset containing transactions related to this journal entry. If _select_accounts_ is True, the accounts are included in the query as well.
**Return type**
_TransactionModelQuerySet_
`get_txs_balances(` _txs_qs:_ TransactionModelQuerySet _| None = None_ , _as_dict: bool = False_ `)` _→ TransactionModelQuerySet_ | Dict[str, Decimal]
Calculates the total CREDIT and DEBIT balances for the journal entry.
This method performs an aggregate database query to compute the sum of CREDITs and DEBITs across the transactions related to this journal entry. Optionally, a pre-fetched _TransactionModelQuerySet_ can be supplied for efficiency. Validation is performed to ensure that all transactions belong to this journal entry.
**Parameters**
- • `txs_qs` ( `TransactionModelQuerySet` _`, optional`_ ) – A pre-fetched queryset of transactions. If None, the queryset is fetched automatically.
- • `as_dict` ( _`bool, optional`_ ) – If True, returns the results as a dictionary with keys “credit” and “debit”. Defaults to False.
## **Returns**
If _as_dict_ is False, returns a queryset of aggregated balances. If _as_dict_ is True, returns a dictionary containing the CREDIT and DEBIT totals.
**Return type**
Union[ _TransactionModelQuerySet_ , Dict[str, Decimal]]
**Raises** _`JournalEntryValidationError`_ – If the provided queryset is invalid or does not belong to this journal entry.
`get_txs_roles(` _txs_qs:_ TransactionModelQuerySet _| None = None_ , _exclude_cash_role: bool = False_ `)` _→_ Set[str]
Retrieves the set of account roles involved in the journal entry’s transactions.
This method extracts the roles associated with the accounts linked to each transaction. Optionally, the CASH role can be excluded from the results.
**Parameters**
- • `txs_qs` ( `TransactionModelQuerySet` _`, optional`_ ) – A pre-fetched queryset of trans-
> actions. If None, the queryset is fetched automatically.
**9.8. Journal Entry Model**
**115**
**Django Ledger**
- • `exclude_cash_role` ( _`bool, optional`_ ) – If True, excludes the CASH role from the result. Defaults to False.
**Returns**
A set of account roles associated with this journal entry’s transactions.
**Return type** Set[str]
`get_unlock_url()` _→_ str
Generates the URL to mark the journal entry as unlocked.
**Returns** The URL for unlocking the journal entry. **Return type** str
`get_unpost_url()` _→_ str Generates the URL to mark the journal entry as unposted.
**Returns** The URL for unposting the journal entry. **Return type** str
`has_activity()` _→_ bool
Checks if the journal entry has an associated activity.
**Returns** True if an activity is defined for the journal entry, otherwise False. **Return type** bool
`is_balance_valid(` _txs_qs:_ TransactionModelQuerySet, _raise_exception: bool = True_ `)` _→_ bool Validates whether the DEBITs and CREDITs of the transactions balance correctly.
**Parameters** • `txs_qs` ( `TransactionModelQuerySet` ) – A QuerySet containing transactions to validate. • `raise_exception` ( _`bool`_ ) – Whether to raise a JournalEntryValidationError if the validation fails. **Returns** True if the transactions are balanced, otherwise False. **Return type** bool **Raises** _`JournalEntryValidationError`_ – If the transactions are not balanced and raise_exception is True.
`is_cash_involved(` _txs_qs:_ TransactionModelQuerySet _| None = None_ `)` _→_ bool
Checks if the transactions involve cash assets.
**Parameters**
`txs_qs` ( _`Optional[`_ `TransactionModelQuerySet` _`]`_ ) – Transactions to evaluate. If None, defaults to class behavior.
**116**
**Chapter 9. Models**
**Django Ledger**
**Returns** True if cash assets are involved, otherwise False. **Return type** bool
`is_financing()` _→_ bool
Checks if the Journal Entry is categorized as a financing activity.
**Returns** True if the activity is financing, otherwise False.
**Return type** bool
`is_in_locked_period(` _new_timestamp: datetime | date | None = None_ `)` _→_ bool
Checks if the current Journal Entry falls within a locked period.
**Parameters** `new_timestamp` ( _`Optional[Union[date, datetime]])`_ ) – An optional date or timestamp to be checked instead of the current timestamp.
**Returns bool**
**Return type** True if the Journal Entry is in a locked period, otherwise False.
`is_investing()` _→_ bool Checks if the Journal Entry is categorized as an investing activity.
**Returns** True if the activity is investing, otherwise False.
**Return type** bool
`is_locked()` _→_ bool
Determines if the Journal Entry is locked.
A Journal Entry is considered locked if it is posted, explicitly marked as locked, falls within a locked period, or the associated ledger is locked.
**Returns** True if the Journal Entry is locked, otherwise False. **Return type** bool
`is_operating()` _→_ bool
Checks if the Journal Entry is categorized as an operating activity.
**Returns** True if the activity is operating, otherwise False. **Return type** bool
`is_posted()` _→_ bool
Returns whether the journal entry has been posted.
**9.8. Journal Entry Model**
**117**
**Django Ledger**
`is_txs_qs_coa_valid(` _txs_qs:_ TransactionModelQuerySet, _raise_exception: bool = True_ `)` _→_ bool
Validates that all transactions in the QuerySet are associated with the same Chart of Accounts (COA).
**Parameters**
`txs_qs` ( `TransactionModelQuerySet` ) – A QuerySet containing transactions to validate.
**Returns**
True if all transactions have the same Chart of Accounts, otherwise False.
**Return type** bool
`is_txs_qs_valid(` _txs_qs:_ TransactionModelQuerySet, _raise_exception: bool = True_ `)` _→_ bool
Validates whether the given Transaction QuerySet belongs to the current Journal Entry.
**Parameters**
- • `txs_qs` ( `TransactionModelQuerySet` ) – A QuerySet containing transactions to validate.
- • `raise_exception` ( _`bool`_ ) – Whether to raise a JournalEntryValidationError if the validation fails.
**Returns**
True if all transactions belong to the Journal Entry, otherwise False.
**Return type**
bool
**Raises**
_`JournalEntryValidationError`_ – If validation fails and raise_exception is True.
`is_verified()` _→_ bool
Checks if the Journal Entry is verified.
**Returns**
True if the Journal Entry is verified, otherwise False.
**Return type**
bool
```
ledger_is_locked()
```
Determines whether the ledger is locked.
This method checks the current state of the ledger to determine if it is locked and unavailable for further operations. It looks for an annotated attribute __ledger_is_locked_ and returns its value if found. If the attribute is not set, it delegates the check to the actual _is_locked_ method of the _ledger_ object.
**Returns**
A boolean value indicating whether the ledger is locked.
**Return type**
bool
`lock(` _**kwargs_ `)`
Proxy function for _mark_as_locked_ method.
`mark_as_locked(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Locked JournalEntryModels do not allow transactions to be edited.
**Parameters**
• `commit` ( _`bool`_ ) – Commits changes into the Database, Defaults to False.
**118**
**Chapter 9. Models**
**Django Ledger**
- • `raise_exception` ( _`bool`_ ) – Raises JournalEntryValidationError if cannot lock. Defaults to False.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments.
- `mark_as_posted(` _commit: bool = False_ , _verify: bool = True_ , _force_lock: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Posted transactions show on the EntityModel ledger and financial statements. :param commit: Commits changes into the Database, Defaults to False. :type commit: bool :param verify: Verifies JournalEntryModel before marking as posted. Defaults to False. :type verify: bool :param force_lock: Forces to lock the JournalEntry before is posted. :type force_lock: bool :param raise_exception: Raises JournalEntryValidationError if cannot post. Defaults to False. :type raise_exception: bool :param kwargs: Additional keyword arguments. :type kwargs: dict
`mark_as_unlocked(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Unlocked JournalEntryModels allow transactions to be edited.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits changes into the Database, Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises JournalEntryValidationError if cannot lock. Defaults to False.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments.
`mark_as_unposted(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
- Un-posted JournalEntryModels do not show on the EntityModel ledger and financial statements.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits changes into the Database, Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises JournalEntryValidationError if cannot post. Defaults to False.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments.
`post(` _**kwargs_ `)`
Proxy function for _mark_as_posted_ method.
`save(` _verify: bool = True_ , _post_on_verify: bool = False_ , _*args_ , _**kwargs_ `)`
Saves the JournalEntryModel instance, with optional verification and posting prior to saving.
**Parameters**
- • `verify` ( _`bool, optional`_ ) – If True, verifies the transactions of the JournalEntryModel before saving. Default is True.
- • `post_on_verify` ( _`bool, optional`_ ) – If True, posts the JournalEntryModel if verification is successful and _can_post()_ is True. Default is False.
**Returns**
The saved JournalEntryModel instance.
**Return type**
_JournalEntryModel_
**Raises** _`JournalEntryValidationError`_ – If the instance fails verification or encounters an issue during save.
**9.8. Journal Entry Model**
**119**
**Django Ledger**
## `unlock(` _**kwargs_ `)`
Proxy function for _mark_as_unlocked_ method.
## `unpost(` _**kwargs_ `)`
Proxy function for _mark_as_unposted_ method.
- `validate_for_entity(` _entity_model:_ EntityModel _| str | UUID_ , _raise_exception: bool = True_ `)` _→_ bool Validates whether the given entity_model owns thr Journal Entry instance.
This method checks if the provided entity_model owns the Journal Entry model instance. The entity_model can be of type _EntityModel_ , _str_ , or _UUID_ . The method performs type-specific checks to ensure proper validation and returns the validation result.
**Parameters**
`entity_model` ( _`Union[`_ `EntityModel` _`, str, UUID]`_ ) – The entity to validate against. It can either be an instance of the _EntityModel_ , a string representation of a UUID, or a UUID object.
**Returns**
A boolean value. True if the given entity_model corresponds to the current entity’s UUID, otherwise False.
## **Return type**
bool
- `verify(` _txs_qs:_ TransactionModelQuerySet _| None = None_ , _force_verify: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)` _→_ Tuple[ _TransactionModelQuerySet_ , bool]
Verifies the validity of the Journal Entry model instance.
**Parameters**
- • `txs_qs` ( _`Optional[`_ `TransactionModelQuerySet` _`], default None`_ ) – Queryset of TransactionModel instances to validate. If None, transactions are queried.
- • `force_verify` ( _`bool, default False`_ ) – Forces re-verification even if already verified.
- • `raise_exception` ( _`bool, default True`_ ) – Determines if exceptions are raised on validation failure.
- • `kwargs` ( _`dict`_ ) – Additional options.
## **Returns**
• The TransactionModelQuerySet associated with the JournalEntryModel.
• A boolean indicating whether verification was successful.
## **Return type**
Tuple[ _TransactionModelQuerySet_ , bool]
- `class django_ledger.models.journal_entry.JournalEntryModelManager(` _*args_ , _**kwargs_ `)`
A custom manager for the JournalEntryModel that extends Django’s default Manager with additional query features. It allows complex query handling based on relationships to the _EntityModel_ and the authenticated _UserModel_ .
This manager provides utility methods for generating filtered querysets (e.g., entries associated with specific users or entities), as well as annotations for convenience in query results.
- `for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ JournalEntryModelQuerySet_
- Filters the JournalEntryModel queryset for a specific entity and user.
This method provides a way to fetch journal entries related to a specific _EntityModel_ , identified by its slug or model instance, with additional filtering scoped to the user.
**120**
**Chapter 9. Models**
**Django Ledger**
## **Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The slug of the entity (or an instance of _EntityModel_ ) used for filtering.
## **Returns**
A customized queryset containing journal entries associated with the given entity and restricted by the user’s access permissions.
## **Return type**
_JournalEntryModelQuerySet_
`get_queryset()` _→ JournalEntryModelQuerySet_
Returns the default queryset for JournalEntryModel with additional annotations applied.
Annotations: - __entity_slug_ : The slug of the related _EntityModel_ . - _txs_count_ : The count of transactions (related _TransactionModel_ instances)
for each journal entry.
## **Returns**
A custom queryset enhanced with annotations.
## **Return type**
_JournalEntryModelQuerySet_
`class django_ledger.models.journal_entry.JournalEntryModelQuerySet(` _model=None_ , _query=None_ ,
_using=None_ , _hints=None_ `)`
A custom QuerySet for working with Journal Entry models, providing additional convenience methods and validations for specific use cases.
This class enhances Django’s default QuerySet by adding tailored methods to manage and filter Journal Entries, such as handling posted, unposted, locked entries, and querying entries associated with specific ledgers.
- `create(` _verify_on_save: bool = False_ , _force_create: bool = False_ , _**kwargs_ `)` _→_
- _JournalEntryModelQuerySet_
Creates a new Journal Entry while enforcing business logic validations.
This method overrides Django’s default _create()_ to ensure that Journal Entries cannot be created in a “posted” state unless explicitly overridden. Additionally, it offers optional pre-save verification.
## **Parameters**
- • `verify_on_save` ( _`bool`_ ) – If True, performs a verification step before saving. This avoids additional database queries for validation when creating new entries. Should be used when the Journal Entry needs no transactional validation.
- • `force_create` ( _`bool`_ ) – If True, allows the creation of a Journal Entry even in a “posted” state. Use with caution and only if you are certain of the consequences.
- • `**kwargs` ( _`dict`_ ) – Additional keyword arguments passed to instantiate the Journal Entry model.
## **Returns**
The newly created Journal Entry.
## **Return type**
_JournalEntryModel_
## **Raises**
`FieldError` – Raised if attempting to create a “posted” Journal Entry without setting _force_create=True_ .
**9.8. Journal Entry Model**
**121**
**Django Ledger**
`for_ledger(` _ledger_pk: str | UUID |_ LedgerModel `)` _→ JournalEntryModelQuerySet_
Filters the QuerySet to include Journal Entries associated with a specific Ledger.
**Parameters**
`ledger_pk` ( _`str, UUID, or`_ `LedgerModel` ) – The LedgerModel instance, its UUID, or a string representation of the UUID to identify the Ledger.
## **Returns**
A filtered QuerySet of Journal Entries associated with the specified Ledger.
**Return type**
_JournalEntryModelQuerySet_
`for_user(` _user_model_ `)` _→ JournalEntryModelQuerySet_
Filters the JournalEntryModel queryset for the given user.
• Superusers will have access to all journal entries.
• Other authenticated users will only see entries for entities where they are admins or managers.
**Parameters**
`user_model` ( _`UserModel`_ ) – An authenticated Django user object.
## **Returns**
A filtered queryset restricted by the user’s entity relationships.
## **Return type**
_JournalEntryModelQuerySet_
`locked()` _→ JournalEntryModelQuerySet_
Filters the QuerySet to include only “locked” Journal Entries.
## **Returns**
A filtered QuerySet containing only locked Journal Entries.
## **Return type**
_JournalEntryModelQuerySet_
`posted()` _→ JournalEntryModelQuerySet_
Filters the QuerySet to include only “posted” Journal Entries.
## **Returns**
A filtered QuerySet containing only posted Journal Entries.
## **Return type**
_JournalEntryModelQuerySet_
`unlocked()` _→ JournalEntryModelQuerySet_
Filters the QuerySet to include only “unlocked” Journal Entries.
## **Returns**
A filtered QuerySet containing only unlocked Journal Entries.
## **Return type**
_JournalEntryModelQuerySet_
`unposted()` _→ JournalEntryModelQuerySet_
Filters the QuerySet to include only “unposted” Journal Entries.
## **Returns**
A filtered QuerySet containing only unposted Journal Entries.
**122**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
## _JournalEntryModelQuerySet_
`exception django_ledger.models.journal_entry.JournalEntryValidationError(` _message_ ,
_code=None_ , _params=None_ `)`
## **9.9 Bank Account Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
A Bank Account refers to the financial institution which holds financial assets for the EntityModel. A bank account usually holds cash, which is a Current Asset. Transactions may be imported using the open financial format specification OFX into a staging area for final disposition into the EntityModel ledger.
`class django_ledger.models.bank_account.BankAccountModel(` _*args_ , _**kwargs_ `)`
- Base Bank Account Model Implementation
## `exception DoesNotExist`
## `exception MultipleObjectsReturned`
`class django_ledger.models.bank_account.BankAccountModelAbstract(` _*args_ , _**kwargs_ `)`
This is the main abstract class which the BankAccountModel database will inherit from. The BankAccountModel inherits functionality from the following MixIns:
1. `BankAccountInfoMixIn`
2. _`CreateUpdateMixIn`_
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
```
name
```
A user defined name for the bank account as a String.
**Type** str
```
entity_model
```
The EntityModel associated with the BankAccountModel instance.
**Type**
_EntityModel_
## `account_model`
The AccountModel associated with the BankAccountModel instance. Must be an account with role ASSET_CA_CASH.
**Type**
_AccountModel_
## `active`
Determines whether the BackAccountModel instance bank account is active. Defaults to True.
**9.9. Bank Account Model**
**123**
**Django Ledger**
**Type** bool
```
hidden
```
Determines whether the BackAccountModel instance bank account is hidden. Defaults to False.
**Type**
bool
`class django_ledger.models.bank_account.BankAccountModelManager(` _*args_ , _**kwargs_ `)`
Custom defined Model Manager for the BankAccountModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ BankAccountModelQuerySet_
Allows only the authorized user to query the BankAccountModel for a given EntityModel. This is the recommended initial QuerySet.
**Parameters** `entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
`get_queryset()` _→ BankAccountModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
`class django_ledger.models.bank_account.BankAccountModelQuerySet(` _model=None_ , _query=None_ ,
_using=None_ , _hints=None_ `)`
A custom-defined QuerySet for the BankAccountModel.
`active()` _→ BankAccountModelQuerySet_ Active bank accounts which can be used to create new transactions.
**Returns** A filtered BankAccountModelQuerySet of active accounts.
**Return type** _BankAccountModelQuerySet_
`hidden()` _→ BankAccountModelQuerySet_
Hidden bank accounts which can be used to create new transactions. but will not show in drop down menus in the UI.
**Returns**
A filtered BankAccountModelQuerySet of active accounts.
**Return type**
_BankAccountModelQuerySet_
`exception django_ledger.models.bank_account.BankAccountValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.10 Chart of Accounts Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
**124**
**Chapter 9. Models**
**Django Ledger**
## **9.10.1 Chart Of Accounts**
A Chart of Accounts (CoA) is a fundamental component of financial management in Django Ledger. It serves as the backbone of financial statements and is organized within a ChartOfAccountModel.
### Key Features
- • **Account Roles** : The CoA includes various account types such as: - Cash - Accounts Receivable - Expenses - Liabilities - Income
- • **Hierarchical Structure** : Accounts are logically grouped to form financial statements. For example, the Balance
**Sheet may have a structure like this:**
- • Fixed Assets - Tangible Assets
- **–** Building
- **–** Plant & Equipment
- **–** Machinery
- **–** Intangible Assets
- • **Financial Statement Preparation** : Individual account balances are aggregated based on the CoA and AccountModel
roles to create comprehensive financial statements.
- ### Usage in EntityModel
- • Every EntityModel must have a default CoA to create any type of transaction.
- • If no explicit CoA is specified, the EntityModel’s default CoA is used.
- • Only ONE Chart of Accounts can be used when creating Journal Entries.
- • Commingling between different CoAs is not allowed to maintain the integrity of Journal Entries.
This structure ensures a clear and organized approach to financial management within Django Ledger, facilitating accurate record-keeping and reporting.
- `class django_ledger.models.chart_of_accounts.ChartOfAccountModel(` _*args_ , _**kwargs_ `)`
- Base ChartOfAccounts Model
- `exception DoesNotExist`
```
exception MultipleObjectsReturned
```
- `class django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract(` _*args_ , _**kwargs_ `)`
- Abstract base class for the Chart of Account model.
```
uuid
```
UUID field for the chart of account model (primary key).
**Type** UUIDField
`entity` ForeignKey to the EntityModel.
**Type** ForeignKey
**9.10. Chart of Accounts Model**
**125**
**Django Ledger**
## `active`
BooleanField indicating whether the chart of account is active or not.
**Type** BooleanField
## `description`
TextField storing the description of the chart of account.
**Type** TextField
## `objects`
Manager for the ChartOfAccountModel.
**Type**
_ChartOfAccountModelManager_
`can_activate()` _→_ bool
Check if the ChartOffAccountModel instance can be activated.
**Return type**
True if the object can be activated, False otherwise.
## `can_deactivate()` _→_ bool
Check if the ChartOffAccountModel instance can be deactivated.
**Return type**
True if the object can be deactivated, False otherwise.
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
## `configure(` _raise_exception: bool = True_ `)`
A method that properly configures the ChartOfAccounts model and creates the appropriate hierarchy boilerplate to support the insertion of new accounts into the chart of account model tree. This method must be called every time the ChartOfAccounts model is created.
## **Parameters**
`raise_exception` ( _`bool, optional`_ ) – Whether to raise an exception if root nodes already exist in the Chart of Accounts (default is True). This indicates that the ChartOfAccountModel instance is already configured.
`create_account(` _code: str_ , _role: str_ , _name: str_ , _balance_type: str_ , _active: bool_ , _root_account_qs:_ AccountModelQuerySet _| None = None_ `)`
Proper method for inserting a new Account Model into a CoA. Use this in liu of the direct instantiation of the AccountModel of using the django related manager.
## **Parameters**
- • `code` ( _`str`_ ) – The code of the account to be created.
- • `role` ( _`str`_ ) – The role of the account. This can be a user-defined value.
- • `name` ( _`str`_ ) – The name of the account.
- • `balance_type` ( _`str`_ ) – The balance type of the account. This can be a user-defined value.
- • `active` ( _`bool`_ ) – Specifies whether the account is active or not.
**126**
**Chapter 9. Models**
**Django Ledger**
- • `root_account_qs` ( _`Optional[`_ `AccountModelQuerySet` _`], optional`_ ) – The query set of root accounts to which the created account should be linked. Defaults to None.
**Returns**
The created account model instance.
**Return type**
_AccountModel_
`generate_slug(` _commit: bool = False_ , _raise_exception: bool = False_ `)` _→_ str
Generates and assigns a slug based on the ChartOfAccounts model instance EntityModel information.
**Parameters** `raise_exception` ( _`bool, optional`_ ) – If set to True, it will raise a ChartOfAccountsModelValidationError if the _self.slug_ is already set.
**Returns** The generated slug for the Chart of Accounts.
**Return type** str **Raises** _`ChartOfAccountsModelValidationError`_ – If _raise_exception_ is set to True and _self.slug_ is already set.
`get_account_root_node(` _account_model:_ AccountModel, _root_account_qs:_ AccountModelQuerySet _| None = None_ , _as_queryset: bool = False_ `)` _→ AccountModel_
Fetches the root node of the ChartOfAccountModel instance. The root node is the highest level of the CoA hierarchy. It can be used to traverse the hierarchy of the CoA structure downstream.
**Parameters**
- • `account_model` ( `AccountModel` ) – The account model for which to find the root node.
- • `root_account_qs` ( _`Optional[`_ `AccountModelQuerySet` _`], optional`_ ) – The queryset of root accounts. If not provided, it will be retrieved using _get_coa_root_accounts_qs_ method.
- • `as_queryset` ( _`bool, optional`_ ) – If True, return the root account queryset instead of a single root account. Default is False.
**Returns**
If _as_queryset_ is True, returns the root account queryset. Otherwise, returns a single root account.
**Return type** Union[ _AccountModelQuerySet_ , _AccountModel_ ]
**Raises** _`ChartOfAccountsModelValidationError`_ – If the account model is not part of the chart of accounts.
`get_coa_account_tree()` _→_ Dict
Performs a bulk dump of the ChartOfAccounts model instance accounts to a dictionary. The method invokes the`dump_bulk` method on the ChartOfAccount model instance root node. See Django Tree Beard documentation for more information.
**Returns**
A dictionary containing all accounts from the chart of accounts in a nested structure.
**9.10. Chart of Accounts Model**
**127**
**Django Ledger**
## **Return type**
## Dict
`get_coa_accounts(` _active_only: bool = True_ `)` _→ AccountModelQuerySet_
Returns the AccountModelQuerySet associated with the ChartOfAccounts model instance.
**Parameters**
`active_only` ( _`bool, optional`_ ) – Flag to indicate whether to retrieve only active accounts or all accounts. Default is True.
## **Returns**
A queryset containing accounts from the chart of accounts.
## **Return type**
_AccountModelQuerySet_
`get_coa_root_accounts_qs()` _→ AccountModelQuerySet_
Retrieves the root accounts in the chart of accounts.
## **Returns**
A queryset containing the root accounts in the chart of accounts.
## **Return type**
_AccountModelQuerySet_
`get_coa_root_node()` _→ AccountModel_
Retrieves the root node of the chart of accounts.
## **Returns**
The root node of the chart of accounts.
## **Return type**
_AccountModel_
`get_non_root_coa_accounts_qs()` _→ AccountModelQuerySet_
Returns a query set of non-root accounts in the chart of accounts.
## **Returns**
A query set of non-root accounts in the chart of accounts.
## **Return type**
_AccountModelQuerySet_
`insert_account(` _account_model:_ AccountModel, _root_account_qs:_ AccountModelQuerySet _| None =_
_None_ `)`
This method inserts the given account model into the chart of accounts (COA) instance. It first verifies if the account model’s COA model ID matches the COA’s UUID. If not, it raises a _ChartOfAccountsModelValidationError_ . If the _root_account_qs_ is not provided, it retrieves the root account query set using the _get_coa_root_accounts_qs_ method. Providing a pre-fetched _root_account_qs_ avoids unnecessary retrieval of the root account query set every an account model is inserted into the CoA.
Next, it validates the provided _root_account_qs_ if it is not None. Then, it obtains the root node for the account model using the _get_account_root_node_ method and assigns it to _account_root_node_ .
Finally, it adds the account model as a child to the _account_root_node_ and retrieves the updated COA accounts query set using the _get_non_root_coa_accounts_qs_ method. It returns the inserted account model found in the COA accounts query set.
## **Parameters**
- • `account_model` ( `AccountModel` ) – The account model to be inserted into the chart of accounts.
**128**
**Chapter 9. Models**
**Django Ledger**
- • `root_account_qs` ( _`Optional[`_ `AccountModelQuerySet` _`], default=None`_ ) – The root account query set. If not provided, it will be obtained using the _get_coa_root_accounts_qs_ method.
**Returns**
The inserted account model.
**Return type** _AccountModel_
**Raises** _`ChartOfAccountsModelValidationError`_ – If the provided account model has an invalid COA model ID for the current COA.
`is_active()` _→_ bool
Check if the ChartOfAccountModel instance is active.
**Returns** True if the ChartOfAccountModel instance is active, False otherwise.
**Return type** bool
`is_default()` _→_ bool
Check if the ChartOfAccountModel instance is set as the default for the EntityModel.
**Returns** True if the ChartOfAccountModel instance is set as the default for the EntityModel. Else, False.
**Return type** bool
`mark_as_active(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Marks the current Chart of Accounts as Active.
**Parameters**
- • `commit` ( _`bool`_ ) – Commit the action into the Database. Default is False.
- • `raise_exception` ( _`bool`_ ) – Raises exception if Chart of Account model instance is already active. Default is False.
`mark_as_active_url()` _→_ str
Returns the URL to mark the current Chart of Accounts instances as active.
**Returns** The URL as a String.
**Return type**
str
`mark_as_default(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Marks the current Chart of Accounts instances as default for the EntityModel.
**Parameters**
- • `commit` ( _`bool`_ ) – Commit the action into the Database. Default is False.
- • `raise_exception` ( _`bool`_ ) – Raises exception if Chart of Account model instance is al-
ready marked as default.
**9.10. Chart of Accounts Model**
**129**
**Django Ledger**
`mark_as_default_url()` _→_ str
Returns the URL to mark the current Chart of Accounts instances as Default for the EntityModel.
**Returns** The URL as a String.
## **Return type**
str
`mark_as_inactive(` _commit: bool = False_ , _raise_exception: bool = False_ , _**kwargs_ `)`
Marks the current Chart of Accounts as Active.
**Parameters**
- • `commit` ( _`bool`_ ) – Commit the action into the Database. Default is False.
• `raise_exception` ( _`bool`_ ) – Raises exception if Chart of Account model instance is already active. Default is False.
`mark_as_inactive_url()` _→_ str
Returns the URL to mark the current Chart of Accounts instances as inactive.
**Returns** The URL as a String.
**Return type**
str
`validate_account_model_qs(` _account_model_qs:_ AccountModelQuerySet `)`
Validates the given AccountModelQuerySet for the ChartOfAccountsModel.
**Parameters**
`account_model_qs` ( `AccountModelQuerySet` ) – The AccountModelQuerySet to validate.
**Raises**
_`ChartOfAccountsModelValidationError`_ – If the account_model_qs is not an instance of AccountModelQuerySet or if it contains an account model with a different coa_model_id than the current CoA model.
`class django_ledger.models.chart_of_accounts.ChartOfAccountModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined ChartOfAccountModelManager that will act as an interface to handling the initial DB queries to the ChartOfAccountModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ChartOfAccountModelQuerySet_
Fetches a QuerySet of ChartOfAccountsModel associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters**
`entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
**Returns**
Returns a ChartOfAccountQuerySet with applied filters.
## **Return type**
ChartOfAccountQuerySet
`get_queryset()` _→ ChartOfAccountModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
**130**
**Chapter 9. Models**
**Django Ledger**
`class django_ledger.models.chart_of_accounts.ChartOfAccountModelQuerySet(` _model=None_ ,
_query=None_ , _using=None_ , _hints=None_ `)`
`active()` _→ ChartOfAccountModelQuerySet_
QuerySet method to retrieve active items.
`for_user(` _user_model_ `)` _→ ChartOfAccountModelQuerySet_
Fetches a QuerySet of ChartOfAccountModel that the UserModel as access to. May include ChartOfAccountModel from multiple Entities. The user has access to bills if: 1. Is listed as Manager of Entity. 2. Is the Admin of the Entity.
**Parameters**
`user_model` – Logged in and authenticated django UserModel instance.
**Returns**
Returns a ChartOfAccountQuerySet with applied filters.
**Return type** ChartOfAccountQuerySet
`not_active()` _→ ChartOfAccountModelQuerySet_
QuerySet method to retrieve not active items.
`exception django_ledger.models.chart_of_accounts.ChartOfAccountsModelValidationError(` _message_ ,
_code=None_ , _params=None_ `)`
## **9.11 Default Chart of Accounts**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
This is the base Chart of Accounts that has all the possible accounts that are useful for the preparation of the Financial Statements. A user may choose to use the default CoA at the creation of each EntityModel but it is not required. The default CoA is intended to provide a QuickStart solution for most use cases.
## **The Chart of Accounts is broadly bifurcated into 5 different Sections:**
- 1. Assets:
- 2. Liabilities
- 3. Shareholder’s Equity
- 4. Income
- 5. COGS
- 6. Expenses
**The Django Ledger Default Chart of Accounts must include the following fields:**
- • Code - String
- • Role - A choice from any of the possible account roles (see django_ledger.roles module).
- • Balance Type - A CREDIT or DEBIT balance account setting.
- • Name - A human readable name.
**9.11. Default Chart of Accounts**
**131**
**Django Ledger**
• Parent - The parent account of the AccountModel instance.
If the DEFAULT_CHART_OF_ACCOUNTS setting is present, the default CoA will be replace by such setting.
## **9.11.1 Default Chart of Accounts Table**
|code|role|balance_type|name|parent|root_gr|
|---|---|---|---|---|---|
|1910|asset_adjustment|debit|Securities Unrealized Gains/Losses||root_as|
|1920|asset_adjustment|debit|PPE Unrealized Gains/Losses||root_as|
|1010|asset_ca_cash|debit|Cash||root_as|
|1050|asset_ca_mkt_sec|debit|Short Term Investments||root_as|
|1200|asset_ca_inv|debit|Inventory||root_as|
|1300|asset_ca_prepaid|debit|Prepaid Expenses||root_as|
|1100|asset_ca_recv|debit|Accounts Receivable||root_as|
|1110|asset_ca_uncoll|credit|Uncollectibles||root_as|
|1810|asset_ia|debit|Goodwill||root_as|
|1820|asset_ia|debit|Intellectual Property||root_as|
|1830|asset_ia_accum_amort|credit|Less: Intangible Assets Accumulated Amortization||root_as|
|1520|asset_lti_land|debit|Land||root_as|
|1510|asset_lti_notes|debit|Notes Receivable||root_as|
|1530|asset_lti_sec|debit|Securities||root_as|
|1610|asset_ppe_build|debit|Buildings||root_as|
|1611|asset_ppe_build_accum_depr|credit|Less: Buildings Accumulated Depreciation||root_as|
|1630|asset_ppe_equip|debit|Equipment||root_as|
|1631|asset_ppe_equip_accum_depr|credit|Less: Equipment Accumulated Depreciation||root_as|
|1620|asset_ppe_plant|debit|Plant||root_as|
|1640|asset_ppe_plant|debit|Vehicles||root_as|
|1650|asset_ppe_plant|debit|Furniture & Fixtures||root_as|
|1621|asset_ppe_plant_depr|credit|Less: Plant Accumulated Depreciation||root_as|
|1641|asset_ppe_plant_depr|credit|Less: Vehicles Accumulated Depreciation||root_as|
|1651|asset_ppe_plant_depr|credit|Less: Furniture & Fixtures Accumulated Depreciation||root_as|
|3910|eq_adjustment|credit|Available for Sale||root_ca|
|3920|eq_adjustment|credit|PPE Unrealized Gains/Losses||root_ca|
|3010|eq_capital|credit|Capital Account 1||root_ca|
|3020|eq_capital|credit|Capital Account 2||root_ca|
|3030|eq_capital|credit|Capital Account 3||root_ca|
|3930|eq_dividends|debit|Dividends & Distributions||root_ca|
|3110|eq_stock_common|credit|Common Stock||root_ca|
|3120|eq_stock_preferred|credit|Preferred Stock||root_ca|
|5010|cogs_regular|debit|Cost of Goods Sold||root_co|
|6075|ex_amortization|debit|Amortization Expense||root_ex|
|6070|ex_depreciation|debit|Depreciation Expense||root_ex|
|6130|ex_interest|debit|Interest Expense||root_ex|
|6500|ex_other|debit|Misc. Expense||root_ex|
|6010|ex_regular|debit|Advertising||root_ex|
|6020|ex_regular|debit|Amortization||root_ex|
|6030|ex_regular|debit|Auto Expense||root_ex|
|6040|ex_regular|debit|Bad Debt||root_ex|
|6050|ex_regular|debit|Bank Charges||root_ex|
|6060|ex_regular|debit|Commission Expense||root_ex|
|6080|ex_regular|debit|Employee Benefts||root_ex|
|6081|ex_regular|debit|Employee Wages||root_ex|
|||||continues|on nex|
**132**
**Chapter 9. Models**
**Django Ledger**
Table 1 – continued from previous page
|code|role|balance_type|name|parent|root_gr|
|---|---|---|---|---|---|
|6090|ex_regular|debit|Freight||root_ex|
|6110|ex_regular|debit|Gifts||root_ex|
|6120|ex_regular|debit|Insurance||root_ex|
|6140|ex_regular|debit|Professional Fees||root_ex|
|6150|ex_regular|debit|License Expense||root_ex|
|6170|ex_regular|debit|Maintenance Expense||root_ex|
|6180|ex_regular|debit|Meals & Entertainment||root_ex|
|6190|ex_regular|debit|Ofce Expense||root_ex|
|6220|ex_regular|debit|Printing||root_ex|
|6230|ex_regular|debit|Postage||root_ex|
|6240|ex_regular|debit|Rent||root_ex|
|6250|ex_regular|debit|Maintenance & Repairs||root_ex|
|6251|ex_regular|debit|Maintenance||root_ex|
|6252|ex_regular|debit|Repairs||root_ex|
|6253|ex_regular|debit|HOA||root_ex|
|6254|ex_regular|debit|Snow Removal||root_ex|
|6255|ex_regular|debit|Lawn Care||root_ex|
|6260|ex_regular|debit|Salaries||root_ex|
|6270|ex_regular|debit|Supplies||root_ex|
|6290|ex_regular|debit|Utilities||root_ex|
|6292|ex_regular|debit|Sewer||root_ex|
|6293|ex_regular|debit|Gas||root_ex|
|6294|ex_regular|debit|Garbage||root_ex|
|6295|ex_regular|debit|Electricity||root_ex|
|6300|ex_regular|debit|Property Management||root_ex|
|6400|ex_regular|debit|Vacancy||root_ex|
|6210|ex_taxes|debit|Payroll Taxes||root_ex|
|6280|ex_taxes|debit|Taxes||root_ex|
|4040|in_gain_loss|credit|Capital Gain/Loss Income||root_inc|
|4030|in_interest|credit|Interest Income||root_inc|
|4010|in_operational|credit|Sales Income||root_inc|
|4050|in_other|credit|Other Income||root_inc|
|4020|in_passive|credit|Investing Income||root_inc|
|2010|lia_cl_acc_payable|credit|Accounts Payable||root_lia|
|2060|lia_cl_def_rev|credit|Deferred Revenues||root_lia|
|2030|lia_cl_int_payable|credit|Interest Payable||root_lia|
|2050|lia_cl_ltd_mat|credit|Current Maturities LT Debt||root_lia|
|2070|lia_cl_other|credit|Other Payables||root_lia|
|2040|lia_cl_st_notes_payable|credit|Short-Term Notes Payable||root_lia|
|2020|lia_cl_wages_payable|credit|Wages Payable||root_lia|
|2120|lia_ltl_bonds|credit|Bonds Payable||root_lia|
|2130|lia_ltl_mortgage|credit|Mortgage Payable||root_lia|
|2110|lia_ltl_notes|credit|Long Term Notes Payable||root_lia|
`django_ledger.models.coa_default.get_default_coa_rst(` _default_coa: Dict | None = None_ `)` _→_ str
Converts the provided Chart of Account into restructuredText format. :param default_coa: A dictionary of chart of accounts. Must follow the same keys as CHART_OF_ACCOUNTS.
**Returns**
The table in RestructuredText format.
## **Return type**
**9.11. Default Chart of Accounts**
**133**
**Django Ledger**
str
```
django_ledger.models.coa_default.verify_unique_code()
```
A function that verifies that there are no duplicate code in the Default CoA during the development and launch.
## **9.12 Receipt Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
Receipt models and utilities.
This module provides models and helpers for recording monetary receipts within an Entity’s ledger. It supports receipts related to customers (sales and refunds), vendors (expenses and refunds), and transfers between accounts. In addition to Django ORM models, the module exposes queryset/manager helpers for filtering receipts, utilities for generating sequential receipt numbers, and migration of staged bank transactions into posted journal entries.
## **Notes**
• All public functions and methods are documented in NumPy docstring style.
• Unless otherwise noted, monetary amounts are Decimal-compatible and are validated server-side.
- `class django_ledger.models.receipt.ReceiptModel(` _*args_ , _**kwargs_ `)`
Concrete receipt model ready for migration and admin usage.
Inherits all behavior from ReceiptModelAbstract and is used as the concrete Django model for persistence.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
- `class django_ledger.models.receipt.ReceiptModelAbstract(` _*args_ , _**kwargs_ `)`
Abstract model representing a monetary receipt.
This class encapsulates the common fields and behaviors for receipts across different types: sales, sales refund, expense, expense refund, and transfer. It includes helpers to generate sequential receipt numbers, validate receipt configuration, and migrate staged transactions to journal entries.
`can_delete()` _→_ bool
Check if the receipt can be safely deleted.
**Returns**
True if the receipt date is after the entity’s last closing date.
**Return type**
bool
`can_generate_receipt_number()` _→_ bool
Whether a receipt number can be generated for this instance.
**Returns**
True if the receipt currently has no receipt_number assigned.
**Return type**
bool
`can_migrate()` _→_ bool
Whether the receipt has enough data to migrate staged transactions.
**134**
**Chapter 9. Models**
**Django Ledger**
## **Returns**
True if a receipt_date is set and either vendor or customer is set.
**Return type** bool
- `clean()`
Model validation for mutually exclusive counterparties.
**Raises**
_`ReceiptModelValidationError`_ – If a sales receipt lacks a customer or an expense receipt lacks a vendor.
- `configure(` _entity_model:_ EntityModel _| str | UUID_ , _receipt_type: Literal['sales', 'customer_refund', 'expense', 'expense_refund']_ , _amount: int | float | Decimal_ , _unit_model:_ EntityUnitModel _| str | UUID | None = None_ , _receipt_date: datetime | str | None = None_ , _vendor_model:_ VendorModel _| str | UUID | None = None_ , _customer_model:_ CustomerModel _| str | UUID | None = None_ , _charge_account:_ AccountModel _| None = None_ , _receipt_account:_ AccountModel _| None = None_ , _staged_transaction_model=None_ , _commit: bool = True_ `)`
Configure the receipt with entity, counterpart, and accounting data.
This method sets related models, validates inputs, creates a posted ledger for the receipt, and generates a receipt number.
## **Parameters**
- • `entity_model` ( `EntityModel` _`or str or UUID`_ ) – The entity instance, slug, or UUID that owns the receipt.
- • `receipt_type` ( _`{SALES_RECEIPT, SALES_REFUND, EXPENSE_RECEIPT, EXPENSE_REFUND}`_ ) – The type of receipt.
- • `amount` ( _`int or float or Decimal`_ ) – Positive monetary amount of the receipt.
- • `unit_model` ( `EntityUnitModel` _`or str or UUID, optional`_ ) – Unit/class/department context.
- • `receipt_date` ( _`datetime or str, optional`_ ) – Date to use for the receipt; defaults to local date.
- • `vendor_model` ( `VendorModel` _`or str or UUID, optional`_ ) – The vendor related to the receipt (mutually exclusive with customer).
- • `customer_model` ( `CustomerModel` _`or str or UUID, optional`_ ) – The customer related to the receipt (mutually exclusive with vendor).
- • `charge_account` ( `AccountModel` _`, optional`_ ) – The cash/credit account where the transaction occurred.
- • `receipt_account` ( `AccountModel` _`, optional`_ ) – The income/expense account impacted by the receipt.
- • `staged_transaction_model` ( _`StagedTransactionModel, optional`_ ) – Optional staged transaction to link for migration.
- • `commit` ( _`bool, default True`_ ) – If True, persist the configured receipt to the database.
## **Raises**
_`ReceiptModelValidationError`_ – On invalid combinations or values.
`delete(` _using=None_ , _keep_parents=False_ , _delete_ledger: bool = True_ , _**kwargs_ `)`
Delete the receipt and related journal entries if allowed.
**9.12. Receipt Model**
**135**
**Django Ledger**
## **Parameters**
- • `using` ( _`str, optional`_ ) – The database alias to use.
- • `keep_parents` ( _`bool, default False`_ ) – Whether to keep parent model records.
- • `delete_ledger` ( _`bool, default True`_ ) – Unused flag preserved for backward compatibility.
- • `**kwargs` – Additional options passed to Django’s delete.
**Returns** A 2-tuple of the number of objects deleted and a dictionary with the number of deletions per object type, as returned by Django.
**Return type** tuple **Raises** _`ReceiptModelValidationError`_ – If the receipt is within a closed period.
```
property entity_slug:str
```
Entity slug convenience property.
**Returns** The slug of the related entity, using the annotated value when present to avoid extra queries. **Return type** str
`property entity_uuid: UUID` Entity UUID convenience property. **Returns** The UUID of the related entity, using the annotated value when available to minimize queries. **Return type** UUID
`generate_receipt_number(` _commit: bool = False_ `)` _→_ str Generate and optionally persist a sequential receipt number.
**Parameters** `commit` ( _`bool, default False`_ ) – If True, persist the newly generated number to the database. **Returns** The generated or existing receipt number. **Return type** str
`get_absolute_url()` _→_ str Absolute URL for the receipt detail view.
**Returns** URL string for this receipt’s detail page. **Return type** str
**136**
**Chapter 9. Models**
**Django Ledger**
`get_customer_list_url()` _→_ str | None
URL for listing receipts for the same customer. **Returns** URL string to the customer’s receipt list, or None when the receipt has no customer. **Return type** str or None `get_customer_report_url()` _→_ str | None URL for a report focused on this receipt’s customer. **Returns** URL string to the customer report, or None when the receipt has no customer. **Return type** str or None `get_delete_url()` _→_ str URL for the receipt delete view. **Returns** URL string for deleting this receipt. **Return type** str
`get_import_job_url()` _→_ str | None URL of the import job page associated with the staged transaction. **Returns** URL string to the import job transactions page, or None when there is no staged transaction linked. **Return type** str or None `get_list_url()` _→_ str URL for the entity’s receipt list view. **Returns** URL string for listing receipts of the same entity. **Return type** str `get_receipt_type_for_amount(` _amount: float | int | Decimal_ `)` _→_ str Derive a receipt type from context and amount sign. **Parameters** `amount` ( _`float or int or Decimal`_ ) – The receipt amount. The sign determines whether a refund or normal receipt is implied given the counterparty type. **Returns** One of SALES_RECEIPT, SALES_REFUND, EXPENSE_RECEIPT, EXPENSE_REFUND. **Return type** str **Raises** _`ReceiptModelValidationError`_ – If both a customer and vendor are set, or neither is set.
**9.12. Receipt Model**
**137**
**Django Ledger**
## **Notes**
Rules: - Customer: amount >= 0 -> SALES_RECEIPT; amount < 0 -> SALES_REFUND - Vendor: amount <= 0 -> EXPENSE_RECEIPT; amount > 0 -> EXPENSE_REFUND
`get_staged_tx_url()` _→_ str | None
Anchor URL pointing to the staged transaction within the import job page.
**Returns** URL string anchored to this receipt’s staged transaction, or None when there is no staged transaction or import job URL.
**Return type** str or None
`get_vendor_list_url()` _→_ str | None
URL for listing receipts for the same vendor.
**Returns**
URL string to the vendor’s receipt list, or None when the receipt has no vendor.
**Return type** str or None
`get_vendor_report_url()` _→_ str | None
URL for a report focused on this receipt’s vendor.
**Returns**
URL string to the vendor report, or None when the receipt has no vendor.
**Return type** str or None
`is_configured()` _→_ bool
Whether the receipt has enough data to operate.
**Returns** True if receipt_date, receipt_type, and ledger_model are set.
**Return type** bool
`is_expense_receipt()` _→_ bool
Whether the receipt is expense-related (expense or refund).
**Returns**
True if receipt_type is EXPENSE_RECEIPT or EXPENSE_REFUND.
**Return type** bool
`is_sales_receipt()` _→_ bool
Whether the receipt is sales-related (sales or refund).
**Returns** True if receipt_type is SALES_RECEIPT or SALES_REFUND.
**Return type** bool
**138**
**Chapter 9. Models**
**Django Ledger**
## `is_transfer_receipt()` _→_ bool
Whether the receipt is a transfer between accounts.
**Returns** True if receipt_type is TRANSFER_RECEIPT.
**Return type**
bool
```
property last_closing_date
```
Entity last closing date convenience property.
**Returns**
The entity’s last closing date, using the annotated value when available to minimize queries.
**Return type**
date
```
property ledger_posted
```
Whether the underlying ledger is posted.
**Returns**
True if the associated ledger is posted, False otherwise.
**Return type**
bool
## `migrate_receipt()`
Post staged transactions into the ledger as journal entries.
This method commits staged transactions linked to the receipt into the associated ledger, marking them as posted journal entries.
**Raises**
_`ReceiptModelValidationError`_ – If the receipt is not configured or lacks the required counterparty to migrate (vendor or customer).
```
property posted
```
Alias for ledger_posted for template convenience.
**Returns** True if the associated ledger is posted, False otherwise.
**Return type**
bool
`class django_ledger.models.receipt.ReceiptModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
`for_customer(` _customer_model:_ CustomerModel _| str | UUID_ `)` _→ ReceiptModelQuerySet_
Filter receipts tied to a specific customer.
**Parameters**
`customer_model` ( `CustomerModel` _`or str or UUID`_ ) – The customer instance, customer number (str), or customer UUID to filter by. Only sales-related receipts are returned.
**Returns** QuerySet containing receipts associated with the given customer.
**Return type**
_ReceiptModelQuerySet_
**9.12. Receipt Model**
**139**
**Django Ledger**
**Raises**
_`ReceiptModelValidationError`_ – If the provided value is not a supported type.
`for_dates(` _from_date_ , _to_date_ `)` _→ ReceiptModelQuerySet_
Filter receipts within an inclusive date range.
## **Parameters**
- • `from_date` ( _`date`_ ) – Start date (inclusive).
- • `to_date` ( _`date`_ ) – End date (inclusive).
## **Returns**
QuerySet containing receipts between the specified dates.
**Return type**
_ReceiptModelQuerySet_
`for_user(` _user_model_ `)` _→ ReceiptModelQuerySet_
Filter receipts visible to a given user.
**Parameters**
`user_model` ( _`django.contrib.auth.models.User`_ ) – The user for whom to filter receipts. The user must be either the entity admin or listed among the entity managers.
**Returns**
QuerySet containing receipts associated with entities the user can manage.
**Return type**
_ReceiptModelQuerySet_
`for_vendor(` _vendor_model:_ VendorModel _| str | UUID_ `)` _→ ReceiptModelQuerySet_
Filter receipts tied to a specific vendor.
**Parameters**
`vendor_model` ( `VendorModel` _`or str or UUID`_ ) – The vendor instance, vendor number (str), or vendor UUID to filter by. Only expense-related receipts are returned.
- **Returns**
QuerySet containing receipts associated with the given vendor.
**Return type**
_ReceiptModelQuerySet_
## **Raises**
_`ReceiptModelValidationError`_ – If the provided value is not a supported type.
`exception django_ledger.models.receipt.ReceiptModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
Domain-specific validation error for receipt operations.
This exception is raised when invalid states or inputs are detected while creating, configuring, validating, or mutating receipt instances.
`django_ledger.models.receipt.receiptmodel_presave(` _instance:_ ReceiptModel, _**kwargs_ `)`
Pre-save signal hook for ReceiptModel.
**Parameters**
- • `instance` ( `ReceiptModel` ) – The model instance being saved.
• `**kwargs` – Additional keyword arguments passed by Django’s pre_save.
**140**
**Chapter 9. Models**
**Django Ledger**
**Notes**
Currently a no-op placeholder for future pre-save logic.
## **9.13 Item Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
The Items refer to the additional detail provided to Bills, Invoices, Purchase Orders and Estimates for the purposes of documenting a breakdown of materials, labor, equipment, and other resources used for the purposes of the business operations.
The items associated with any of the aforementioned models are responsible for calculating the different amounts that ultimately drive the behavior of Journal Entries onto the company books.
Each item must be assigned a UnitOfMeasureModel which is the way or method used to quantify such resource. Examples are Pounds, Gallons, Man Hours, etc used to measure how resources are quantified when associated with a specific ItemTransactionModel. If many unit of measures are used for the same item, it would constitute a different item hence a new record must be created.
ItemsTransactionModels constitute the way multiple items and used resources are associated with Bills, Invoices, Purchase Orders and Estimates. Each transaction will record the unit of measure and quantity of each resource. Totals will be calculated and associated with the containing model at the time of update.
## `class django_ledger.models.items.ItemModel(` _*args_ , _**kwargs_ `)`
Base ItemModel from Abstract.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
- `class django_ledger.models.items.ItemModelAbstract(` _*args_ , _**kwargs_ `)`
Base implementation of the ItemModel.
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
```
name
```
Human readable name of the ItemModel instance. Maximum of 100 characters.
**Type** str
```
item_role
```
A choice of ITEM_ROLE_CHOICES that determines whether the ItemModel should be treated as an expense, inventory, service or product.
**Type**
str
## `item_type`
A choice of ITEM_TYPE_CHOICES that determines whether the ItemModel should be treated as labor, material, equipment, lump sum or other.
**Type**
str
**9.13. Item Model**
**141**
**Django Ledger**
## `uom`
The assigned UnitOfMeasureModel of the ItemModel instance. Mandatory.
**Type** _UnitOfMeasureModel_ `sku` The SKU number associated with the ItemModel instance. Maximum 50 characters. **Type** str
## `upc`
The UPC number associated with the ItemModel instance. Maximum 50 characters. **Type** str
## `item_id`
EntityModel specific id associated with the ItemModel instance. Maximum 50 characters.
**Type** str
```
item_number
```
Auto generated human-readable item number.
**Type** str
```
is_active
```
Determines if the ItemModel instance is considered active. Defaults to True.
**Type**
bool
```
default_amount
```
The default, prepopulated monetary amount of the ItemModel instance .
**Type**
Decimal
```
for_inventory
```
Legacy field used to determine if the ItemModel instance is considered an inventory item. Mandatory. Superseded by item_role field. Will be deprecated.
**Type**
bool
```
is_product_or_service
```
Legacy field used to determine if the ItemModel instance is considered a product or service item. Mandatory. Superseded by item_role field. Will be deprecated.
**Type**
bool
```
sold_as_unit
```
Determines if only whole numbers can be used when specifying the quantity on ItemTransactionModels.
**Type** bool
**142**
**Chapter 9. Models**
**Django Ledger**
## `inventory_account`
Inventory account associated with the ItemModel instance. Enforced if ItemModel instance is_inventory() is True.
**Type** _AccountModel_
## `inventory_received`
Holds the total quantity of the inventory received for the whole EntityModel instance.
**Type** Decimal
## `inventory_received_value`
Holds the total monetary value of the inventory received for the whole EntityModel instance.
**Type** Decimal
```
cogs_account
```
COGS account associated with the ItemModel instance. Enforced if ItemModel instance is_inventory() is True.
**Type** _AccountModel_
## `earnings_account`
**Earnings account associated with the ItemModel instance. Enforced if ItemModel instance**
**is_product() or** is_service() is True.
**Type** _AccountModel_
```
expense_account
```
Expense account associated with the ItemModel instance. Enforced if ItemModel instance is_expense() is True.
**Type**
_AccountModel_
```
additional_info
```
Additional user defined information stored as JSON document in the Database.
**Type** dict
`entity` The EntityModel associated with the ItemModel instance.
**Type** _EntityModel_
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
**9.13. Item Model**
**143**
**Django Ledger**
## `generate_item_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next Vendor Number available. @param commit: Commit transaction into VendorModel. @return: A String, representing the current InvoiceModel instance Document Number.
## `save(` _**kwargs_ `)`
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
`class django_ledger.models.items.ItemModelManager(` _*args_ , _**kwargs_ `)`
A custom defined ItemModelManager that implement custom QuerySet methods related to the ItemModel
`for_bill(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_
Returns a QuerySet of ItemModels that can only be used for BillModels for a specific EntityModel & UserModel. These types of items qualify as expenses or inventory purchases. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
## **Returns**
A Filtered ItemModelQuerySet.
## **Return type**
_ItemModelQuerySet_
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_ Marks the _for_entity_ method as deprecated in behavior and provides an updated usage approach.
This method allows querying a _QuerySet_ filtered by various representations of an entity, such as an instance of _EntityModel_ , a string slug, or a UUID. Leveraging this method with deprecated parameters may lead to a warning and compatibility concerns in future releases.
## **Parameters**
- • `entity_model` ( `EntityModel` _`| str | UUID, optional`_ ) – The entity to filter the queryset by. Can be an instance of _EntityModel_ , a slug ( _str_ ), or a unique identifier ( _UUID_ ). If not provided, no filtering is applied.
- • `kwargs` ( _`dict`_ ) – Additional keyword arguments, though currently only the _user_model_ parameter is recognized but deprecated. The _user_model_ behavior will be removed in future releases.
## **Returns**
A filtered queryset corresponding to the specified entity.
## **Return type**
_ItemModelQuerySet_
**Raises**
- • _`ItemModelValidationError`_ – If the _entity_model_ parameter is not of type _EntityModel_ , _str_ , or _UUID_ .
- • `DeprecationWarning` – When the _user_model_ parameter is used, indicating behavior slated for future removal.
`for_entity_active(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_
- Returns a QuerySet of Active ItemModel associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**144**
**Chapter 9. Models**
**Django Ledger**
## **Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
## **Returns**
A Filtered ItemModelQuerySet.
## **Return type**
_ItemModelQuerySet_
`for_estimate(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_
Returns a QuerySet of ItemModels that can only be used for EstimateModels for a specific EntityModel & UserModel. These types of items qualify as products. May pass an instance of EntityModel or a String representing the EntityModel slug.
## **Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
## **Returns**
A Filtered ItemModelQuerySet.
## **Return type**
_ItemModelQuerySet_
`for_invoice(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_
Returns a QuerySet of ItemModels that can only be used for InvoiceModels for a specific EntityModel & UserModel. These types of items qualify as products or services sold. May pass an instance of EntityModel or a String representing the EntityModel slug.
## **Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
## **Returns**
A Filtered ItemModelQuerySet.
## **Return type**
_ItemModelQuerySet_
`for_po(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ ItemModelQuerySet_
Returns a QuerySet of ItemModels that can only be used for PurchaseOrders for a specific EntityModel & UserModel. These types of items qualify as inventory purchases. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters**
`entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
## **Returns**
A Filtered ItemModelQuerySet.
## **Return type**
_ItemModelQuerySet_
`get_queryset()` _→ ItemModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
**9.13. Item Model**
**145**
**Django Ledger**
`class django_ledger.models.items.ItemModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
A custom-defined ItemModelQuerySet that implements custom QuerySet methods related to the ItemModel.
```
active()
```
Filters the QuerySet to only active Item Models.
**Returns**
A QuerySet with applied filters.
**Return type**
_ItemModelQuerySet_
`bills()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that are eligible only for bills..
**Returns**
A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
`expenses()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that only qualify as expenses.
**Returns**
A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
`inventory_all()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that only qualify as inventory. These types of items may be finished or unfinished.
**Returns**
A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
`inventory_wip()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that only qualify as inventory. These types of items cannot be sold as they are not considered a finished product.
**Returns**
A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
`products()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that only qualify as products.
**Returns**
A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
**146**
**Chapter 9. Models**
**Django Ledger**
`services()` _→ ItemModelQuerySet_
Filters the QuerySet to ItemModels that only qualify as services.
**Returns** A Filtered ItemModelQuerySet.
**Return type**
_ItemModelQuerySet_
`exception django_ledger.models.items.ItemModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
`class django_ledger.models.items.ItemTransactionModel(` _*args_ , _**kwargs_ `)`
Base ItemTransactionModel from Abstract.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.items.ItemTransactionModelAbstract(` _*args_ , _**kwargs_ `)`
`can_create_bill()` _→_ bool
Determines if the ItemModel instance can be associated with a BillModel. :returns: True, if instance can be associated with a BillModel, else False. :rtype: bool
`clean()` Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`get_status_css_class()` _→_ str
Determines the CSS Class used to represent the ItemModel instance in the UI based on its status.
**Returns** The CSS class as a String. **Return type** str `has_bill()` Determines if the ItemModel instance is associated with a BillModel. **Returns** True if associated with an BillModel, else False. **Return type** bool `has_estimate()` _→_ bool Determines if the ItemModel instance is associated with an EstimateModel. **Returns** True if associated with an EstimateModel, else False. **Return type** bool
`has_invoice()` Determines if the ItemModel instance is associated with a InvoiceModel.
**9.13. Item Model**
**147**
**Django Ledger**
## **Returns**
True if associated with an InvoiceModel, else False.
**Return type** bool
`has_po()` _→_ bool
Determines if the ItemModel instance is associated with a PurchaseOrderModel.
**Returns** True if associated with an PurchaseOrderModel, else False.
**Return type** bool
## `html_id()` _→_ str
Unique ItemModel instance HTML ID.
**Returns** HTML ID as a String.
**Return type** str
`html_id_quantity()` _→_ str
Unique ItemModel instance quantity field HTML ID.
**Returns** HTML ID as a String.
**Return type** str
## `html_id_unit_cost()` _→_ str
Unique ItemModel instance unit cost field HTML ID.
**Returns** HTML ID as a String.
**Return type** str
```
is_canceled()
```
Determines if the ItemModel instance is canceled. ItemModel status is only relevant for ItemModels associated with PurchaseOrderModels.
**Returns**
True if canceled, else False.
**Return type** bool
`is_ordered()` _→_ bool
Determines if the ItemModel instance is ordered. ItemModel status is only relevant for ItemModels associated with PurchaseOrderModels.
**Returns** True if received, else False. **Return type** bool
**148**
**Chapter 9. Models**
**Django Ledger**
## `is_received()` _→_ bool
Determines if the ItemModel instance is received. ItemModel status is only relevant for ItemModels associated with PurchaseOrderModels.
## **Returns**
True if received, else False.
**Return type**
bool
## `update_cost_estimate()`
Hook that updates and checks the ItemModel instance cost estimate fields according to its associations. Calculates and updates ce_cost_estimate accordingly. Called on every clean() call.
## `update_po_total_amount()`
Hook that updates and checks the ItemModel instance purchase order fields according to its associations. Calculates and updates po_total_amount accordingly. Called on every clean() call.
## `update_revenue_estimate()`
Hook that updates and checks the ItemModel instance revenue estimate fields according to its associations. Calculates and updates ce_revenue_estimate accordingly. Called on every clean() call.
## `update_total_amount()`
Hook that updates and checks the ItemModel instance fields according to its associations. Calculates and updates total_amount accordingly. Called on every clean() call.
## `class django_ledger.models.items.ItemTransactionModelQuerySet(` _model=None_ , _query=None_ ,
_using=None_ , _hints=None_ `)`
QuerySet class for handling ItemTransactionModel-specific database queries.
This class extends Django’s QuerySet to provide additional methods to filter and retrieve specific subsets of ItemTransactionModel entries based on various criteria such as user permissions, transaction status, or custom aggregate calculations.
`for_user(` _user_model_ `)` _→ ItemTransactionModelQuerySet_
Filters the queryset based on the provided user model.
This method restricts the queryset to items associated with the specified user. If the user is a superuser, all items in the queryset are returned. Otherwise, only items managed or administered by the user are included.
## **Parameters**
`user_model` ( _`UserModel`_ ) – The user model instance used to filter the queryset.
**Returns**
The filtered queryset containing items accessible by the given user.
**Return type**
_ItemTransactionModelQuerySet_
## `get_estimate_aggregate()` _→_ Dict[str, int]
Calculate aggregated estimates for cost, revenue, and total items.
This method computes the sum of _ce_cost_estimate_ and _ce_revenue_estimate_ for all elements in the iterable, as well as the total number of items.
## **Returns**
**A dictionary containing the following keys:**
- • ’ce_cost_estimate__sum’: The total sum of all _ce_cost_estimate_ values.
- • ’ce_revenue_estimate__sum’: The total sum of all _ce_revenue_estimate_ values.
**9.13. Item Model**
**149**
**Django Ledger**
• ’total_items’: The total count of items in the iterable.
**Return type** Dict[str, int]
`in_transit()` _→ ItemTransactionModelQuerySet_
Filters and retrieves items in the “in transit” status.
**Returns**
A queryset containing items whose status is “in transit”.
## **Return type**
_ItemTransactionModelQuerySet_
`is_ordered()` _→ ItemTransactionModelQuerySet_
Filters the queryset to include only items with the status “ORDERED”.
**Returns**
A filtered queryset containing items with the status “ORDERED”.
**Return type**
_ItemTransactionModelQuerySet_
`is_orphan()` _→ ItemTransactionModelQuerySet_
Filters the query set for items that are considered “orphan”, meaning they are not linked to any bill, purchase order, or cost estimate models.
**Returns**
A filtered query set containing only the orphan items.
**Return type**
_ItemTransactionModelQuerySet_
`is_received()` _→ ItemTransactionModelQuerySet_
Filters the queryset to include only items with the status ‘received’.
A queryset containing only the items with the status ‘received’.
**Returns Return type** _ItemTransactionModelQuerySet_
`exception django_ledger.models.items.ItemTransactionModelValidationError(` _message_ ,
_code=None_ , _params=None_ `)`
`class django_ledger.models.items.UnitOfMeasureModel(` _*args_ , _**kwargs_ `)`
Base UnitOfMeasureModel from Abstract.
```
exception DoesNotExist
```
```
exception MultipleObjectsReturned
```
`class django_ledger.models.items.UnitOfMeasureModelAbstract(` _*args_ , _**kwargs_ `)`
Base implementation of a Unit of Measure assigned to each Item Transaction.
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
**150**
**Chapter 9. Models**
**Django Ledger**
```
name
```
The name of the unit of measure. Maximum of 50 characters.
**Type** str
`unit_abbr` An abbreviation of the unit of measure used as an identifier or slug for URLs and queries.
**Type** str
```
is_active
```
A boolean representing of the UnitOfMeasureModel instance is active to be used on new transactions. **Type** bool
`entity` The EntityModel associated with the UnitOfMeasureModel instance.
**Type**
_EntityModel_
`class django_ledger.models.items.UnitOfMeasureModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined QuerySet Manager for the UnitOfMeasureModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ UnitOfMeasureModelQuerySet_ Fetches the UnitOfMeasureModels associated with the provided EntityModel and UserModel.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The EntityModel slug or EntityModel used to filter the QuerySet.
**Returns** A QuerySet with applied filters.
**Return type** QuerySet
`for_entity_active(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ UnitOfMeasureModelQuerySet_
Fetches the Active UnitOfMeasureModels associated with the provided EntityModel and UserModel.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The EntityModel slug or EntityModel used to filter the QuerySet.
**Returns** A QuerySet with applied filters.
**Return type** QuerySet
`get_queryset()` _→ UnitOfMeasureModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
`class django_ledger.models.items.UnitOfMeasureModelQuerySet(` _model=None_ , _query=None_ ,
_using=None_ , _hints=None_ `)`
**9.13. Item Model**
**151**
**Django Ledger**
## **9.14 Bill Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
This module implements the BillModel, which represents an Invoice received from a Supplier/Vendor, on which the Vendor states the amount owed by the recipient for the purposes of supplying goods and/or services. In addition to tracking the bill amount, it tracks the paid and due amount.
`class django_ledger.models.bill.BillModel(` _*args_ , _**kwargs_ `)`
Base BillModel from Abstract.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.bill.BillModelAbstract(` _*args_ , _**kwargs_ `)`
This is the main abstract class which the BillModel database will inherit from. The BillModel inherits functionality from the following MixIns:
1. 1. `LedgerWrapperMixIn`
1. 2. _`PaymentTermsMixIn`_
1. 3. _`MarkdownNotesMixIn`_
1. 4. _`CreateUpdateMixIn`_
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type**
UUID
## `bill_number`
Auto assigned number at creation by generate_bill_number() function. Prefix be customized with DJANGO_LEDGER_BILL_NUMBER_PREFIX setting. Includes a reference to the Fiscal Year and a sequence number. Max Length is 20.
**Type**
str
```
bill_status
```
Current status of the BillModel. Must be one of the choices as mentioned under “BILL_STATUS”. By default , the status will be “Draft”. Options are: Draft, In Review, Approved, Paid, Void or Canceled.
**Type**
str
## `xref`
This is the filed for capturing of any External reference number like the PO number of the buyer. Any other reference number like the Vendor code in buyer books may also be captured.
**Type**
str
```
vendor
```
This is the foreign key reference to the VendorModel from whom the purchase has been made.
**Type**
```
VendorModel
```
**152**
**Chapter 9. Models**
**Django Ledger**
## `additional_info`
Any additional metadata about the BillModel may be stored here as a dictionary object. The data is serialized and stored as a JSON document in the Database.
**Type**
dict
## `bill_items`
A foreign key reference to the list of ItemTransactionModel that make the bill amount.
```
ce_model
```
A foreign key to the BillModel associated EstimateModel for overall Job/Contract tracking.
**Type**
_EstimateModel_
```
date_draft
```
The draft date represents the date when the BillModel was first created. Defaults to `localdate` .
**Type**
date
## `date_in_review`
The in review date represents the date when the BillModel was marked as In Review status. Will be null if BillModel is canceled during draft status. Defaults to `localdate` .
**Type**
date
## `date_approved`
The approved date represents the date when the BillModel was approved. Will be null if BillModel is canceled. Defaults to `localdate` .
**Type** date
## `date_paid`
The paid date represents the date when the BillModel was paid and amount_due equals amount_paid. Will be null if BillModel is canceled. Defaults to `localdate` .
**Type** date
```
date_void
```
The void date represents the date when the BillModel was void, if applicable. Will be null unless BillModel is void. Defaults to `localdate` .
**Type**
date
```
date_canceled
```
The canceled date represents the date when the BillModel was canceled, if applicable. Will be null unless BillModel is canceled. Defaults to `localdate` .
**Type**
date
```
BILL_STATUS = [('draft', 'Draft'), ('in_review', 'In Review'), ('approved',
'Approved'), ('paid', 'Paid'), ('canceled', 'Canceled'), ('void', 'Void')]
```
The different bill status options and their representation in the Database.
**9.14. Bill Model**
**153**
**Django Ledger**
`bind_estimate(` _estimate_model_ , _commit: bool = False_ , _raise_exception: bool = True_ `)`
Binds BillModel to a given EstimateModel. Raises ValueError if EstimateModel cannot be bound.
**Parameters**
- • `estimate_model` ( `EstimateModel` ) – EstimateModel to bind.
- • `raise_exception` ( _`bool`_ ) – Raises BillModelValidationError if unable to bind EstimateModel.
- • `commit` ( _`bool`_ ) – Commits transaction into current BillModel.
`can_approve()` _→_ bool
Checks if the BillModel can be marked as Approved.
**Returns** True if BillModel can be marked as approved, else False.
**Return type** bool
`can_bind_estimate(` _estimate_model_ , _raise_exception: bool = False_ `)` _→_ bool Checks if the BillModel can be bound to a given EstimateModel.
**Parameters**
- • `estimate_model` ( `EstimateModel` ) – EstimateModel to check against.
- • `raise_exception` ( _`bool`_ ) – If True, raises BillModelValidationError if unable to bind. Else, returns False.
**Returns** True if can bind provided EstimateModel, else False.
**Return type** bool
`can_bind_po(` _po_model_ , _raise_exception: bool = False_ `)` _→_ bool
Checks if the BillModel can be bound to a given PurchaseOrderModel.
**Parameters**
- • `po_model` ( `PurchaseOrderModel` ) – The PurchaseOrderModel to check against.
- • `raise_exception` ( _`bool`_ ) – If True, raises BillModelValidationError if unable to bind, else False.
**Returns** True if can bind provided PurchaseOderModel, else False.
**Return type** bool
`can_cancel()` _→_ bool
Checks if the BillModel can be marked as Canceled status.
**Returns**
True if BillModel can be marked as canceled, else False.
**Return type** bool
**154**
**Chapter 9. Models**
**Django Ledger**
`can_delete()` _→_ bool
Checks if the BillModel can be deleted.
**Returns** True if BillModel can be deleted, else False.
**Return type** bool
`can_draft()` _→_ bool
Checks if the BillModel can be marked as Draft.
**Returns**
True if BillModel can be marked as draft, else False.
**Return type** bool
`can_edit_items()` _→_ bool
Checks if the BillModel item transactions can be edited.
**Returns**
True if BillModel items can be edited, else False.
**Return type** bool
`can_generate_bill_number()` _→_ bool
Checks if BillModel can generate its Document Number.
**Returns**
True if BillModel can generate its bill_number, else False.
**Return type** bool
`can_make_payment()` _→_ bool
Checks if the BillModel can accept a payment.
**Returns** True if can bind provided PurchaseOderModel, else False. **Return type** bool
`can_migrate()` _→_ bool
Checks if the BillModel can be migrated.
**Returns** True if BillModel can be migrated, else False. **Return type** bool
`can_migrate_itemtxs()` _→_ bool
Checks if item transaction list can be migrated.
**Return type** bool
**9.14. Bill Model**
**155**
**Django Ledger**
## `can_pay()` _→_ bool
Checks if the BillModel can be marked as Paid.
**Returns**
True if BillModel can be marked as paid, else False.
**Return type**
bool
`can_review()` _→_ bool
Checks if the BillModel can be marked as In Review.
**Returns**
True if BillModel can be marked as in review, else False.
**Return type**
bool
`can_void()` _→_ bool
Checks if the BillModel can be marked as Void status.
**Returns**
True if BillModel can be marked as void, else False.
**Return type**
bool
`clean(` _commit: bool = True_ `)`
Clean method for BillModel. Results in a DB query if bill number has not been generated and the BillModel is eligible to generate a bill_number.
## **Parameters**
`commit` ( _`bool`_ ) – If True, commits into DB the generated BillModel number if generated.
`configure(` _entity_slug: str |_ EntityModel, _user_model: User | None = None_ , _date_draft: datetime | date | None = None_ , _ledger_posted: bool = False_ , _ledger_name: str = None_ , _commit: bool = False_ , _commit_ledger: bool = False_ `)`
A configuration hook which executes all initial BillModel setup on to the LedgerModel and all initial values of the BillModel. Can only call this method once in the lifetime of a BillModel.
## **Parameters**
- • `date_draft` ( _`date`_ ) – Optional date to use as Draft Date. Defaults to localdate() if None.
- • `entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel to associate the Bill with.
- • `user_model` ( _`UserModel`_ ) – The UserModel making the request to check for QuerySet permissions.
- • `ledger_posted` ( _`bool`_ ) – An option to mark the BillModel Ledger as posted at the time of configuration. Defaults to False.
- • `ledger_name` ( _`str`_ ) – Optional additional InvoiceModel ledger name or description.
- • `commit` ( _`bool`_ ) – Saves the current BillModel after being configured.
- • `commit_ledger` ( _`bool`_ ) – Saves the BillModel’s LedgerModel while being configured.
## **Return type**
A tuple of _LedgerModel_ , _BillModel_
**156**
**Chapter 9. Models**
**Django Ledger**
`generate_bill_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next BillModel document number available. The operation will result in two additional queries if the BillModel & LedgerModel is not cached in QuerySet via select_related(‘ledger’).
**Parameters**
`commit` ( _`bool`_ ) – Commits transaction into BillModel.
**Returns** A String, representing the generated BillModel instance Document Number. **Return type** str
`get_document_id()` _→_ str | None
Human-readable document number. Defaults to bill_number.
**Returns** Document Number as a String. **Return type** str
`get_html_amount_due_id()` _→_ str Unique amount due HTML ID. **Returns** HTML ID as a String. **Return type** str
`get_html_amount_paid_id()` _→_ str Unique amount paid HTML ID **Returns** HTML ID as a String. **Return type** str
`get_html_form_id()` _→_ str Unique BillModel Form HTML ID. **Returns** HTML ID as a String. **Return type** str
`get_html_id()` _→_ str Unique BillNumber HTML ID. **Returns** HTML ID as a String. **Return type** str
`get_item_model_qs()` _→ ItemModelQuerySet_
Fetches the ItemModelQuerySet eligible to itemize.
**9.14. Bill Model**
**157**
**Django Ledger**
## **Return type**
_ItemModelQuerySet_
`get_itemtxs_data(` _queryset:_ ItemTransactionModelQuerySet _| None = None_ , _aggregate_on_db: bool = False_ , _lazy_agg: bool = False_ `)` _→_ Tuple[ _ItemTransactionModelQuerySet_ , Dict]
Fetches the BillModel Items and aggregates the QuerySet.
**Parameters**
- • `queryset` – Optional pre-fetched ItemModelQueryset to use. Avoids additional DB query if provided.
- • `aggregate_on_db` ( _`bool`_ ) – If True, performs aggregation of ItemsTransactions in the DB resulting in one additional DB query.
**Returns A tuple**
**Return type** _ItemTransactionModelQuerySet_ , dict
`get_mark_as_approved_html_id()` _→_ str
BillModel Mark as Approved HTML ID.
**Returns** HTML ID as a String.
**Return type** str
`get_mark_as_approved_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns** Mark-as-Approved BillModel confirmation message as a String.
**Return type** str
`get_mark_as_approved_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Approved action URL.
**Parameters** `entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** BillModel mark-as-approved action URL. **Return type** str
`get_mark_as_canceled_html_id()` _→_ str
BillModel Mark as Canceled HTML ID Tag.
**Returns** HTML ID as a String.
**Return type** str
**158**
**Chapter 9. Models**
**Django Ledger**
`get_mark_as_canceled_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns**
Mark-as-Canceled BillModel confirmation message as a String.
**Return type**
str
`get_mark_as_canceled_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Canceled action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** BillModel mark-as-canceled action URL.
**Return type** str
`get_mark_as_draft_html_id()` _→_ str
BillModel Mark as Draft HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
`get_mark_as_draft_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns**
Mark-as-Draft BillModel confirmation message as a String.
**Return type** str
`get_mark_as_draft_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Draft action URL.
**Parameters** `entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** HTML ID as a String **Return type** str
`get_mark_as_paid_html_id()` _→_ str
BillModel Mark as Paid HTML ID Tag.
**Returns** HTML ID as a String **Return type** str
**9.14. Bill Model**
**159**
**Django Ledger**
`get_mark_as_paid_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns**
Mark-as-Paid BillModel confirmation message as a String.
**Return type** str
`get_mark_as_paid_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Paid action URL.
**Parameters** `entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** BillModel mark-as-paid action URL. **Return type** str
`get_mark_as_review_html_id()` _→_ str
BillModel Mark as In Review HTML ID Tag.
**Returns** HTML ID as a String. **Return type** str
`get_mark_as_review_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns** Mark-as-Review BillModel confirmation message as a String. **Return type** str
`get_mark_as_review_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Review action URL.
**Parameters** `entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet. **Returns** BillModel mark-as-review action URL. **Return type** str
`get_mark_as_void_html_id()` _→_ str
BillModel Mark as Void HTML ID Tag. **Returns** HTML ID as a String. **Return type** str
**160**
**Chapter 9. Models**
**Django Ledger**
`get_mark_as_void_message()` _→_ str
Internationalized confirmation message with Bill Number.
**Returns** Mark-as-Void BillModel confirmation message as a String.
**Return type** str
`get_mark_as_void_url(` _entity_slug: str | None = None_ `)` _→_ str
BillModel Mark-as-Void action URL.
**Parameters** `entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Return type** BillModel mark-as-void action URL.
`get_migrate_state_desc()` _→_ str
Description used when migrating transactions into the LedgerModel.
**Returns** Description as a string.
**Return type**
str
`get_migration_data(` _queryset:_ ItemTransactionModelQuerySet _| None = None_ `)` _→_
_ItemTransactionModelQuerySet_
Fetches necessary item transaction data to perform a migration into the LedgerModel.
**Parameters**
`queryset` ( `ItemTransactionModelQuerySet` ) – Optional pre-fetched ItemModelTransactionQueryset to use. Avoids additional DB query if provided.
`get_status_action_date()` _→_ date
Current status action date.
**Returns** A date. i.e. If status is Approved, return date_approved. If Paid, return date_paid. **Return type** date
`get_terms_start_date()` _→_ date | None Date where BillModel term start to apply.
**Returns** A date which represents the start of BillModel terms.
**Return type** date
`get_transaction_queryset(` _annotated: bool = False_ `)`
Fetches the TransactionModelQuerySet associated with the BillModel instance.
```
is_active()
```
Checks if the BillModel has the potential to impact the books and produce financial statements status.
**Returns**
True if BillModel is Active, else False.
**9.14. Bill Model**
**161**
**Django Ledger**
**Return type**
bool
`is_approved()` _→_ bool Checks if the BillModel is in Approved status.
**Returns** True if BillModel is Approved, else False.
**Return type** bool
`is_canceled()` _→_ bool
Checks if the BillModel is in Canceled status.
**Returns** True if BillModel is Canceled, else False.
**Return type** bool
`is_configured()` _→_ bool Determines if the accruable financial instrument is properly configured.
**Returns** True if configured, else False.
**Return type** bool
`is_draft()` _→_ bool Checks if the BillModel is in Draft status. **Returns** True if BillModel is Draft, else False. **Return type** bool
`is_paid()` _→_ bool Checks if the BillModel is in Paid status. **Returns** True if BillModel is Paid, else False. **Return type** bool
`is_past_due()` _→_ bool Checks if the BillModel is past due. **Returns** True if BillModel is past due, else False. **Return type** bool
`is_review()` _→_ bool Checks if the BillModel is In Review status.
**Returns**
True if BillModel is in Review, else False.
**162**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
## bool
`is_void()` _→_ bool
Checks if the BillModel is in Void status.
## **Returns**
True if BillModel is Void, else False.
## **Return type**
bool
`make_payment(` _payment_amount: Decimal | float | int_ , _payment_date: datetime | date | None = None_ , _commit: bool = False_ , _raise_exception: bool = True_ `)`
Makes a payment to the BillModel.
**Parameters**
- • `payment_amount` ( _`Decimal ot float`_ ) – The payment amount to process.
- • `payment_date` ( _`datetime or date.`_ ) – Date or timestamp of the payment being applied.
- • `commit` ( _`bool`_ ) – If True, commits the transaction into the DB. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – If True, raises BillModelValidationError if payment exceeds amount due, else False.
## **Returns**
True if can make payment, else False.
## **Return type**
bool
`mark_as_approved(` _user_model_ , _entity_slug: str | None = None_ , _date_approved: datetime | date | None = None_ , _commit: bool = False_ , _force_migrate: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks BillModel as Approved.
**Parameters**
- • `entity_slug` – Entity slug associated with the BillModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_approved` ( _`date`_ ) – BillModel approved date. Defaults to localdate().
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
- • `force_migrate` ( _`bool`_ ) – Forces migration. True if Accounting Method is Accrual.
`mark_as_canceled(` _date_canceled: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Mark BillModel as Canceled.
**Parameters**
- • `date_canceled` ( _`date`_ ) – BillModel canceled date. Defaults to localdate() if None.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_draft(` _date_draft: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks BillModel as Draft.
**Parameters**
**9.14. Bill Model**
**163**
**Django Ledger**
- • `date_draft` ( _`date`_ ) – Draft date. If None, defaults to localdate().
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_paid(` _user_model_ , _entity_slug: str | None = None_ , _date_paid: datetime | date | None = None_ , _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks BillModel as Paid.
**Parameters**
- • `entity_slug` ( _`str`_ ) – Entity slug associated with the BillModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_paid` ( _`date`_ ) – BillModel paid date. Defaults to localdate() if None.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Pre-fetched ItemTransactionModelQuerySet. Avoids additional DB query. Validated if passed.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_review(` _commit: bool = False_ , _itemtxs_qs:_ ItemTransactionModelQuerySet _= None_ , _date_in_review: date | None = None_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks BillModel as In Review.
## **Parameters**
- • `date_in_review` ( _`date`_ ) – BillModel in review date. Defaults to localdate() if None.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Pre fetched ItemTransactionModelQuerySet to use. Avoids additional DB Query if previously fetched.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises BillModelValidationError if BillModel cannot be marked as in review. Defaults to True.
- `mark_as_void(` _user_model_ , _entity_slug: str | None = None_ , _date_void: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks BillModel as Void. When mark as void, all transactions associated with BillModel are reversed as of the void date.
## **Parameters**
- • `entity_slug` ( _`str`_ ) – Entity slug associated with the BillModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_void` ( _`date`_ ) – BillModel void date. Defaults to localdate() if None.
- • `commit` ( _`bool`_ ) – Commits transaction into DB. Defaults to False.
`migrate_itemtxs(` _itemtxs: Dict_ , _operation: str_ , _commit: bool = False_ `)`
Migrates a predefined item transaction list.
- **Parameters**
- • `itemtxs` ( _`dict`_ ) – A dictionary where keys are the document number (invoice/bill number, etc) and values are a dictionary:
- • `operation` ( _`str`_ ) – A choice of ITEMIZE_REPLACE, ITEMIZE_APPEND, ITEMIZE_UPDATE
**164**
**Chapter 9. Models**
**Django Ledger**
• `commit` ( _`bool`_ ) – If True, commits transaction into the DB. Default to False
**Returns** A list of ItemTransactionModel appended or created.
**Return type** list
`update_amount_due(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _] | None = None_ `)` _→ ItemTransactionModelQuerySet_
Updates the BillModel amount due.
**Parameters** `itemtxs_qs` ( `ItemTransactionModelQuerySet` _`or list of`_ `ItemTransactionModel` ) – Optional pre-fetched ItemTransactionModelQuerySet. Avoids additional DB if provided. Queryset is validated if provided.
**Returns**
Newly fetched of previously fetched ItemTransactionModelQuerySet if provided.
**Return type** _ItemTransactionModelQuerySet_
`validate_itemtxs_qs(` _queryset:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _]_ `)`
Validates that the entire ItemTransactionModelQuerySet is bound to the BillModel.
**Parameters** `queryset` ( `ItemTransactionModelQuerySet` _`or list of ItemTransactionModel.`_ ) – ItemTransactionModelQuerySet to validate.
`class django_ledger.models.bill.BillModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined BillModelManager that will act as an interface to handling the initial DB queries to the BillModel. The default “get_queryset” has been overridden to refer the custom defined “BillModelQuerySet”.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ BillModelQuerySet_
Fetches a QuerySet of BillModels associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
**Returns**
Returns a BillModelQuerySet with applied filters.
**Return type** _BillModelQuerySet_
`get_queryset()` _→ BillModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
## `class django_ledger.models.bill.BillModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
A custom defined QuerySet for the BillModel. This implements multiple methods or queries needed to get a filtered QuerySet based on the BillModel status. For example, we might want to have list of bills which are paid, unpaid, due ,overdue, approved or in draft stage. All these separate functions will assist in making such queries and building customized reports.
**9.14. Bill Model**
**165**
**Django Ledger**
## `active()`
Active bills are those that are approved or paid, which have impacted or have the potential to impact the Entity’s Ledgers.
**Returns** Returns a QuerySet of active bills only.
**Return type** _BillModelQuerySet_
## `approved()`
Approved bills are those that have been reviewed and are expected to be paid before the due date.
**Returns**
Returns a QuerySet of approved bills only.
**Return type** _BillModelQuerySet_
## `canceled()`
Canceled bills are those that are discarded during the draft or in review status. These bills never had an impact on the books.
**Returns**
Returns a QuerySet of canceled bills only.
**Return type**
_BillModelQuerySet_
## `draft()`
Default status of any bill that is created. Draft bills do not impact the Ledger.
**Returns** Returns a QuerySet of draft bills only.
**Return type** _BillModelQuerySet_
`for_user(` _user_model_ `)` _→ BillModelQuerySet_
Fetches a QuerySet of BillModels that the UserModel as access to. May include BillModels from multiple Entities.
**The user has access to bills if:**
1. Is listed as Manager of Entity.
- 2. Is the Admin of the Entity.
**Parameters**
`user_model` – Logged in and authenticated django UserModel instance.
**Returns** Returns a BillModelQuerySet with applied filters.
**Return type** _BillModelQuerySet_
## `in_review()`
In review bills are those that need additional review or approvals before being approved. In review bills do not impact the Ledger.
**166**
**Chapter 9. Models**
**Django Ledger**
**Returns**
Returns a QuerySet of bills in review only.
**Return type** _BillModelQuerySet_
```
overdue()
```
Overdue bills are those which due date is in the past.
**Returns** Returns a QuerySet of overdue bills only. **Return type** _BillModelQuerySet_
## `paid()`
Paid bills are those that have received 100% of the amount due.
**Returns** Returns a QuerySet of paid bills only.
**Return type** _BillModelQuerySet_ `unpaid()` _→ BillModelQuerySet_ Unpaid bills are those that are approved but have not received 100% of the amount due. Equivalent to approved(). **Returns** Returns a QuerySet of paid bills only.
**Return type** _BillModelQuerySet_
## `void()`
Void bills are those that where rolled back after being approved. Void bills rollback all transactions by creating a new set of transactions posted on the date_void.
**Returns** Returns a QuerySet of void bills only. **Return type** _BillModelQuerySet_
`exception django_ledger.models.bill.BillModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.15 Estimate Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
The EstimateModel provides the means to estimate customer requests, jobs or quotes that may ultimately be considered contracts, if approved. The EstimateModels will estimate revenues and costs associated with a specific scope of work which is documented using ItemTransactionModels.
Once approved, the user may initiate purchase orders, bills and invoices that will be associated with the EstimateModel for tracking purposes. It is however not required to always have an EstimateModel, but recommended in order to be able to produce more specific financial reports associated with a specific scope of work.
**9.15. Estimate Model**
**167**
**Django Ledger**
- `class django_ledger.models.estimate.EstimateModel(` _*args_ , _**kwargs_ `)`
Base EstimateModel Class.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.estimate.EstimateModelAbstract(` _*args_ , _**kwargs_ `)`
This is the main abstract class which the EstimateModel database will inherit from. The EstimateModel inherits functionality from the following MixIns:
1. _`MarkdownNotesMixIn`_
2. _`CreateUpdateMixIn`_
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
## `estimate_number`
Auto assigned number at creation by generate_estimate_number() function. Prefix be customized with DJANGO_LEDGER_ESTIMATE_NUMBER_PREFIX setting. Includes a reference to the Fiscal Year and a sequence number. Max Length is 20.
**Type** str
```
entity
```
The EntityModel associated with te EntityModel instance.
**Type** _EntityModel_
```
customer
```
The CustomerModel associated with the EstimateModel instance.
**Type** _CustomerModel_
`title` A string representing the name or title of the EstimateModel instance.
**Type** str
```
status
```
The status of the EstimateModel instance. Must be one of Draft, In Review, Approved, Completed Void or Canceled.
**Type** str
```
terms
```
The contract terms that will be associated with this EstimateModel instance. Choices are Fixed Price, Target Price, Time & Materials and Other.
**Type**
str
**168**
**Chapter 9. Models**
**Django Ledger**
## `date_draft`
The draft date represents the date when the EstimateModel was first created. Defaults to `localdate` .
**Type** date
## `date_in_review`
The in review date represents the date when the EstimateModel was marked as In Review status. Will be null if EstimateModel is canceled during draft status. Defaults to `localdate` .
**Type**
date
```
date_approved
```
The approved date represents the date when the EstimateModel was approved. Will be null if EstimateModel is canceled. Defaults to `localdate` .
**Type**
date
## `date_completed`
The paid date represents the date when the EstimateModel was completed and fulfilled. Will be null if EstimateModel is canceled. Defaults to `localdate` .
**Type** date
## `date_void`
The void date represents the date when the EstimateModel was void, if applicable. Will be null unless EstimateModel is void. Defaults to `localdate` .
**Type**
date
## `date_canceled`
The canceled date represents the date when the EstimateModel was canceled, if applicable. Will be null unless EstimateModel is canceled. Defaults to `localdate` .
**Type**
date
## `revenue_estimate`
The total estimated revenue of the EstimateModel instance.
**Type**
Decimal
```
labor_estimate
```
The total labor costs estimate of the EstimateModel instance.
**Type**
Decimal
```
material_estimate
```
The total material costs estimate of the EstimateModel instance.
**Type** Decimal
**9.15. Estimate Model**
**169**
**Django Ledger**
`equipment_estimate` The total equipment costs estimate of the EstimateModel instance. **Type** Decimal `other_estimate` the total miscellaneous costs estimate of the EstimateModel instance. **Type** Decimal `can_approve()` Determines if the EstimateModel can be marked as approved. **Returns** True if EstimateModel can be marked as approved, else False. **Return type** bool `can_bind()` Determines if the EstimateModel can be bound to a set of POs, Bills or Invoices. **Returns** True if EstimateModel can be bound, else False. **Return type** bool `can_cancel()` Determines if the EstimateModel can be marked as canceled. **Returns** True if EstimateModel can be marked as canceled, else False. **Return type** bool `can_complete()` Determines if the EstimateModel can be marked as completed. **Returns** True if EstimateModel can be marked as completed, else False. **Return type** bool `can_draft()` _→_ bool Determines if the EstimateModel can be marked as Draft. **Returns** True if EstimateModel can be marked as draft, else False. **Return type** bool `can_generate_estimate_number()` Determines if the EstimateModel can generate its own estimate number..
**Returns** True if EstimateModel can generate the estimate number, else False.
**170**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
## bool
## `can_migrate_itemtxs()` _→_ bool
Checks if item transaction list can be migrated.
**Return type**
bool
```
can_review()
```
Determines if the EstimateModel can be marked as In Review.
**Returns**
True if EstimateModel can be marked as In Review, else False.
**Return type** bool
## `can_update_items()`
Determines if the EstimateModel item transactions can be edited or changed.
**Returns**
True if EstimateModel item transactions can be edited or changed, else False.
**Return type**
bool
## `can_void()`
Determines if the EstimateModel can be marked as void.
**Returns**
True if EstimateModel can be marked as void, else False.
**Return type**
bool
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`configure(` _entity_slug:_ EntityModel _| UUID | str_ , _customer_model:_ CustomerModel, _user_model: User | None = None_ , _date_draft: date | None = None_ , _estimate_title: str | None = None_ , _commit: bool = False_ , _raise_exception: bool = True_ `)`
A configuration hook which executes all initial EstimateModel setup. Can only call this method once in the lifetime of a EstimateModel.
## **Parameters**
- • `entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel to associate the Bill with.
- • `user_model` – The UserModel making the request to check for QuerySet permissions.
- • `date_draft` ( _`date`_ ) – The draft date to use. If None defaults to localdate().
- • `customer_model` ( `CustomerModel` ) – The CustomerModel to be associated with this EstimateModel instance.
- • `commit` ( _`bool`_ ) – Saves the current EstimateModel after being configured.
- • `estimate_title` ( _`str`_ ) – Optional EstimateModel title.
**9.15. Estimate Model**
**171**
**Django Ledger**
- • `raise_exception` ( _`bool`_ ) – If True, raises EstimateModelValidationError when model is already configured.
## **Returns**
The configured EstimateModel instance.
**Return type**
_EstimateModel_
`generate_estimate_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next EstimateModel document number available. The operation will result in two additional queries if the EntityModel is not cached in QuerySet via select_related(‘entity’).
**Parameters** `commit` ( _`bool`_ ) – Commits transaction into BillModel.
**Returns** A String, representing the generated BillModel instance Document Number.
## **Return type**
str
`get_contract_summary(` _po_qs:_ PurchaseOrderModelQuerySet _| None = None_ , _bill_qs:_ BillModelQuerySet _| None = None_ , _invoice_qs:_ InvoiceModelQuerySet _| None = None_ `)` _→_ dict Computes an aggregate of all related ItemTransactionModels summarizing original contract amounts, amounts authorized, amounts billed and amount invoiced.
**Parameters**
- • `po_qs` ( `PurchaseOrderModelQuerySet` ) – Prefetched PurchaseOrderModelQuerySet. If provided will be validated.
- • `bill_qs` ( `BillModelQuerySet` ) – Prefetched BillModelQuerySet. If provided will be validated.
- • `invoice_qs` ( `InvoiceModelQuerySet` ) – Prefetched InvoiceModelQuerySet. If provided will be validated.
## **Returns**
A dictionary of aggregated values.
**Return type**
dict
`get_cost_estimate(` _as_float: bool = False_ `)` _→_ float | Decimal
Calculates the total EstimateModel cost by summing all individual cost components: Labor, Material, Equipment & Other costs.
**Parameters**
`as_float` ( _`bool`_ ) – If True, will return value as float, else as Decimal.
**Returns** The total EstimateModel cost.
**Return type** Decimal or float
`get_gross_margin_estimate(` _as_percent: bool = False_ , _raise_exception: bool = False_ `)` _→_ float Computes the EstimateModel gross margin.
**Parameters**
• `as_percent` ( _`bool`_ ) – If True, computes gross margin as percent.
**172**
**Chapter 9. Models**
**Django Ledger**
• `raise_exception` ( _`bool`_ )
**Returns** The EstimateModel gross margin.
**Return type** float
`get_item_model_qs()` _→ ItemModelQuerySet_
Fetches the ItemModelQuerySet eligible to itemize.
**Return type**
_ItemModelQuerySet_
`get_itemtxs_annotation(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ `)`
Gets an annotated ItemTransactionModelQuerySet with additional average unit cost & revenue.
**Parameters**
`itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Prefetched ItemTransactionModelQuerySet if any. If None a new queryset will be evaluated. Will be validated if provided.
**Returns** The original ItemTransactionModelQuerySet and the annotated ItemTransactionModelQuerySet.
**Return type** tuple
`get_itemtxs_data(` _queryset:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _] | None = None_ , _aggregate_on_db: bool = False_ , _lazy_agg: bool = False_ `)`
Returns all ItemTransactionModels associated with the EstimateModel and a total aggregate.
**Parameters**
`queryset` ( `ItemTransactionModelQuerySet` ) – ItemTransactionModelQuerySet to use. Avoids additional DB query if provided. Validated if provided.
**Return type**
_ItemTransactionModelQuerySet_
## `get_mark_as_approved_html_id()`
EstimateModel Mark as Approved HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
```
get_mark_as_approved_message()
```
EstimateModel Mark as Approved Message.
**Returns** Message as a String
**Return type** str
## `get_mark_as_approved_url()`
EstimateModel Mark as Approved URL.
**Returns** URL as a String
**9.15. Estimate Model**
**173**
**Django Ledger**
**Return type** str
`get_mark_as_canceled_html_id()` EstimateModel Mark as Canceled HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
## `get_mark_as_canceled_message()`
EstimateModel Mark as Canceled Message.
**Returns** Message as a String
**Return type** str
## `get_mark_as_canceled_url()`
EstimateModel Mark as Canceled URL.
**Returns** URL as a String
**Return type** str
## `get_mark_as_completed_html_id()`
EstimateModel Mark as Complete HTML ID Tag.
**Returns** HTML ID as a String **Return type** str
```
get_mark_as_completed_message()
```
EstimateModel Mark as Completed Message.
**Returns** Message as a String **Return type** str
`get_mark_as_completed_url()` EstimateModel Mark as Completed URL. **Returns** URL as a String **Return type** str
```
get_mark_as_draft_html_id()
```
EstimateModel Mark as Draft HTML ID Tag.
**Returns** HTML ID as a String
**174**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
str
```
get_mark_as_draft_message()
```
EstimateModel Mark as Draft Message.
**Returns** Message as a String
**Return type** str
## `get_mark_as_draft_url()`
EstimateModel Mark as Draft URL.
**Returns** URL as a String
**Return type** str
## `get_mark_as_review_html_id()`
EstimateModel Mark as Review HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
## `get_mark_as_review_message()`
EstimateModel Mark as In Review Message.
**Returns** Message as a String
**Return type** str
## `get_mark_as_review_url()`
EstimateModel Mark as In Review URL.
**Returns** URL as a String
**Return type**
str
```
get_mark_as_void_html_id()
```
EstimateModel Mark as Void HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
`get_mark_as_void_message()` EstimateModel Mark as Void message.
**Returns** Message as a String
**9.15. Estimate Model**
**175**
**Django Ledger**
## **Return type**
str
```
get_mark_as_void_url()
```
EstimateModel Mark as Void URL.
**Returns**
URL as a String
**Return type**
str
`get_profit_estimate(` _as_float: bool = False_ `)`
Calculates the total EstimateModel profit estimate.
**Parameters**
`as_float` ( _`bool`_ ) – If True, will return value as float, else as Decimal.
**Returns**
The total EstimateModel profit.
**Return type** Decimal or float
`get_revenue_estimate(` _as_float: bool = False_ `)`
Calculates the total EstimateModel revenue.
**Parameters**
`as_float` ( _`bool`_ ) – If True, will return value as float, else as Decimal.
**Returns**
The total EstimateModel revenue.
**Return type**
Decimal or float
`get_status_action_date()` _→_ date
The date when the latest status took place.
## **Examples**
If EstimateModel is Draft, will return date_draft. If EstimateModel is In Review, will return date_in_review. If EstimateModel is Approved, will return date_approved.
**Returns**
The latest action date.
**Return type**
date
`is_approved()` _→_ bool
Determines if the EstimateModel is in Approved status.
**Returns**
True if EstimateModel is in Approved status, else False.
**Return type**
bool
`is_canceled()` _→_ bool
Determines if the EstimateModel is in Canceled status.
**176**
**Chapter 9. Models**
**Django Ledger**
**Returns** True if EstimateModel is in Canceled status, else False. **Return type** bool `is_completed()` _→_ bool Determines if the EstimateModel is in Completed status. **Returns** True if EstimateModel is in Completed status, else False. **Return type** bool `is_configured()` _→_ bool Determines if the EstimateModel is configured. **Returns** True if EstimateModel is configured, else False. **Return type** bool `is_contract()` Determines if the EstimateModel is considered a Contract. **Returns** True if EstimateModel is a Contract, else False. **Return type** bool `is_draft()` _→_ bool Determines if the EstimateModel is in Draft status. **Returns** True if EstimateModel is in Draft status, else False. **Return type** bool `is_review()` _→_ bool Determines if the EstimateModel is In Review status. **Returns** True if EstimateModel is In Review status, else False. **Return type** bool `is_void()` Determines if the EstimateModel is in Void status. **Returns** True if EstimateModel is in Void status, else False. **Return type** bool
**9.15. Estimate Model**
**177**
**Django Ledger**
`mark_as_approved(` _commit=False_ , _date_approved: date | None = None_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as Approved.
- **Parameters**
- • `commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
- • `date_approved` ( _`date`_ ) – Optional date when EstimateModel instance is Approved. Defaults to localdate().
`mark_as_canceled(` _commit: bool = False_ , _date_canceled: date | None = None_ , _raise_exception: bool =_
_True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as Canceled.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
- • `date_canceled` ( _`date`_ ) – Optional date when EstimateModel instance is canceled. Defaults to localdate().
`mark_as_completed(` _commit=False_ , _date_completed: date | None = None_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as Completed.
- **Parameters**
- • `commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
- • `date_completed` ( _`date`_ ) – Optional date when EstimateModel instance is completed. Defaults to localdate().
`mark_as_draft(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as Draft.
## **Parameters**
`commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
`mark_as_review(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ , _date_in_review: date | None = None_ , _raise_exception: bool = True_ , _commit: bool = True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as In Review.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Optional, pre-fetched ItemTransactionModelQuerySet. Avoids additional DB query. Validated if provided.
- • `date_in_review` ( _`date`_ ) – Optional date when EstimateModel instance is In Review. Defaults to localdate().
- `mark_as_void(` _commit: bool = False_ , _date_void: date | None = None_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks the current EstimateModel instance as Void.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits transaction into current EstimateModel instance.
- • `date_void` ( _`date`_ ) – Optional date when EstimateModel instance is void. Defaults to localdate().
**178**
**Chapter 9. Models**
**Django Ledger**
`migrate_itemtxs(` _itemtxs: Dict_ , _operation: str_ , _commit: bool = False_ `)`
Migrates a predefined item transaction list.
**Parameters**
- • `itemtxs` ( _`dict`_ ) – A dictionary where keys are the document number (invoice/bill number, etc) and values are a dictionary:
- • `operation` ( _`str`_ ) – A choice of ITEMIZE_REPLACE, ITEMIZE_APPEND, ITEMIZE_UPDATE
- • `commit` ( _`bool`_ ) – If True, commits transaction into the DB. Default to False
**Returns**
A list of ItemTransactionModel appended or created.
**Return type**
list
`save(` _**kwargs_ `)`
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
`update_cost_estimate(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ , _commit: bool = False_ `)` Updates the cost estimate of the EstimateModel instance.
**Parameters**
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Prefetched ItemTransactionModelQuerySet. A new ItemTransactionModelQuerySet will be fetched from DB if not provided. If provided will be validated.
- • `commit` ( _`bool`_ ) – If True, the new revenue estimate will be committed into the DB.
`update_revenue_estimate(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ , _commit: bool =_
_False_ `)`
Updates the revenue estimate of the EstimateModel instance.
**Parameters**
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Prefetched ItemTransactionModelQuerySet. A new ItemTransactionModelQuerySet will be fetched from DB if not provided. If provided will be validated.
- • `commit` ( _`bool`_ ) – If True, the new revenue estimate will be committed into the DB.
- `validate_bill_queryset(` _bill_qs:_ BillModelQuerySet `)` _→ BillModelQuerySet_
Validates a prefetched BillModelQuerySet against the EstimateModel instance.
**Parameters**
`bill_qs` ( `BillModelQuerySet` ) – The BillModelQuerySet to validate
**Returns**
The validated BillModelQuerySet.
**Return type**
_BillModelQuerySet_
`validate_invoice_queryset(` _invoice_qs:_ InvoiceModelQuerySet `)` _→ InvoiceModelQuerySet_
Validates a prefetched InvoiceModelQuerySet against the EstimateModel instance.
**9.15. Estimate Model**
**179**
**Django Ledger**
**Parameters**
`invoice_qs` ( `InvoiceModelQuerySet` ) – The InvoiceModelQuerySet to validate
**Returns**
The validated InvoiceModelQuerySet.
**Return type**
_InvoiceModelQuerySet_
`validate_item_transaction_qs(` _itemtxs_qs:_ ItemTransactionModelQuerySet _|_
_List[_ ItemTransactionModel _]_ `)`
Validates that the entire ItemTransactionModelQuerySet is bound to the BillModel.
**Parameters**
`itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – ItemTransactionModelQuerySet to validate.
`validate_itemtxs_qs(` _queryset:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _]_ `)`
Validates that the entire ItemTransactionModelQuerySet is bound to the EstimateModel.
**Parameters**
`queryset` ( `ItemTransactionModelQuerySet` _`or list of`_
_`ItemTransactionModel.`_ ) – ItemTransactionModelQuerySet to validate.
`validate_po_queryset(` _po_qs:_ PurchaseOrderModelQuerySet `)` _→ PurchaseOrderModelQuerySet_
Validates a prefetched PurchaseOrderModelQuerySet against the EstimateModel instance.
**Parameters**
`po_qs` ( `PurchaseOrderModelQuerySet` ) – The PurchaseOrderModelQuerySet to validate
**Returns**
The validated PurchaseOrderModelQuerySet.
**Return type**
_PurchaseOrderModelQuerySet_
`class django_ledger.models.estimate.EstimateModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined EstimateModelManager that that implements custom QuerySet methods related to the EstimateModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ EstimateModelQuerySet_
Filters the queryset based on the given entity model.
This method allows filtering the queryset by an _entity_model_ parameter, which can be of type _EntityModel_ , _str_ , or _UUID_ . It also handles deprecated behavior if _user_model_ is passed in the _kwargs_ .
**Parameters**
- • `entity_model` ( `EntityModel` _`, str, UUID`_ ) – Specifies the entity against which the queryset should be filtered. Accepts an _EntityModel_ instance, a string (representing the entity slug), or a UUID (representing the entity ID).
- • `**kwargs` – Additional keyword arguments. Supports a deprecated _user_model_ argument for backward compatibility.
**Returns**
A Django QuerySet filtered according to the given entity model.
**Return type**
QuerySet
**180**
**Chapter 9. Models**
**Django Ledger**
## **Raises**
_`EstimateModelValidationError`_ – If _entity_model_ is of an unsupported type.
`class django_ledger.models.estimate.EstimateModelQuerySet(` _model=None_ , _query=None_ , _using=None_ , _hints=None_ `)`
A custom-defined LedgerModelManager that implements custom QuerySet methods related to the EstimateModel.
```
approved()
```
Approved Estimates or Sales Orders are those that have been approved or completed.
**Returns** A EstimateModelQuerySet with applied filters.
**Return type** _EstimateModelQuerySet_
```
contracts()
```
A contract are Estimates or Sales Orders are those that have been approved or completed.
**Returns** A EstimateModelQuerySet with applied filters. Equivalent to approve. **Return type** _EstimateModelQuerySet_
```
estimates()
```
Estimates or Sales Orders are those that have not been approved or completed.
**Returns** A EstimateModelQuerySet with applied filters. Equivalent to not approved.
**Return type** _EstimateModelQuerySet_
```
not_approved()
```
Not approved Estimates or Sales Orders are those that have not been approved or completed.
**Returns** A EstimateModelQuerySet with applied filters.
**Return type** _EstimateModelQuerySet_
`exception django_ledger.models.estimate.EstimateModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.16 Purchase Order Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
A purchase order is a commercial source document that is issued by a business purchasing department when placing an order with its vendors or suppliers. The document indicates the details on the items that are to be purchased, such as the types of goods, quantity, and price. In simple terms, it is the contract drafted by the buyer when purchasing goods from the seller.
**9.16. Purchase Order Model**
**181**
**Django Ledger**
The PurchaseOrderModel is designed to track the status of a Purchase Order and all its items. The PurchaseOrderModel starts in draft model by default and goes through different states including InReview, Approved, Fulfilled, Canceled and Void. The PurchaseOrderModel also keeps track of when these states take place.
`class django_ledger.models.purchase_order.PurchaseOrderModel(` _*args_ , _**kwargs_ `)`
- Purchase Order Base Model
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.purchase_order.PurchaseOrderModelAbstract(` _*args_ , _**kwargs_ `)` The base implementation of the PurchaseOrderModel.
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4(). **Type** UUID
`po_number` A unique human-readable and sequential PO Number identifier. Automatically generated. **Type** str
`po_title` The PurchaseOrderModel instance title. **Type** str
```
po_status
```
One of PO_STATUS values representing the current status of the PurchaseOrderModel instance. **Type** str
`po_amount` The total value of the PurchaseOrderModel instance. **Type** Decimal
`po_amount_received` The PurchaseOrderModel instance total value received to date. Cannot be greater than PO amount. **Type** Decimal `entity` The EntityModel associated with the PurchaseOrderModel instance. **Type** _EntityModel_
`date_draft` The draft date represents the date when the PurchaseOrderModel was first created. Defaults to `localdate` . **Type** date
**182**
**Chapter 9. Models**
**Django Ledger**
## `date_in_review`
The in review date represents the date when the PurchaseOrderModel was marked as In Review status. Will be null if PurchaseOrderModel is canceled during draft status. Defaults to `localdate` .
**Type**
date
## `date_approved`
The approved date represents the date when the PurchaseOrderModel was approved. Will be null if PurchaseOrderModel is canceled. Defaults to `localdate` .
**Type** date
## `date_fulfilled`
The paid date represents the date when the PurchaseOrderModel was fulfilled and po_amount_received equals po_amount. Will be null if PurchaseOrderModel is canceled. Defaults to `localdate` .
**Type** date
## `date_void`
The void date represents the date when the PurchaseOrderModel was void, if applicable. Will be null unless PurchaseOrderModel is void. Defaults to `localdate` .
**Type**
date
## `date_canceled`
The canceled date represents the date when the PurchaseOrderModel was canceled, if applicable. Will be null unless PurchaseOrderModel is canceled. Defaults to `localdate` .
**Type** date
## `po_items`
A foreign key reference to the list of ItemTransactionModel that make the PurchaseOrderModel amount.
```
ce_model
```
A foreign key reference to the EstimateModel associated with the PurchaseOrderModel, if any.
**Type**
_EstimateModel_
```
PO_STATUS_CANCELED = 'canceled'
```
The different valid PO Status and their representation in the Database
`action_bind_estimate(` _estimate_model_ , _commit: bool = False_ `)`
Binds a specific EstimateModel to the PurchaseOrderModel instance.
**Parameters**
• `estimate_model` ( `EstimateModel` ) – The EstimateModel to bind.
- • `commit` ( _`bool`_ ) – Commits the changes in the Database, if True. Defaults to False.
`can_approve()` _→_ bool
Checks if the PurchaseOrderModel can be marked as Approved.
**Returns**
True if PurchaseOrderModel can be marked as Approved, else False.
**9.16. Purchase Order Model**
**183**
**Django Ledger**
**Return type** bool `can_bind_estimate(` _estimate_model_ , _raise_exception: bool = False_ `)` _→_ bool
Checks if the PurchaseOrderModel ican be bound to an EstimateModel.
**Returns** True if PurchaseOrderModel can be bound to an EstimateModel, else False. **Return type** bool
`can_cancel()` _→_ bool Checks if the PurchaseOrderModel can be marked as Canceled.
**Returns** True if PurchaseOrderModel can be marked as Canceled, else False. **Return type** bool
`can_delete()` _→_ bool Checks if the PurchaseOrderModel can be deleted.
**Returns** True if PurchaseOrderModel can be deleted, else False. **Return type** bool `can_draft()` _→_ bool Checks if the PurchaseOrderModel can be marked as Draft. **Returns** True if PurchaseOrderModel can be marked as Draft, else False. **Return type** bool
`can_edit_items()` _→_ bool Checks if the PurchaseOrderModel items can be edited.
**Returns** True if PurchaseOrderModel items can be edited, else False. **Return type** bool `can_fulfill()` _→_ bool Checks if the PurchaseOrderModel can be marked as Fulfilled.
**Returns** True if PurchaseOrderModel can be marked as Fulfilled, else False. **Return type** bool
```
can_generate_po_number()
```
Checks if PurchaseOrderModel can generate its Document Number.
**Returns**
True if PurchaseOrderModel can generate its po_number, else False.
**184**
**Chapter 9. Models**
**Django Ledger**
## **Return type** bool
`can_migrate_itemtxs()` _→_ bool
Checks if item transaction list can be migrated.
**Return type** bool
`can_review()` _→_ bool
Checks if the PurchaseOrderModel can be marked as In Review.
**Returns**
True if PurchaseOrderModel can be marked as In Review, else False.
**Return type**
bool
`can_void()` _→_ bool
Checks if the PurchaseOrderModel can be marked as Void.
**Returns**
True if PurchaseOrderModel can be marked as Void, else False.
**Return type**
bool
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`configure(` _entity_slug: str |_ EntityModel, _po_title: str | None = None_ , _user_model: User | None = None_ , _draft_date: date | None = None_ , _estimate_model=None_ , _commit: bool = False_ `)`
A configuration hook which executes all initial PurchaseOrderModel setup on to the EntityModel and all initial values of the EntityModel. Can only call this method once in the lifetime of a PurchaseOrderModel.
**Parameters**
- • `entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel to associate the Bill with.
- • `user_model` – The UserModel making the request to check for QuerySet permissions.
- • `ledger_posted` – An option to mark the BillModel Ledger as posted at the time of configuration. Defaults to False.
- • `bill_desc` ( _`str`_ ) – An optional description appended to the LedgerModel name.
- • `commit` ( _`bool`_ ) – Saves the current BillModel after being configured.
**Returns**
The configured PurchaseOrderModel instance.
**Return type**
_PurchaseOrderModel_
`generate_po_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next PurchaseOrder document number available.
**Parameters**
`commit` ( _`bool`_ ) – Commits transaction into PurchaseOrderModel.
**9.16. Purchase Order Model**
**185**
**Django Ledger**
## **Returns**
A String, representing the generated or current PurchaseOrderModel instance Document Number.
**Return type** str
`get_item_model_qs()` _→ ItemModelQuerySet_
Fetches the ItemModelQuerySet eligible to itemize.
**Return type**
_ItemModelQuerySet_
- `get_itemtxs_data(` _queryset:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _] | None = None_ , _aggregate_on_db: bool = False_ , _lazy_agg: bool = False_ `)` _→_ Tuple
Fetches the PurchaseOrderModel Items and aggregates the QuerySet.
**Parameters**
- • `queryset` ( `ItemTransactionModelQuerySet` ) – Optional pre-fetched ItemModelQueryset to use. Avoids additional DB query if provided. Validated if provided.
- • `aggregate_on_db` ( _`bool`_ ) – If True, performs aggregation of ItemsTransactions in the DB resulting in one additional DB query.
**Returns**
**A tuple**
**Return type** _ItemTransactionModelQuerySet_ , dict
## `get_mark_as_approved_html_id()`
PurchaseOrderModel Mark as Approved HTML ID Tag.
**Returns** HTML ID as a String.
**Return type**
str
```
get_mark_as_approved_message()
```
PurchaseOrderModel Mark as Approved Message.
**Returns** Message as a String.
**Return type** str
```
get_mark_as_approved_url()
```
PurchaseOrderModel Mark as Approved URL ID Tag.
**Returns** HTML ID as a String.
**Return type** str
```
get_mark_as_canceled_html_id()
```
PurchaseOrderModel Mark as Canceled HTML ID Tag.
**Returns** HTML ID as a String.
**186**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
## str
```
get_mark_as_canceled_message()
```
PurchaseOrderModel Mark as Canceled Message.
**Returns** Message as a String.
**Return type** str
## `get_mark_as_canceled_url()`
PurchaseOrderModel Mark as Canceled URL ID Tag.
**Returns** HTML ID as a String.
**Return type** str
## `get_mark_as_draft_html_id()`
PurchaseOrderModel Mark as Draft HTML ID Tag.
**Returns** HTML ID as a String.
**Return type** str
## `get_mark_as_draft_message()`
PurchaseOrderModel Mark as Draft Message.
**Returns** Message as a String. **Return type** str
## `get_mark_as_draft_url()`
PurchaseOrderModel Mark as Draft URL ID Tag.
**Returns** HTML ID as a String. **Return type** str
```
get_mark_as_fulfilled_html_id()
```
PurchaseOrderModel Mark as Fulfilled HTML ID Tag.
**Returns** HTML ID as a String. **Return type** str
`get_mark_as_fulfilled_message()` PurchaseOrderModel Mark as Fulfilled Message.
**Returns** Message as a String.
**9.16. Purchase Order Model**
**187**
**Django Ledger**
**Return type** str
```
get_mark_as_fulfilled_url()
```
PurchaseOrderModel Mark as Fulfilled URL ID Tag.
**Returns** URL as a String.
**Return type** str
## `get_mark_as_review_html_id()`
PurchaseOrderModel Mark as In Review HTML ID Tag.
**Returns** HTML ID as a String.
**Return type** str
```
get_mark_as_review_message()
```
PurchaseOrderModel Mark as Review Message.
**Returns** Message as a String.
**Return type** str
```
get_mark_as_review_url()
```
PurchaseOrderModel Mark as In Review URL ID Tag.
**Returns** HTML ID as a String. **Return type** str
## `get_mark_as_void_html_id()`
PurchaseOrderModel Mark as Void HTML ID Tag.
**Returns** HTML ID as a String. **Return type** str
`get_mark_as_void_message()` PurchaseOrderModel Mark as Void Message.
**Returns** Message as a String. **Return type** str
`get_mark_as_void_url()` PurchaseOrderModel Mark as Void URL ID Tag.
**Returns** HTML ID as a String.
**188**
**Chapter 9. Models**
**Django Ledger**
**Return type**
str
`get_po_bill_queryset()` _→ BillModelQuerySet_
Fetches a BillModelQuerySet of all BillModels associated with the PurchaseOrderModel instance.
**Return type**
_BillModelQuerySet_
```
get_status_action_date()
```
Current status action date.
**Returns** A date. i.e. If status is Approved, return date_approved. If In Review, return date_in_review. **Return type** date
`is_approved()` _→_ bool Checks if the PurchaseOrderModel is in Approved status.
**Returns** True if PurchaseOrderModel is Approved, else False. **Return type** bool
`is_canceled()` _→_ bool Checks if the PurchaseOrderModel is in Canceled status.
**Returns** True if PurchaseOrderModel is in Canceled, else False. **Return type** bool
`is_contract_bound()` Checks if the PurchaseOrderModel is bound to an EstimateModel.
**Returns** True if PurchaseOrderModel is bound to an EstimateModel, else False. **Return type** bool
`is_draft()` _→_ bool Checks if the PurchaseOrderModel is in Draft status.
**Returns** True if PurchaseOrderModel is Draft, else False. **Return type** bool `is_fulfilled()` _→_ bool Checks if the PurchaseOrderModel is in Fulfilled status.
**Returns** True if PurchaseOrderModel is in Fulfilled status, else False. **Return type** bool
**9.16. Purchase Order Model**
**189**
**Django Ledger**
`is_review()` _→_ bool
Checks if the PurchaseOrderModel is in Review status.
**Returns**
True if PurchaseOrderModel is Review, else False.
**Return type**
bool
`is_void()` _→_ bool
Checks if the PurchaseOrderModel is in Void status.
**Returns**
True if PurchaseOrderModel is Void, else False.
**Return type**
bool
`mark_as_approved(` _date_approved: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks PurchaseOrderModel as Approved.
**Parameters**
• `date_approved` ( _`date`_ ) – Approved date. If None, defaults to localdate().
• `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_canceled(` _date_canceled: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)` Marks PurchaseOrderModel as Canceled.
**Parameters**
• `date_canceled` ( _`date`_ ) – Canceled date. If None, defaults to localdate().
• `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_draft(` _date_draft: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks PurchaseOrderModel as Draft.
**Parameters**
• `date_draft` ( _`date`_ ) – Draft date. If None, defaults to localdate().
• `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_fulfilled(` _date_fulfilled: date = None_ , _po_items:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _] = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks PurchaseOrderModel as Fulfilled.
**Parameters**
• `date_fulfilled` ( _`date`_ ) – Fulfilled date. If None, defaults to localdate().
- • `po_items`
- `po_items` ( `ItemTransactionModelQuerySet` _`or list of ItemTransactionModel.`_ ) – Pre-fetched ItemTransactionModelQuerySet or list of ItemTransactionModel. Validated if provided.
• `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_review(` _date_in_review: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)` Marks PurchaseOrderModel as In Review.
**Parameters**
• `date_in_review` ( _`date`_ ) – Draft date. If None, defaults to localdate().
**190**
**Chapter 9. Models**
**Django Ledger**
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_void(` _void_date: date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks PurchaseOrderModel as Fulfilled.
**Parameters**
- • `void_date` ( _`date`_ ) – Void date. If None, defaults to localdate().
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`migrate_itemtxs(` _itemtxs: Dict_ , _operation: str_ , _commit: bool = False_ `)`
Migrates a predefined item transaction list.
**Parameters**
- • `itemtxs` ( _`dict`_ ) – A dictionary where keys are the document number (invoice/bill number, etc) and values are a dictionary:
- • `operation` ( _`str`_ ) – A choice of ITEMIZE_REPLACE, ITEMIZE_APPEND, ITEMIZE_UPDATE
- • `commit` ( _`bool`_ ) – If True, commits transaction into the DB. Default to False
- **Returns**
A list of ItemTransactionModel appended or created.
**Return type** list
`update_state(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| List[_ ItemTransactionModel _] | None = None_ `)` _→_ Tuple
Updates the state of the PurchaseOrderModel.
**Parameters** `itemtxs_qs` ( `ItemTransactionModelQuerySet` _`or list of`_ `ItemTransactionModel` )
**Returns** A tuple of ItemTransactionModels and Aggregation
**Return type** tuple
`validate_item_transaction_qs(` _queryset:_ ItemTransactionModelQuerySet _|_
_List[_ ItemTransactionModel _]_ `)`
Validates that the entire ItemTransactionModelQuerySet is bound to the PurchaseOrderModel.
**Parameters** `queryset` ( `ItemTransactionModelQuerySet` _`or list of ItemTransactionModel.`_ ) – ItemTransactionModelQuerySet to validate.
`class django_ledger.models.purchase_order.PurchaseOrderModelManager(` _*args_ , _**kwargs_ `)`
A custom defined PurchaseOrderModel Manager.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ PurchaseOrderModelQuerySet_
Fetches a QuerySet of PurchaseOrderModel associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Returns**
A PurchaseOrderModelQuerySet with applied filters.
**9.16. Purchase Order Model**
**191**
**Django Ledger**
## **Return type**
_PurchaseOrderModelQuerySet_
`class django_ledger.models.purchase_order.PurchaseOrderModelQuerySet(` _model=None_ ,
_query=None_ , _using=None_ , _hints=None_ `)`
A custom-defined PurchaseOrderModel QuerySet.
```
active()
```
Filters the QuerySet to include Active PurchaseOrderModels only. Active PurchaseOrderModels are either approved or fulfilled, which are those that may contain associated transactions on the Ledger.
**Returns**
A PurchaseOrderModelQuerySet with applied filters.
**Return type** _PurchaseOrderModelQuerySet_
```
approved()
```
Filters the QuerySet to include Approved PurchaseOrderModels only.
**Returns** A PurchaseOrderModelQuerySet with applied filters.
**Return type** _PurchaseOrderModelQuerySet_
```
fulfilled()
```
Filters the QuerySet to include Fulfilled PurchaseOrderModels only.
**Returns**
A PurchaseOrderModelQuerySet with applied filters.
## **Return type**
_PurchaseOrderModelQuerySet_
`exception django_ledger.models.purchase_order.PurchaseOrderModelValidationError(` _message_ ,
_code=None_ , _params=None_ `)`
## **9.17 Invoice Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
This module implements the InvoiceModel, which represents the Sales Invoice/ Sales Invoice/ Tax Invoice/ Proof of Sale which the _`EntityModel`_ issues to its customers for the supply of goods or services. The model manages all the Sales Invoices which are issued by the _`EntityModel`_ . In addition to tracking the invoice amount , it tracks the receipt and due amount.
## **Examples**
`>>> user_model = request.user` _`# django UserModel`_ `>>> entity_slug = kwargs['entity_slug']` _`# may come from view kwargs`_ `>>> invoice_model = InvoiceModel() >>> ledger_model, invoice_model = invoice_model.configure(entity_slug=entity_slug, user_` _˓→_ `model=user_model) >>> invoice_model.save()`
**192**
**Chapter 9. Models**
**Django Ledger**
- `class django_ledger.models.invoice.InvoiceModel(` _*args_ , _**kwargs_ `)`
- Base Invoice Model from Abstract.
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
- `class django_ledger.models.invoice.InvoiceModelAbstract(` _*args_ , _**kwargs_ `)`
This is the main abstract class which the InvoiceModel database will inherit from. The InvoiceModel inherits functionality from the following MixIns:
1. 1. `LedgerWrapperMixIn`
1. 2. _`PaymentTermsMixIn`_
1. 3. _`MarkdownNotesMixIn`_
1. 4. _`CreateUpdateMixIn`_
## `uuid`
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type**
UUID
## `invoice_number`
Auto assigned number at creation by generate_invoice_number() function. Prefix be customized with DJANGO_LEDGER_INVOICE_NUMBER_PREFIX setting. Includes a reference to the Fiscal Year, Entity Unit and a sequence number. Max Length is 20.
**Type**
str
```
invoice_status
```
Current status of the InvoiceModel. Must be one of the choices as mentioned under “INVOICE_STATUS”. By default, the status will be “Draft”.
**Type** str
```
customer
```
This is the foreign key reference to the CustomerModel from whom the purchase has been made.
**Type**
```
CustomerModel
```
## `additional_info`
Any additional metadata about the InvoiceModel may be stored here as a dictionary object. The data is serialized and stored as a JSON document in the Database.
**Type**
dict
```
invoice_items
```
A foreign key reference to the list of ItemTransactionModel that make the invoice amount.
```
ce_model
```
A foreign key to the InvoiceModel associated EstimateModel for overall Job/Contract tracking.
**Type**
_EstimateModel_
**9.17. Invoice Model**
**193**
**Django Ledger**
## `date_draft`
The draft date represents the date when the InvoiceModel was first created. Defaults to `localdate` .
**Type** date
## `date_in_review`
The in review date represents the date when the InvoiceModel was marked as In Review status. Will be null if InvoiceModel is canceled during draft status. Defaults to `localdate` .
**Type**
date
```
date_approved
```
The approved date represents the date when the InvoiceModel was approved. Will be null if InvoiceModel is canceled. Defaults to `localdate` .
**Type**
date
## `date_paid`
The paid date represents the date when the InvoiceModel was paid and amount_due equals amount_paid. Will be null if InvoiceModel is canceled. Defaults to `localdate` .
**Type** date
## `date_void`
The void date represents the date when the InvoiceModel was void, if applicable. Will be null unless InvoiceModel is void. Defaults to `localdate` .
**Type**
date
## `date_canceled`
The canceled date represents the date when the InvoiceModel was canceled, if applicable. Will be null unless InvoiceModel is canceled. Defaults to `localdate` .
**Type**
date
```
INVOICE_STATUS = [('draft', 'Draft'), ('in_review', 'In Review'), ('approved',
```
```
'Approved'), ('paid', 'Paid'), ('void', 'Void'), ('canceled', 'Canceled')]
```
The different invoice status options and their representation in the Database.
`bind_estimate(` _estimate_model_ , _commit: bool = False_ `)`
Binds InvoiceModel to a given EstimateModel. Raises ValueError if EstimateModel cannot be bound.
**Parameters**
- • `estimate_model` ( `EstimateModel` ) – EstimateModel to bind.
- • `raise_exception` ( _`bool`_ ) – Raises InvoiceModelValidationError if unable to bind EstimateModel.
- • `commit` ( _`bool`_ ) – Commits transaction into current InvoiceModel.
## `can_approve()`
Checks if the InvoiceModel can be marked as Approved.
**194**
**Chapter 9. Models**
**Django Ledger**
## **Returns**
True if InvoiceModel can be marked as approved, else False.
**Return type**
bool
`can_bind_estimate(` _estimate_model_ , _raise_exception: bool = False_ `)` _→_ bool
Checks if the InvoiceModel can be bound to a given EstimateModel.
**Parameters**
- • `estimate_model` ( `EstimateModel` ) – EstimateModel to check against.
- • `raise_exception` ( _`bool`_ ) – If True, raises InvoiceModelValidationError if unable to bind. Else, returns False.
**Returns**
True if can bind provided EstimateModel, else False.
**Return type**
bool
```
can_cancel()
```
Checks if the InvoiceModel can be marked as Canceled status.
**Returns**
True if InvoiceModel can be marked as canceled, else False.
**Return type**
bool
```
can_delete()
```
Checks if the InvoiceModel can be deleted.
**Returns**
True if InvoiceModel can be deleted, else False.
**Return type** bool
```
can_draft()
```
Checks if the InvoiceModel can be marked as Draft.
**Returns**
True if InvoiceModel can be marked as draft, else False.
**Return type**
bool
```
can_edit_items()
```
Checks if the InvoiceModel item transactions can be edited.
**Returns**
True if InvoiceModel items can be edited, else False.
**Return type**
bool
## `can_generate_invoice_number()`
Checks if InvoiceModel can generate its Document Number.
**Returns**
True if InvoiceModel can generate its invoice_number, else False.
**9.17. Invoice Model**
**195**
**Django Ledger**
## **Return type**
bool
## `can_make_payment()` _→_ bool
Checks if the BillModel can accept a payment.
**Returns**
True if can bind provided PurchaseOderModel, else False.
**Return type**
bool
## `can_migrate()`
Checks if the InvoiceModel can be migrated.
**Returns**
True if InvoiceModel can be migrated, else False.
**Return type** bool
`can_migrate_itemtxs()` _→_ bool
Checks if item transaction list can be migrated.
**Return type** bool
## `can_pay()`
Checks if the InvoiceModel can be marked as Paid.
**Returns** True if InvoiceModel can be marked as paid, else False.
**Return type** bool
## `can_review()`
Checks if the InvoiceModel can be marked as In Review.
**Returns** True if InvoiceModel can be marked as in review, else False.
**Return type**
bool
## `can_void()`
Checks if the InvoiceModel can be marked as Void status.
**Returns**
True if InvoiceModel can be marked as void, else False.
**Return type**
bool
`clean(` _commit: bool = True_ `)`
Clean method for InvoiceModel. Results in a DB query if invoice number has not been generated and the InvoiceModel is eligible to generate an invoice_number.
**Parameters**
`commit` ( _`bool`_ ) – If True, commits into DB the generated InvoiceModel number if generated.
**196**
**Chapter 9. Models**
**Django Ledger**
`configure(` _entity_slug:_ EntityModel _| str_ , _user_model: User | None = None_ , _date_draft: date | None = None_ , _ledger_posted: bool = False_ , _ledger_name: str | None = None_ , _commit: bool = False_ , _commit_ledger: bool = False_ `)` A configuration hook which executes all initial InvoiceModel setup on to the LedgerModel and all initial values of the InvoiceModel. Can only call this method once in the lifetime of a InvoiceModel.
**Parameters**
- • `entity_slug` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel to associate the Invoice with.
- • `user_model` ( _`UserModel`_ ) – The UserModel making the request to check for QuerySet permissions.
- • `ledger_posted` ( _`bool`_ ) – An option to mark the InvoiceModel Ledger as posted at the time of configuration. Defaults to False.
- • `ledger_name` ( _`str`_ ) – Optional additional InvoiceModel ledger name or description.
- • `invoice_desc` ( _`str`_ ) – An optional description appended to the LedgerModel name.
- • `commit` ( _`bool`_ ) – Saves the current InvoiceModel after being configured.
- • `commit_ledger` ( _`bool`_ ) – Saves the InvoiceModel’s LedgerModel while being configured.
- **Return type**
A tuple of _LedgerModel_ , _InvoiceModel_
`generate_invoice_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next InvoiceModel document number available. The operation will result in two additional queries if the InvoiceModel & LedgerModel is not cached in QuerySet via select_related(‘ledger’).
**Parameters** `commit` ( _`bool`_ ) – Commits transaction into InvoiceModel. **Returns** A String, representing the generated InvoiceModel instance Document Number. **Return type** str
```
get_document_id()
```
Human-readable document number. Defaults to invoice_number.
**Returns** Document Number as a String. **Return type** str
`get_html_amount_due_id()` Unique amount due HTML ID. **Returns** HTML ID as a String. **Return type** str
```
get_html_amount_paid_id()
```
Unique amount paid HTML ID
**9.17. Invoice Model**
**197**
**Django Ledger**
**Returns** HTML ID as a String. **Return type** str `get_html_form_id()` Unique InvoiceModel Form HTML ID. **Returns** HTML ID as a String. **Return type** str `get_html_id()` Unique InvoiceNumber HTML ID. **Returns** HTML ID as a String. **Return type** str `get_item_model_qs()` _→ ItemModelQuerySet_ Fetches the ItemModelQuerySet eligible to itemize.
**Return type** _ItemModelQuerySet_
`get_itemtxs_data(` _queryset:_ ItemTransactionModelQuerySet _= None_ , _aggregate_on_db: bool = False_ , _lazy_agg: bool = False_ `)` _→_ Tuple[ _ItemTransactionModelQuerySet_ , Dict]
Fetches the InvoiceModel Items and aggregates the QuerySet.
**Parameters** `queryset` – Optional pre-fetched ItemModelQueryset to use. Avoids additional DB query if provided. **Returns A tuple Return type** _ItemTransactionModelQuerySet_ , dict
`get_mark_as_approved_html_id()` InvoiceModel Mark as Approved HTML ID. **Returns** HTML ID as a String. **Return type** str
`get_mark_as_approved_message()` Internationalized confirmation message with Invoice Number.
**Returns** Mark-as-Approved InvoiceModel confirmation message as a String. **Return type** str
**198**
**Chapter 9. Models**
**Django Ledger**
## `get_mark_as_approved_url()`
InvoiceModel Mark-as-Approved action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns**
InvoiceModel mark-as-approved action URL.
**Return type**
str
```
get_mark_as_canceled_html_id()
```
InvoiceModel Mark as Canceled HTML ID Tag.
**Returns**
HTML ID as a String.
**Return type**
str
## `get_mark_as_canceled_message()`
Internationalized confirmation message with Invoice Number.
**Returns**
Mark-as-Canceled InvoiceModel confirmation message as a String.
**Return type**
str
```
get_mark_as_canceled_url()
```
InvoiceModel Mark-as-Canceled action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** InvoiceModel mark-as-canceled action URL.
**Return type**
str
```
get_mark_as_draft_html_id()
```
InvoiceModel Mark as Draft HTML ID Tag.
**Returns** HTML ID as a String
**Return type**
str
## `get_mark_as_draft_message()`
Internationalized confirmation message with Invoice Number.
**Returns**
Mark-as-Draft InvoiceModel confirmation message as a String.
**Return type**
str
**9.17. Invoice Model**
**199**
**Django Ledger**
```
get_mark_as_draft_url()
```
InvoiceModel Mark-as-Draft action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** HTML ID as a String
**Return type** str
```
get_mark_as_paid_html_id()
```
InvoiceModel Mark as Paid HTML ID Tag.
**Returns** HTML ID as a String
**Return type** str
## `get_mark_as_paid_message()`
Internationalized confirmation message with Invoice Number.
**Returns** Mark-as-Paid InvoiceModel confirmation message as a String.
**Return type** str
`get_mark_as_paid_url(` _entity_slug: str = None_ `)`
InvoiceModel Mark-as-Paid action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns** InvoiceModel mark-as-paid action URL.
**Return type** str
```
get_mark_as_review_html_id()
```
InvoiceModel Mark as In Review HTML ID Tag.
**Returns** HTML ID as a String.
**Return type** str
## `get_mark_as_review_message()`
Internationalized confirmation message with Invoice Number.
**Returns**
Mark-as-Review InvoiceModel confirmation message as a String.
**Return type** str
**200**
**Chapter 9. Models**
**Django Ledger**
## `get_mark_as_review_url()`
InvoiceModel Mark-as-Review action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Returns**
InvoiceModel mark-as-review action URL.
**Return type**
str
```
get_mark_as_void_html_id()
```
InvoiceModel Mark as Void HTML ID Tag.
**Returns**
HTML ID as a String.
**Return type**
str
```
get_mark_as_void_message()
```
Internationalized confirmation message with Invoice Number.
**Returns**
Mark-as-Void InvoiceModel confirmation message as a String.
**Return type**
str
```
get_mark_as_void_url()
```
InvoiceModel Mark-as-Void action URL.
**Parameters**
`entity_slug` ( _`str`_ ) – Entity Slug kwarg. If not provided, will result in addition DB query if select_related(‘ledger__entity’) is not cached on QuerySet.
**Return type**
InvoiceModel mark-as-void action URL.
```
get_migrate_state_desc()
```
Description used when migrating transactions into the LedgerModel.
**Returns** Description as a string.
**Return type**
str
`get_migration_data(` _queryset:_ ItemTransactionModelQuerySet _| None = None_ `)` _→_
_ItemTransactionModelQuerySet_
Fetches necessary item transaction data to perform a migration into the LedgerModel.
**Parameters**
`queryset` ( `ItemTransactionModelQuerySet` ) – Optional pre-fetched ItemModelTransactionQueryset to use. Avoids additional DB query if provided.
## `get_status_action_date()`
Current status action date.
**9.17. Invoice Model**
**201**
**Django Ledger**
**Returns**
A date. i.e. If status is Approved, return date_approved. If Paid, return date_paid.
**Return type** date
`get_terms_start_date()` _→_ date Date where InvoiceModel term start to apply.
**Returns** A date which represents the start of InvoiceModel terms.
**Return type** date
`get_transaction_queryset(` _annotated: bool = False_ `)`
Fetches the TransactionModelQuerySet associated with the InvoiceModel instance.
```
is_active()
```
Checks if the InvoiceModel has the potential to impact the books and produce financial statements status.
**Returns** True if InvoiceModel is Active, else False.
**Return type** bool
`is_approved()` _→_ bool
Checks if the InvoiceModel is in Approved status.
**Returns** True if InvoiceModel is Approved, else False.
**Return type** bool
`is_canceled()` _→_ bool
Checks if the InvoiceModel is in Canceled status.
**Returns** True if InvoiceModel is Canceled, else False.
**Return type** bool
`is_configured()` _→_ bool
Determines if the accruable financial instrument is properly configured.
**Returns** True if configured, else False.
**Return type** bool
`is_draft()` _→_ bool
Checks if the InvoiceModel is in Draft status.
**Returns** True if InvoiceModel is Draft, else False.
**Return type** bool
**202**
**Chapter 9. Models**
**Django Ledger**
`is_paid()` _→_ bool
Checks if the InvoiceModel is in Paid status.
**Returns**
True if InvoiceModel is Paid, else False.
**Return type**
bool
`is_past_due()` _→_ bool
Checks if the InvoiceModel is past due.
**Returns**
True if InvoiceModel is past due, else False.
**Return type**
bool
`is_review()` _→_ bool
Checks if the InvoiceModel is In Review status.
**Returns**
True if InvoiceModel is in Review, else False.
**Return type**
bool
`is_void()` _→_ bool
Checks if the InvoiceModel is in Void status.
## **Returns**
True if InvoiceModel is Void, else False.
## **Return type**
bool
`make_payment(` _payment_amount: Decimal | float | int_ , _payment_date: datetime | date | None = None_ , _commit: bool = False_ , _raise_exception: bool = True_ `)`
Makes a payment to the InvoiceModel.
## **Parameters**
- • `payment_amount` ( _`Decimal ot float`_ ) – The payment amount to process.
- • `payment_date` ( _`datetime or date.`_ ) – Date or timestamp of the payment being applied.
- • `commit` ( _`bool`_ ) – If True, commits the transaction into the DB. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – If True, raises InvoiceModelValidationError if payment exceeds amount due, else False.
**Returns**
True if can make payment, else False.
**Return type**
bool
`mark_as_approved(` _entity_slug_ , _user_model_ , _date_approved: date = None_ , _commit: bool = False_ , _force_migrate: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Marks InvoiceModel as Approved.
**Parameters**
**9.17. Invoice Model**
**203**
**Django Ledger**
- • `entity_slug` – Entity slug associated with the InvoiceModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_approved` ( _`date`_ ) – InvoiceModel approved date. Defaults to localdate().
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
- • `force_migrate` ( _`bool`_ ) – Forces migration. True if Accounting Method is Accrual.
`mark_as_canceled(` _date_canceled: date = None_ , _commit: bool = False_ , _**kwargs_ `)`
Mark InvoiceModel as Canceled.
**Parameters**
- • `date_canceled` ( _`date`_ ) – InvoiceModel canceled date. Defaults to localdate() if None.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_draft(` _draft_date: date | datetime_ , _commit: bool = False_ , _**kwargs_ `)` Marks InvoiceModel as Draft.
**Parameters**
- • `date_draft` ( _`date`_ ) – Draft date. If None, defaults to localdate().
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
- `mark_as_paid(` _entity_slug: str_ , _user_model_ , _date_paid: date = None_ , _commit: bool = False_ , _**kwargs_ `)` Marks InvoiceModel as Paid.
**Parameters**
- • `entity_slug` ( _`str`_ ) – Entity slug associated with the InvoiceModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_paid` ( _`date`_ ) – InvoiceModel paid date. Defaults to localdate() if None.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Pre-fetched ItemTransactionModelQuerySet. Avoids additional DB query. Validated if passed.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
`mark_as_review(` _date_in_review: date = None_ , _itemtxs_qs=None_ , _commit: bool = False_ , _**kwargs_ `)` Marks InvoiceModel as In Review.
**Parameters**
- • `date_in_review` ( _`date`_ ) – InvoiceModel in review date. Defaults to localdate() if None.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Pre fetched ItemTransactionModelQuerySet to use. Avoids additional DB Query if previously fetched.
- • `commit` ( _`bool`_ ) – Commits transaction into the Database. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – Raises InvoiceModelValidationError if InvoiceModel cannot be marked as in review. Defaults to True.
- `mark_as_void(` _entity_slug: str_ , _user_model_ , _date_void: datetime | date | None = None_ , _commit: bool = False_ , _**kwargs_ `)`
Marks InvoiceModel as Void. When mark as void, all transactions associated with InvoiceModel are reversed as of the void date.
**204**
**Chapter 9. Models**
**Django Ledger**
**Parameters**
- • `entity_slug` ( _`str`_ ) – Entity slug associated with the InvoiceModel. Avoids additional DB query if passed.
- • `user_model` – UserModel associated with request.
- • `date_void` ( _`date`_ ) – InvoiceModel void date. Defaults to localdate() if None.
- • `commit` ( _`bool`_ ) – Commits transaction into DB. Defaults to False.
`migrate_itemtxs(` _itemtxs: Dict_ , _operation: str_ , _commit: bool = False_ `)`
Migrates a predefined item transaction list.
**Parameters**
- • `itemtxs` ( _`dict`_ ) – A dictionary where keys are the document number (invoice/bill number, etc) and values are a dictionary:
- • `operation` ( _`str`_ ) – A choice of ITEMIZE_REPLACE, ITEMIZE_APPEND, ITEMIZE_UPDATE
- • `commit` ( _`bool`_ ) – If True, commits transaction into the DB. Default to False
**Returns**
A list of ItemTransactionModel appended or created.
- **Return type**
list
`save(` _**kwargs_ `)`
Save method for InvoiceModel. Results in a DB query if invoice number has not been generated and the InvoiceModel is eligible to generate a invoice_number.
`update_amount_due(` _itemtxs_qs:_ ItemTransactionModelQuerySet _| None = None_ `)` _→_
_ItemTransactionModelQuerySet_
Updates the InvoiceModel amount due.
**Parameters**
`itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – Optional pre-fetched ItemTransactionModelQuerySet. Avoids additional DB if provided. Queryset is validated if provided.
**Returns**
Newly fetched of previously fetched ItemTransactionModelQuerySet if provided.
**Return type**
_ItemTransactionModelQuerySet_
`validate_itemtxs_qs(` _queryset:_ ItemTransactionModelQuerySet `)`
Validates that the entire ItemTransactionModelQuerySet is bound to the InvoiceModel.
**Parameters**
`queryset` ( `ItemTransactionModelQuerySet` ) – ItemTransactionModelQuerySet to vali-
date.
`class django_ledger.models.invoice.InvoiceModelManager(` _*args_ , _**kwargs_ `)`
A custom defined InvoiceModel Manager that will act as an interface to handling the DB queries to the InvoiceModel. The default “get_queryset” has been overridden to refer the custom defined “InvoiceModelQuerySet”
**9.17. Invoice Model**
**205**
**Django Ledger**
- `for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ InvoiceModelQuerySet_
Returns a QuerySet of InvoiceModels associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
**Returns**
A Filtered InvoiceModelQuerySet.
**Return type**
_InvoiceModelQuerySet_
`get_queryset()` _→ InvoiceModelQuerySet_
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
`class django_ledger.models.invoice.InvoiceModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
A custom defined QuerySet for the InvoiceModel. This implements multiple methods or queries that we need to run to get a status of Invoices raised by the entity. For example, We might want to have list of invoices which are paid, unpaid, due , overDue, approved or in draft stage. All these separate functions will assist in making such queries and building customized reports.
## `active()`
Active invoices are those that are approved or paid, which have impacted or have the potential to impact the Entity’s Ledgers.
**Returns**
Returns a QuerySet of active invoices only.
**Return type**
_InvoiceModelQuerySet_
```
approved()
```
Approved invoices are those that have been reviewed and are expected to be paid before the due date.
**Returns**
Returns a QuerySet of approved invoices only.
**Return type** _InvoiceModelQuerySet_
## `canceled()`
Canceled invoices are those that are discarded during the draft or in review status. These invoices never had an impact on the books.
**Returns**
Returns a QuerySet of canceled invoices only.
**Return type**
_InvoiceModelQuerySet_
## `draft()`
Default status of any invoice that is created. Draft invoices do not impact the Ledger.
**Returns**
Returns a QuerySet of draft invoices only.
**206**
**Chapter 9. Models**
**Django Ledger**
## **Return type**
_InvoiceModelQuerySet_
```
in_review()
```
In review invoices are those that need additional review or approvals before being approved. Draft invoices do not impact the Ledger.
**Returns** Returns a QuerySet of in review invoices only.
**Return type**
_InvoiceModelQuerySet_
## `overdue()`
Overdue invoices are those which due date is in the past.
**Returns** Returns a QuerySet of overdue invoices only.
**Return type** _InvoiceModelQuerySet_
## `paid()`
Paid invoices are those that have received 100% of the amount due.
**Returns** Returns a QuerySet of paid invoices only.
**Return type** _InvoiceModelQuerySet_
## `unpaid()`
Unpaid invoices are those that are approved but have not received 100% of the amount due. Equivalent to approved().
**Returns** Returns a QuerySet of paid invoices only.
**Return type** _InvoiceModelQuerySet_
## `void()`
Void invoices are those that where rolled back after being approved. Void invoices rollback all transactions by creating a new set of transactions posted on the date_void.
**Returns**
Returns a QuerySet of void invoices only.
## **Return type**
_InvoiceModelQuerySet_
`exception django_ledger.models.invoice.InvoiceModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.18 Customer Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
**9.18. Customer Model**
**207**
**Django Ledger**
A Customer refers to the person or entity that buys product and services. When issuing Invoices, a Customer must be created before it can be assigned to the InvoiceModel. Only customers who are active can be assigned to new Invoices.
`class django_ledger.models.customer.CustomerModel(` _*args_ , _**kwargs_ `)`
Base Customer Model Implementation
```
exception DoesNotExist
```
## `exception MultipleObjectsReturned`
`class django_ledger.models.customer.CustomerModelAbstract(` _*args_ , _**kwargs_ `)` This is the main abstract class which the CustomerModel database will inherit from. The CustomerModel inherits functionality from the following MixIns:
1. _`ContactInfoMixIn`_ 2. _`CreateUpdateMixIn`_ `uuid` This is a unique primary key generated for the table. The default value of this field is uuid4(). **Type** UUID `entity_model` The EntityModel associated with this Customer. **Type** _EntityModel_ `customer_name` A string representing the name the customer uses to do business with the EntityModel. **Type** str `customer_number` A unique, auto-generated human-readable number which identifies the customer within the EntityModel. **Type** str `description` A text field to capture the description about the customer. **Type** str `active` We can set any customer code to be active or inactive. Defaults to True. **Type** bool `hidden` Hidden CustomerModels don’t show on the UI. Defaults to False. **Type** bool
**208**
**Chapter 9. Models**
**Django Ledger**
```
additional_info
```
Any additional information about the customer, stored as a JSON object using a JSONField.
**Type** dict
`can_generate_customer_number()` _→_ bool
Determines if the CustomerModel can be issued a Customer Number. CustomerModels have a unique sequential number, which is unique for each EntityMode/CustomerModel.
**Returns** True if customer model can be generated, else False.
**Return type** bool
```
clean()
```
Custom defined clean method that fetches the next customer number if not yet fetched. Additional validation may be provided.
`generate_customer_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next Customer Number available.
**Parameters** `commit` ( _`bool`_ ) – Commits transaction into CustomerModel. Defaults to False.
**Returns** A String, representing the current CustomerModel instance Document Number.
**Return type** str
`save(` _**kwargs_ `)`
Custom-defined save method that automatically fetches the customer number if not present.
**Parameters**
`kwargs` – Keywords passed to the super().save() method of the CustomerModel.
`class django_ledger.models.customer.CustomerModelManager(` _*args_ , _**kwargs_ `)`
A custom-defined CustomerModelManager that will act as an interface to handling the DB queries to the CustomerModel.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ CustomerModelQueryset_
Fetches a QuerySet of CustomerModel associated with a specific EntityModel & UserModel. May pass an instance of EntityModel or a String representing the EntityModel slug.
**Parameters** `entity_model` ( _`str or`_ `EntityModel` ) – The entity slug or EntityModel used for filtering the QuerySet.
**Returns** A filtered CustomerModel QuerySet.
**Return type**
_CustomerModelQueryset_
- `class django_ledger.models.customer.CustomerModelQueryset(` _model=None_ , _query=None_ , _using=None_ , _hints=None_ `)`
A custom defined QuerySet for the CustomerModel. This implements multiple methods or queries needed to get a filtered QuerySet based on the CustomerModel status. For example, we might want to have list of Customers
**9.18. Customer Model**
**209**
**Django Ledger**
that are active or hidden. All these separate functions will assist in making such queries and building customized reports.
`active()` _→_ QuerySet
Active customers can be assigned to new Invoices and show on dropdown menus and views.
**Returns**
A QuerySet of active Customers.
**Return type**
_CustomerModelQueryset_
`for_user(` _user_model_ `)`
Fetches a QuerySet of BillModels that the UserModel as access to. May include BillModels from multiple Entities.
**The user has access to bills if:**
- 1. Is listed as Manager of Entity.
- 2. Is the Admin of the Entity.
**Parameters**
`user_model` – Logged in and authenticated django UserModel instance.
`hidden()` _→_ QuerySet
Hidden customers do not show on dropdown menus, but may be used via APIs or any other method that does not involve the UI.
**Returns**
A QuerySet of hidden Customers.
**Return type**
_CustomerModelQueryset_
`inactive()` _→_ QuerySet
Active customers can be assigned to new Invoices and show on dropdown menus and views. Marking CustomerModels as inactive can help reduce Database load to populate select inputs and also inactivate CustomerModels that are not relevant to the Entity anymore. Also, it makes de UI cleaner by not populating unnecessary choices.
**Returns**
A QuerySet of inactive Customers.
**Return type**
_CustomerModelQueryset_
`visible()` _→_ QuerySet
Visible customers show on dropdown menus and views. Visible customers are active and not hidden.
**Returns**
A QuerySet of visible Customers.
**Return type**
_CustomerModelQueryset_
`exception django_ledger.models.customer.CustomerModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
> `django_ledger.models.customer.customer_picture_upload_to(` _instance_ , _filename_ `)`
> Stores pictures under: customer_pictures//.
**210**
**Chapter 9. Models**
**Django Ledger**
## **9.19 Vendor Model**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
A Vendor refers to the person or entity that provides products and services to the business for a fee. Vendors are an integral part of the billing process as they are the providers of goods and services for the business.
Vendors can be flagged as active/inactive or hidden. Vendors who no longer conduct business with the EntityModel, whether temporarily or indefinitely may be flagged as inactive (i.e. active is False). Hidden Vendors will not show up as an option in the UI, but can still be used programmatically (via API).
`class django_ledger.models.vendor.VendorModel(` _*args_ , _**kwargs_ `)`
- Base Vendor Model Implementation
## `exception DoesNotExist`
## `exception MultipleObjectsReturned`
`class django_ledger.models.vendor.VendorModelAbstract(` _*args_ , _**kwargs_ `)`
This is the main abstract class which the VendorModel database will inherit from. The VendorModel inherits functionality from the following MixIns:
1. 1. _`ContactInfoMixIn`_
1. 2. `BankAccountInfoMixIn`
3. _`TaxInfoMixIn`_
1. 4. _`CreateUpdateMixIn`_
```
uuid
```
This is a unique primary key generated for the table. The default value of this field is uuid4().
**Type** UUID
```
entity_model
```
The EntityModel associated with this Vendor.
**Type** _EntityModel_
```
vendor_name
```
A string representing the name the customer uses to do business with the EntityModel.
**Type** str
```
vendor_number
```
A unique, auto-generated human-readable number which identifies the vendor within the EntityModel.
**Type** str
```
description
```
A text field to capture the description about the vendor.
**Type**
str
**9.19. Vendor Model**
**211**
**Django Ledger**
```
active
```
We can set any vendor to be active or inactive. Defaults to True.
**Type** bool
```
hidden
```
Hidden VendorModel don’t show on the UI. Defaults to False.
**Type** bool
```
additional_info
```
Any additional information about the vendor, stored as a JSON object using a JSONField.
**Type** dict
`can_generate_vendor_number()` _→_ bool
Determines if the VendorModel can be issued a Vendor Number. VendorModel have a unique sequential number, which is unique for each EntityModel/VendorModel.
**Returns**
True if the vendor number can be generated, else False.
**Return type** bool
```
clean()
```
Custom defined clean method that fetches the next vendor number if not yet fetched. Additional validation may be provided.
`generate_vendor_number(` _commit: bool = False_ `)` _→_ str
Atomic Transaction. Generates the next Vendor Number available.
**Parameters** `commit` ( _`bool`_ ) – Commits transaction into VendorModel. Defaults to False. **Returns** A String, representing the current VendorModel instance document number. **Return type** str
`save(` _**kwargs_ `)`
Custom-defined save method that automatically fetches the vendor number if not present.
**Parameters**
`kwargs` – Keywords passed to the super().save() method of the VendorModel.
`class django_ledger.models.vendor.VendorModelManager(` _*args_ , _**kwargs_ `)`
Manages operations related to VendorModel instances.
A specialized manager for handling interactions with VendorModel entities, providing additional support for filtering based on associated EntityModel or EntityModel slug.
`for_entity(` _entity_model:_ EntityModel _| str | UUID = None_ , _**kwargs_ `)` _→ VendorModelQuerySet_
Filters the queryset for a given entity model.
This method modifies the queryset to include only those records associated with the specified entity model. The entity model can be provided in various formats, such as an instance of _EntityModel_ , a string representing the entity’s slug, or its UUID.
**212**
**Chapter 9. Models**
**Django Ledger**
If a deprecated parameter _user_model_ is provided, it will issue a warning and may alter the behavior if the deprecated behavior flag _DJANGO_LEDGER_USE_DEPRECATED_BEHAVIOR_ is set.
**Parameters**
- • `entity_model` ( `EntityModel` _`| str | UUID`_ ) – The entity model or its identifier (slug or UUID) to filter the queryset by.
- • `**kwargs` – Additional parameters for optional functionality. The parameter _user_model_ is supported for backward compatibility but is deprecated and should be avoided.
## **Returns**
A queryset filtered for the given entity model.
## **Return type**
_VendorModelQuerySet_
`class django_ledger.models.vendor.VendorModelQuerySet(` _model=None_ , _query=None_ , _using=None_ ,
_hints=None_ `)`
Custom defined VendorModel QuerySet.
`active()` _→ VendorModelQuerySet_
Active vendors can be assigned to new bills and show on dropdown menus and views.
**Returns**
A QuerySet of active Vendors.
**Return type**
_VendorModelQuerySet_
`hidden()` _→ VendorModelQuerySet_
Hidden vendors do not show on dropdown menus, but may be used via APIs or any other method that does not involve the UI.
## **Returns**
A QuerySet of hidden Vendors.
## **Return type**
_VendorModelQuerySet_
`inactive()` _→ VendorModelQuerySet_
Active vendors can be assigned to new bills and show on dropdown menus and views. Marking VendorModels as inactive can help reduce Database load to populate select inputs and also inactivate VendorModels that are not relevant to the Entity anymore. Also, it makes de UI cleaner by not populating unnecessary choices.
## **Returns**
A QuerySet of inactive Vendors.
## **Return type**
_VendorModelQuerySet_
`visible()` _→ VendorModelQuerySet_
Visible vendors show on dropdown menus and views. Visible vendors are active and not hidden.
## **Returns**
A QuerySet of visible Vendors.
## **Return type**
_VendorModelQuerySet_
**9.19. Vendor Model**
**213**
**Django Ledger**
`exception django_ledger.models.vendor.VendorModelValidationError(` _message_ , _code=None_ ,
_params=None_ `)`
## **9.20 MixIns**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
This module implements the different model MixIns used on different Django Ledger Models to implement common functionality.
- `class django_ledger.models.mixins.AccrualMixIn(` _*args_ , _**kwargs_ `)`
Implements functionality used to track accruable financial instruments to a base Django Model. Examples of this include bills and invoices expenses/income, that depending on the Entity’s accrual method, may be recognized on the Income Statement differently.
```
amount_due
```
The total amount due of the financial instrument.
**Type** Decimal
```
amount_paid
```
The total amount paid or settled.
**Type** Decimal
```
amount_receivable
```
The total amount allocated to Accounts Receivable based on the progress.
**Type** Decimal
`amount_unearned` The total amount allocated to Accounts Payable based on the progress.
**Type** Decimal
```
amount_earned
```
The total amount that is recognized on the earnings based on progress.
`accrue` If True, the financial instrument will follow the Accrual Method of Accounting, otherwise it will follow the Cash Method of Accounting. Defaults to the EntityModel preferred method of accounting.
**Type** bool
`progress` A decimal number representing the amount of progress of the financial instrument. Value is between 0.00 and 1.00.
**Type** Decimal
**214**
**Chapter 9. Models**
**Django Ledger**
## `ledger`
The LedgerModel associated with the Accruable financial instrument.
**Type** _LedgerModel_
```
cash_account
```
The AccountModel used to track cash payments to the financial instrument. Must be of role ASSET_CA_CASH.
**Type** _AccountModel_
## `prepaid_account`
The AccountModel used to track receivables to the financial instrument. Must be of role ASSET_CA_PREPAID.
**Type** _AccountModel_
## `unearned_account`
The AccountModel used to track receivables to the financial instrument. Must be of role LIABILITY_CL_DEFERRED_REVENUE.
**Type** _AccountModel_
## `can_migrate()` _→_ bool
Determines if the Accruable financial instrument can be migrated to the books. Results in additional Database query if ‘ledger’ field is not pre-fetch on QuerySet.
**Returns** True if can migrate, else False.
**Return type** bool
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
## `get_amount_cash()` _→_ Decimal | float
Determines the impact to the EntityModel cash balance based on the financial instrument debit or credit configuration. i.e, Invoices are debit financial instrument because payments to invoices increase cash.
**Returns** Financial instrument progress as a percent.
**Return type** float
`get_amount_earned()` _→_ Decimal | float
Determines the impact to the EntityModel earnings based on financial instrument progress.
**Returns**
Financial instrument amount earned.
**Return type** float or Decimal
**9.20. MixIns**
**215**
**Django Ledger**
`get_amount_open()` _→_ Decimal | float
Determines the open amount left to be progressed.
**Returns** Financial instrument amount open.
**Return type** float or Decimal
`get_amount_prepaid()` _→_ Decimal | float
Determines the impact to the EntityModel Accounts Receivable based on financial instrument progress.
**Returns**
Financial instrument amount prepaid.
**Return type** float or Decimal
`get_amount_unearned()` _→_ Decimal | float
Determines the impact to the EntityModel Accounts Payable based on financial instrument progress.
**Returns**
Financial instrument amount unearned.
**Return type** float or Decimal
`get_progress()` _→_ Decimal | float
Determines the progress amount based on amount due, amount paid and accrue field.
**Returns**
Financial instrument progress as a Decimal.
**Return type** Decimal
`get_progress_percent()` _→_ float
Determines the progress amount as percent based on amount due, amount paid and accrue field.
**Returns** Financial instrument progress as a percent.
**Return type** float
`get_state(` _commit: bool = False_ `)`
Determines the new state of the financial instrument based on progress.
**Parameters** `commit` ( _`bool`_ ) – Commits the new financial instrument state into the model.
**Returns** A dictionary with new amount_paid, amount_receivable, amount_unearned and amount_earned as keys. **Return type** dict
`get_tx_type(` _acc_bal_type: dict_ , _adjustment_amount: Decimal_ `)`
Determines the transaction type associated with an increase/decrease of an account balance of the financial instrument.
**216**
**Chapter 9. Models**
**Django Ledger**
## **Parameters**
- • `acc_bal_type` – The balance type of the account to be adjusted.
- • `adjustment_amount` ( _`Decimal`_ ) – The adjustment, whether positive or negative.
**Returns** The transaction type of the account adjustment.
**Return type**
str
`is_configured()` _→_ bool
Determines if the accruable financial instrument is properly configured.
**Returns**
True if configured, else False.
**Return type**
bool
```
is_posted()
```
Determines if the accruable financial instrument is posted. Results in additional Database query if ‘ledger’ field is not pre-fetch on QuerySet.
**Returns** True if posted, else False.
**Return type** bool
`lock_ledger(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Convenience method to lock the LedgerModel associated with the Accruable financial instrument.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits the transaction in the database. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – If True, raises ValidationError if LedgerModel already locked.
`migrate_state(` _user_model_ , _entity_slug: str_ , _itemtxs_qs: QuerySet | None = None_ , _force_migrate: bool = False_ , _commit: bool = True_ , _void: bool = False_ , _je_timestamp: str | datetime | date | None = None_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Migrates the current Accruable financial instrument into the books. The main objective of the migrate_state method is to determine the JournalEntry and TransactionModels necessary to accurately reflect the financial instrument state in the books.
**Parameters**
- • `user_model` – The Django User Model.
- • `entity_slug` ( _`str`_ ) – The EntityModel slug.
- • `itemtxs_qs` ( `ItemTransactionModelQuerySet` ) – The pre-fetched ItemTransactionModelQuerySet containing the item information associated with the financial element migration. If provided, it will avoid an additional database query.
- • `force_migrate` ( _`bool`_ ) – Forces migration of the financial instrument bypassing the can_migrate() check.
- • `commit` ( _`bool`_ ) – If True the migration will be committed in the database. Defaults to True.
**9.20. MixIns**
**217**
**Django Ledger**
- • `void` ( _`bool`_ ) – If True, the migration will perform a VOID actions of the financial instrument.
- • `je_timestamp` ( _`date`_ ) – The JournalEntryModel date to be used for this migration.
- • `raise_exception` ( _`bool`_ ) – Raises ValidationError if migration is not allowed. Defaults to True.
## **Returns**
A tuple of the ItemTransactionModel and the Digest Result from IOMixIn.
## **Return type**
tuple
`post_ledger(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Convenience method to post the LedgerModel associated with the Accruable financial instrument.
## **Parameters**
- • `commit` ( _`bool`_ ) – Commits the transaction in the database. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – If True, raises ValidationError if LedgerModel already locked.
`classmethod split_amount(` _amount: Decimal | float_ , _unit_split: Dict_ , _account_uuid: UUID_ , _account_balance_type: str_ `)` _→_ Dict
Splits an amount into different proportions representing the unit splits. Makes sure that 100% of the amount is numerically allocated taking into consideration decimal points.
**Parameters**
- • `amount` ( _`Decimal or float`_ ) – The amount to be split.
- • `unit_split` ( _`dict`_ ) – A dictionary with information related to each unit split and proportions.
- • `account_uuid` ( _`UUID`_ ) – The AccountModel UUID associated with the splits.
- • `account_balance_type` ( _`str`_ ) – The AccountModel balance type to determine whether to perform a credit or a debit.
- **Returns**
A dictionary with the split information.
**Return type**
dict
`unlock_ledger(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Convenience method to un-lock the LedgerModel associated with the Accruable financial instrument.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits the transaction in the database. Defaults to False.
- • `raise_exception` ( _`bool`_ ) – If True, raises ValidationError if LedgerModel already locked.
`unpost_ledger(` _commit: bool = False_ , _raise_exception: bool = True_ , _**kwargs_ `)`
Convenience method to un-lock the LedgerModel associated with the Accruable financial instrument.
**Parameters**
- • `commit` ( _`bool`_ ) – Commits the transaction in the database. Defaults to False.
**218**
**Chapter 9. Models**
**Django Ledger**
- • `raise_exception` ( _`bool`_ ) – If True, raises ValidationError if LedgerModel already locked.
`update_state(` _state: Dict | None = None_ `)`
Updates the state on the financial instrument.
**Parameters** `state` ( _`dict`_ ) – Optional user provided state to use.
`void_state(` _commit: bool = False_ `)` _→_ Dict
Determines the VOID state of the financial instrument.
**Parameters** `commit` ( _`bool`_ ) – Commits the new financial instrument state into the model. **Returns** A dictionary with new amount_paid, amount_receivable, amount_unearned and amount_earned as keys. **Return type** dict
`class django_ledger.models.mixins.ContactInfoMixIn(` _*args_ , _**kwargs_ `)`
Implements a common set of fields used to document contact information.
`address_1` A string used to document the first line of an address. Mandatory. Max length is 70. **Type** str `address_2` A string used to document the first line of an address. Optional. **Type** str `city` A string used to document the city. Optional. **Type** str `state` A string used to document the State of Province. Optional. **Type** str `zip_code` A string used to document the ZIP code. Optional **Type** str `country` A string used to document the country. Optional. **Type** str
**9.20. MixIns**
**219**
**Django Ledger**
## `email`
A string used to document the contact email. Uses django’s EmailField for validation.
**Type** str
```
website
```
A string used to document the contact website. Uses django’s URLField for validation.
**Type** str
```
phone
```
A string used to document the contact phone. **Type** str
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`class django_ledger.models.mixins.CreateUpdateMixIn(` _*args_ , _**kwargs_ `)`
Implements a created and an updated field to a base Django Model.
`created` A created timestamp. Defaults to now(). **Type** datetime
```
updated
```
An updated timestamp used to identify when models are updated.
**Type** str
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`class django_ledger.models.mixins.FinancialAccountInfoMixin(` _*args_ , _**kwargs_ `)`
Implements functionality used to add bank account details to base Django Models.
```
account_number
```
The Bank Account number. Only Digits are allowed. Max 30 digists.
**Type** str
`routing_number` Routing number for the concerned bank account. Also called as ‘Routing Transit Number (RTN)’. Max 30 digists.
**Type** str
**220**
**Chapter 9. Models**
**Django Ledger**
```
aba_number
```
The American Bankers Association Number assigned to each bank.
**Type** str
`account_type` A choice of ACCOUNT_TYPES. Each account will have to select from the available choices Checking, Savings.
**Type** str
`swift_number` SWIFT electronic communications network number of the bank institution.
**Type** str
`exception django_ledger.models.mixins.ItemizeError(` _message_ , _code=None_ , _params=None_ `)`
`class django_ledger.models.mixins.ItemizeMixIn(` _*args_ , _**kwargs_ `)`
`can_migrate_itemtxs()` _→_ bool
Checks if item transaction list can be migrated.
**Return type** bool
```
clean()
```
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
## `get_item_model_qs()`
Fetches the ItemModelQuerySet eligible to itemize.
**Return type** _ItemModelQuerySet_
`get_itemtxs_data(` _queryset=None_ , _aggregate_on_db: bool = False_ , _lazy_agg: bool = False_ `)`
Fetches the ItemTransactionModelQuerySet associated with the model.
**Parameters**
- • `queryset` ( `ItemTransactionModelQuerySet` ) – Pre-fetched ItemTransactionModelQuerySet. Validated if provided.
- • `aggregate_on_db` ( _`bool`_ ) – If True, performs aggregation at the DB layer. Defaults to False.
- • `lazy_agg` ( _`bool`_ ) – If True, performs queryset aggregation metrics. Defaults to False.
**Returns** ItemModelQuerySet, dict
**Return type** tuple
**9.20. MixIns**
**221**
**Django Ledger**
`migrate_itemtxs(` _itemtxs: Dict_ , _operation: str_ , _commit: bool = False_ `)`
Migrates a predefined item transaction list.
**Parameters**
- • `itemtxs` ( _`dict`_ ) – A dictionary where keys are the document number (invoice/bill number, etc) and values are a dictionary:
- • `operation` ( _`str`_ ) – A choice of ITEMIZE_REPLACE, ITEMIZE_APPEND, ITEMIZE_UPDATE
• `commit` ( _`bool`_ ) – If True, commits transaction into the DB. Default to False
**Returns**
A list of ItemTransactionModel appended or created.
**Return type**
list
`validate_itemtxs(` _itemtxs_ `)`
Validates the provided item transaction list.
**Parameters**
`itemtxs` ( _`dict`_ ) – Item transaction list to replace/aggregate.
## `validate_itemtxs_qs()`
Validates that the provided item transaction list is valid.
## `class django_ledger.models.mixins.LoggingMixIn`
Implements functionality used to add logging capabilities to any python class. Useful for production and or testing environments.
`class django_ledger.models.mixins.MarkdownNotesMixIn(` _*args_ , _**kwargs_ `)`
Implements functionality used to add a Mark-Down notes to a base Django Model.
```
markdown_notes
```
A string of text representing the mark-down document.
**Type**
str
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
```
notes_html()
```
Compiles the markdown_notes field into html.
**Returns**
Compiled HTML document as a string.
**Return type**
str
## `class django_ledger.models.mixins.PaymentTermsMixIn(` _*args_ , _**kwargs_ `)`
Implements functionality used to track dates relate to various payment terms. Examples of this include tracking bills and invoices that are due on receipt, 30, 60 or 90 days after they are approved.
**222**
**Chapter 9. Models**
**Django Ledger**
## `terms`
A choice of TERM_CHOICES that determines the payment terms.
**Type** str
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`due_in_days()` _→_ int | None
Determines how many days until the due date.
**Returns**
Days as integer.
**Return type**
int
`get_terms_net_90_plus()` _→_ int
Determines the number of days for 90+ days terms of payment.
**Returns** The date when terms of payment starts.
**Return type** date
`get_terms_start_date()` _→_ date
Determines the start date for the terms of payment.
**Returns** The date when terms of payment starts.
**Return type** date
`get_terms_timedelta()` _→_ timedelta
Calculates a timedelta relative to the terms start date.
**Returns** Timedelta relative to terms start date.
**Return type** timedelta
`get_terms_timedelta_days()` _→_ int
Determines the number of days from the terms start date.
**Returns** The number of days as integer.
**Return type** int
```
net_due_group()
```
Determines the group where the financial instrument falls based on the number of days until the due date.
**Returns**
The terms group as a string.
**9.20. MixIns**
**223**
**Django Ledger**
## **Return type**
str
## `class django_ledger.models.mixins.SlugNameMixIn(` _*args_ , _**kwargs_ `)`
Implements a slug field and a name field to a base Django Model.
```
slug
```
A unique slug field to use as an index. Validates that the slug is at least 10 characters long.
**Type** str
```
name
```
A human-readable name for display purposes. Maximum 150 characters.
**Type** str
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`class django_ledger.models.mixins.TaxCollectionMixIn(` _*args_ , _**kwargs_ `)`
Implements functionality used to add tax collection rates and or withholding to a base Django Model. This field may be used to set a pre-defined withholding rate to a financial instrument, customer, vendor, etc.
```
sales_tax_rate
```
The tax rate as a float. A Number between 0.00 and 1.00.
**Type** float
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
`class django_ledger.models.mixins.TaxInfoMixIn(` _*args_ , _**kwargs_ `)`
## `clean()`
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
## **9.21 Signals**
Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
The signals module provide the means to notify listeners about important events or states in the models, such as a ledger model being posted or a bill status changing.
**224**
**Chapter 9. Models**
**CHAPTER TEN**
## **INDICES AND TABLES**
- • genindex
- • modindex
- • search
**225**
**Django Ledger**
**226**
**Chapter 10. Indices and tables**
## **PYTHON MODULE INDEX**
d
`django_ledger.io.io_context` , 35 `django_ledger.io.io_core` , 40 `django_ledger.io.io_generator` , 58 `django_ledger.io.io_library` , 35 `django_ledger.io.io_middleware` , 35 `django_ledger.io.ratios` , 58 `django_ledger.io.roles` , 58 `django_ledger.models.accounts` , 85 `django_ledger.models.bank_account` , 123 `django_ledger.models.bill` , 152 `django_ledger.models.chart_of_accounts` , 124 `django_ledger.models.coa_default` , 131 `django_ledger.models.customer` , 207 `django_ledger.models.entity` , 61 `django_ledger.models.estimate` , 167 `django_ledger.models.invoice` , 192 `django_ledger.models.items` , 141 `django_ledger.models.journal_entry` , 108 `django_ledger.models.ledger` , 96 `django_ledger.models.mixins` , 214 `django_ledger.models.purchase_order` , 181 `django_ledger.models.receipt` , 134 `django_ledger.models.signals` , 224 `django_ledger.models.transactions` , 101 `django_ledger.models.unit` , 83 `django_ledger.models.vendor` , 211
**227**
**Django Ledger**
**228**
**Python Module Index**
## **INDEX**
## Symbols
|Symbols
_method_), 183|
|---|
|`_coa_slug` (_django_ledger.models.accounts.AccountModelAbstract_
_attribute_), 88
`activate()` (_django_ledger.models.accounts.AccountModelAbstract_
_method_), 87
`active` (_django_ledger.models.accounts.AccountModelAbstract_|
|A
_attribute_), 87|
|`aba_number` (_django_ledger.models.mixins.FinancialAccountInfoMixin_
_attribute_), 220
`account` (_django_ledger.models.transactions.TransactionModelAbstract_
_attribute_), 102
`account_code` (_django_ledger.io.io_library.TransactionInstructionItem_
_attribute_), 39
`account_model` (_django_ledger.io.io_library.TransactionInstructionItem_
_attribute_), 40
`account_model` (_django_ledger.models.bank_account.BankAccountModelAbstract_
_attribute_), 123
`account_number` (_django_ledger.models.mixins.FinancialAccountInfoMixin_
_attribute_), 220
`account_type` (_django_ledger.models.mixins.FinancialAccountInfoMixin_
_attribute_), 221
`AccountModel`
(_class_
_in_
_django_ledger.models.accounts_), 86
`AccountModel.DoesNotExist`, 86
`AccountModel.MultipleObjectsReturned`, 86
`AccountModelAbstract`
(_class_
_in_
_django_ledger.models.accounts_), 86
`AccountModelAbstract.Meta`
(_class_
_in_
_django_ledger.models.accounts_), 87
`AccountModelManager`
(_class_
_in_
_django_ledger.models.accounts_), 92
`AccountModelQuerySet`
(_class_
_in_
_django_ledger.models.accounts_), 93
`AccountModelValidationError`, 96
`accounts_digest`
(_django_ledger.io.io_core.IOResult_
_attribute_), 55
`accrual_method` (_django_ledger.models.entity.EntityModelAbstract_
_attribute_), 63
`AccrualMixIn` (_class in django_ledger.models.mixins_),
214
`accrue` (_django_ledger.models.mixins.AccrualMixIn at-_
_tribute_), 214
`action_bind_estimate()`
(_django_ledger.models.purchase_order.PurchaseOrderModelAbstract_
`active` (_django_ledger.models.bank_account.BankAccountModelAbstract_
_attribute_), 123
`active` (_django_ledger.models.chart_of_accounts.ChartOfAccountModelAb_
_attribute_), 125
`active` (_django_ledger.models.customer.CustomerModelAbstract_
_attribute_), 208
`active` (_django_ledger.models.unit.EntityUnitModelAbstract_
_attribute_), 83
`active` (_django_ledger.models.vendor.VendorModelAbstract_
_attribute_), 211
`active()` (_django_ledger.models.accounts.AccountModelQuerySet_
_method_), 93
`active()` (_django_ledger.models.bank_account.BankAccountModelQueryS_
_method_), 124
`active()` (_django_ledger.models.bill.BillModelQuerySet_
_method_), 165
`active()` (_django_ledger.models.chart_of_accounts.ChartOfAccountMode_
_method_), 131
`active()` (_django_ledger.models.customer.CustomerModelQueryset_
_method_), 210
`active()` (_django_ledger.models.invoice.InvoiceModelQuerySet_
_method_), 206
`active()` (_django_ledger.models.items.ItemModelQuerySet_
_method_), 146
`active()` (_django_ledger.models.purchase_order.PurchaseOrderModelQue_
_method_), 192
`active()` (_django_ledger.models.vendor.VendorModelQuerySet_
_method_), 213
`activity` (_django_ledger.models.journal_entry.JournalEntryModelAbstrac_
_attribute_), 109
`ActivityEnum`
(_class_
_in_
_django_ledger.models.journal_entry_), 108
`additional_info` (_django_ledger.models.bill.BillModelAbstract_
_attribute_), 152
`additional_info` (_django_ledger.models.customer.CustomerModelAbstra_
_attribute_), 208
`additional_info` (_django_ledger.models.invoice.InvoiceModelAbstract_|
**229**
**Django Ledger**
|_attribute_), 193|`BankAccountModelManager`
(_class_|_in_|
|---|---|---|
|`additional_info` (_django_ledger.models.items.ItemModelAbstract_
_django_ledger.models.bank_account_), 124|||
|_attribute_), 143|`BankAccountModelQuerySet`
(_class_|_in_|
|`additional_info` (_django_ledger.models.vendor.VendorModelAbstract_
_django_ledger.models.bank_account_), 124|||
|_attribute_), 212|`BankAccountValidationError`, 124||
|`address_1` (_django_ledger.models.mixins.ContactInfoMixIn_
`bill_items` (_django_ledger.models.bill.BillModelAbstract_|||
|_attribute_), 219|_attribute_), 153||
|`address_2` (_django_ledger.models.mixins.ContactInfoMixIn_
`bill_number` (_django_ledger.models.bill.BillModelAbstract_|||
|_attribute_), 219|_attribute_), 152||
|`admin` (_django_ledger.models.entity.EntityModelAbstract_|`BILL_STATUS` (_django_ledger.models.bill.BillModelAbstract_||
|_attribute_), 62|_attribute_), 153||
|`aggregate_balances()`|`bill_status` (_django_ledger.models.bill.BillModelAbstract_||
|(_django_ledger.io.io_core.IODatabaseMixIn_|_attribute_), 152||
|_static method_), 42|`BillModel` (_class in django_ledger.models.bill_), 152||
|`alt_str()` (_django_ledger.models.accounts.AccountModelAbstract_
`BillModel.DoesNotExist`, 152|||
|_method_), 87|`BillModel.MultipleObjectsReturned`, 152||
|`amount` (_django_ledger.io.io_library.TransactionInstructionItem_
`BillModelAbstract`
(_class_||_in_|
|_attribute_), 39|_django_ledger.models.bill_), 152||
|`amount` (_django_ledger.models.transactions.TransactionModelAbstract_
`BillModelManager`
(_class_||_in_|
|_attribute_), 102|_django_ledger.models.bill_), 165||
|`amount_due` (_django_ledger.models.mixins.AccrualMixIn_|`BillModelQuerySet`
(_class_|_in_|
|_attribute_), 214|_django_ledger.models.bill_), 165||
|`amount_earned` (_django_ledger.models.mixins.AccrualMixIn_
`BillModelValidationError`, 167|||
|_attribute_), 214|`bills()` (_django_ledger.models.items.ItemModelQuerySet_||
|`amount_paid` (_django_ledger.models.mixins.AccrualMixIn_|_method_), 146||
|_attribute_), 214|`bind_estimate()` (_django_ledger.models.bill.BillModelAbstract_||
|`amount_receivable` (_django_ledger.models.mixins.AccrualMixIn_
_method_), 153|||
|_attribute_), 214|`bind_estimate()` (_django_ledger.models.invoice.InvoiceModelAbstract_||
|`amount_unearned` (_django_ledger.models.mixins.AccrualMixIn_
_method_), 194|||
|_attribute_), 214
`approved()` (_django_ledger.models.bill.BillModelQuerySet_
C|||
|_method_), 166|`can_activate()` (_django_ledger.models.accounts.AccountModelAbstract_||
|`approved()` (_django_ledger.models.estimate.EstimateModelQuerySet_
_method_), 87|||
|_method_), 181|`can_activate()` (_django_ledger.models.chart_of_accounts.ChartOfAccou_||
|`approved()` (_django_ledger.models.invoice.InvoiceModelQuerySet_
_method_), 126|||
|_method_), 206|`can_approve()` (_django_ledger.models.bill.BillModelAbstract_||
|`approved()` (_django_ledger.models.purchase_order.PurchaseOrderModelQuerySet_
_method_), 154|||
|_method_), 192|`can_approve()` (_django_ledger.models.estimate.EstimateModelAbstract_||
|B|_method_), 170
`can_approve()` (_django_ledger.models.invoice.InvoiceModelAbstract_||
|`balance_sheet_statement`|_method_), 194||
|(_django_ledger.io.io_core.IOReportMixIn.ReportTuple_
`can_approve()` (_django_ledger.models.purchase_order.PurchaseOrderMo_|||
|_attribute_), 49|_method_), 183||
|`BALANCE_TYPE` (_django_ledger.models.accounts.AccountModelAbstract_
`can_bind()` (_django_ledger.models.estimate.EstimateModelAbstract_|||
|_attribute_), 86|_method_), 170||
|`balance_type` (_django_ledger.models.accounts.AccountModelAbstract_
`can_bind_estimate()`|||
|_attribute_), 86|(_django_ledger.models.bill.BillModelAbstract_||
|`BankAccountModel`
(_class_
_in_|_method_), 154||
|_django_ledger.models.bank_account_), 123|`can_bind_estimate()`||
|`BankAccountModel.DoesNotExist`, 123|(_django_ledger.models.invoice.InvoiceModelAbstract_||
|`BankAccountModel.MultipleObjectsReturned`, 123|_method_), 195||
|`BankAccountModelAbstract`
(_class_
_in_|`can_bind_estimate()`||
|_django_ledger.models.bank_account_), 123|(_django_ledger.models.purchase_order.PurchaseOrderModelAbst_||
||_method_), 184||
**230**
**Index**
**Django Ledger**
`can_bind_po()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 170 _method_ ), 154 `can_generate_invoice_number() can_cancel()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 154 _method_ ), 195 `can_cancel()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `can_generate_je_number()` _method_ ), 170 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `can_cancel()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 110 _method_ ), 195 `can_generate_po_number() can_cancel()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 184 _method_ ), 184 `can_complete()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `can_generate_receipt_number()` _method_ ), 170 ( _django_ledger.models.receipt.ReceiptModelAbstract_ `can_create_bill()` ( _django_ledger.models.items.ItemTransactionModelAbstractmethod_ ), 134 _method_ ), 147 `can_generate_vendor_number() can_deactivate()` ( _django_ledger.models.accounts.AccountModelAbstract_ ( _django_ledger.models.vendor.VendorModelAbstract method_ ), 87 _method_ ), 212 `can_deactivate()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `can_hide()` ( _django_ledger.models.ledger.LedgerModelAbstract method_ ), 126 _method_ ), 97 `can_delete()` ( _django_ledger.models.bill.BillModelAbstract_ `can_lock()` ( _django_ledger.models.journal_entry.JournalEntryModelAbst method_ ), 154 _method_ ), 110 `can_delete()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `can_lock()` ( _django_ledger.models.ledger.LedgerModelAbstract method_ ), 195 _method_ ), 97 `can_delete()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `can_make_payment()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 110 _method_ ), 155 `can_delete()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `can_make_payment()` ( _django_ledger.models.invoice.InvoiceModelAbstra method_ ), 184 _method_ ), 196 `can_delete()` ( _django_ledger.models.receipt.ReceiptModelAbstract_ `can_migrate()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 134 _method_ ), 155 `can_draft()` ( _django_ledger.models.bill.BillModelAbstract_ `can_migrate()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 155 _method_ ), 196 `can_draft()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `can_migrate()` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 170 _method_ ), 215 `can_draft()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `can_migrate()` ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 195 _method_ ), 134 `can_draft()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `can_migrate_itemtxs()` _method_ ), 184 ( _django_ledger.models.bill.BillModelAbstract_ `can_edit()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 155 _method_ ), 110 `can_migrate_itemtxs() can_edit_items()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 155 _method_ ), 171 `can_edit_items()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `can_migrate_itemtxs()` _method_ ), 195 ( _django_ledger.models.invoice.InvoiceModelAbstract_ `can_edit_items()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 196 _method_ ), 184 `can_migrate_itemtxs() can_fulfill()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.mixins.ItemizeMixIn method_ ), 184 _method_ ), 221 `can_generate_bill_number() can_migrate_itemtxs()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 155 _method_ ), 185 `can_generate_customer_number() can_pay()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.customer.CustomerModelAbstract method_ ), 155 _method_ ), 209 `can_pay()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `can_generate_estimate_number()` _method_ ), 196 ( _django_ledger.models.estimate.EstimateModelAbstract_ `can_post()` ( _django_ledger.models.journal_entry.JournalEntryModelAbst_
**Index**
**231**
**Django Ledger**
_method_ ), 110 _attribute_ ), 153 `can_post()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `ce_model` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 97 _attribute_ ), 193 `can_review()` ( _django_ledger.models.bill.BillModelAbstract_ `ce_model` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbs method_ ), 156 _attribute_ ), 183 `can_review()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `ce_to_date` ( _django_ledger.io.io_core.IOResult atmethod_ ), 171 _tribute_ ), 55 `can_review()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `ChartOfAccountModel` ( _class in method_ ), 196 _django_ledger.models.chart_of_accounts_ ), `can_review()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ 125 _method_ ), 185 `ChartOfAccountModel.DoesNotExist` , 125 `can_transact()` ( _django_ledger.models.accounts.AccountModelAbstract_ `ChartOfAccountModel.MultipleObjectsReturned` , _method_ ), 88 125 `can_transact()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `ChartOfAccountModelAbstract` ( _class in method_ ), 93 _django_ledger.models.chart_of_accounts_ ), `can_unhide()` ( _django_ledger.models.ledger.LedgerModelAbstract_ 125 _method_ ), 97 `ChartOfAccountModelManager` ( _class in_ `can_unlock()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractdjango_ledger.models.chart_of_accounts_ ), _method_ ), 110 130 `can_unlock()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `ChartOfAccountModelQuerySet` ( _class in method_ ), 98 _django_ledger.models.chart_of_accounts_ ), `can_unpost()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ 130 _method_ ), 110 `ChartOfAccountsModelValidationError` , 131 `can_unpost()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `check_tx_balance()` ( _in module method_ ), 98 _django_ledger.io.io_core_ ), 55 `can_update_items()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `city` ( _django_ledger.models.mixins.ContactInfoMixIn atmethod_ ), 171 _tribute_ ), 219 `can_void()` ( _django_ledger.models.bill.BillModelAbstract_ `clean()` ( _django_ledger.models.accounts.AccountModelAbstract method_ ), 156 _method_ ), 88 `can_void()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `clean()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 171 _method_ ), 156 `can_void()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `clean()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelA method_ ), 196 _method_ ), 126 `can_void()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `clean()` ( _django_ledger.models.customer.CustomerModelAbstract method_ ), 185 _method_ ), 209 `canceled()` ( _django_ledger.models.bill.BillModelQuerySet_ `clean()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 166 _method_ ), 63 `canceled()` ( _django_ledger.models.invoice.InvoiceModelQuerySet_ `clean()` ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 206 _method_ ), 171 `capital_contribution clean()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.io.io_generator.EntityDataGenerator method_ ), 196 _attribute_ ), 59 `clean()` ( _django_ledger.models.items.ItemModelAbstract_ `cash()` ( _django_ledger.models.accounts.AccountModelQuerySet method_ ), 143 _method_ ), 93 `clean()` ( _django_ledger.models.items.ItemTransactionModelAbstract_ `cash_account` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 147 _attribute_ ), 215 `clean()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `cash_flow_statement` _method_ ), 110 ( _django_ledger.io.io_core.IOReportMixIn.ReportTuple_ `clean()` ( _django_ledger.models.mixins.AccrualMixIn attribute_ ), 49 _method_ ), 215 `ce_from_date` ( _django_ledger.io.io_core.IOResult at-_ `clean()` ( _django_ledger.models.mixins.ContactInfoMixIn tribute_ ), 54 _method_ ), 220 `ce_match` ( _django_ledger.io.io_core.IOResult attribute_ ), `clean()` ( _django_ledger.models.mixins.CreateUpdateMixIn_ 54 _method_ ), 220 `ce_model` ( _django_ledger.models.bill.BillModelAbstract_ `clean()` ( _django_ledger.models.mixins.ItemizeMixIn_
**232**
**Index**
**Django Ledger**
_method_ ), 221 `contracts()` ( _django_ledger.models.estimate.EstimateModelQuerySet_ `clean()` ( _django_ledger.models.mixins.MarkdownNotesMixIn method_ ), 181 _method_ ), 222 `country` ( _django_ledger.models.mixins.ContactInfoMixIn_ `clean()` ( _django_ledger.models.mixins.PaymentTermsMixIn attribute_ ), 219 _method_ ), 223 `create()` ( _django_ledger.models.journal_entry.JournalEntryModelQueryS_ `clean()` ( _django_ledger.models.mixins.SlugNameMixIn method_ ), 121 _method_ ), 224 `create_account()` ( _django_ledger.models.accounts.AccountModelAbstra_ `clean()` ( _django_ledger.models.mixins.TaxCollectionMixIn class method_ ), 88 _method_ ), 224 `create_account()` ( _django_ledger.models.chart_of_accounts.ChartOfAcc_ `clean()` ( _django_ledger.models.mixins.TaxInfoMixIn method_ ), 126 _method_ ), 224 `create_account()` ( _django_ledger.models.entity.EntityModelAbstract_ `clean()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 63 _method_ ), 185 `create_account_by_kwargs() clean()` ( _django_ledger.models.receipt.ReceiptModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 135 _method_ ), 64 `clean()` ( _django_ledger.models.unit.EntityUnitModelAbstract_ `create_bank_account()` _method_ ), 84 ( _django_ledger.models.entity.EntityModelAbstract_ `clean()` ( _django_ledger.models.vendor.VendorModelAbstract method_ ), 64 _method_ ), 212 `create_bill()` ( _django_ledger.models.entity.EntityModelAbstract_ `cleared` ( _django_ledger.models.transactions.TransactionModelAbstractmethod_ ), 65 _attribute_ ), 103 `create_chart_of_accounts() coa_id` ( _django_ledger.models.transactions.TransactionModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract property_ ), 103 _method_ ), 66 `coa_model` ( _django_ledger.models.accounts.AccountModelAbstract_ `create_customer()` ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 87, 88 _method_ ), 66 `coa_slug` ( _django_ledger.models.accounts.AccountModelAbstract_ `create_entity()` ( _django_ledger.models.entity.EntityModelAbstract property_ ), 88 _class method_ ), 66 `code` ( _django_ledger.models.accounts.AccountModelAbstract_ `create_entity_unit_slug()` _attribute_ ), 86 ( _django_ledger.models.unit.EntityUnitModelAbstract_ `cogs_account` ( _django_ledger.models.items.ItemModelAbstract method_ ), 84 _attribute_ ), 143 `create_estimate()` ( _django_ledger.models.entity.EntityModelAbstract_ `commit()` ( _django_ledger.io.io_library.IOBluePrint method_ ), 66 _method_ ), 35 `create_invoice()` ( _django_ledger.models.entity.EntityModelAbstract_ `commit()` ( _django_ledger.io.io_library.IOCursor method_ ), 67 _method_ ), 37 `create_item_expense() commit_txs()` ( _django_ledger.io.io_core.IODatabaseMixIn_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 43 _method_ ), 67 `compile_instructions() create_item_inventory()` ( _django_ledger.io.io_library.IOCursor_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 37 _method_ ), 68 `configure()` ( _django_ledger.models.bill.BillModelAbstract_ `create_item_product()` _method_ ), 156 ( _django_ledger.models.entity.EntityModelAbstract_ `configure()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractmethod_ ), 68 _method_ ), 126 `create_item_service() configure()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 171 _method_ ), 69 `configure()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `create_purchase_order()` _method_ ), 196 ( _django_ledger.models.entity.EntityModelAbstract_ `configure()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 69 _method_ ), 185 `create_uom()` ( _django_ledger.models.entity.EntityModelAbstract_ `configure()` ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 69 _method_ ), 135 `create_vendor()` ( _django_ledger.models.entity.EntityModelAbstract_ `ContactInfoMixIn` ( _class in method_ ), 70 _django_ledger.models.mixins_ ), 219 `created` ( _django_ledger.models.mixins.CreateUpdateMixIn_
**Index**
**233**
**Django Ledger**
_attribute_ ), 220 `date_draft` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `CreateUpdateMixIn` ( _class in attribute_ ), 193 _django_ledger.models.mixins_ ), 220 `date_draft` ( _django_ledger.models.purchase_order.PurchaseOrderModelA_ `credit()` ( _django_ledger.io.io_library.IOBluePrint attribute_ ), 182 _method_ ), 36 `date_fulfilled` ( _django_ledger.models.purchase_order.PurchaseOrderM_ `current()` ( _django_ledger.models.ledger.LedgerModelQuerySet attribute_ ), 183 _method_ ), 100 `date_in_review` ( _django_ledger.models.bill.BillModelAbstract_ `customer` ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 153 _attribute_ ), 168 `date_in_review` ( _django_ledger.models.estimate.EstimateModelAbstract_ `customer` ( _django_ledger.models.invoice.InvoiceModelAbstract attribute_ ), 169 _attribute_ ), 193 `date_in_review` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `customer_name` ( _django_ledger.models.customer.CustomerModelAbstractattribute_ ), 194 _attribute_ ), 208 `date_in_review` ( _django_ledger.models.purchase_order.PurchaseOrderM_ `customer_number` ( _django_ledger.models.customer.CustomerModelAbstracattribue_ _**t**_ ), 182 _attribute_ ), 208 `date_paid` ( _django_ledger.models.bill.BillModelAbstract_ `customer_picture_upload_to()` ( _in module attribute_ ), 153 _django_ledger.models.customer_ ), 210 `date_paid` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `CustomerModel` ( _class in attribute_ ), 194 _django_ledger.models.customer_ ), 208 `date_void` ( _django_ledger.models.bill.BillModelAbstract_ `CustomerModel.DoesNotExist` , 208 _attribute_ ), 153 `CustomerModel.MultipleObjectsReturned` , 208 `date_void` ( _django_ledger.models.estimate.EstimateModelAbstract_ `CustomerModelAbstract` ( _class in attribute_ ), 169 _django_ledger.models.customer_ ), 208 `date_void` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `CustomerModelManager` ( _class in attribute_ ), 194 _django_ledger.models.customer_ ), 209 `date_void` ( _django_ledger.models.purchase_order.PurchaseOrderModelAb_ `CustomerModelQueryset` ( _class in attribute_ ), 183 _django_ledger.models.customer_ ), 209 `days_forward` ( _django_ledger.io.io_generator.EntityDataGenerator_ `CustomerModelValidationError` , 210 _attribute_ ), 59 `db_from_date` ( _django_ledger.io.io_core.IOResult at-_ D _tribute_ ), 54 `database_digest()` ( _django_ledger.io.io_core.IODatabaseMixIn_ `db_to_date` ( _django_ledger.io.io_core.IOResult atmethod_ ), 43 _tribute_ ), 54 `date_approved` ( _django_ledger.models.bill.BillModelAbstract_ `deactivate()` ( _django_ledger.models.accounts.AccountModelAbstract attribute_ ), 153 _method_ ), 89 `date_approved` ( _django_ledger.models.estimate.EstimateModelAbstract_ `debit()` ( _django_ledger.io.io_library.IOBluePrint attribute_ ), 169 _method_ ), 36 `date_approved` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `default_amount` ( _django_ledger.models.items.ItemModelAbstract attribute_ ), 194 _attribute_ ), 142 `date_approved` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `default_coa` ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 183 _attribute_ ), 63 `date_canceled` ( _django_ledger.models.bill.BillModelAbstract_ `delete()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstrac attribute_ ), 153 _method_ ), 111 `date_canceled` ( _django_ledger.models.estimate.EstimateModelAbstract_ `delete()` ( _django_ledger.models.receipt.ReceiptModelAbstract attribute_ ), 169 _method_ ), 135 `date_canceled` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `description` ( _django_ledger.io.io_library.TransactionInstructionItem attribute_ ), 194 _attribute_ ), 40 `date_canceled` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `description` ( _django_ledger.models.chart_of_accounts.ChartOfAccountM attribute_ ), 183 _attribute_ ), 126 `date_completed` ( _django_ledger.models.estimate.EstimateModelAbstract_ `description` ( _django_ledger.models.customer.CustomerModelAbstract attribute_ ), 169 _attribute_ ), 208 `date_draft` ( _django_ledger.models.bill.BillModelAbstract_ `description` ( _django_ledger.models.journal_entry.JournalEntryModelAbs attribute_ ), 153 _attribute_ ), 109 `date_draft` ( _django_ledger.models.estimate.EstimateModelAbstract_ `description` ( _django_ledger.models.transactions.TransactionModelAbstra attribute_ ), 168 _attribute_ ), 102
**234**
**Index**
**Django Ledger**
- `description` ( _django_ledger.models.vendor.VendorModelAbstract attribute_ ), 211
- `diff_tx_data()` ( _in module django_ledger.io.io_core_ ), 55
- `digest()` ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 45
- `digest_balance_sheet()` ( _django_ledger.io.io_core.IOReportMixIn method_ ), 49
- `digest_cash_flow_statement()`
- ( _django_ledger.io.io_core.IOReportMixIn method_ ), 50
- `digest_financial_statements()`
- ( _django_ledger.io.io_core.IOReportMixIn method_ ), 50
- `digest_income_statement()`
- ( _django_ledger.io.io_core.IOReportMixIn_
- _method_ ), 51
- `dispatch()` ( _django_ledger.io.io_library.IOCursor_
- _method_ ), 37
- `django_ledger.io.io_context module` , 35
- `django_ledger.io.io_core module` , 40
`django_ledger.models.journal_entry module` , 108 `django_ledger.models.ledger module` , 96 `django_ledger.models.mixins module` , 214 `django_ledger.models.purchase_order module` , 181 `django_ledger.models.receipt module` , 134 `django_ledger.models.signals module` , 224 `django_ledger.models.transactions module` , 101 `django_ledger.models.unit module` , 83 `django_ledger.models.vendor module` , 211 `document_prefix` ( _django_ledger.models.unit.EntityUnitModelAbstract attribute_ ), 83 `draft()` ( _django_ledger.models.bill.BillModelQuerySet method_ ), 166 `draft()` ( _django_ledger.models.invoice.InvoiceModelQuerySet method_ ), 206 `due_in_days()` ( _django_ledger.models.mixins.PaymentTermsMixIn method_ ), 223
- `django_ledger.io.io_generator module` , 58
- `django_ledger.io.io_library module` , 35
E
- `django_ledger.io.io_middleware module` , 35
- `django_ledger.io.ratios module` , 58
- `django_ledger.io.roles module` , 58
- `django_ledger.models.accounts module` , 85
- `django_ledger.models.bank_account module` , 123
- `django_ledger.models.bill module` , 152
- `django_ledger.models.chart_of_accounts module` , 124
- `django_ledger.models.coa_default module` , 131
- `django_ledger.models.customer module` , 207
`earnings_account` ( _django_ledger.models.items.ItemModelAbstract attribute_ ), 143 `email` ( _django_ledger.models.mixins.ContactInfoMixIn attribute_ ), 219 `entity` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAb attribute_ ), 125 `entity` ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 168 `entity` ( _django_ledger.models.items.ItemModelAbstract attribute_ ), 143 `entity` ( _django_ledger.models.items.UnitOfMeasureModelAbstract attribute_ ), 151 `entity` ( _django_ledger.models.ledger.LedgerModelAbstract attribute_ ), 97 `entity` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstra attribute_ ), 182 `entity` ( _django_ledger.models.unit.EntityUnitModelAbstract attribute_ ), 83
- `django_ledger.models.entity module` , 61
- `django_ledger.models.estimate module` , 167
`entity_last_closing_date` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract property_ ), 111 `entity_model` ( _django_ledger.io.io_generator.EntityDataGenerator attribute_ ), 59
- `django_ledger.models.invoice module` , 192
- `entity_model` ( _django_ledger.models.bank_account.BankAccountModelAb attribute_ ), 123
- `django_ledger.models.items module` , 141
**Index**
**235**
**Django Ledger**
`entity_model` ( _django_ledger.models.customer.CustomerModelAbstractdjango_ledger.models.unit_ ), 84 _attribute_ ), 208 `EntityUnitModelManager` ( _class in_ `entity_model` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractdjango_ledger.models.unit_ ), 84 _property_ ), 111 `EntityUnitModelQuerySet` ( _class in_ `entity_model` ( _django_ledger.models.vendor.VendorModelAbstract django_ledger.models.unit_ ), 85 _attribute_ ), 211 `EntityUnitModelValidationError` , 85 `entity_slug` ( _django_ledger.models.accounts.AccountModelAbstract_ `equipment_estimate` ( _django_ledger.models.estimate.EstimateModelAbst property_ ), 89 _attribute_ ), 169 `entity_slug` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `estimate_number` ( _django_ledger.models.estimate.EstimateModelAbstract property_ ), 111 _attribute_ ), 168 `entity_slug` ( _django_ledger.models.receipt.ReceiptModelAbstract_ `EstimateModel` ( _class in property_ ), 136 _django_ledger.models.estimate_ ), 167 `entity_unit` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `EstimateModel.DoesNotExist` , 168 _attribute_ ), 109 `EstimateModel.MultipleObjectsReturned` , 168 `entity_uuid` ( _django_ledger.models.receipt.ReceiptModelAbstract_ `EstimateModelAbstract` ( _class in property_ ), 136 _django_ledger.models.estimate_ ), 168 `EntityDataGenerator` ( _class in_ `EstimateModelManager` ( _class in django_ledger.io.io_generator_ ), 58 _django_ledger.models.estimate_ ), 180 `EntityManagementModel` ( _class in_ `EstimateModelQuerySet` ( _class in django_ledger.models.entity_ ), 62 _django_ledger.models.estimate_ ), 181 `EntityManagementModel.DoesNotExist` , 62 `EstimateModelValidationError` , 181 `EntityManagementModel.MultipleObjectsReturned` , `estimates()` ( _django_ledger.models.estimate.EstimateModelQuerySet_ 62 _method_ ), 181 `EntityManagementModelAbstract` ( _class in_ `expense_account` ( _django_ledger.models.items.ItemModelAbstract django_ledger.models.entity_ ), 62 _attribute_ ), 143 `EntityModel` ( _class in django_ledger.models.entity_ ), 62 `expenses()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `EntityModel.DoesNotExist` , 62 _method_ ), 94 `EntityModel.MultipleObjectsReturned` , 62 `expenses()` ( _django_ledger.models.items.ItemModelQuerySet_ `EntityModelAbstract` ( _class in method_ ), 146 _django_ledger.models.entity_ ), 62 `EntityModelAbstract.Meta` ( _class in_ F _django_ledger.models.entity_ ), 63 `FinancialAccountInfoMixin` ( _class in_ `EntityModelClosingEntryMixIn` ( _class in django_ledger.models.mixins_ ), 220 _django_ledger.models.entity_ ), 79 `FINANCING` ( _django_ledger.models.journal_entry.ActivityEnum_ `EntityModelFiscalPeriodMixIn` ( _class in attribute_ ), 108 _django_ledger.models.entity_ ), 79 `for_accounts()` ( _django_ledger.models.transactions.TransactionModelQu_ `EntityModelManager` ( _class in method_ ), 104 _django_ledger.models.entity_ ), 81 `for_activity()` ( _django_ledger.models.transactions.TransactionModelQu_ `EntityModelQuerySet` ( _class in method_ ), 104 _django_ledger.models.entity_ ), 82 `for_bill()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `EntityModelValidationError` , 59, 82 _method_ ), 94 `EntityStateModel` ( _class in_ `for_bill()` ( _django_ledger.models.items.ItemModelManager django_ledger.models.entity_ ), 82 _method_ ), 144 `EntityStateModel.DoesNotExist` , 82 `for_bill()` ( _django_ledger.models.transactions.TransactionModelQueryS_ `EntityStateModel.MultipleObjectsReturned` , 82 _method_ ), 105 `EntityStateModelAbstract` ( _class in_ `for_customer()` ( _django_ledger.models.receipt.ReceiptModelQuerySet django_ledger.models.entity_ ), 82 _method_ ), 139 `EntityUnitModel` ( _class in django_ledger.models.unit_ ), `for_dates()` ( _django_ledger.models.receipt.ReceiptModelQuerySet_ 83 _method_ ), 140 `EntityUnitModel.DoesNotExist` , 83 `for_entity()` ( _django_ledger.models.accounts.AccountModelManager_ `EntityUnitModel.MultipleObjectsReturned` , 83 _method_ ), 92 `EntityUnitModelAbstract` ( _class in_ `for_entity()` ( _django_ledger.models.bank_account.BankAccountModelM django_ledger.models.unit_ ), 83 _method_ ), 124 `EntityUnitModelAbstract.Meta` ( _class in_
**236**
**Index**
**Django Ledger**
`for_entity()` ( _django_ledger.models.bill.BillModelManager method_ ), 106 _method_ ), 165 `for_user()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `for_entity()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelManagermethod_ ), 94 _method_ ), 130 `for_user()` ( _django_ledger.models.bill.BillModelQuerySet_ `for_entity()` ( _django_ledger.models.customer.CustomerModelManagermethod_ ), 166 _method_ ), 209 `for_user()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountMo_ `for_entity()` ( _django_ledger.models.estimate.EstimateModelManagermethod_ ), 131 _method_ ), 180 `for_user()` ( _django_ledger.models.customer.CustomerModelQueryset_ `for_entity()` ( _django_ledger.models.invoice.InvoiceModelManagermethod_ ), 210 _method_ ), 205 `for_user()` ( _django_ledger.models.entity.EntityModelManager_ `for_entity()` ( _django_ledger.models.items.ItemModelManager method_ ), 81 _method_ ), 144 `for_user()` ( _django_ledger.models.items.ItemTransactionModelQuerySet_ `for_entity()` ( _django_ledger.models.items.UnitOfMeasureModelManagermethod_ ), 149 _method_ ), 151 `for_user()` ( _django_ledger.models.journal_entry.JournalEntryModelQue_ `for_entity()` ( _django_ledger.models.journal_entry.JournalEntryModelManagermethod_ ), 122 _method_ ), 120 `for_user()` ( _django_ledger.models.receipt.ReceiptModelQuerySet_ `for_entity()` ( _django_ledger.models.ledger.LedgerModelManager method_ ), 140 _method_ ), 100 `for_user()` ( _django_ledger.models.transactions.TransactionModelQueryS_ `for_entity()` ( _django_ledger.models.purchase_order.PurchaseOrderModelManagermethod_ ), 106 _method_ ), 191 `for_vendor()` ( _django_ledger.models.receipt.ReceiptModelQuerySet_ `for_entity()` ( _django_ledger.models.transactions.TransactionModelManagermethod_ ), 140 _method_ ), 104 `from_date()` ( _django_ledger.models.transactions.TransactionModelQuery_ `for_entity()` ( _django_ledger.models.unit.EntityUnitModelManagermethod_ ), 106 _method_ ), 84 `fulfilled()` ( _django_ledger.models.purchase_order.PurchaseOrderMode_ `for_entity()` ( _django_ledger.models.vendor.VendorModelManager method_ ), 192 _method_ ), 212 `fy_start_month` ( _django_ledger.models.entity.EntityModelAbstract_ `for_entity_active()` _attribute_ ), 63 ( _django_ledger.models.items.ItemModelManager method_ ), 144 G `for_entity_active() gb_bs_role()` ( _django_ledger.models.accounts.AccountModelQuerySet_ ( _django_ledger.models.items.UnitOfMeasureModelManagermethod_ ), 94 _method_ ), 151 `generate_activity() for_estimate()` ( _django_ledger.models.items.ItemModelManager_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstract method_ ), 145 _method_ ), 111 `for_inventory` ( _django_ledger.models.items.ItemModelAbstract_ `generate_bill_number()` _attribute_ ), 142 ( _django_ledger.models.bill.BillModelAbstract_ `for_invoice()` ( _django_ledger.models.accounts.AccountModelQuerySetmethod_ ), 156 _method_ ), 94 `generate_customer_number() for_invoice()` ( _django_ledger.models.items.ItemModelManager_ ( _django_ledger.models.customer.CustomerModelAbstract method_ ), 145 _method_ ), 209 `for_invoice()` ( _django_ledger.models.transactions.TransactionModelQuerySet_ `generate_estimate_number()` _method_ ), 105 ( _django_ledger.models.estimate.EstimateModelAbstract_ `for_journal_entry()` _method_ ), 172 ( _django_ledger.models.transactions.TransactionModelQuerySet_ `generate_invoice_number()` _method_ ), 105 ( _django_ledger.models.invoice.InvoiceModelAbstract_ `for_ledger()` ( _django_ledger.models.journal_entry.JournalEntryModelQuerySetmethod_ ), 197 _method_ ), 121 `generate_item_number() for_ledger()` ( _django_ledger.models.transactions.TransactionModelQuerySet_ ( _django_ledger.models.items.ItemModelAbstract method_ ), 105 _method_ ), 143 `for_po()` ( _django_ledger.models.items.ItemModelManager_ `generate_je_number()` _method_ ), 145 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `for_roles()` ( _django_ledger.models.transactions.TransactionModelQuerySetmethod_ ), 112 _method_ ), 105 `generate_po_number() for_unit()` ( _django_ledger.models.transactions.TransactionModelQuerySet_
( _django_ledger.models.purchase_order.PurchaseOrderModelAbst_
**Index**
**237**
**Django Ledger**
_method_ ), 185 _method_ ), 113 `generate_random_code() get_all_accounts()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.accounts.AccountModelAbstract method_ ), 71 _method_ ), 89 `get_all_coa_accounts() generate_receipt_number()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 71 _method_ ), 136 `get_amount_cash()` ( _django_ledger.models.mixins.AccrualMixIn_ `generate_slug()` ( _django_ledger.models.chart_of_accounts.ChartOfAccmethd_ _**o** untModelAbstract_ ), 215 _method_ ), 127 `get_amount_earned() generate_slug()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.mixins.AccrualMixIn method_ ), 70 _method_ ), 215 `generate_slug_from_name() get_amount_open()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 215 _static method_ ), 70 `get_amount_prepaid() generate_vendor_number()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.vendor.VendorModelAbstract method_ ), 216 _method_ ), 212 `get_amount_unearned() get_absolute_url()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ ( _django_ledger.models.mixins.AccrualMixIn method_ ), 112 _method_ ), 216 `get_absolute_url()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `get_balance_sheet_statement()` _method_ ), 98 ( _django_ledger.io.io_core.IOReportMixIn_ `get_absolute_url()` ( _django_ledger.models.receipt.ReceiptModelAbstractmethod_ ), 51 _method_ ), 136 `get_balance_sheet_url() get_account_model_qs()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.io.io_library.IOCursor method_ ), 71 _method_ ), 38 `get_bank_accounts() get_account_move_choice_queryset()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.accounts.AccountModelAbstract method_ ), 71 _method_ ), 89 `get_banks_url()` ( _django_ledger.models.entity.EntityModelAbstract_ `get_account_root_node()` _method_ ), 71 ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `get_bills()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 127 _method_ ), 72 `get_accounts_url()` ( _django_ledger.models.entity.EntityModelAbstract_ `get_bills_url()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 70 _method_ ), 72 `get_accounts_with_codes() get_blueprint()` ( _django_ledger.io.io_library.IOLibrary_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 39 _method_ ), 70 `get_cash_flow_statement() get_action_lock_url()` ( _django_ledger.io.io_core.IOReportMixIn_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 52 _method_ ), 112 `get_cashflow_statement_url() get_action_post_url()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 72 _method_ ), 112 `get_coa_account_tree() get_action_unlock_url()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelA_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 127 _method_ ), 112 `get_coa_accounts()` ( _django_ledger.models.chart_of_accounts.ChartOfA_ `get_action_unpost_url()` _method_ ), 128 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `get_coa_accounts()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 113 _method_ ), 72 `get_activity_from_roles() get_coa_model_qs()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 72 _class method_ ), 113 `get_coa_root_accounts_qs() get_activity_name()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelA_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 128
**238**
**Index**
**Django Ledger**
`get_coa_root_node()` _method_ ), 113 ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `get_detail_url()` ( _django_ledger.models.journal_entry.JournalEntryMo method_ ), 128 _method_ ), 114 `get_code_prefix()` ( _django_ledger.models.accounts.AccountModelAbstract_ `get_document_id()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 90 _method_ ), 157 `get_contract_summary() get_document_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 197 _method_ ), 172 `get_entity_last_closing_date() get_cost_estimate()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 114 _method_ ), 172 `get_entity_model_from_io() get_create_url()` ( _django_ledger.models.ledger.LedgerModelAbstract_ ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 98 _method_ ), 46 `get_cursor()` ( _django_ledger.io.io_library.IOLibrary_ `get_entity_unit_name()` _method_ ), 39 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `get_customer_list_url()` _method_ ), 114 ( _django_ledger.models.receipt.ReceiptModelAbstract_ `get_estimate_aggregate()` _method_ ), 136 ( _django_ledger.models.items.ItemTransactionModelQuerySet_ `get_customer_report_url()` _method_ ), 149 ( _django_ledger.models.receipt.ReceiptModelAbstract_ `get_estimates()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 137 _method_ ), 74 `get_customers()` ( _django_ledger.models.entity.EntityModelAbstract_ `get_financial_statements()` _method_ ), 72 ( _django_ledger.io.io_core.IOReportMixIn_ `get_customers_url()` _method_ ), 53 ( _django_ledger.models.entity.EntityModelAbstract_ `get_fiscal_quarter_dates()` _method_ ), 73 ( _django_ledger.models.entity.EntityModelFiscalPeriodMixIn_ `get_dashboard_url()` _method_ ), 79 ( _django_ledger.models.entity.EntityModelAbstract_ `get_fiscal_year_dates()` _method_ ), 73 ( _django_ledger.models.entity.EntityModelFiscalPeriodMixIn_ `get_dashboard_url()` _method_ ), 79 ( _django_ledger.models.unit.EntityUnitModelAbstract_ `get_fy_end()` ( _django_ledger.models.entity.EntityModelFiscalPeriodMixI method_ ), 84 _method_ ), 79 `get_data_import_url() get_fy_for_date()` ( _django_ledger.models.entity.EntityModelFiscalPerio_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 80 _method_ ), 73 `get_fy_start()` ( _django_ledger.models.entity.EntityModelFiscalPeriodM_ `get_default_account_for_role()` _method_ ), 80 ( _django_ledger.models.entity.EntityModelAbstract_ `get_fy_start_month()` _method_ ), 73 ( _django_ledger.models.entity.EntityModelFiscalPeriodMixIn_ `get_default_coa()` ( _django_ledger.models.entity.EntityModelAbstractmethod_ ), 80 _method_ ), 73 `get_gross_margin_estimate() get_default_coa_accounts()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 172 _method_ ), 74 `get_html_amount_due_id() get_default_coa_rst()` ( _in module_ ( _django_ledger.models.bill.BillModelAbstract django_ledger.models.coa_default_ ), 133 _method_ ), 157 `get_delete_message() get_html_amount_due_id()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 113 _method_ ), 197 `get_delete_url()` ( _django_ledger.models.entity.EntityModelAbstract_ `get_html_amount_paid_id()` _method_ ), 74 ( _django_ledger.models.bill.BillModelAbstract_ `get_delete_url()` ( _django_ledger.models.receipt.ReceiptModelAbstractmethod_ ), 157 _method_ ), 137 `get_html_amount_paid_id() get_detail_txs_url()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 197
**Index**
**239**
**Django Ledger**
`get_html_form_id()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 157 _method_ ), 75 `get_html_form_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `get_itemtxs_annotation()` _method_ ), 198 ( _django_ledger.models.estimate.EstimateModelAbstract_ `get_html_id()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 173 _method_ ), 157 `get_itemtxs_data()` ( _django_ledger.models.bill.BillModelAbstract_ `get_html_id()` ( _django_ledger.models.invoice.InvoiceModelAbstractmethod_ ), 158 _method_ ), 198 `get_itemtxs_data()` ( _django_ledger.models.estimate.EstimateModelAbst_ `get_html_pixel_indent()` _method_ ), 173 ( _django_ledger.models.accounts.AccountModelAbstract_ `get_itemtxs_data()` ( _django_ledger.models.invoice.InvoiceModelAbstra method_ ), 90 _method_ ), 198 `get_import_job_url() get_itemtxs_data()` ( _django_ledger.models.mixins.ItemizeMixIn_ ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 221 _method_ ), 137 `get_itemtxs_data()` ( _django_ledger.models.purchase_order.PurchaseOr_ `get_income_statement()` _method_ ), 186 ( _django_ledger.io.io_core.IOReportMixIn_ `get_journal_entry_create_url()` _method_ ), 53 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `get_income_statement_url()` _method_ ), 114 ( _django_ledger.models.entity.EntityModelAbstract_ `get_journal_entry_list_url()` _method_ ), 74 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `get_invoices()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 114 _method_ ), 74 `get_journal_entry_model() get_invoices_url()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 74 _method_ ), 46 `get_item_model_qs() get_ledger_model_qs()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.io.io_library.IOCursor method_ ), 157 _method_ ), 38 `get_item_model_qs() get_ledgers_url()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 75 _method_ ), 173 `get_list_url()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `get_item_model_qs()` _method_ ), 98 ( _django_ledger.models.invoice.InvoiceModelAbstract_ `get_list_url()` ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 198 _method_ ), 137 `get_item_model_qs() get_localdate()` ( _in module_ ( _django_ledger.models.mixins.ItemizeMixIn django_ledger.io.io_core_ ), 56 _method_ ), 221 `get_localtime()` ( _in module_ `get_item_model_qs()` _django_ledger.io.io_core_ ), 56 ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `get_lock_url()` ( _django_ledger.models.journal_entry.JournalEntryMode method_ ), 186 _method_ ), 114 `get_items_all()` ( _django_ledger.models.entity.EntityModelAbstract_ `get_manage_url()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 74 _method_ ), 76 `get_items_expenses() get_mark_as_approved_html_id()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 75 _method_ ), 158 `get_items_inventory() get_mark_as_approved_html_id()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 75 _method_ ), 173 `get_items_inventory_wip() get_mark_as_approved_html_id()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 75 _method_ ), 198 `get_items_products() get_mark_as_approved_html_id()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 75 _method_ ), 186 `get_items_services() get_mark_as_approved_message()`
**240**
**Index**
**Django Ledger**
( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 158 _method_ ), 199 `get_mark_as_approved_message() get_mark_as_canceled_url()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 173 _method_ ), 187 `get_mark_as_approved_message() get_mark_as_completed_html_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 198 _method_ ), 174 `get_mark_as_approved_message() get_mark_as_completed_message()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 186 _method_ ), 174 `get_mark_as_approved_url() get_mark_as_completed_url()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 158 _method_ ), 174 `get_mark_as_approved_url() get_mark_as_draft_html_id()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 173 _method_ ), 159 `get_mark_as_approved_url() get_mark_as_draft_html_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 198 _method_ ), 174 `get_mark_as_approved_url() get_mark_as_draft_html_id()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 186 _method_ ), 199 `get_mark_as_canceled_html_id() get_mark_as_draft_html_id()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 158 _method_ ), 187 `get_mark_as_canceled_html_id() get_mark_as_draft_message()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 174 _method_ ), 159 `get_mark_as_canceled_html_id() get_mark_as_draft_message()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 199 _method_ ), 175 `get_mark_as_canceled_html_id() get_mark_as_draft_message()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 186 _method_ ), 199 `get_mark_as_canceled_message() get_mark_as_draft_message()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 158 _method_ ), 187 `get_mark_as_canceled_message() get_mark_as_draft_url()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 174 _method_ ), 159 `get_mark_as_canceled_message() get_mark_as_draft_url()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 199 _method_ ), 175 `get_mark_as_canceled_message() get_mark_as_draft_url()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 187 _method_ ), 199 `get_mark_as_canceled_url() get_mark_as_draft_url()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 159 _method_ ), 187 `get_mark_as_canceled_url() get_mark_as_fulfilled_html_id()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 174 _method_ ), 187 `get_mark_as_canceled_url() get_mark_as_fulfilled_message()`
**Index**
**241**
**Django Ledger**
( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 187 _method_ ), 200 `get_mark_as_fulfilled_url() get_mark_as_review_url()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 188 _method_ ), 188 `get_mark_as_paid_html_id() get_mark_as_void_html_id()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 159 _method_ ), 160 `get_mark_as_paid_html_id() get_mark_as_void_html_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 200 _method_ ), 175 `get_mark_as_paid_message() get_mark_as_void_html_id()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 159 _method_ ), 201 `get_mark_as_paid_message() get_mark_as_void_html_id()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 200 _method_ ), 188 `get_mark_as_paid_url() get_mark_as_void_message()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 160 _method_ ), 160 `get_mark_as_paid_url() get_mark_as_void_message()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 200 _method_ ), 175 `get_mark_as_review_html_id() get_mark_as_void_message()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 160 _method_ ), 201 `get_mark_as_review_html_id() get_mark_as_void_message()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 175 _method_ ), 188 `get_mark_as_review_html_id() get_mark_as_void_url()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 200 _method_ ), 161 `get_mark_as_review_html_id() get_mark_as_void_url()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 188 _method_ ), 176 `get_mark_as_review_message() get_mark_as_void_url()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 160 _method_ ), 201 `get_mark_as_review_message() get_mark_as_void_url()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst method_ ), 175 _method_ ), 188 `get_mark_as_review_message() get_migrate_state_desc()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 200 _method_ ), 161 `get_mark_as_review_message() get_migrate_state_desc()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 188 _method_ ), 201 `get_mark_as_review_url() get_migration_data()` ( _django_ledger.models.bill.BillModelAbstract_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 160 _method_ ), 161 `get_mark_as_review_url() get_migration_data()` ( _django_ledger.models.estimate.EstimateModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 175 _method_ ), 201 `get_mark_as_review_url() get_name()` ( _django_ledger.io.io_library.IOBluePrint_
**242**
**Index**
**Django Ledger**
_method_ ), 36 _method_ ), 176 `get_non_root_coa_accounts_qs() get_root_role()` ( _django_ledger.models.accounts.AccountModelAbstract_ ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractmethod_ ), 90 _method_ ), 128 `get_staged_transaction_model() get_po_bill_queryset()` ( _django_ledger.io.io_core.IODatabaseMixIn_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 46 _method_ ), 189 `get_staged_tx_url() get_post_url()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 114 _method_ ), 138 `get_profit_estimate() get_state()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 216 _method_ ), 176 `get_status_action_date() get_progress()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.bill.BillModelAbstract method_ ), 216 _method_ ), 161 `get_progress_percent() get_status_action_date()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 216 _method_ ), 176 `get_purchase_orders() get_status_action_date()` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 76 _method_ ), 201 `get_quarter_end()` ( _django_ledger.models.entity.EntityModelFiscalPeriodMixIn_ `get_status_action_date()` _method_ ), 80 ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst_ `get_quarter_start()` _method_ ), 189 ( _django_ledger.models.entity.EntityModelFiscalPeriodMixIn_ `get_status_css_class()` _method_ ), 81 ( _django_ledger.models.items.ItemTransactionModelAbstract_ `get_queryset()` ( _django_ledger.models.accounts.AccountModelManagermethod_ ), 147 _method_ ), 93 `get_terms_net_90_plus() get_queryset()` ( _django_ledger.models.bank_account.BankAccountModelManager_ ( _django_ledger.models.mixins.PaymentTermsMixIn method_ ), 124 _method_ ), 223 `get_queryset()` ( _django_ledger.models.bill.BillModelManager_ `get_terms_start_date()` _method_ ), 165 ( _django_ledger.models.bill.BillModelAbstract_ `get_queryset()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelManagermethod_ ), 161 _method_ ), 130 `get_terms_start_date() get_queryset()` ( _django_ledger.models.entity.EntityModelManager_ ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 82 _method_ ), 202 `get_queryset()` ( _django_ledger.models.invoice.InvoiceModelManager_ `get_terms_start_date()` _method_ ), 206 ( _django_ledger.models.mixins.PaymentTermsMixIn_ `get_queryset()` ( _django_ledger.models.items.ItemModelManager method_ ), 223 _method_ ), 145 `get_terms_timedelta() get_queryset()` ( _django_ledger.models.items.UnitOfMeasureModelManager_ ( _django_ledger.models.mixins.PaymentTermsMixIn method_ ), 151 _method_ ), 223 `get_queryset()` ( _django_ledger.models.journal_entry.JournalEntryModelManager_ `get_terms_timedelta_days()` _method_ ), 121 ( _django_ledger.models.mixins.PaymentTermsMixIn_ `get_queryset()` ( _django_ledger.models.ledger.LedgerModelManagermethod_ ), 223 _method_ ), 100 `get_transaction_model() get_queryset()` ( _django_ledger.models.transactions.TransactionModelManager_ ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 104 _method_ ), 47 `get_queryset()` ( _django_ledger.models.unit.EntityUnitModelManager_ `get_transaction_queryset()` _method_ ), 85 ( _django_ledger.models.bill.BillModelAbstract_ `get_receipt_type_for_amount()` _method_ ), 161 ( _django_ledger.models.receipt.ReceiptModelAbstract_ `get_transaction_queryset()` _method_ ), 137 ( _django_ledger.models.invoice.InvoiceModelAbstract_ `get_revenue_estimate()` _method_ ), 202 ( _django_ledger.models.estimate.EstimateModelAbstract_ `get_transaction_queryset()`
**Index**
**243**
**Django Ledger**
( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `hidden()` ( _django_ledger.models.customer.CustomerModelQueryset method_ ), 115 _method_ ), 210 `get_tx_type()` ( _django_ledger.models.mixins.AccrualMixIn_ `hidden()` ( _django_ledger.models.entity.EntityModelQuerySet method_ ), 216 _method_ ), 82 `get_txs_balances()` ( _django_ledger.models.journal_entry.JournalEntryM_ `hidden()` ( _djang_ledger.models.ledger.LedgerModelQuerySet_ _**o** delAbstract method_ ), 115 _method_ ), 100 `get_txs_roles()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `hidden()` ( _django_ledger.models.vendor.VendorModelQuerySet method_ ), 115 _method_ ), 213 `get_unlock_url()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `html_id()` ( _django_ledger.models.items.ItemTransactionModelAbstract method_ ), 116 _method_ ), 148 `get_unpost_url()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `html_id_quantity()` ( _django_ledger.models.items.ItemTransactionModel method_ ), 116 _method_ ), 148 `get_uom_all()` ( _django_ledger.models.entity.EntityModelAbstract_ `html_id_unit_cost()` _method_ ), 76 ( _django_ledger.models.items.ItemTransactionModelAbstract_ `get_update_url()` ( _django_ledger.models.ledger.LedgerModelAbstracmehod_ _**t**_ ), 148 _method_ ), 98 `get_vendor_list_url()` I ( _django_ledger.models.receipt.ReceiptModelAbstract_ `in_review()` ( _django_ledger.models.bill.BillModelQuerySet method_ ), 138 _method_ ), 166 `get_vendor_report_url() in_review()` ( _django_ledger.models.invoice.InvoiceModelQuerySet_ ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 207 _method_ ), 138 `in_transit()` ( _django_ledger.models.items.ItemTransactionModelQueryS_ `get_vendors()` ( _django_ledger.models.entity.EntityModelAbstract method_ ), 150 _method_ ), 76 `inactive()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `get_vendors_url()` ( _django_ledger.models.entity.EntityModelAbstractmethod_ ), 95 _method_ ), 76 `inactive()` ( _django_ledger.models.customer.CustomerModelQueryset method_ ), 210 H `inactive()` ( _django_ledger.models.vendor.VendorModelQuerySet_ `has_activity()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 213 _method_ ), 116 `income_statement` ( _django_ledger.io.io_core.IOReportMixIn.ReportTuple_ `has_bill()` ( _django_ledger.models.items.ItemTransactionModelAbstractattribute_ ), 49 _method_ ), 147 `insert_account()` ( _django_ledger.models.chart_of_accounts.ChartOfAcc_ `has_default_coa()` ( _django_ledger.models.entity.EntityModelAbstractmethod_ ), 128 _method_ ), 76 `inventory_account` ( _django_ledger.models.items.ItemModelAbstract_ `has_estimate()` ( _django_ledger.models.items.ItemTransactionModelAbstractattribute_ ), 142 _method_ ), 147 `inventory_adjustment() has_invoice()` ( _django_ledger.models.items.ItemTransactionModelAbstract_ ( _django_ledger.models.entity.EntityModelAbstract method_ ), 147 _static method_ ), 76 `has_po()` ( _django_ledger.models.items.ItemTransactionModelAbstract_ `inventory_all()` ( _django_ledger.models.items.ItemModelQuerySet method_ ), 148 _method_ ), 146 `hidden` ( _django_ledger.models.bank_account.BankAccountModelAbstract_ `inventory_received` ( _django_ledger.models.items.ItemModelAbstract attribute_ ), 124 _attribute_ ), 143 `hidden` ( _django_ledger.models.customer.CustomerModelAbstract_ `inventory_received_value` _attribute_ ), 208 ( _django_ledger.models.items.ItemModelAbstract_ `hidden` ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 143 _attribute_ ), 63 `inventory_wip()` ( _django_ledger.models.items.ItemModelQuerySet_ `hidden` ( _django_ledger.models.ledger.LedgerModelAbstract method_ ), 146 _attribute_ ), 97 `INVESTING` ( _django_ledger.models.journal_entry.ActivityEnum_ `hidden` ( _django_ledger.models.unit.EntityUnitModelAbstract attribute_ ), 108 _attribute_ ), 84 `invoice_items` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `hidden` ( _django_ledger.models.vendor.VendorModelAbstract attribute_ ), 193 _attribute_ ), 212 `invoice_number` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `hidden()` ( _django_ledger.models.bank_account.BankAccountModelQuerySetattribute_ ), 193 _method_ ), 124
**244**
**Index**
**Django Ledger**
`INVOICE_STATUS` ( _django_ledger.models.invoice.InvoiceModelAbstractmethod_ ), 90 _attribute_ ), 194 `is_balance_valid()` ( _django_ledger.models.journal_entry.JournalEntryM_ `invoice_status` ( _django_ledger.models.invoice.InvoiceModelAbstractmethod_ ), 116 _attribute_ ), 193 `is_canceled()` ( _django_ledger.models.bill.BillModelAbstract_ `InvoiceModel` ( _class in django_ledger.models.invoice_ ), _method_ ), 162 192 `is_canceled()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `InvoiceModel.DoesNotExist` , 193 _method_ ), 176 `InvoiceModel.MultipleObjectsReturned` , 193 `is_canceled()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `InvoiceModelAbstract` ( _class in method_ ), 202 _django_ledger.models.invoice_ ), 193 `is_canceled()` ( _django_ledger.models.items.ItemTransactionModelAbstra_ `InvoiceModelManager` ( _class in method_ ), 148 _django_ledger.models.invoice_ ), 205 `is_canceled()` ( _django_ledger.models.purchase_order.PurchaseOrderMo_ `InvoiceModelQuerySet` ( _class in method_ ), 189 _django_ledger.models.invoice_ ), 206 `is_capital()` ( _django_ledger.models.accounts.AccountModelAbstract_ `InvoiceModelValidationError` , 207 _method_ ), 90 `IO_CURSOR_CLASS` ( _django_ledger.io.io_library.IOLibrary_ `is_cash_involved()` ( _django_ledger.models.journal_entry.JournalEntryM attribute_ ), 39 _method_ ), 116 `IOBluePrint` ( _class in django_ledger.io.io_library_ ), 35 `is_closing_entry` ( _django_ledger.models.journal_entry.JournalEntryMo_ `IOBluePrintValidationError` , 37 _attribute_ ), 110 `IOCursor` ( _class in django_ledger.io.io_library_ ), 37 `is_closing_entry()` ( _django_ledger.models.transactions.TransactionMo_ `IOCursorMode` ( _class in django_ledger.io.io_library_ ), 38 _method_ ), 106 `IOCursorValidationError` , 38 `is_coa_root()` ( _django_ledger.models.accounts.AccountModelAbstract_ `IODatabaseMixIn` ( _class in django_ledger.io.io_core_ ), _method_ ), 91 42 `is_coa_root()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `IODigestValidationError` , 35 _method_ ), 95 `IOLibrary` ( _class in django_ledger.io.io_library_ ), 39 `is_cogs()` ( _django_ledger.models.accounts.AccountModelAbstract_ `IOLibraryError` , 39 _method_ ), 91 `IOMixIn` ( _class in django_ledger.io.io_core_ ), 48 `is_committed()` ( _django_ledger.io.io_library.IOCursor_ `IOReportMixIn` ( _class in django_ledger.io.io_core_ ), 48 _method_ ), 38 `IOReportMixIn.ReportTuple` ( _class in_ `is_completed()` ( _django_ledger.models.estimate.EstimateModelAbstract django_ledger.io.io_core_ ), 49 _method_ ), 177 `IOResult` ( _class in django_ledger.io.io_core_ ), 54 `is_configured()` ( _django_ledger.models.bill.BillModelAbstract_ `IOValidationError` , 55 _method_ ), 162 `is_active` ( _django_ledger.models.items.ItemModelAbstract_ `is_configured()` ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 142 _method_ ), 177 `is_active` ( _django_ledger.models.items.UnitOfMeasureModelAbstract_ `is_configured()` ( _django_ledger.models.invoice.InvoiceModelAbstract attribute_ ), 151 _method_ ), 202 `is_active()` ( _django_ledger.models.accounts.AccountModelAbstract_ `is_configured()` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 90 _method_ ), 217 `is_active()` ( _django_ledger.models.bill.BillModelAbstract_ `is_configured()` ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 161 _method_ ), 138 `is_active()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `is_contract()` ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 129 _method_ ), 177 `is_active()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `is_contract_bound()` _method_ ), 202 ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst_ `is_approved()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 189 _method_ ), 162 `is_credit()` ( _django_ledger.models.accounts.AccountModelAbstract_ `is_approved()` ( _django_ledger.models.estimate.EstimateModelAbstracmehod_ _**t**_ ), 91 _method_ ), 176 `is_credit()` ( _django_ledger.models.transactions.TransactionModelAbstra_ `is_approved()` ( _django_ledger.models.invoice.InvoiceModelAbstractmethod_ ), 103 _method_ ), 202 `is_debit()` ( _django_ledger.models.accounts.AccountModelAbstract_ `is_approved()` ( _django_ledger.models.purchase_order.PurchaseOrderMmeth_ _**od** elAbstract_ ), 91 _method_ ), 189 `is_debit()` ( _django_ledger.models.transactions.TransactionModelAbstrac_ `is_asset()` ( _django_ledger.models.accounts.AccountModelAbstract method_ ), 103
**Index**
**245**
**Django Ledger**
`is_default()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractmethod_ ), 162 _method_ ), 129 `is_paid()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `is_draft()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 202 _method_ ), 162 `is_past_due()` ( _django_ledger.models.bill.BillModelAbstract_ `is_draft()` ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 162 _method_ ), 177 `is_past_due()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `is_draft()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 203 _method_ ), 202 `is_posted()` ( _django_ledger.models.journal_entry.JournalEntryModelAbs_ `is_draft()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 117 _method_ ), 189 `is_posted()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `is_entity_model()` ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 99 _method_ ), 47 `is_posted()` ( _django_ledger.models.mixins.AccrualMixIn_ `is_entity_unit_model()` _method_ ), 217 ( _django_ledger.io.io_core.IODatabaseMixIn_ `is_product_or_service` _method_ ), 47 ( _django_ledger.models.items.ItemModelAbstract_ `is_expense()` ( _django_ledger.models.accounts.AccountModelAbstracatribute_ _**t**_ ), 142 _method_ ), 91 `is_received()` ( _django_ledger.models.items.ItemTransactionModelAbstra_ `is_expense_receipt()` _method_ ), 148 ( _django_ledger.models.receipt.ReceiptModelAbstract_ `is_received()` ( _django_ledger.models.items.ItemTransactionModelQuery method_ ), 138 _method_ ), 150 `is_financing()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `is_review()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 117 _method_ ), 162 `is_fulfilled()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `is_review()` ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 189 _method_ ), 177 `is_hidden()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `is_review()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 99 _method_ ), 203 `is_in_locked_period() is_review()` ( _django_ledger.models.purchase_order.PurchaseOrderMode_ ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 189 _method_ ), 117 `is_role_default()` ( _django_ledger.models.accounts.AccountModelQuery_ `is_income()` ( _django_ledger.models.accounts.AccountModelAbstractmethod_ ), 95 _method_ ), 91 `is_root_account()` ( _django_ledger.models.accounts.AccountModelAbstr_ `is_indented()` ( _django_ledger.models.accounts.AccountModelAbstracmehod_ _**t**_ ), 92 _method_ ), 92 `is_sales_receipt()` ( _django_ledger.models.receipt.ReceiptModelAbstrac_ `is_investing()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 138 _method_ ), 117 `is_transfer_receipt() is_ledger_model()` ( _django_ledger.io.io_core.IODatabaseMixIn_ ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 47 _method_ ), 138 `is_liability()` ( _django_ledger.models.accounts.AccountModelAbstract_ `is_txs_qs_coa_valid()` _method_ ), 92 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `is_locked()` ( _django_ledger.models.accounts.AccountModelAbstractmethod_ ), 117 _method_ ), 92 `is_txs_qs_valid()` ( _django_ledger.models.journal_entry.JournalEntryM_ `is_locked()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 118 _method_ ), 117 `is_verified()` ( _django_ledger.models.journal_entry.JournalEntryModelA_ `is_locked()` ( _django_ledger.models.ledger.LedgerModelAbstract method_ ), 118 _method_ ), 99 `is_void()` ( _django_ledger.models.bill.BillModelAbstract_ `is_operating()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractmethod_ ), 163 _method_ ), 117 `is_void()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `is_ordered()` ( _django_ledger.models.items.ItemTransactionModelAbstractmethod_ ), 177 _method_ ), 148 `is_void()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `is_ordered()` ( _django_ledger.models.items.ItemTransactionModelQuerySetmethod_ ), 203 _method_ ), 150 `is_void()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAb_ `is_orphan()` ( _django_ledger.models.items.ItemTransactionModelQuerySetmethod_ ), 190 _method_ ), 150 `item_id` ( _django_ledger.models.items.ItemModelAbstract_ `is_paid()` ( _django_ledger.models.bill.BillModelAbstract attribute_ ), 142
**246**
**Index**
**Django Ledger**
`item_number` ( _django_ledger.models.items.ItemModelAbstract_ `last_closing_date` ( _django_ledger.models.receipt.ReceiptModelAbstract attribute_ ), 142 _property_ ), 139 `item_role` ( _django_ledger.models.items.ItemModelAbstract_ `ledger` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract attribute_ ), 141 _attribute_ ), 110 `item_type` ( _django_ledger.models.items.ItemModelAbstract_ `ledger` ( _django_ledger.models.mixins.AccrualMixIn atattribute_ ), 141 _tribute_ ), 214 `ItemizeError` , 221 `ledger_is_locked()` ( _django_ledger.models.journal_entry.JournalEntryM_ `ItemizeMixIn` ( _class in django_ledger.models.mixins_ ), _method_ ), 118 221 `ledger_posted` ( _django_ledger.models.receipt.ReceiptModelAbstract_ `ItemModel` ( _class in django_ledger.models.items_ ), 141 _property_ ), 139 `ItemModel.DoesNotExist` , 141 `ledger_xid` ( _django_ledger.models.ledger.LedgerModelAbstract_ `ItemModel.MultipleObjectsReturned` , 141 _attribute_ ), 97 `ItemModelAbstract` ( _class in_ `LedgerModel` ( _class in django_ledger.models.ledger_ ), 96 _django_ledger.models.items_ ), 141 `LedgerModel.DoesNotExist` , 96 `ItemModelManager` ( _class in_ `LedgerModel.MultipleObjectsReturned` , 96 _django_ledger.models.items_ ), 144 `LedgerModelAbstract` ( _class in_ `ItemModelQuerySet` ( _class in django_ledger.models.ledger_ ), 96 _django_ledger.models.items_ ), 145 `LedgerModelManager` ( _class in_ `ItemModelValidationError` , 147 _django_ledger.models.ledger_ ), 100 `ItemTransactionModel` ( _class in_ `LedgerModelQuerySet` ( _class in django_ledger.models.items_ ), 147 _django_ledger.models.ledger_ ), 100 `ItemTransactionModel.DoesNotExist` , 147 `LedgerModelValidationError` , 101 `ItemTransactionModel.MultipleObjectsReturned` , `lock()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ 147 _method_ ), 118 `ItemTransactionModelAbstract` ( _class in_ `lock()` ( _django_ledger.models.ledger.LedgerModelAbstract django_ledger.models.items_ ), 147 _method_ ), 99 `ItemTransactionModelQuerySet` ( _class in_ `lock_ledger()` ( _django_ledger.models.mixins.AccrualMixIn django_ledger.models.items_ ), 149 _method_ ), 217 `ItemTransactionModelValidationError` , 150 `locked` ( _django_ledger.models.accounts.AccountModelAbstract attribute_ ), 87 J `locked` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `je_number` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractattributeattribute_ ), 110 _attribute_ ), 109 109 `locked` ( _django_ledger.models.ledger.LedgerModelAbstract_ `journal_entry` ( _django_ledger.models.transactions.TransactionModelAbstractattributeattribute_ ), 97 _attribute_ ), 102 102 `locked()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `JOURNAL_ENTRY_MODEL_CLASS` _method_ ), 95 ( _django_ledger.io.io_core.IODatabaseMixIn_ `locked()` ( _django_ledger.models.journal_entry.JournalEntryModelQueryS attribute_ ), 42 42 _method_ ), 122 `JournalEntryModel` ( _class in_ `locked()` ( _django_ledger.models.ledger.LedgerModelQuerySet django_ledger.models.journal_entry_ ), 109 109 _method_ ), 100, 101 `JournalEntryModel.DoesNotExist` , 109 109 `LoggingMixIn` ( _class in django_ledger.models.mixins_ ), `JournalEntryModel.MultipleObjectsReturned` 222
`je_number` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractattributeattribute attribute_ ), 109 109 `locked` ( `journal_entry` ( _django_ledger.models.transactions.TransactionModelAbstractattributeattribute attribute_ ), 102 102 `locked()` ( `JOURNAL_ENTRY_MODEL_CLASS` _method_ ( _django_ledger.io.io_core.IODatabaseMixIn_ `locked()` ( _attribute_ ), 42 42 _method_ `JournalEntryModel` ( _class in_ `locked()` ( _django_ledger.models.journal_entry_ ), 109 109 _method_ `JournalEntryModel.DoesNotExist` , 109 109 `LoggingMixIn` ( 222 `JournalEntryModel.MultipleObjectsReturned` , 109 M `JournalEntryModelAbstract` ( _class in django_ledger.models.journal_entry_ ), 109 `make_payment()` ( `JournalEntryModelManager` ( _class in method_ ), 163 _django_ledger.models.journal_entry_ ), 120 `make_payment()` ( `JournalEntryModelQuerySet` ( _class in method_ ), 203 _django_ledger.models.journal_entry_ ), 121 `managers` ( `JournalEntryValidationError` , 123 _attribute_ ), 63
`make_payment()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 163 `make_payment()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 203 `managers` ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 63 `mark_as_active()` ( _django_ledger.models.chart_of_accounts.ChartOfAcc method_ ), 129
## L
`mark_as_active_url()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelA_
`labor_estimate` ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 169 (
**Index**
**247**
**Django Ledger**
_method_ ), 129 _method_ ), 204 `mark_as_approved()` ( _django_ledger.models.bill.BillModelAbstract_ `mark_as_review()` ( _django_ledger.models.purchase_order.PurchaseOrde method_ ), 163 _method_ ), 190 `mark_as_approved()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `mark_as_unlocked()` ( _django_ledger.models.journal_entry.JournalEntryM method_ ), 177 _method_ ), 119 `mark_as_approved()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `mark_as_unposted()` ( _django_ledger.models.journal_entry.JournalEntryM method_ ), 203 _method_ ), 119 `mark_as_approved()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `mark_as_void()` ( _django_ledger.models.bill.BillModelAbstract method_ ), 190 _method_ ), 164 `mark_as_canceled()` ( _django_ledger.models.bill.BillModelAbstract_ `mark_as_void()` ( _django_ledger.models.estimate.EstimateModelAbstract method_ ), 163 _method_ ), 178 `mark_as_canceled()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `mark_as_void()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 178 _method_ ), 204 `mark_as_canceled()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `mark_as_void()` ( _django_ledger.models.purchase_order.PurchaseOrderM method_ ), 204 _method_ ), 191 `mark_as_canceled()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `markdown_notes` ( _django_ledger.models.mixins.MarkdownNotesMixIn method_ ), 190 _attribute_ ), 222 `mark_as_completed() MarkdownNotesMixIn` ( _class in_ ( _django_ledger.models.estimate.EstimateModelAbstract django_ledger.models.mixins_ ), 222 _method_ ), 178 `material_estimate` ( _django_ledger.models.estimate.EstimateModelAbstra_ `mark_as_default()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractattribute_ ), 169 _method_ ), 129 `migrate_itemtxs()` ( _django_ledger.models.bill.BillModelAbstract_ `mark_as_default_url()` _method_ ), 164 ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `migrate_itemtxs()` ( _django_ledger.models.estimate.EstimateModelAbstra method_ ), 129 _method_ ), 178 `mark_as_draft()` ( _django_ledger.models.bill.BillModelAbstract_ `migrate_itemtxs()` ( _django_ledger.models.invoice.InvoiceModelAbstract method_ ), 163 _method_ ), 205 `mark_as_draft()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `migrate_itemtxs()` ( _django_ledger.models.mixins.ItemizeMixIn method_ ), 178 _method_ ), 221 `mark_as_draft()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `migrate_itemtxs()` ( _django_ledger.models.purchase_order.PurchaseOrd method_ ), 204 _method_ ), 191 `mark_as_draft()` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ `migrate_receipt()` ( _django_ledger.models.receipt.ReceiptModelAbstract method_ ), 190 _method_ ), 139 `mark_as_fulfilled() migrate_state()` ( _django_ledger.models.mixins.AccrualMixIn_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstractmethod_ ), 217 _method_ ), 190 `module mark_as_inactive()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `django_ledger.io.io_context` , 35 _method_ ), 130 `django_ledger.io.io_core` , 40 `mark_as_inactive_url() django_ledger.io.io_generator` , 58 ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `django_ledger.io.io_library` , 35 _method_ ), 130 `django_ledger.io.io_middleware` , 35 `mark_as_locked()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `django_ledger.io.ratios` , 58 _method_ ), 118 `django_ledger.io.roles` , 58 `mark_as_paid()` ( _django_ledger.models.bill.BillModelAbstract_ `django_ledger.models.accounts` , 85 _method_ ), 164 `django_ledger.models.bank_account` , 123 `mark_as_paid()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `django_ledger.models.bill` , 152 _method_ ), 204 `django_ledger.models.chart_of_accounts` , `mark_as_posted()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ 124 _method_ ), 119 `django_ledger.models.coa_default` , 131 `mark_as_review()` ( _django_ledger.models.bill.BillModelAbstract_ `django_ledger.models.customer` , 207 _method_ ), 164 `django_ledger.models.entity` , 61 `mark_as_review()` ( _django_ledger.models.estimate.EstimateModelAbstract_ `django_ledger.models.estimate` , 167 _method_ ), 178 `django_ledger.models.invoice` , 192 `mark_as_review()` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `django_ledger.models.items` , 141
**248**
**Index**
**Django Ledger**
`django_ledger.models.journal_entry` , 108 P `django_ledger.models.ledger` , 96 `paid()` ( _django_ledger.models.bill.BillModelQuerySet_ `django_ledger.models.mixins` , 214 _method_ ), 167 `django_ledger.models.purchase_order` , 181 `paid()` ( _django_ledger.models.invoice.InvoiceModelQuerySet_ `django_ledger.models.receipt` , 134 _method_ ), 207 `django_ledger.models.signals` , 224 `PaymentTermsMixIn` ( _class in_ `django_ledger.models.transactions` , 101 _django_ledger.models.mixins_ ), 222 `django_ledger.models.unit` , 83 `PDF_REPORT_MEASURE_UNIT django_ledger.models.vendor` , 211 ( _django_ledger.io.io_core.IOReportMixIn attribute_ ), 49 N `PDF_REPORT_ORIENTATION name` ( _django_ledger.models.accounts.AccountModelAbstract_ ( _django_ledger.io.io_core.IOReportMixIn attribute_ ), 86 _attribute_ ), 49 `name` ( _django_ledger.models.bank_account.BankAccountModelAbstract_ `PDF_REPORT_PAGE_SIZE` _attribute_ ), 123 ( _django_ledger.io.io_core.IOReportMixIn_ `name` ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 49 _attribute_ ), 62 `phone` ( _django_ledger.models.mixins.ContactInfoMixIn_ `name` ( _django_ledger.models.items.ItemModelAbstract atattribute_ ), 220 _tribute_ ), 141 `picture` ( _django_ledger.models.entity.EntityModelAbstract_ `name` ( _django_ledger.models.items.UnitOfMeasureModelAbstract attribute_ ), 63 _attribute_ ), 150 `po_amount` ( _django_ledger.models.purchase_order.PurchaseOrderModelAb_ `name` ( _django_ledger.models.ledger.LedgerModelAbstract attribute_ ), 182 _attribute_ ), 96 `po_amount_received` ( _django_ledger.models.purchase_order.PurchaseOr_ `name` ( _django_ledger.models.mixins.SlugNameMixIn atattribute_ ), 182 _tribute_ ), 224 `po_items` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbs_ `net_due_group()` ( _django_ledger.models.mixins.PaymentTermsMixInattribute_ ), 183 _method_ ), 223 `po_number` ( _django_ledger.models.purchase_order.PurchaseOrderModelAb_ `not_active()` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelQuerySetattribute_ ), 182 _method_ ), 131 `po_status` ( _django_ledger.models.purchase_order.PurchaseOrderModelAb_ `not_approved()` ( _django_ledger.models.estimate.EstimateModelQuerySetattribute_ ), 182 _method_ ), 181 `PO_STATUS_CANCELED` ( _django_ledger.models.purchase_order.PurchaseOr_ `not_closing_entry()` _attribute_ ), 183 ( _django_ledger.models.transactions.TransactionModelQuerySet_ `po_title` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbs method_ ), 107 _attribute_ ), 182 `not_coa_root()` ( _django_ledger.models.accounts.AccountModelQuerySet_ `populate_default_coa()` _method_ ), 95 ( _django_ledger.models.entity.EntityModelAbstract_ `notes_html()` ( _django_ledger.models.mixins.MarkdownNotesMixIn method_ ), 77 _method_ ), 222 `post()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract method_ ), 119 O `post()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `objects` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractmethod_ ), 99 _attribute_ ), 126 `post_ledger()` ( _django_ledger.models.mixins.AccrualMixIn_ `objects` ( _django_ledger.models.transactions.TransactionModelAbstractmethod_ ), 218 _attribute_ ), 103 `posted` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `OPERATING` ( _django_ledger.models.journal_entry.ActivityEnum attribute_ ), 109 _attribute_ ), 108 `posted` ( _django_ledger.models.ledger.LedgerModelAbstract_ `origin` ( _django_ledger.models.journal_entry.JournalEntryModelAbstractattribute_ ), 97 _attribute_ ), 109 `posted` ( _django_ledger.models.receipt.ReceiptModelAbstract_ `other_estimate` ( _django_ledger.models.estimate.EstimateModelAbstractproperty_ ), 139 _attribute_ ), 170 `posted()` ( _django_ledger.models.journal_entry.JournalEntryModelQueryS_ `overdue()` ( _django_ledger.models.bill.BillModelQuerySet method_ ), 122 _method_ ), 167 `posted()` ( _django_ledger.models.ledger.LedgerModelQuerySet_ `overdue()` ( _django_ledger.models.invoice.InvoiceModelQuerySet method_ ), 100, 101 _method_ ), 207 `posted()` ( _django_ledger.models.transactions.TransactionModelQuerySet_
**Index**
**249**
**Django Ledger**
_method_ ), 107 `role_default` ( _django_ledger.models.accounts.AccountModelAbstract_ `prepaid_account` ( _django_ledger.models.mixins.AccrualMixIn attribute_ ), 86 _attribute_ ), 215 `routing_number` ( _django_ledger.models.mixins.FinancialAccountInfoMixi_ `products()` ( _django_ledger.models.items.ItemModelQuerySet attribute_ ), 220 _method_ ), 146 `progress` ( _django_ledger.models.mixins.AccrualMixIn_ S _attribute_ ), 214 `sales_tax_rate` ( _django_ledger.models.mixins.TaxCollectionMixIn_ `PurchaseOrderModel` ( _class in attribute_ ), 224 _django_ledger.models.purchase_order_ ), 182 `save()` ( _django_ledger.models.customer.CustomerModelAbstract_ `PurchaseOrderModel.DoesNotExist` , 182 _method_ ), 209 `PurchaseOrderModel.MultipleObjectsReturned` , `save()` ( _django_ledger.models.estimate.EstimateModelAbstract_ 182 _method_ ), 179 `PurchaseOrderModelAbstract` ( _class in_ `save()` ( _django_ledger.models.invoice.InvoiceModelAbstract django_ledger.models.purchase_order_ ), 182 _method_ ), 205 `PurchaseOrderModelManager` ( _class in_ `save()` ( _django_ledger.models.items.ItemModelAbstract django_ledger.models.purchase_order_ ), 191 _method_ ), 144 `PurchaseOrderModelQuerySet` ( _class in_ `save()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract django_ledger.models.purchase_order_ ), 192 _method_ ), 119 `PurchaseOrderModelValidationError` , 192 `save()` ( _django_ledger.models.vendor.VendorModelAbstract_ `python_digest()` ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 212 _method_ ), 47 `services()` ( _django_ledger.models.items.ItemModelQuerySet method_ ), 146 R `sku` ( _django_ledger.models.items.ItemModelAbstract at-_ `random()` ( _in module django_ledger.io.io_generator_ ), 59 _tribute_ ), 142 `ReceiptModel` ( _class in django_ledger.models.receipt_ ), `slug` ( _django_ledger.models.mixins.SlugNameMixIn at-_ 134 _tribute_ ), 224 `ReceiptModel.DoesNotExist` , 134 `slug` ( _django_ledger.models.unit.EntityUnitModelAbstract_ `ReceiptModel.MultipleObjectsReturned` , 134 _attribute_ ), 83 `receiptmodel_presave()` ( _in module_ `SlugNameMixIn` ( _class in django_ledger.models.mixins_ ), _django_ledger.models.receipt_ ), 140 224 `ReceiptModelAbstract` ( _class in_ `sold_as_unit` ( _django_ledger.models.items.ItemModelAbstract django_ledger.models.receipt_ ), 134 _attribute_ ), 142 `ReceiptModelQuerySet` ( _class in_ `split_amount()` ( _django_ledger.models.mixins.AccrualMixIn django_ledger.models.receipt_ ), 139 _class method_ ), 218 `ReceiptModelValidationError` , 140 `STAGED_TRANSACTION_MODEL_CLASS reconciled` ( _django_ledger.models.transactions.TransactionModelAbstract_ ( _django_ledger.io.io_core.IODatabaseMixIn attribute_ ), 103 _attribute_ ), 42 `recorded_inventory() start_dttm` ( _django_ledger.io.io_generator.EntityDataGenerator_ ( _django_ledger.models.entity.EntityModelAbstract attribute_ ), 59 _method_ ), 77 `state` ( _django_ledger.models.mixins.ContactInfoMixIn_ `ReportTuple` ( _django_ledger.io.io_core.IOReportMixIn attribute_ ), 219 _attribute_ ), 49 `status` ( _django_ledger.models.estimate.EstimateModelAbstract_ `resolve_account_model_qs()` _attribute_ ), 168 ( _django_ledger.io.io_library.IOCursor_ `swift_number` ( _django_ledger.models.mixins.FinancialAccountInfoMixin method_ ), 38 _attribute_ ), 221 `resolve_ledger_model_qs()` ( _django_ledger.io.io_library.IOCursor_ T _method_ ), 38 `TaxCollectionMixIn` ( _class in_ `revenue_estimate` ( _django_ledger.models.estimate.EstimateModelAbstractdjango_ledger.models.mixins_ ), 224 _attribute_ ), 169 `TaxInfoMixIn` ( _class in django_ledger.models.mixins_ ), `role` ( _django_ledger.models.accounts.AccountModelAbstract_ 224 _attribute_ ), 86 `terms` ( _django_ledger.models.estimate.EstimateModelAbstract_ `role_bs` ( _django_ledger.models.accounts.AccountModelAbstract attribute_ ), 168
`role_bs` ( _django_ledger.models.accounts.AccountModelAbstract property_ ), 92
**250**
**Index**
**Django Ledger**
`terms` ( _django_ledger.models.mixins.PaymentTermsMixIn_ `unlock_ledger()` ( _django_ledger.models.mixins.AccrualMixIn attribute_ ), 222 _method_ ), 218 `timestamp` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `unlocked()` ( _django_ledger.models.accounts.AccountModelQuerySet attribute_ ), 109 _method_ ), 95 `title` ( _django_ledger.models.estimate.EstimateModelAbstract_ `unlocked()` ( _django_ledger.models.journal_entry.JournalEntryModelQue attribute_ ), 168 _method_ ), 122 `to_date()` ( _django_ledger.models.transactions.TransactionModelQuerySet_ `unlocked()` ( _django_ledger.models.ledger.LedgerModelQuerySet method_ ), 107 _method_ ), 100, 101 `TRANSACTION_MODEL_CLASS unpaid()` ( _django_ledger.models.bill.BillModelQuerySet_ ( _django_ledger.io.io_core.IODatabaseMixIn method_ ), 167 _attribute_ ), 42 `unpaid()` ( _django_ledger.models.invoice.InvoiceModelQuerySet_ `TransactionInstructionItem` ( _class in method_ ), 207 _django_ledger.io.io_library_ ), 39 `unpost()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstrac_ `TransactionModel` ( _class in method_ ), 120 _django_ledger.models.transactions_ ), 102 `unpost()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `TransactionModel.DoesNotExist` , 102 _method_ ), 99 `TransactionModel.MultipleObjectsReturned` , 102 `unpost_ledger()` ( _django_ledger.models.mixins.AccrualMixIn_ `transactionmodel_presave()` ( _in module method_ ), 218 _django_ledger.models.transactions_ ), 107 `unposted()` ( _django_ledger.models.journal_entry.JournalEntryModelQue_ `TransactionModelAbstract` ( _class in method_ ), 122 _django_ledger.models.transactions_ ), 102 `unposted()` ( _django_ledger.models.ledger.LedgerModelQuerySet_ `TransactionModelManager` ( _class in method_ ), 100, 101 _django_ledger.models.transactions_ ), 103 `uom` ( _django_ledger.models.items.ItemModelAbstract at-_ `TransactionModelQuerySet` ( _class in tribute_ ), 141 _django_ledger.models.transactions_ ), 104 `upc` ( _django_ledger.models.items.ItemModelAbstract at-_ `TransactionModelValidationError` , 107 _tribute_ ), 142 `tx_type` ( _django_ledger.io.io_library.TransactionInstructionItem_ `update_amount_due()` _attribute_ ), 40 ( _django_ledger.models.bill.BillModelAbstract_ `tx_type` ( _django_ledger.models.transactions.TransactionModelAbstractmethod_ ), 165 _attribute_ ), 102 `update_amount_due() txs_queryset` ( _django_ledger.io.io_core.IOResult at-_ ( _django_ledger.models.invoice.InvoiceModelAbstract tribute_ ), 55 _method_ ), 205 `update_cost_estimate()` U ( _django_ledger.models.estimate.EstimateModelAbstract_ `unearned_account` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 179 _attribute_ ), 215 `update_cost_estimate() unit_abbr` ( _django_ledger.models.items.UnitOfMeasureModelAbstract_ ( _django_ledger.models.items.ItemTransactionModelAbstract attribute_ ), 151 _method_ ), 149 `UnitOfMeasureModel` ( _class in_ `update_inventory()` ( _django_ledger.models.entity.EntityModelAbstract django_ledger.models.items_ ), 150 _method_ ), 78 `UnitOfMeasureModel.DoesNotExist` , 150 `update_po_total_amount() UnitOfMeasureModel.MultipleObjectsReturned` , ( _django_ledger.models.items.ItemTransactionModelAbstract_ 150 _method_ ), 149 `UnitOfMeasureModelAbstract` ( _class in_ `update_revenue_estimate()` _django_ledger.models.items_ ), 150 ( _django_ledger.models.estimate.EstimateModelAbstract_ `UnitOfMeasureModelManager` ( _class in method_ ), 179 _django_ledger.models.items_ ), 151 `update_revenue_estimate() UnitOfMeasureModelQuerySet` ( _class in_ ( _django_ledger.models.items.ItemTransactionModelAbstract django_ledger.models.items_ ), 151 _method_ ), 149 `unlock()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `update_state()` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 119 _method_ ), 219 `unlock()` ( _django_ledger.models.ledger.LedgerModelAbstract_ `update_state()` ( _django_ledger.models.purchase_order.PurchaseOrderM method_ ), 99 _method_ ), 191 `update_total_amount()`
**Index**
**251**
**Django Ledger**
( _django_ledger.models.items.ItemTransactionModelAbstract_ `validate_dates()` ( _in module method_ ), 149 _django_ledger.io.io_core_ ), 57 `updated` ( _django_ledger.models.mixins.CreateUpdateMixIn_ `validate_for_entity()` _attribute_ ), 220 ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `user_model` ( _django_ledger.io.io_generator.EntityDataGenerator method_ ), 120 _attribute_ ), 58 `validate_invoice_queryset() uuid` ( _django_ledger.models.accounts.AccountModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 86 _method_ ), 179 `uuid` ( _django_ledger.models.bank_account.BankAccountModelAbstract_ `validate_io_timestamp()` ( _in module attribute_ ), 123 _django_ledger.io.io_core_ ), 57 `uuid` ( _django_ledger.models.bill.BillModelAbstract at-_ `validate_item_qs()` ( _django_ledger.models.entity.EntityModelAbstract tribute_ ), 152 _method_ ), 78 `uuid` ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstract_ `validate_item_transaction_qs()` _attribute_ ), 125 ( _django_ledger.models.estimate.EstimateModelAbstract_ `uuid` ( _django_ledger.models.customer.CustomerModelAbstract method_ ), 180 _attribute_ ), 208 `validate_item_transaction_qs() uuid` ( _django_ledger.models.entity.EntityModelAbstract_ ( _django_ledger.models.purchase_order.PurchaseOrderModelAbst attribute_ ), 62 _method_ ), 191 `uuid` ( _django_ledger.models.estimate.EstimateModelAbstract_ `validate_itemtxs()` ( _django_ledger.models.mixins.ItemizeMixIn attribute_ ), 168 _method_ ), 222 `uuid` ( _django_ledger.models.invoice.InvoiceModelAbstract_ `validate_itemtxs_qs()` _attribute_ ), 193 ( _django_ledger.models.bill.BillModelAbstract_ `uuid` ( _django_ledger.models.items.ItemModelAbstract atmethod_ ), 165 _tribute_ ), 141 `validate_itemtxs_qs() uuid` ( _django_ledger.models.items.UnitOfMeasureModelAbstract_ ( _django_ledger.models.estimate.EstimateModelAbstract attribute_ ), 150 _method_ ), 180 `uuid` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract_ `validate_itemtxs_qs()` _attribute_ ), 109 ( _django_ledger.models.invoice.InvoiceModelAbstract_ `uuid` ( _django_ledger.models.ledger.LedgerModelAbstract method_ ), 205 _attribute_ ), 96 `validate_itemtxs_qs() uuid` ( _django_ledger.models.purchase_order.PurchaseOrderModelAbstract_ ( _django_ledger.models.mixins.ItemizeMixIn attribute_ ), 182 _method_ ), 222 `uuid` ( _django_ledger.models.transactions.TransactionModelAbstract_ `validate_month()` ( _django_ledger.models.entity.EntityModelFiscalPeriod attribute_ ), 102 _method_ ), 81 `uuid` ( _django_ledger.models.unit.EntityUnitModelAbstract_ `validate_po_queryset()` _attribute_ ), 83 ( _django_ledger.models.estimate.EstimateModelAbstract_ `uuid` ( _django_ledger.models.vendor.VendorModelAbstract method_ ), 180 _attribute_ ), 211 `validate_quarter()` ( _django_ledger.models.entity.EntityModelFiscalPer method_ ), 81 V `validate_roles()` ( _in module django_ledger.io.roles_ ), `validate_account_model_for_coa()` 58 ( _django_ledger.models.entity.EntityModelAbstract_ `vendor` ( _django_ledger.models.bill.BillModelAbstract atmethod_ ), 78 _tribute_ ), 152 `validate_account_model_qs() vendor_name` ( _django_ledger.models.vendor.VendorModelAbstract_ ( _django_ledger.models.chart_of_accounts.ChartOfAccountModelAbstractattribute_ ), 211 _method_ ), 130 `vendor_number` ( _django_ledger.models.vendor.VendorModelAbstract_ `validate_activity()` ( _in module attribute_ ), 211 _django_ledger.io.io_core_ ), 56 `VendorModel` ( _class in django_ledger.models.vendor_ ), `validate_bill_queryset()` 211 ( _django_ledger.models.estimate.EstimateModelAbstract_ `VendorModel.DoesNotExist` , 211 _method_ ), 179 `VendorModel.MultipleObjectsReturned` , 211 `validate_chart_of_accounts_for_entity() VendorModelAbstract` ( _class in_ ( _django_ledger.models.entity.EntityModelAbstract django_ledger.models.vendor_ ), 211 _method_ ), 78 `VendorModelManager` ( _class in_
**252**
**Index**
**Django Ledger**
_django_ledger.models.vendor_ ), 212 `VendorModelQuerySet` ( _class in django_ledger.models.vendor_ ), 213 `VendorModelValidationError` , 213 `verify()` ( _django_ledger.models.journal_entry.JournalEntryModelAbstract method_ ), 120 `verify_unique_code()` ( _in module django_ledger.models.coa_default_ ), 134 `visible()` ( _django_ledger.models.customer.CustomerModelQueryset method_ ), 210 `visible()` ( _django_ledger.models.entity.EntityModelQuerySet method_ ), 82 `visible()` ( _django_ledger.models.ledger.LedgerModelQuerySet method_ ), 100, 101 `visible()` ( _django_ledger.models.vendor.VendorModelQuerySet method_ ), 213 `void()` ( _django_ledger.models.bill.BillModelQuerySet method_ ), 167 `void()` ( _django_ledger.models.invoice.InvoiceModelQuerySet method_ ), 207 `void_state()` ( _django_ledger.models.mixins.AccrualMixIn method_ ), 219
## W
`website` ( _django_ledger.models.mixins.ContactInfoMixIn attribute_ ), 220 `with_roles()` ( _django_ledger.models.accounts.AccountModelQuerySet method_ ), 95
## X
`xref` ( _django_ledger.models.bill.BillModelAbstract attribute_ ), 152
## Z
`zip_code` ( _django_ledger.models.mixins.ContactInfoMixIn attribute_ ), 219
**Index**
**253**