Skip to content

Commit

Permalink
V0.5.2.18 (#141)
Browse files Browse the repository at this point in the history
* TransactionModel documentation update.

* Purchase Order Model documentation.

* Purchase Order Model documentation.
PO Methods optimization.

* Remove Dependency Pinning

* Purchase Order Model documentation.

* Default CoA Module Documentation
DEFAULT_CHART_OF_ACCOUNTS setting.
Pipfile Update

* ItemModel documentation and refactoring.

* ItemModel documentation and refactoring.

* LedgerModel documentation and refactoring.

* LedgerModel Optimizations

* Estimate Model Documentation

* MisIns Documentation

* MisIns Documentation

* MixIns Documentation
GraphQL Foundation Update

* MixIns Documentation
GraphQL Foundation Update

* v0.5.2.18
  • Loading branch information
elarroba authored Apr 14, 2023
1 parent a5f86ba commit b73e6aa
Show file tree
Hide file tree
Showing 33 changed files with 3,322 additions and 1,667 deletions.
2 changes: 1 addition & 1 deletion .graphqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://192.168.1.101:8000/api/v1/graphql/",
"url": "http://127.0.0.1:8000/api/v1/graphql/",
"headers": {
"user-agent": "JS GraphQL",
"Authorization": "Bearer "
Expand Down
11 changes: 5 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ name = "pypi"

[packages]
django = ">=2.2"
django-treebeard = "~=4.5.1"
ofxtools = "~=0.9.5"
markdown = "~=3.4.1"
faker = "~=15.3.3"
django-treebeard = ">=4.5.1"
ofxtools = ">=0.9.5"
markdown = ">=3.4.1"
faker = ">=15.3.3"
pillow = ">=9.3.0"

[graphql]
django-filter = ">=2.1.0"
graphene = ">=3.2.1"
graphene_django = ">=3.0.0"
django-oauth-toolkit = ">=2.2.0"
#django-graphql-jwt = "*"
#django-graphql-auth = "*"

[dev-packages]
jupyterlab = "*"
Expand All @@ -28,6 +26,7 @@ pylint = "*"
furo = "*"
twine = "*"
python-dotenv = "*"
tabulate = "*"

[requires]
python_version = "3.11"
Expand Down
1,666 changes: 822 additions & 844 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dev_env/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.global_settings import DEBUG
from django.conf import settings
from django.contrib import admin
from django.urls import path, include

Expand All @@ -13,10 +13,10 @@
try:
if DJANGO_LEDGER_GRAPHQL_ENABLED:
from django_ledger.contrib.django_ledger_graphene.api import schema
from django_ledger.contrib.django_ledger_graphene.views import ProtectedOAuth2GraphQLView
from django_ledger.contrib.django_ledger_graphene.views import DjangoLedgerOAuth2GraphQLView

urlpatterns += [
path('api/v1/graphql/', ProtectedOAuth2GraphQLView.as_view(graphiql=DEBUG, schema=schema)),
path('api/v1/graphql/', DjangoLedgerOAuth2GraphQLView.as_view(graphiql=settings.DEBUG, schema=schema)),
path('api/v1/o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
]

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.2.17'
__version__ = '0.5.2.18'
__license__ = 'GPLv3 License'

__author__ = 'Miguel Sanda'
Expand Down
28 changes: 14 additions & 14 deletions django_ledger/contrib/django_ledger_graphene/api.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import graphene
from django.urls import reverse
from django.utils.functional import SimpleLazyObject

from django_ledger.contrib.django_ledger_graphene.coa.schema import ChartOfAccountsQuery
from django_ledger.contrib.django_ledger_graphene.entity.schema import EntityModelQuery

API_PATH = SimpleLazyObject(lambda: reverse("api"))
from django_ledger.contrib.django_ledger_graphene.coa.schema import ChartOfAccountsModelType
from django_ledger.contrib.django_ledger_graphene.entity.schema import EntityModelQuery, EntityModelType


class Query(
EntityModelQuery,
# ChartOfAccountsModelQuery
# CustomerQuery,
# Bill_list_Query,
# Accountlist_Query,
# Bank_account_Query ,
# ChartOfAccountsQuery,
EntityModelQuery,
ChartOfAccountsQuery
# UnitOfMeasureQuery,
# VendorsQuery,
# EntityUnitQuery,
Expand All @@ -28,15 +24,19 @@ class Query(
pass


class Mutation(
# CustomerMutations,
# BankAccountMutations,
# AuthMutation,
):
pass
# class Mutation(
# # CustomerMutations,
# # BankAccountMutations,
# # AuthMutation,
# ):
# pass


schema = graphene.Schema(
types=[
EntityModelType,
ChartOfAccountsModelType
],
query=Query,
# mutation=Mutation
)
28 changes: 13 additions & 15 deletions django_ledger/contrib/django_ledger_graphene/coa/schema.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

import graphene
from graphene import relay
from graphene_django import DjangoObjectType

from django_ledger.models import ChartOfAccountModel


class ChartOfAccountsModelListNode(DjangoObjectType):
class ChartOfAccountsModelType(DjangoObjectType):
class Meta:
model = ChartOfAccountModel
fields = [
Expand All @@ -17,16 +16,15 @@ class Meta:
]
interfaces = (relay.Node,)


class ChartOfAccountsQuery(graphene.ObjectType):
all_coa = graphene.List(ChartOfAccountsModelListNode, slug=graphene.String(required=True))

def resolve_all_coa(self, info, slug, **kwargs):

if info.context.user.is_authenticated:
return ChartOfAccountModel.objects.for_entity(
entity_slug=slug,
user_model=info.context.user,
)
else:
return ChartOfAccountModel.objects.none()
# class ChartOfAccountsModelQuery(graphene.ObjectType):
# all_coa = graphene.List(ChartOfAccountsModelType, slug=graphene.String(required=True))
#
# def resolve_all_coa(self, info, slug, **kwargs):
#
# if info.context.user.is_authenticated:
# return ChartOfAccountModel.objects.for_entity(
# entity_slug=slug,
# user_model=info.context.user,
# )
# else:
# return ChartOfAccountModel.objects.none()
45 changes: 24 additions & 21 deletions django_ledger/contrib/django_ledger_graphene/entity/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
]


class EntityModelListNode(DjangoObjectType):
class EntityModelType(DjangoObjectType):
is_admin = graphene.Boolean()

def resolve_is_admin(self, info):
Expand All @@ -29,29 +29,32 @@ class Meta:
model = EntityModel
fields = ENTITY_MODEL_BASE_FIELDS
filter_fields = {
'name': ['exact', 'icontains', 'istartswith'],
'name': [
'exact',
'icontains',
'istartswith'
],
}
interfaces = (relay.Node,)


class EntityModelDetailNode(EntityModelListNode):
class EntityModelTypeDetail(EntityModelType):
class Meta:
model = EntityModel
fields = ENTITY_MODEL_BASE_FIELDS + [
'default_coa',
# 'chartofaccountmodel_set'
'default_coa'
]


class EntityModelQuery(graphene.ObjectType):
all_entity_list = graphene.List(EntityModelListNode)
visible_entity_list = graphene.List(EntityModelListNode)
hidden_entity_list = graphene.List(EntityModelListNode)
managed_entity_list = graphene.List(EntityModelListNode)
admin_entity_list = graphene.List(EntityModelListNode)
entity_model_list_all = graphene.List(EntityModelType)
entity_model_list_visible = graphene.List(EntityModelType)
entity_model_list_hidden = graphene.List(EntityModelType)
entity_model_list_managed = graphene.List(EntityModelType)
entity_model_list_is_admin = graphene.List(EntityModelType)

entity_detail_by_uuid = graphene.Field(EntityModelDetailNode, uuid=graphene.String(required=True))
entity_detail_by_slug = graphene.Field(EntityModelDetailNode, slug=graphene.String(required=True))
entity_model_detail_by_uuid = graphene.Field(EntityModelTypeDetail, uuid=graphene.String(required=True))
entity_model_detail_by_slug = graphene.Field(EntityModelTypeDetail, slug=graphene.String(required=True))

@staticmethod
def get_base_queryset(info):
Expand All @@ -60,32 +63,32 @@ def get_base_queryset(info):
return EntityModel.objects.none()

# list ....
def resolve_all_entity_list(self, info, **kwargs):
def resolve_entity_model_list_all(self, info, **kwargs):
return EntityModelQuery.get_base_queryset(info)

def resolve_visible_entity_list(self, info, **kwargs):
def resolve_entity_model_list_visible(self, info, **kwargs):
qs = EntityModelQuery.get_base_queryset(info)
return qs.visible()

def resolve_hidden_entity_list(self, info, **kwargs):
def resolve_entity_model_list_hidden(self, info, **kwargs):
qs = EntityModelQuery.get_base_queryset(info)
return qs.hidden()

def resolve_managed_entity_list(self, info, **kwargs):
def resolve_entity_model_list_managed(self, info, **kwargs):
qs: EntityModelQuerySet = EntityModelQuery.get_base_queryset(info)
user_model = info.context.resource_owner
return qs.filter(managers__in=[user_model])

def resolve_admin_entity_list(self, info, **kwargs):
def resolve_entity_model_list_is_admin(self, info, **kwargs):
qs: EntityModelQuerySet = EntityModelQuery.get_base_queryset(info)
user_model = info.context.resource_owner
return qs.filter(admin=user_model)

# detail...
def resolve_entity_detail_by_slug(self, info, slug, **kwargs):
def resolve_entity_model_detail_by_slug(self, info, slug, **kwargs):
qs: EntityModelQuerySet = EntityModelQuery.get_base_queryset(info)
return qs.select_related('default_coa', ).get(slug__exact=slug)
return qs.select_related('default_coa').get(slug__exact=slug)

def resolve_entity_detail_by_uuid(self, info, uuid, **kwargs):
def resolve_entity_model_detail_by_uuid(self, info, uuid, **kwargs):
qs: EntityModelQuerySet = EntityModelQuery.get_base_queryset(info)
return qs.select_related('default_coa', ).get(uuid__exact=uuid)
return qs.select_related('default_coa').get(uuid__exact=uuid)
71 changes: 35 additions & 36 deletions django_ledger/contrib/django_ledger_graphene/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
type Query {
allCoa(slug: String!): [ChartOfAccountsModelListNode]
allEntityList: [EntityModelListNode]
visibleEntityList: [EntityModelListNode]
hiddenEntityList: [EntityModelListNode]
managedEntityList: [EntityModelListNode]
adminEntityList: [EntityModelListNode]
entityDetailByUuid(uuid: String!): EntityModelDetailNode
entityDetailBySlug(slug: String!): EntityModelDetailNode
}

type ChartOfAccountsModelListNode implements Node {
slug: String!
name: String
uuid: UUID!
locked: Boolean!

"""The ID of the object"""
id: ID!
}

"""An object with an ID"""
interface Node {
"""The ID of the object"""
id: ID!
}

"""
Leverages the internal Python implementation of UUID (uuid.UUID) to provide native UUID objects
in fields, resolvers and input.
"""
scalar UUID

type EntityModelListNode implements Node {
type EntityModelType implements Node {
slug: String!
created: DateTime!
updated: DateTime
Expand All @@ -47,13 +14,25 @@ type EntityModelListNode implements Node {
isAdmin: Boolean
}

"""An object with an ID"""
interface Node {
"""The ID of the object"""
id: ID!
}

"""
The `DateTime` scalar type represents a DateTime
value as specified by
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
"""
scalar DateTime

"""
Leverages the internal Python implementation of UUID (uuid.UUID) to provide native UUID objects
in fields, resolvers and input.
"""
scalar UUID

enum DjangoLedgerEntityModelFyStartMonthChoices {
"""January"""
A_1
Expand Down Expand Up @@ -92,7 +71,27 @@ enum DjangoLedgerEntityModelFyStartMonthChoices {
A_12
}

type EntityModelDetailNode {
type ChartOfAccountsModelType implements Node {
slug: String!
name: String
uuid: UUID!
locked: Boolean!

"""The ID of the object"""
id: ID!
}

type Query {
entityModelListAll: [EntityModelType]
entityModelListVisible: [EntityModelType]
entityModelListHidden: [EntityModelType]
entityModelListManaged: [EntityModelType]
entityModelListIsAdmin: [EntityModelType]
entityModelDetailByUuid(uuid: String!): EntityModelTypeDetail
entityModelDetailBySlug(slug: String!): EntityModelTypeDetail
}

type EntityModelTypeDetail {
slug: String!
created: DateTime!
updated: DateTime
Expand All @@ -102,6 +101,6 @@ type EntityModelDetailNode {
accrualMethod: Boolean!
fyStartMonth: DjangoLedgerEntityModelFyStartMonthChoices!
picture: String
defaultCoa: ChartOfAccountsModelListNode
defaultCoa: ChartOfAccountsModelType
isAdmin: Boolean
}
Loading

0 comments on commit b73e6aa

Please sign in to comment.