3
3
4
4
from nxtbn .core import CurrencyTypes
5
5
from nxtbn .core .admin_permissions import gql_required_perm
6
- from nxtbn .core .admin_types import CurrencyExchangeType
7
- from nxtbn .core .models import CurrencyExchange
6
+ from nxtbn .core .admin_types import CurrencyExchangeType , InvoiceSettingsInput , InvoiceSettingsType
7
+ from nxtbn .core .models import CurrencyExchange , InvoiceSettings
8
8
from nxtbn .users import UserRole
9
9
10
10
class CurrencyExchangeInput (graphene .InputObjectType ):
@@ -77,9 +77,33 @@ def mutate(root, info, id):
77
77
78
78
currency_exchange .delete () # Delete the record
79
79
return DeleteCurrencyExchange (success = True ) # Return success
80
+
81
+
82
+
83
+ class CreateInvoiceSettings (graphene .Mutation ):
84
+ class Arguments :
85
+ input = InvoiceSettingsInput ()
86
+
87
+ invoice_settings = graphene .Field (InvoiceSettingsType )
88
+
89
+ @gql_required_perm (InvoiceSettings , 'add_invoicesettings' )
90
+ @staticmethod
91
+ def mutate (root , info , input ):
92
+ invoice_settings = InvoiceSettings .objects .create (
93
+ store_name = input .store_name ,
94
+ store_address = input .store_address ,
95
+ city = input .city ,
96
+ country = input .country ,
97
+ postal_code = input .postal_code ,
98
+ contact_email = input .contact_email ,
99
+ contact_phone = input .contact_phone ,
100
+ is_default = input .is_default ,
101
+ )
102
+ return CreateInvoiceSettings (invoice_settings = invoice_settings )
80
103
81
104
82
105
class CoreMutation (graphene .ObjectType ):
83
106
update_exchange_rate = UpdateCurrencyExchange .Field ()
84
107
create_exchange_rate = CreateCurrencyExchange .Field ()
85
- delete_exchange_rate = DeleteCurrencyExchange .Field ()
108
+ delete_exchange_rate = DeleteCurrencyExchange .Field ()
109
+ create_invoice_settings = CreateInvoiceSettings .Field ()
0 commit comments