Skip to content

Commit

Permalink
v0.6.4 (#223)
Browse files Browse the repository at this point in the history
* Relaxing Dependency Constraints

* Issue 208 ofx files (#209)

* fix: initial attempt

* Allow .qfx files in data_import form.

The accept attribute in the file-input field now includes .qfx files. This permits users to import data from files in .qfx format in addition to the previously supported .ofx format.

* remove debugging lines, remove debug code, add sample ofx for tests

---------

Co-authored-by: Miguel Sanda <[email protected]>

* v0.6.3 (#214)

* Add proxy functions to JournalEntry model

The commit introduces proxy functions to the JournalEntry model in the Django Ledger code. Specifically, it adds 'post', 'unpost', 'lock', and 'unlock' methods, each serving as a proxy to their counterpart methods 'mark_as_posted', 'mark_as_unposted', 'mark_as_locked', and 'mark_as_unlocked'. This simplifies the interface for interacting with JournalEntry objects.

* Minor code optimization & Django Ledger admin fields.

* access the queryset instance using .all() which returns a queryset. (#213)

* Correct urls for going back in entity and ledger balance sheet view (#215)

* Add signal handling for various models' statuses

Added signals for different status changes of Django Ledger models to enable real-time, event-driven system behavior. Signals are now sent each time an action is performed in the Ledger, Invoice, Bill, Journal Entry, Purchase Order, and Estimate. These changes will allow us to trigger specific actions depending on these changes.

* Update Python version and package versions in Pipfile

Updated the Python version from 3.11 to 3.12 in Pipfile and Pipfile.lock. Also, updated the package versions of 'django', 'faker' and 'pillow' in Pipfile.lock for improved functionality and security.

* Update Django Ledger version to 0.6.3

This commit updates the version number of the Django Ledger project in both __init__.py and pyproject.toml files. The version has been incremented from 0.6.2 to 0.6.3.

* Update signal comments in models

Updated the comments in the signals.py file to clearly specify that the signals correspond to Journal Entry Models. Additional context was also included for the signals module to enhance clarity for developers in understanding the importance of events or states in the models.

* Update documentation structure

Rearrange sections in documentation, focusing on IO and models. For docs/source/models.rst, the automodule section for django_ledger.models.signals was added. Meanwhile, in docs/source/io.rst, sections were reshuffled and terms updated for better clarity. These steps aim to enhance documentation readability and accuracy.

---------

Co-authored-by: Eric paul <[email protected]>
Co-authored-by: Ubaid ur Rehman <[email protected]>

* Update dependencies versions in Pipfile.lock

Upgraded several packages to their latest versions, including Faker, Alabaster, and SQLParse, among others. Added new dependencies appnope and backports.tarfile, and adjusted Python version markers for some packages. Removed cryptography and jeepney from the list of dependencies.

* Updated Logos

* comment out attribute that doesn't exist (#220)

* Docker Fix (#218)

* Update version to 0.6.4

Bump the version number in `__init__.py` and `pyproject.toml`. This update ensures consistency and readiness for the next release cycle.

* API authentication (#217)

* access the queryset instance using .all() which returns a queryset.

* fixed invalid client

* changes in API authentication usage

* API Authentication usage

* Add DjangoCon2024 Jupyter notebook example

Introduced a detailed Jupyter notebook for DjangoCon 2024. This notebook demonstrates various functionalities including setting up Django, creating a UserModel, defining an EntityModel, and creating and populating a Chart of Accounts.

* Update entity model CoA handling and streamline notebook

Enhanced the entity model to handle various types for CoA (Chart of Accounts) input. Cleared execution counts and outputs from DjangoCon2024 notebook for better clarity.

* Add support for validating parent roles in accounts

Implemented `VALID_PARENTS` to allow filtering accounts based on hierarchical roles. This ensures that parent-child relationships between account roles are correctly validated and managed.

* Pipfile Update

* Refactor and improve docs for AccountModel and QuerySets

Refactored and enhanced documentation for AccountModel and its related query sets to ensure clarity and consistency. Introduced detailed attribute descriptions and method explanations while maintaining code functionality.

---------

Co-authored-by: Tom Hodder <[email protected]>
Co-authored-by: Eric paul <[email protected]>
Co-authored-by: Ubaid ur Rehman <[email protected]>
Co-authored-by: Krzysztof Czapla <[email protected]>
  • Loading branch information
5 people authored Sep 10, 2024
1 parent b71bf96 commit 27ae142
Show file tree
Hide file tree
Showing 48 changed files with 2,391 additions and 1,019 deletions.
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ RUN pip3 install --upgrade pip

RUN pip3 install -U pipenv

COPY Pipfile Pipfile.lock /app/

COPY . /app/

COPY entrypoint.sh /app/

RUN pipenv install

EXPOSE 8000
Expand Down
8 changes: 1 addition & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
django = ">=4.2"
django = ">=2.2"
django-treebeard = ">=4.5.1"
ofxtools = ">=0.9.5"
markdown = ">=3.4.1"
Expand All @@ -26,12 +26,6 @@ behave = "*"
twine = "*"
jupyterlab = "*"
pandas = "*"
#pipenv-setup = "*"
#pylint = "*"
#furo = "*"
#python-dotenv = "*"
#tabulate = "*"
#myst_parser = "*"

[requires]
python_version = "3.12"
Expand Down
1,328 changes: 676 additions & 652 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dev_env/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
# ],
}

OAUTH2_PROVIDER = {
'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore',
}

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
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.6.3'
__version__ = '0.6.4'
__license__ = 'GPLv3 License'

__author__ = 'Miguel Sanda'
Expand Down
3 changes: 1 addition & 2 deletions django_ledger/admin/coa.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class ChartOfAccountsModelAdmin(ModelAdmin):
list_display_links = ['name']
fields = [
'name',
'locked',
'description',
]
inlines = [
Expand All @@ -132,4 +131,4 @@ def get_queryset(self, request):
def account_model_count(self, obj):
return obj.accountmodel__count

account_model_count.short_description = 'Accounts'
account_model_count.short_description = 'Accounts'
147 changes: 30 additions & 117 deletions django_ledger/contrib/django_ledger_graphene/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,146 +2,59 @@
# Django ledger Graphql Api

## Usage and installation
Install Required Packages





First, install the necessary packages:
```
pip install graphene-django
```
```
pip install django-graphql-auth
pip install django-oauth-toolkit
```
Enable Graphql by navigating to ./django_ledger/settings.py
```
DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED = True
```
Makemigrations
```
python manage.py makemigrations
python manage.py migrate
```
Runserver
```
Start the Django development server:
```
python manage.py runserver
```
make sure you are loged in the main application go to the admin
site http://127.0.0.1:8000/admin/django_ledger/entitymodel/ choose your
entity and get your slug name from the entity choosen or

Open new tab and navigate to
```
http://127.0.0.1:8000/graphql/
```
paste this to the console and run the query

```
{
allEntityList{
slug
name
}
```
this will return the current user logged in slug and name, use the slug for other queries (Slugname:String!)
## sample graphql Query
paste this at the graphql console and run the query
on the admin site ensure to add an Application with the fields
```
{
allEntityList{
edges{
node{
slug
name
}
}
}
```
this will return the current user logged in slug and name, use the slug for other queries (Slugname:String!)
## sample graphql Query
paste this at the graphql console and run the query
```
allCustomers(slugName:"jusper-onderi-ondieki-db23x1y8"){
edges {
node {
customerName
city
state
active
}
}
}
client type: confidential
Authorization grant type: Resource owner password-based
```

# Query results
```
"allCustomers": {
"edges": [
{
"node": {
"customerName": "booka",
"city": "kenya",
"state": "huj",
"active": true
}
},
{
"node": {
"customerName": "stats",
"city": "kenya",
"state": "huj",
"active": true
}
},
{
"node": {
"customerName": "Brooke Weaver",
"city": "South Michelleborough",
"state": "WA",
"active": true
}
},
{
"node": {
"customerName": "Tamara Wilson",
"city": "Castilloport",
"state": "WV",
"active": true
}
},
Use Postman or Thunder Client to make a POST request to obtain an access token. Send a request to the following URL:

}
]
}
}
}
```
http://127.0.0.1:8000/api/v1/o/token/
```
## Using graphql-auth
Register user
Include the following JSON body in your request:
```
mutation {
register(
email: "[email protected]",
username: "new_user",
password1: "dave123456",
password2: "dave123456",
) {
success,
errors,
token,
}
{
"username": "eric",
"password": "eric",
"client_id": "cXFFgnvWhWiZDofGkwiwUBdfuxfNnLsmBtAVsVXv",
"client_secret": "dave101",
"grant_type": "password"
}
```
Returns a token and a succes message
If the request is successful, you will receive a response like this:
```
{
"data": {
"register": {
"success": true,
"errors": null,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Im5ld191c2VyIiwiZXhwIjoxNjQ5NzY2Nzc4LCJvcmlnSWF0IjoxNjQ5NzY2NDc4fQ.cHaPq8CjQy60ifUawR4Pnyyu_E_SCU2J6CapBK0P8P4"
}
}
"access_token": "YPMh29n648qpahgtOjrDHMDy5bt81e",
"expires_in": 36000,
"token_type": "Bearer",
"scope": "read write",
"refresh_token": "huBiNKw9IhtuYPKVNR9i4WnQesMqEl"
}
```
for more detail usage visit the documentation
https://django-graphql-auth.readthedocs.io/en/latest/quickstart/
Now you can use the access token to authenticate your GraphQL requests.

33 changes: 22 additions & 11 deletions django_ledger/forms/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

class AccountModelCreateForm(ModelForm):
"""
Create Form:
This Form is used for creation of a new account that does not exist in the default Chart of Accounts. It has some external as well as some internal field.
The entity slug and the user model are the field which are internal and are predetermined in the lass itself
AccountModelCreateForm
======================
Remaining fields which needs to be defined by user are :
A form for creating and managing account models within the system.
Attributes
----------
ENTITY : Model
The entity model being used in the form.
COA_MODEL : Model
The Chart of Account Model being used in the form.
USER_MODEL : Model
The user model being used in the form.
code: The code will be used to uniquely identify the particular account
name: The name of the account. The name of the account should be resemblance of the nature of the transactions that will be in the account
role: The role needs to be selected rom list of the options available. Choices are given under ACCOUNT ROLES. Refer the account model documentation for more info
balance_type: Need to be selected from drop down as "Debit" or Credit"
"""

def __init__(self, entity_model, coa_model, user_model, *args, **kwargs):
Expand Down Expand Up @@ -84,9 +88,16 @@ class Meta:

class AccountModelUpdateForm(MoveNodeForm):
"""
Update Account Form:
This form is for updating the account. This works for both the parent or the child Account .
We can update the Parent , or The Code or even the Name of the Account.
AccountModelUpdateForm
A form for updating account model, inheriting from MoveNodeForm.
Attributes
----------
_position : ChoiceField
A choice field for selecting the position.
_ref_node_id : ChoiceField
An optional choice field for selecting the relative node.
"""

_position = ChoiceField(required=True,
Expand Down
6 changes: 6 additions & 0 deletions django_ledger/io/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,9 @@ def validate_roles(roles: Union[str, List[str]], raise_exception: bool = True) -
if raise_exception:
raise InvalidRoleError('{rls}) is invalid. Choices are {ch}'.format(ch=', '.join(VALID_ROLES), rls=r))
return set(roles)

VALID_PARENTS = {
ASSET_PPE_BUILDINGS_ACCUM_DEPRECIATION: [ASSET_PPE_BUILDINGS],
ASSET_PPE_EQUIPMENT_ACCUM_DEPRECIATION: [ASSET_PPE_EQUIPMENT],
ASSET_PPE_PLANT_ACCUM_DEPRECIATION: [ASSET_PPE_PLANT],
}
Loading

0 comments on commit 27ae142

Please sign in to comment.