Skip to content
Snippets Groups Projects
Commit 49a8d306 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Use payment pledge as variant when cost is zero

parent 2148f26c
No related branches found
No related tags found
1 merge request!78Resolve "Rewrite registration wizard"
Pipeline #196020 passed with warnings
......@@ -397,7 +397,12 @@ class EventRegistration(ExtensibleModel):
def get_invoice(self):
# FIXME Maybe do not hard-code this
client, __ = Client.objects.get_or_create(name=get_site_preferences()["paweljong__event_invoice_client_name"])
client, __ = Client.objects.get_or_create(
name=get_site_preferences()["paweljong__event_invoice_client_name"],
defaults={
"pledge_enabled": True,
},
)
group, __ = InvoiceGroup.objects.get_or_create(
name=get_site_preferences()["paweljong__event_invoice_group_name"],
client=client,
......
......@@ -52,7 +52,12 @@ class Query(graphene.ObjectType):
@staticmethod
def resolve_paweljong_payment_choices(root, info):
client, __ = Client.objects.get_or_create(name=get_site_preferences()["paweljong__event_invoice_client_name"])
client, __ = Client.objects.get_or_create(
name=get_site_preferences()["paweljong__event_invoice_client_name"],
defaults={
"pledge_enabled": True,
},
)
group, __ = InvoiceGroup.objects.get_or_create(
name=get_site_preferences()["paweljong__event_invoice_group_name"],
client=client,
......
......@@ -192,7 +192,12 @@ class SendEventRegistrationMutation(graphene.Mutation):
# TODO Implement existing voucher handling
invoice = registration.get_invoice()
invoice.variant = event_registration["payment"]["payment_method"]
if amount == 0:
invoice.variant = "pledge"
else:
invoice.variant = event_registration["payment"]["payment_method"]
if invoice.variant == "" or invoice.variant is None:
raise ValidationError(_("The field 'Payment method' is required."))
invoice.save()
registration.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment