mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Refs #250 -- Keep payment deadlines on weekdays
This commit is contained in:
@@ -266,7 +266,15 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d
|
||||
total = sum([c.price for c in positions])
|
||||
payment_fee = payment_provider.calculate_fee(total)
|
||||
total += payment_fee
|
||||
expires = [now_dt + timedelta(days=event.settings.get('payment_term_days', as_type=int))]
|
||||
|
||||
exp_by_date = now_dt + timedelta(days=event.settings.get('payment_term_days', as_type=int))
|
||||
if event.settings.get('payment_term_weekdays'):
|
||||
if exp_by_date.weekday() == 5:
|
||||
exp_by_date += timedelta(days=2)
|
||||
elif exp_by_date.weekday() == 6:
|
||||
exp_by_date += timedelta(days=1)
|
||||
|
||||
expires = [exp_by_date]
|
||||
if event.settings.get('payment_term_last'):
|
||||
expires.append(event.settings.get('payment_term_last', as_type=datetime))
|
||||
order = Order.objects.create(
|
||||
|
||||
@@ -53,6 +53,10 @@ DEFAULTS = {
|
||||
'default': None,
|
||||
'type': datetime,
|
||||
},
|
||||
'payment_term_weekdays': {
|
||||
'default': 'True',
|
||||
'type': bool
|
||||
},
|
||||
'payment_term_expire_automatically': {
|
||||
'default': 'True',
|
||||
'type': bool
|
||||
|
||||
@@ -204,6 +204,13 @@ class PaymentSettingsForm(SettingsForm):
|
||||
required=False,
|
||||
widget=forms.DateTimeInput(attrs={'class': 'datetimepicker'})
|
||||
)
|
||||
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' "
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<legend>{% trans "Payment settings" %}</legend>
|
||||
{% bootstrap_field sform.payment_term_days layout="horizontal" %}
|
||||
{% bootstrap_field sform.payment_term_last layout="horizontal" %}
|
||||
{% bootstrap_field sform.payment_term_weekdays layout="horizontal" %}
|
||||
{% bootstrap_field sform.payment_term_expire_automatically layout="horizontal" %}
|
||||
{% bootstrap_field sform.payment_term_accept_late layout="horizontal" %}
|
||||
{% bootstrap_field sform.tax_rate_default layout="horizontal" %}
|
||||
|
||||
Reference in New Issue
Block a user