Skip to content

Commit 1979b7b

Browse files
Updated invoice
1 parent c117cdf commit 1979b7b

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

nxtbn/core/admin_queries.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class AdminCoreQuery(graphene.ObjectType):
1313
currency_exchanges = DjangoFilterConnectionField(CurrencyExchangeType)
1414
currency_exchange = graphene.Field(CurrencyExchangeType, id=graphene.ID(required=True))
1515
allowed_currency_list = graphene.List(AdminCurrencyTypesEnum)
16-
default_invoice_settings = graphene.Field(InvoiceSettingsType)
16+
invoice_setting = graphene.Field(InvoiceSettingsType, invoice_settings_id=graphene.ID(required=False))
17+
invoice_settings = DjangoFilterConnectionField(InvoiceSettingsType)
1718

1819
@gql_store_admin_required
1920
def resolve_currency_exchanges(self, info, **kwargs):
@@ -39,6 +40,11 @@ def resolve_allowed_currency_list(self, info):
3940
]
4041

4142
@gql_store_admin_required
42-
def resolve_default_invoice_settings(self, info):
43-
site_id = getattr(settings, 'SITE_ID', 1)
44-
return InvoiceSettings.objects.get(site__id=site_id)
43+
def resolve_invoice_setting(self, info, invoice_settings_id=None, **kwargs):
44+
if not invoice_settings_id:
45+
return InvoiceSettings.objects.get(is_default=True)
46+
return InvoiceSettings.objects.get(id=invoice_settings_id)
47+
48+
@gql_store_admin_required
49+
def resolve_invoice_settings(self, info, **kwargs):
50+
return InvoiceSettings.objects.all()

nxtbn/core/admin_types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class InvoiceSettingsType(DjangoObjectType):
2323
class Meta:
2424
model = InvoiceSettings
2525
fields = "__all__"
26+
interfaces = (relay.Node,)
27+
filter_fields = {
28+
'store_name': ['exact', 'icontains'],
29+
}
2630

2731
class AdminCurrencyTypesEnum(graphene.ObjectType):
2832
value = graphene.String()

nxtbn/core/api/dashboard/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Meta:
2323
'country',
2424
'postal_code',
2525
'contact_email',
26+
'is_default',
2627
]
2728

2829

nxtbn/core/api/dashboard/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
urlpatterns = [
66
path('site-settings/', core_views.SiteSettingsView.as_view(), name='site-settings'),
7-
path('invoice-settings/', core_views.InvoiceSettingsView.as_view(), name='invoice-settings'),
7+
path('invoice-settings/<int:pk>/', core_views.InvoiceSettingsView.as_view(), name='invoice-settings'),
88
path('system-status/', status_views.SystemStatusAPIView.as_view(), name='system-status'),
99
path('db-tables-details/', status_views.DatabaseTableInfoAPIView.as_view(), name='db-details'),
1010
path('language-list/', core_views.LanguageChoicesAPIView.as_view(), name='language-list'),

nxtbn/core/api/dashboard/views.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,7 @@ class InvoiceSettingsView(generics.RetrieveUpdateAPIView):
5454
permission_classes = (IsStoreAdmin,)
5555
queryset = InvoiceSettings.objects.all()
5656
serializer_class = InvoiceSettingsSerializer
57-
58-
59-
60-
def get_object(self):
61-
current_site = get_current_site(self.request)
62-
try:
63-
return InvoiceSettings.objects.get(site=current_site)
64-
except InvoiceSettings.DoesNotExist:
65-
raise NotFound("Site settings for the current site do not exist.")
57+
lookup_field = 'pk'
6658

6759

6860

nxtbn/core/receivers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def create_default_site_settings(sender, **kwargs):
3737
country="Default Country",
3838
postal_code="123456",
3939
contact_email="[email protected]",
40+
is_default=True,
4041
)
4142

4243
if Warehouse.objects.count() == 0:

0 commit comments

Comments
 (0)