Skip to content
Snippets Groups Projects
Commit 71b73958 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Reformat

parent 8f01a050
No related branches found
No related tags found
1 merge request!17Update Invoice if person changes
Pipeline #60799 failed
......@@ -15,6 +15,5 @@ class DefaultConfig(AppConfig):
([2022], "Tom Teichler", "tom.teichler@teckids.org"),
)
def ready(self):
from .signals import update_on_person_change
from .signals import update_on_person_change # noqa
from django.utils.translation import gettext as _
from material import Layout, Row, Fieldset
from material import Fieldset, Layout, Row
from aleksis.core.forms import ActionForm
from aleksis.core.mixins import ExtensibleForm
......@@ -47,7 +47,7 @@ class EditClientForm(ExtensibleForm):
_("Debit"),
"sdd_enabled",
Row("sdd_creditor", "sdd_creditor_identifier"),
Row("sdd_iban", "sdd_bic")
Row("sdd_iban", "sdd_bic"),
),
)
......
......@@ -3,9 +3,8 @@ from django.db import models
from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from localflavor.generic.models import IBANField, BICField
from localflavor.generic.models import BICField, IBANField
from aleksis.core.util.core_helpers import get_site_preferences
from aleksis.core.mixins import ExtensibleModel
......@@ -20,22 +19,34 @@ class Client(ExtensibleModel):
email = models.EmailField(verbose_name=_("Email"))
sofort_enabled = models.BooleanField(verbose_name=_("Sofort / Klarna enabled"), default=False)
sofort_api_id = models.CharField(verbose_name=_("Sofort / Klarna API ID"), blank=True, max_length=255)
sofort_api_key = models.CharField(verbose_name=_("Sofort / Klarna API key"), blank=True, max_length=255)
sofort_project_id = models.CharField(verbose_name=_("Sofort / Klarna Project ID"), blank=True, max_length=255)
sofort_api_id = models.CharField(
verbose_name=_("Sofort / Klarna API ID"), blank=True, max_length=255
)
sofort_api_key = models.CharField(
verbose_name=_("Sofort / Klarna API key"), blank=True, max_length=255
)
sofort_project_id = models.CharField(
verbose_name=_("Sofort / Klarna Project ID"), blank=True, max_length=255
)
paypal_enabled = models.BooleanField(verbose_name=_("PayPal enabled"), default=False)
paypal_client_id = models.CharField(verbose_name=_("PayPal client ID"), blank=True, max_length=255)
paypal_client_id = models.CharField(
verbose_name=_("PayPal client ID"), blank=True, max_length=255
)
paypal_secret = models.CharField(verbose_name=_("PayPal secret"), blank=True, max_length=255)
paypal_capture = models.BooleanField(
verbose_name=_("Use PayPal Authorize & Capture"), default=False
)
sdd_enabled = models.BooleanField(verbose_name=_("Debit enabled"), default=False)
sdd_creditor = models.CharField(verbose_name=_("SEPA Direct Debit - Creditor name"), blank=True, max_length=255)
sdd_creditor = models.CharField(
verbose_name=_("SEPA Direct Debit - Creditor name"), blank=True, max_length=255
)
sdd_creditor_identifier = models.CharField(
verbose_name=_("SEPA Direct Debit - Creditor identifier"), blank=True, max_length=35, validators=[RegexValidator("^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,31}$")]
verbose_name=_("SEPA Direct Debit - Creditor identifier"),
blank=True,
max_length=35,
validators=[RegexValidator("^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,31}$")],
)
sdd_iban = IBANField(verbose_name=_("IBAN of bank account"), blank=True)
sdd_bic = BICField(verbose_name=_("BIC/SWIFT code of bank"), blank=True)
......@@ -46,29 +57,35 @@ class Client(ExtensibleModel):
constraints = [
models.UniqueConstraint(fields=["name", "site"], name="uniq_client_per_site"),
models.CheckConstraint(
check=((
Q(sofort_enabled=True)
& ~Q(sofort_api_id="")
& ~Q(sofort_api_key="")
& ~Q(sofort_project_id="")
)
| Q(sofort_enabled=False)),
check=(
(
Q(sofort_enabled=True)
& ~Q(sofort_api_id="")
& ~Q(sofort_api_key="")
& ~Q(sofort_project_id="")
)
| Q(sofort_enabled=False)
),
name="sofort_enabled_configured",
),
models.CheckConstraint(
check=((
Q(sdd_enabled=True)
& ~Q(sdd_creditor="")
& ~Q(sdd_creditor_identifier="")
& ~Q(sdd_iban="")
& ~Q(sdd_bic="")
)
| Q(sdd_enabled=False)),
check=(
(
Q(sdd_enabled=True)
& ~Q(sdd_creditor="")
& ~Q(sdd_creditor_identifier="")
& ~Q(sdd_iban="")
& ~Q(sdd_bic="")
)
| Q(sdd_enabled=False)
),
name="sdd_enabled_configured",
),
models.CheckConstraint(
check=((Q(paypal_enabled=True) & ~Q(paypal_client_id="") & ~Q(paypal_secret=""))
| Q(paypal_enabled=False)),
check=(
(Q(paypal_enabled=True) & ~Q(paypal_client_id="") & ~Q(paypal_secret=""))
| Q(paypal_enabled=False)
),
name="paypal_enabled_configured",
),
]
......
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Q
from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _
......
from django.utils.translation import gettext_lazy as _
from dynamic_preferences.preferences import Section
from dynamic_preferences.types import BooleanPreference, StringPreference
from dynamic_preferences.types import BooleanPreference
from aleksis.core.registries import site_preferences_registry
......
from django.db.models.signals import post_save
from django.dispatch import receiver
from aleksis.core.util.core_helpers import get_site_preferences
from aleksis.core.models import Person
from aleksis.core.util.core_helpers import get_site_preferences
from .models.invoice import Invoice
@receiver(post_save, sender=Person)
def update_on_person_change(sender, instance, **kwargs):
......
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