Payment term in minutes (#1760)

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Felix Rindt
2020-09-14 13:44:28 +02:00
committed by GitHub
parent 2f21dc8c3c
commit 8f2c125435
12 changed files with 155 additions and 30 deletions

View File

@@ -584,9 +584,11 @@ class CancelSettingsForm(SettingsForm):
class PaymentSettingsForm(SettingsForm):
auto_fields = [
'payment_term_mode',
'payment_term_days',
'payment_term_last',
'payment_term_weekdays',
'payment_term_minutes',
'payment_term_last',
'payment_term_expire_automatically',
'payment_term_accept_late',
'payment_explanation',
@@ -599,6 +601,18 @@ class PaymentSettingsForm(SettingsForm):
"will set the tax rate and reverse charge rules, other settings of the tax rule are ignored.")
)
def clean_payment_term_days(self):
value = self.cleaned_data.get('payment_term_days')
if self.cleaned_data.get('payment_term_mode') == 'days' and value is None:
raise ValidationError(_("This field is required."))
return value
def clean_payment_term_minutes(self):
value = self.cleaned_data.get('payment_term_minutes')
if self.cleaned_data.get('payment_term_mode') == 'minutes' and value is None:
raise ValidationError(_("This field is required."))
return value
def clean(self):
data = super().clean()
settings_dict = self.obj.settings.freeze()