Skip to content

Commit 27ae142

Browse files
elarrobatolland25-doubaidrmnKrzysztofCzapla
authored
v0.6.4 (#223)
* 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]>
1 parent b71bf96 commit 27ae142

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2391
-1019
lines changed

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ RUN pip3 install --upgrade pip
1111

1212
RUN pip3 install -U pipenv
1313

14-
COPY Pipfile Pipfile.lock /app/
15-
1614
COPY . /app/
1715

18-
COPY entrypoint.sh /app/
19-
2016
RUN pipenv install
2117

2218
EXPOSE 8000

Pipfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
django = ">=4.2"
7+
django = ">=2.2"
88
django-treebeard = ">=4.5.1"
99
ofxtools = ">=0.9.5"
1010
markdown = ">=3.4.1"
@@ -26,12 +26,6 @@ behave = "*"
2626
twine = "*"
2727
jupyterlab = "*"
2828
pandas = "*"
29-
#pipenv-setup = "*"
30-
#pylint = "*"
31-
#furo = "*"
32-
#python-dotenv = "*"
33-
#tabulate = "*"
34-
#myst_parser = "*"
3529

3630
[requires]
3731
python_version = "3.12"

Pipfile.lock

Lines changed: 676 additions & 652 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev_env/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@
118118
# ],
119119
}
120120

121+
OAUTH2_PROVIDER = {
122+
'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore',
123+
}
124+
121125
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
122126

123127
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

django_ledger/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
default_app_config = 'django_ledger.apps.DjangoLedgerConfig'
1010

1111
"""Django Ledger"""
12-
__version__ = '0.6.3'
12+
__version__ = '0.6.4'
1313
__license__ = 'GPLv3 License'
1414

1515
__author__ = 'Miguel Sanda'

django_ledger/admin/coa.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ class ChartOfAccountsModelAdmin(ModelAdmin):
108108
list_display_links = ['name']
109109
fields = [
110110
'name',
111-
'locked',
112111
'description',
113112
]
114113
inlines = [
@@ -132,4 +131,4 @@ def get_queryset(self, request):
132131
def account_model_count(self, obj):
133132
return obj.accountmodel__count
134133

135-
account_model_count.short_description = 'Accounts'
134+
account_model_count.short_description = 'Accounts'

django_ledger/contrib/django_ledger_graphene/README.md

Lines changed: 30 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,146 +2,59 @@
22
# Django ledger Graphql Api
33

44
## Usage and installation
5+
Install Required Packages
56

6-
7-
8-
9-
7+
First, install the necessary packages:
108
```
119
pip install graphene-django
1210
```
1311
```
14-
pip install django-graphql-auth
12+
pip install django-oauth-toolkit
13+
```
14+
Enable Graphql by navigating to ./django_ledger/settings.py
15+
```
16+
DJANGO_LEDGER_GRAPHQL_SUPPORT_ENABLED = True
1517
```
1618
Makemigrations
1719
```
1820
python manage.py makemigrations
1921
python manage.py migrate
20-
```
21-
Runserver
22+
```
23+
Start the Django development server:
2224
```
2325
python manage.py runserver
24-
```
25-
make sure you are loged in the main application go to the admin
26-
site http://127.0.0.1:8000/admin/django_ledger/entitymodel/ choose your
27-
entity and get your slug name from the entity choosen or
28-
29-
Open new tab and navigate to
30-
```
31-
http://127.0.0.1:8000/graphql/
32-
```
33-
paste this to the console and run the query
34-
3526
```
36-
{
37-
allEntityList{
38-
slug
39-
name
40-
}
41-
```
42-
this will return the current user logged in slug and name, use the slug for other queries (Slugname:String!)
43-
## sample graphql Query
44-
paste this at the graphql console and run the query
27+
on the admin site ensure to add an Application with the fields
4528
```
46-
{
47-
allEntityList{
48-
edges{
49-
node{
50-
slug
51-
name
52-
}
53-
}
54-
}
55-
```
56-
this will return the current user logged in slug and name, use the slug for other queries (Slugname:String!)
57-
## sample graphql Query
58-
paste this at the graphql console and run the query
59-
```
60-
allCustomers(slugName:"jusper-onderi-ondieki-db23x1y8"){
61-
edges {
62-
node {
63-
customerName
64-
city
65-
state
66-
active
67-
68-
}
69-
}
70-
}
29+
client type: confidential
30+
Authorization grant type: Resource owner password-based
7131
```
7232

73-
# Query results
74-
```
75-
"allCustomers": {
76-
"edges": [
77-
{
78-
"node": {
79-
"customerName": "booka",
80-
"city": "kenya",
81-
"state": "huj",
82-
"active": true
83-
}
84-
},
85-
{
86-
"node": {
87-
"customerName": "stats",
88-
"city": "kenya",
89-
"state": "huj",
90-
"active": true
91-
}
92-
},
93-
{
94-
"node": {
95-
"customerName": "Brooke Weaver",
96-
"city": "South Michelleborough",
97-
"state": "WA",
98-
"active": true
99-
}
100-
},
101-
{
102-
"node": {
103-
"customerName": "Tamara Wilson",
104-
"city": "Castilloport",
105-
"state": "WV",
106-
"active": true
107-
}
108-
},
33+
Use Postman or Thunder Client to make a POST request to obtain an access token. Send a request to the following URL:
10934

110-
}
111-
]
112-
}
113-
}
114-
}
35+
```
11536
37+
http://127.0.0.1:8000/api/v1/o/token/
11638
```
117-
## Using graphql-auth
118-
Register user
39+
Include the following JSON body in your request:
11940
```
120-
mutation {
121-
register(
122-
123-
username: "new_user",
124-
password1: "dave123456",
125-
password2: "dave123456",
126-
) {
127-
success,
128-
errors,
129-
token,
130-
131-
}
41+
{
42+
"username": "eric",
43+
"password": "eric",
44+
"client_id": "cXFFgnvWhWiZDofGkwiwUBdfuxfNnLsmBtAVsVXv",
45+
"client_secret": "dave101",
46+
"grant_type": "password"
13247
}
13348
```
134-
Returns a token and a succes message
49+
If the request is successful, you will receive a response like this:
13550
```
13651
{
137-
"data": {
138-
"register": {
139-
"success": true,
140-
"errors": null,
141-
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Im5ld191c2VyIiwiZXhwIjoxNjQ5NzY2Nzc4LCJvcmlnSWF0IjoxNjQ5NzY2NDc4fQ.cHaPq8CjQy60ifUawR4Pnyyu_E_SCU2J6CapBK0P8P4"
142-
}
143-
}
52+
"access_token": "YPMh29n648qpahgtOjrDHMDy5bt81e",
53+
"expires_in": 36000,
54+
"token_type": "Bearer",
55+
"scope": "read write",
56+
"refresh_token": "huBiNKw9IhtuYPKVNR9i4WnQesMqEl"
14457
}
14558
```
146-
for more detail usage visit the documentation
147-
https://django-graphql-auth.readthedocs.io/en/latest/quickstart/
59+
Now you can use the access token to authenticate your GraphQL requests.
60+

django_ledger/forms/account.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919

2020
class AccountModelCreateForm(ModelForm):
2121
"""
22-
Create Form:
23-
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.
24-
The entity slug and the user model are the field which are internal and are predetermined in the lass itself
22+
AccountModelCreateForm
23+
======================
2524
26-
Remaining fields which needs to be defined by user are :
25+
A form for creating and managing account models within the system.
26+
27+
Attributes
28+
----------
29+
ENTITY : Model
30+
The entity model being used in the form.
31+
COA_MODEL : Model
32+
The Chart of Account Model being used in the form.
33+
USER_MODEL : Model
34+
The user model being used in the form.
2735
28-
code: The code will be used to uniquely identify the particular account
29-
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
30-
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
31-
balance_type: Need to be selected from drop down as "Debit" or Credit"
3236
"""
3337

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

8589
class AccountModelUpdateForm(MoveNodeForm):
8690
"""
87-
Update Account Form:
88-
This form is for updating the account. This works for both the parent or the child Account .
89-
We can update the Parent , or The Code or even the Name of the Account.
91+
AccountModelUpdateForm
92+
93+
A form for updating account model, inheriting from MoveNodeForm.
94+
95+
Attributes
96+
----------
97+
_position : ChoiceField
98+
A choice field for selecting the position.
99+
_ref_node_id : ChoiceField
100+
An optional choice field for selecting the relative node.
90101
"""
91102

92103
_position = ChoiceField(required=True,

django_ledger/io/roles.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,9 @@ def validate_roles(roles: Union[str, List[str]], raise_exception: bool = True) -
660660
if raise_exception:
661661
raise InvalidRoleError('{rls}) is invalid. Choices are {ch}'.format(ch=', '.join(VALID_ROLES), rls=r))
662662
return set(roles)
663+
664+
VALID_PARENTS = {
665+
ASSET_PPE_BUILDINGS_ACCUM_DEPRECIATION: [ASSET_PPE_BUILDINGS],
666+
ASSET_PPE_EQUIPMENT_ACCUM_DEPRECIATION: [ASSET_PPE_EQUIPMENT],
667+
ASSET_PPE_PLANT_ACCUM_DEPRECIATION: [ASSET_PPE_PLANT],
668+
}

0 commit comments

Comments
 (0)