class PaymentSettingsForm(SettingsForm): payment_term_days = forms.IntegerField( label=_('Payment term in days'), help_text=_("The number of days after placing an order the user has to pay to preserve their reservation. If " "you use slow payment methods like bank transfer, we recommend 14 days. If you only use real-time " "payment methods, we recommend still setting two or three days to allow people to retry failed " "payments."), ) payment_term_last = RelativeDateField( label=_('Last date of payments'), help_text=_("The last date any payments are accepted. This has precedence over the number of " "days configured above. If you use the event series feature and an order contains tickets for " "multiple dates, the earliest date will be used."), required=False, ) payment_term_weekdays = forms.BooleanField( label=_('Only end payment terms on weekdays'), help_text=_("If this is activated and the payment term of any order ends on a Saturday or Sunday, it will be " "moved to the next Monday instead. This is required in some countries by civil law. This will " "not effect the last date of payments configured above."), required=False, ) payment_term_expire_automatically = forms.BooleanField( label=_('Automatically expire unpaid orders'), help_text=_("If checked, all unpaid orders will automatically go from 'pending' to 'expired' " "after the end of their payment deadline. This means that those tickets go back to " "the pool and can be ordered by other people."), required=False ) payment_term_accept_late = forms.BooleanField( label=_('Accept late payments'), help_text=_("Accept payments for orders even when they are in 'expired' state as long as enough " "capacity is available. No payments will ever be accepted after the 'Last date of payments' " "configured above."), required=False ) tax_rate_default = forms.ModelChoiceField( queryset=TaxRule.objects.none(), label=_('Tax rule for payment fees'), required=False, help_text=_("The tax rule that applies for additional fees you configured for single payment methods. This " "will set the tax rate and reverse charge rules, other settings of the tax rule are ignored.") ) def clean(self): cleaned_data = super().clean() payment_term_last = cleaned_data.get('payment_term_last') if payment_term_last and self.obj.presale_end: if payment_term_last.date(self.obj) < self.obj.presale_end.date(): self.add_error( 'payment_term_last', _('The last payment date cannot be before the end of presale.'), ) return cleaned_data def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['tax_rate_default'].queryset = self.obj.tax_rules.all()
class PaymentSettingsForm(SettingsForm): payment_term_days = forms.IntegerField( label=_('Payment term in days'), help_text= _("The number of days after placing an order the user has to pay to preserve his reservation." ), ) payment_term_last = RelativeDateField( label=_('Last date of payments'), help_text= _("The last date any payments are accepted. This has precedence over the number of " "days configured above. If you use the event series feature and an order contains tickets for " "multiple dates, the earliest date will be used."), required=False, ) payment_term_weekdays = forms.BooleanField( label=_('Only end payment terms on weekdays'), help_text= _("If this is activated and the payment term of any order ends on a saturday or sunday, it will be " "moved to the next monday instead. This is required in some countries by civil law. This will " "not effect the last date of payments configured above."), required=False, ) payment_term_expire_automatically = forms.BooleanField( label=_('Automatically expire unpaid orders'), help_text= _("If checked, all unpaid orders will automatically go from 'pending' to 'expired' " "after the end of their payment deadline. This means that those tickets go back to " "the pool and can be ordered by other people."), required=False) payment_term_accept_late = forms.BooleanField( label=_('Accept late payments'), help_text= _("Accept payments for orders even when they are in 'expired' state as long as enough " "capacity is available. No payments will ever be accepted after the 'Last date of payments' " "configured above."), required=False) tax_rate_default = forms.DecimalField( label=_('Tax rate for payment fees'), help_text=_( "The tax rate that applies for additional fees you configured for single payment methods " "(in percent)."), ) def clean(self): cleaned_data = super().clean() payment_term_last = cleaned_data.get('payment_term_last') if payment_term_last and self.obj.presale_end: if payment_term_last.date(self.obj) < self.obj.presale_end.date(): self.add_error( 'payment_term_last', _('The last payment date cannot be before the end of presale.' ), ) return cleaned_data
def settings_form_fields(self) -> dict: """ When the event's administrator visits the event configuration page, this method is called to return the configuration fields available. It should therefore return a dictionary where the keys should be (unprefixed) settings keys and the values should be corresponding Django form fields. The default implementation returns the appropriate fields for the ``_enabled``, ``_fee_abs``, ``_fee_percent`` and ``_availability_date`` settings mentioned above. We suggest that you return an ``OrderedDict`` object instead of a dictionary and make use of the default implementation. Your implementation could look like this:: @property def settings_form_fields(self): return OrderedDict( list(super().settings_form_fields.items()) + [ ('bank_details', forms.CharField( widget=forms.Textarea, label=_('Bank account details'), required=False )) ] ) .. WARNING:: It is highly discouraged to alter the ``_enabled`` field of the default implementation. """ places = settings.CURRENCY_PLACES.get(self.event.currency, 2) d = OrderedDict([ ('_enabled', forms.BooleanField( label=_('Enable payment method'), required=False, )), ('_availability_date', RelativeDateField( label=_('Available until'), help_text= _('Users will not be able to choose this payment provider after the given date.' ), required=False, )), ('_invoice_text', I18nFormField( label=_('Text on invoices'), help_text= _('Will be printed just below the payment figures and above the closing text on invoices. ' 'This will only be used if the invoice is generated before the order is paid. If the ' 'invoice is generated later, it will show a text stating that it has already been paid.' ), required=False, widget=I18nTextarea, widget_kwargs={'attrs': { 'rows': '2' }})), ('_total_min', forms.DecimalField( label=_('Minimum order total'), help_text= _('This payment will be available only if the order total is equal to or exceeds the given ' 'value. The order total for this purpose may be computed without taking the fees imposed ' 'by this payment method into account.'), localize=True, required=False, decimal_places=places, widget=DecimalTextInput(places=places))), ('_total_max', forms.DecimalField( label=_('Maximum order total'), help_text= _('This payment will be available only if the order total is equal to or below the given ' 'value. The order total for this purpose may be computed without taking the fees imposed ' 'by this payment method into account.'), localize=True, required=False, decimal_places=places, widget=DecimalTextInput(places=places))), ('_fee_abs', forms.DecimalField(label=_('Additional fee'), help_text=_('Absolute value'), localize=True, required=False, decimal_places=places, widget=DecimalTextInput(places=places))), ('_fee_percent', forms.DecimalField( label=_('Additional fee'), help_text=_('Percentage of the order total.'), localize=True, required=False, )), ('_fee_reverse_calc', forms.BooleanField( label=_( 'Calculate the fee from the total value including the fee.' ), help_text= _('We recommend to enable this if you want your users to pay the payment fees of your ' 'payment provider. <a href="{docs_url}" target="_blank" rel="noopener">Click here ' 'for detailed information on what this does.</a> Don\'t forget to set the correct fees ' 'above!'). format( docs_url= 'https://docs.pretix.eu/en/latest/user/payments/fees.html' ), required=False)), ('_restricted_countries', forms.MultipleChoiceField( label=_('Restrict to countries'), choices=Countries(), help_text= _('Only allow choosing this payment provider for invoice addresses in the selected ' 'countries. If you don\'t select any country, all countries are allowed. This is only ' 'enabled if the invoice address is required.'), widget=forms.CheckboxSelectMultiple( attrs={'class': 'scrolling-multiple-choice'}), required=False, disabled=not self.event.settings.invoice_address_required)), ]) d['_restricted_countries']._as_type = list return d
def settings_form_fields(self) -> dict: """ When the event's administrator visits the event configuration page, this method is called to return the configuration fields available. It should therefore return a dictionary where the keys should be (unprefixed) settings keys and the values should be corresponding Django form fields. The default implementation returns the appropriate fields for the ``_enabled``, ``_fee_abs``, ``_fee_percent`` and ``_availability_date`` settings mentioned above. We suggest that you return an ``OrderedDict`` object instead of a dictionary and make use of the default implementation. Your implementation could look like this:: @property def settings_form_fields(self): return OrderedDict( list(super().settings_form_fields.items()) + [ ('bank_details', forms.CharField( widget=forms.Textarea, label=_('Bank account details'), required=False )) ] ) .. WARNING:: It is highly discouraged to alter the ``_enabled`` field of the default implementation. """ return OrderedDict([ ('_enabled', forms.BooleanField( label=_('Enable payment method'), required=False, )), ('_fee_abs', forms.DecimalField(label=_('Additional fee'), help_text=_('Absolute value'), required=False)), ('_fee_percent', forms.DecimalField(label=_('Additional fee'), help_text=_('Percentage'), required=False)), ('_availability_date', RelativeDateField( label=_('Available until'), help_text= _('Users will not be able to choose this payment provider after the given date.' ), required=False, )), ('_fee_reverse_calc', forms.BooleanField( label=_( 'Calculate the fee from the total value including the fee.' ), help_text= _('We recommend you to enable this if you want your users to pay the payment fees of your ' 'payment provider. <a href="{docs_url}" target="_blank">Click here ' 'for detailled information on what this does.</a> Don\'t forget to set the correct fees ' 'above!'). format( docs_url= 'https://docs.pretix.eu/en/latest/user/payments/fees.html' ), required=False)), ('_invoice_text', I18nFormField( label=_('Text on invoices'), help_text= _('Will be printed just below the payment figures and above the closing text on invoices.' ), required=False, widget=I18nTextarea, )), ])
def settings_form_fields(self) -> dict: """ When the event's administrator visits the event configuration page, this method is called to return the configuration fields available. It should therefore return a dictionary where the keys should be (unprefixed) settings keys and the values should be corresponding Django form fields. The default implementation returns the appropriate fields for the ``_enabled``, ``_fee_abs``, ``_fee_percent`` and ``_availability_date`` settings mentioned above. We suggest that you return an ``OrderedDict`` object instead of a dictionary and make use of the default implementation. Your implementation could look like this:: @property def settings_form_fields(self): return OrderedDict( list(super().settings_form_fields.items()) + [ ('bank_details', forms.CharField( widget=forms.Textarea, label=_('Bank account details'), required=False )) ] ) .. WARNING:: It is highly discouraged to alter the ``_enabled`` field of the default implementation. """ places = settings.CURRENCY_PLACES.get(self.event.currency, 2) return OrderedDict([ ('_enabled', forms.BooleanField( label=_('Enable payment method'), required=False, )), ('_availability_date', RelativeDateField( label=_('Available until'), help_text=_('Users will not be able to choose this payment provider after the given date.'), required=False, )), ('_invoice_text', I18nFormField( label=_('Text on invoices'), help_text=_('Will be printed just below the payment figures and above the closing text on invoices. ' 'This will only be used if the invoice is generated before the order is paid. If the ' 'invoice is generated later, it will show a text stating that it has already been paid.'), required=False, widget=I18nTextarea, widget_kwargs={'attrs': {'rows': '2'}} )), ('_fee_abs', forms.DecimalField( label=_('Additional fee'), help_text=_('Absolute value'), localize=True, required=False, decimal_places=places, widget=DecimalTextInput(places=places) )), ('_fee_percent', forms.DecimalField( label=_('Additional fee'), help_text=_('Percentage of the order total. Note that this percentage will currently only ' 'be calculated on the summed price of sold tickets, not on other fees like e.g. shipping ' 'fees, if there are any.'), localize=True, required=False, )), ('_fee_reverse_calc', forms.BooleanField( label=_('Calculate the fee from the total value including the fee.'), help_text=_('We recommend to enable this if you want your users to pay the payment fees of your ' 'payment provider. <a href="{docs_url}" target="_blank" rel="noopener">Click here ' 'for detailed information on what this does.</a> Don\'t forget to set the correct fees ' 'above!').format(docs_url='https://docs.pretix.eu/en/latest/user/payments/fees.html'), required=False )), ])