diff --git a/aleksis/apps/paweljong/schema/event_registration.py b/aleksis/apps/paweljong/schema/event_registration.py index f4f9164a7ac01fbc9fe7691d9ef8614c4bc186bc..b617a2a2b12239642097f384af6d244f6fc20ed8 100644 --- a/aleksis/apps/paweljong/schema/event_registration.py +++ b/aleksis/apps/paweljong/schema/event_registration.py @@ -131,6 +131,7 @@ class SendEventRegistrationMutation(graphene.Mutation): event=event, person=person, medical_information=event_registration["medical_information"], + donation=0, **school_details, ) for field in event.additional_fields.all(): @@ -145,18 +146,19 @@ class SendEventRegistrationMutation(graphene.Mutation): registration.cost = event.cost - if event.max_cost is not None and event.max_cost > 0: + if event.max_cost is None or event.max_cost > 0: amount = event_registration["payment"]["amount"] if amount < event.cost: voucher_amount = event.cost - amount - discount = voucher_amount / event.cost - Voucher.objects.create( + discount = voucher_amount / event.cost * 100 + voucher = Voucher.objects.create( person=person, event=event, used=True, discount=discount, ) + registration.voucher = voucher elif amount > event.cost: registration.donation = amount - event.cost