Skip to content

Commit

Permalink
V0.5.4.0 PDF Reporting Capabilities (arrobalytics#147)
Browse files Browse the repository at this point in the history
* v0.5.4.0
Financial Statements PDF Export

* v0.5.4.0
PDF Reporting

* BalanceSheet HTML View Terminology Update
IOMixIn Refactoring
DJL Logo for PDF Reports
BalanceSheetContextManager Update
First PDF Download View Implementation Prototype

* IncomeStatementPDF Report Generation
pdf_core.py class for PDF report generation.

* README.md update

* FPDF2 in favor of less maintained FPDF

* financial_statement.py view module creation.

* PDFReportMixIn

* PDFReport EntityModel API
IOMixIn now accepts None user.

* PDF Reports Filename Generator Update

* PDF Reports Generation Implementation for EntityModels, EntityUnitModels and LedgerModels. Includes Bills and Invoices.

* PDFReportMixIn optimization.

* PDFReportMixIn optimization.
DataGenerator Update.
Report Subtitle Option.
README.md update.
QuickStart Notebook.ipynb update.

* Report Screenshots

* PDF Pipfile dependency.
  • Loading branch information
elarroba authored Jun 21, 2023
1 parent 75c9bad commit 0ef22b8
Show file tree
Hide file tree
Showing 57 changed files with 2,776 additions and 827 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
python: "3.10"
formats:
- epub
- pdf
- report
- htmlzip
sphinx:
configuration: docs/source/conf.py
Expand Down
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ graphene = ">=3.2.1"
graphene_django = ">=3.0.0"
django-oauth-toolkit = ">=2.2.0"

[pdf]
fpdf2 = ">=2.7.4"

[dev-packages]
jupyterlab = "*"
sphinx = "*"
Expand Down
551 changes: 356 additions & 195 deletions Pipfile.lock

Large diffs are not rendered by default.

82 changes: 63 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__Django Ledger__ is a double entry accounting system based on
the [Django Web Framework](https://www.djangoproject.com),
which aims to power financially driven applications by removing the complexity of the accounting domain into a simple,
high-level API. _Prior experience with Django is required to more effectively use this software_.
high-level API. _Prior experience with Django is required to more effectively use this software_.

__Django Ledger__ was created and is currently maintained and developed by lead developer Miguel Sanda.
If you want to contribute please consider joining our new discord channel here.
Expand Down Expand Up @@ -39,8 +39,8 @@ Django Ledger supports:
- Financial Statements (Income Statement, Balance Sheet & Cash Flow Statement).
- Purchase Orders, Sales Orders (Estimates), Bills and Invoices.
- Automatic financial ratio & insight calculations.
- High Level Entity API.
- Multi tenancy (multiple companies/users/clients).
- Hierarchical entity management (for consolidated financial statements - v0.9).
- Self-contained Ledgers, Journal Entries & Transactions.
- Basic OFX & QFX file import.
- Bills & Invoices with optional cash/accrual functionality.
Expand Down Expand Up @@ -74,20 +74,21 @@ More details available in the [Django Ledger v0.5 Page](https://www.arrobalytics
* Start creating basic package documentation via [Sphinx](https://www.sphinx-doc.org/en/master/)
* Document code and functions within code base.
* Generate HTML documentation.
* Work with Accountants, Subject Experts and Developers to define an initial list of Unit Tests to validate output __(
* Work with Accountants, Subject Experts and Developers to define an initial list of Unit Tests to validate output _
_(
help needed!)__.
* Update package and code documentation.
* Bugfixes & UI/UX Enhancements.
* __0.5.0__: Inventory tracking.
* ~~__0.5.0__~~: Inventory tracking.
* Average Cost.
* __0.5.1__: Customer estimates & contract tracking.
* ~~__0.5.1__~~: Customer estimates & contract tracking.
* Link Estimate/PO/Bill/Invoice workflow.
* Journal Entry activity determination & validation (for cash flow).
* __0.5.2__: Cash flow statement.
* ~~__0.5.2__~~: Cash flow statement.
* Human Readable Journal Entry document numbers.
* Hierarchical Account Model Management.
* Generate all Django Ledger Model documentation.
* __0.5.3__: High Level EntityModel API.
* ~~__0.5.3__~~: High Level EntityModel API.
* __0.5.4__: Balance Sheet Statement, Income Statement & Cash Flow Statement API & PDF report export.
* __0.5.5__: Closing entries and snapshots.
* __0.5.6__: Chart of Accounts Import.
Expand Down Expand Up @@ -142,25 +143,62 @@ See __[contribution guidelines](https://github.com/arrobalytics/django-ledger/bl

## Quick Start

Django Ledger comes with a default CoA ready to use, or you could use your own. Make sure to select the appropriate
option when creating new entities.
Django Ledger is a [Django](https://www.djangoproject.com/) application. If you haven't, you need a working knowledge of
Django and a working Django
Project before you can use Django Ledger. A good place to start
is [here](https://docs.djangoproject.com/en/4.2/intro/tutorial01/#creating-a-project).
Make sure you refer to the django version you are using. A quick way to start a new django project is to run the
following command:

To install Python Pipenv

```shell script
pip install pipenv
```

* Go to your desired development folder and run:

```shell
mkdir django-ledger-project && cd django-ledger-project
```

* Install Django on you virtual environment.

```shell
pipenv install django
```

* Install Django Ledger

```shell script
pip install django-ledger
pipenv install django-ledger --categories graphql,pdf
```

To install Django Virtual Environment
```pip install pipenv```
* Activate your new virtual environment:

```shell
pipenv shell
```

* Or with pipenv:
* Create a new django project.

```shell script
pipenv install django-ledger
django-admin startproject django-ledger-project
```

* Perform database migrations:

```shell
python manage.py migrate
```

* Add django_ledger to INSTALLED_APPS
* Add Django SuperUser and follow the prompts.

```shell
python manage.py createsuperuser
```

* Add django_ledger to INSTALLED_APPS in you new Django Project.

```python
INSTALLED_APPS = [
Expand All @@ -170,7 +208,7 @@ INSTALLED_APPS = [
]
```

* Add URLs to your project:
* Add URLs to your project's __urls.py__:

```python
from django.urls import include, path
Expand All @@ -182,13 +220,13 @@ urlpatterns = [
]
```

* Add Django SuperUser if necessary.
* Run your project:

```shell
python manage.py createsuperuser
python manage.py runserver
```

* Navigate to Django Ledger root view assigned in your project urlpattern setting.
* Navigate to Django Ledger root view assigned in your project urlpatterns setting.
* Use your user credentials.

# How To Set Up Django Ledger for Development
Expand Down Expand Up @@ -260,3 +298,9 @@ python manage.py test django_ledger
![django ledger income statement](https://us-east-1.linodeobjects.com/django-ledger/public/img/django_ledger_balance_sheet.png)
![django ledger bill](https://us-east-1.linodeobjects.com/django-ledger/public/img/django_ledger_bill.png)
![django ledger invoice](https://us-east-1.linodeobjects.com/django-ledger/public/img/django_ledger_invoice.png)

# Financial Statements Screenshots

![balance_sheet_report](https://django-ledger.us-east-1.linodeobjects.com/public/img/BalanceSheetStatement.png)
![income_statement_report](https://django-ledger.us-east-1.linodeobjects.com/public/img/IncomeStatement.png)
![cash_flow_statement_report](https://django-ledger.us-east-1.linodeobjects.com/public/img/CashFlowStatement.png)
9 changes: 5 additions & 4 deletions dev_env/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
from pathlib import Path

from django_ledger.settings import DJANGO_LEDGER_GRAPHQL_ENABLED
from django_ledger.settings import DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = Path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

SECRET_KEY = os.getenv('SECRET_KEY')
if not SECRET_KEY:
Expand All @@ -21,7 +22,7 @@
'django_ledger',
]

if DJANGO_LEDGER_GRAPHQL_ENABLED:
if DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED:
INSTALLED_APPS += [
'graphene_django',
'oauth2_provider'
Expand Down Expand Up @@ -107,7 +108,7 @@
'django.contrib.auth.backends.ModelBackend',
]

if DJANGO_LEDGER_GRAPHQL_ENABLED:
if DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED:
GRAPHENE = {
'SCHEMA': 'django_ledger.contrib.django_ledger_graphene.api.schema',
'SCHEMA_OUTPUT': '../django_ledger/contrib/django_ledger_graphene/schema.graphql', # defaults to schema.json,
Expand Down
4 changes: 2 additions & 2 deletions dev_env/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib import admin
from django.urls import path, include

from django_ledger.settings import DJANGO_LEDGER_GRAPHQL_ENABLED
from django_ledger.settings import DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED

urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -11,7 +11,7 @@

# GraphQl API Support...
try:
if DJANGO_LEDGER_GRAPHQL_ENABLED:
if DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED:
from django_ledger.contrib.django_ledger_graphene.api import schema
from django_ledger.contrib.django_ledger_graphene.views import DjangoLedgerOAuth2GraphQLView

Expand Down
2 changes: 1 addition & 1 deletion django_ledger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
default_app_config = 'django_ledger.apps.DjangoLedgerConfig'

"""Django Ledger"""
__version__ = '0.5.3.2'
__version__ = '0.5.4.0'
__license__ = 'GPLv3 License'

__author__ = 'Miguel Sanda'
Expand Down
2 changes: 1 addition & 1 deletion django_ledger/forms/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __init__(self, *args,
self.INVOICE_MODEL: InvoiceModel = invoice_model
self.ENTITY_SLUG = entity_slug

items_qs = ItemModel.objects.products(
items_qs = ItemModel.objects.for_invoice(
entity_slug=self.ENTITY_SLUG,
user_model=self.USER_MODEL
)
Expand Down
25 changes: 14 additions & 11 deletions django_ledger/io/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,8 @@ def create_invoice(self, date_draft: date):
item_model: ItemModel = choice(self.product_models)
quantity = Decimal.from_float(round(random() * randint(1, 2), 2))
entity_unit = choice(self.entity_unit_models) if random() > .75 else None
margin = Decimal(random() + 1.5)
margin = Decimal(random() + 3.5)
avg_cost = item_model.get_average_cost()
unit_cost = round(random() * randint(100, 999), 2)
if item_model.is_product():
if item_model.inventory_received is not None and item_model.inventory_received > 0.0:
if quantity > item_model.inventory_received:
Expand All @@ -665,15 +664,19 @@ def create_invoice(self, date_draft: date):
quantity = 0.0
unit_cost = 0.0

itm = ItemTransactionModel(
invoice_model=invoice_model,
item_model=item_model,
quantity=quantity,
unit_cost=unit_cost,
entity_unit=entity_unit
)
itm.full_clean()
invoice_items.append(itm)
if all([
quantity > 0.00,
unit_cost > 0.00
]):
itm = ItemTransactionModel(
invoice_model=invoice_model,
item_model=item_model,
quantity=quantity,
unit_cost=unit_cost,
entity_unit=entity_unit
)
itm.full_clean()
invoice_items.append(itm)

invoice_items = invoice_model.itemtransactionmodel_set.bulk_create(invoice_items)
invoice_model.update_amount_due(itemtxs_qs=invoice_items)
Expand Down
Loading

0 comments on commit 0ef22b8

Please sign in to comment.