Skip to content

Commit 3b2c856

Browse files
authored
V0.5.3.1 (#143)
* EntityModel High Level ItemModel API for expenses, products, services and inventory. * EntityModel API documentation. * EntityModel API documentation. * EntityModel items API documentation. * EntityModel items API documentation. * EntityModelAPI QuickStart Update Create UoM EntityModel API * EntityModelAPI Tests Update * Random Data Generator now uses HighLevel EntityModel API. * QuickStart Guide Update * QuickStart Guide Update
1 parent 123497e commit 3b2c856

21 files changed

+1566
-494
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ More details available in the [Django Ledger v0.5 Page](https://www.arrobalytics
9696

9797
### Version 0.6
9898

99+
* IO Digest Context Manager
99100
* Credit Line Models.
100101
* Time tracking.
101102
* Transaction tagging.

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.5.3.0'
12+
__version__ = '0.5.3.1'
1313
__license__ = 'GPLv3 License'
1414

1515
__author__ = 'Miguel Sanda'

django_ledger/io/data_generator.py

Lines changed: 129 additions & 165 deletions
Large diffs are not rendered by default.

django_ledger/io/roles.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sys
1010
from itertools import chain
11-
from typing import Set
11+
from typing import Set, List, Union
1212

1313
from django.utils.translation import gettext as _
1414

@@ -609,10 +609,25 @@
609609
GROUPS_DIRECTORY[group] = getattr(mod, group)
610610

611611

612-
def validate_roles(roles) -> Set[str]:
612+
def validate_roles(roles: Union[str, List[str]], raise_exception: bool = True) -> Set[str]:
613+
"""
614+
Validates a given role identifier against the valid role available.
615+
Parameters
616+
----------
617+
roles: str or list
618+
The role or list of roles to validate.
619+
raise_exception: bool
620+
Raises InvalidRoleError if any of the roles provided if not valid.
621+
622+
Returns
623+
-------
624+
set
625+
A set of the valid roles.
626+
"""
613627
if isinstance(roles, str):
614628
roles = set(roles)
615629
for r in roles:
616630
if r not in VALID_ROLES:
617-
raise InvalidRoleError('{rls}) is invalid. Choices are {ch}'.format(ch=', '.join(VALID_ROLES), rls=r))
631+
if raise_exception:
632+
raise InvalidRoleError('{rls}) is invalid. Choices are {ch}'.format(ch=', '.join(VALID_ROLES), rls=r))
618633
return set(roles)

django_ledger/models/accounts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def with_roles(self, roles: Union[List, str]):
107107
roles = validate_roles(roles)
108108
return self.filter(role__in=roles)
109109

110+
def expenses(self):
111+
return self.filter(role__in=GROUP_EXPENSES)
112+
110113
def is_coa_root(self):
111114
return self.filter(role__in=ROOT_GROUP)
112115

@@ -139,7 +142,7 @@ def gb_bs_role(self):
139142
]
140143

141144
def is_role_default(self):
142-
return self.filter(role_default=True)
145+
return self.not_coa_root().filter(role_default=True)
143146

144147

145148
class AccountModelManager(MP_NodeManager):

django_ledger/models/bill.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def configure(self,
470470
ledger_model.name = ledger_name
471471

472472
ledger_model.clean()
473+
ledger_model.clean_fields()
473474

474475
self.ledger = ledger_model
475476

@@ -480,6 +481,7 @@ def configure(self,
480481
self.generate_bill_number(commit=commit)
481482

482483
self.clean()
484+
self.clean_fields()
483485

484486
if commit:
485487
self.save()

django_ledger/models/coa_default.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,16 @@
309309

310310
]
311311

312+
313+
def get_default_coa() -> List[Dict]:
314+
if DJANGO_LEDGER_DEFAULT_COA is not None and isinstance(DJANGO_LEDGER_DEFAULT_COA, list):
315+
return DJANGO_LEDGER_DEFAULT_COA
316+
return DEFAULT_CHART_OF_ACCOUNTS
317+
318+
319+
if DJANGO_LEDGER_DEFAULT_COA:
320+
DJANGO_LEDGER_DEFAULT_COA = get_default_coa()
321+
312322
PREFIX_MAP = {
313323
'in': ROOT_INCOME,
314324
'ex': ROOT_EXPENSES,
@@ -337,12 +347,6 @@ def verify_unique_code():
337347
raise DjangoLedgerConfigurationError('Default CoA is not unique.')
338348

339349

340-
def get_default_coa() -> List[Dict]:
341-
if DJANGO_LEDGER_DEFAULT_COA is not None and isinstance(DJANGO_LEDGER_DEFAULT_COA, list):
342-
return DJANGO_LEDGER_DEFAULT_COA
343-
return DEFAULT_CHART_OF_ACCOUNTS
344-
345-
346350
def get_default_coa_rst(default_coa: Optional[Dict] = None) -> str:
347351
"""
348352
Converts the provided Chart of Account into restructuredText format.

0 commit comments

Comments
 (0)