diff --git a/aleksis/apps/tezor/models/invoice.py b/aleksis/apps/tezor/models/invoice.py index 550cbe08f1f122b9a7b97ef66e29224efbe3d760..d5b38960b6b1942a6b1fa144a9037860832ee6cc 100644 --- a/aleksis/apps/tezor/models/invoice.py +++ b/aleksis/apps/tezor/models/invoice.py @@ -113,16 +113,23 @@ class Invoice(BasePayment, PureDjangoModel): if person: self.person = person + + address = person.addresses.first() + street = address.street if address is not None else "" + housenumber = address.housenumber if address is not None else "" + postal_code = address.postal_code if address is not None else "" + place = address.place if address is not None else "" + if not self.billing_last_name: self.billing_last_name = person.last_name if not self.billing_first_name: self.billing_first_name = person.first_name if not self.billing_address_1: - self.billing_address_1 = f"{person.street} {person.housenumber}" + self.billing_address_1 = f"{street} {housenumber}" if not self.billing_city: - self.billing_city = person.place + self.billing_city = place if not self.billing_postcode: - self.billing_postcode = person.postal_code + self.billing_postcode = postal_code super().save(*args, **kwargs) diff --git a/aleksis/apps/tezor/signals.py b/aleksis/apps/tezor/signals.py index ab72a66e29ff86911abed1a696d1fb128131e82f..e0b31139c9ac2fede9a07bb617833ef8c6f5a493 100644 --- a/aleksis/apps/tezor/signals.py +++ b/aleksis/apps/tezor/signals.py @@ -10,11 +10,17 @@ from .models.invoice import Invoice @receiver(post_save, sender=Person) def update_on_person_change(sender, instance, **kwargs): if get_site_preferences()["payments__update_on_person_change"]: + address = instance.addresses.first() + street = address.street if address is not None else "" + housenumber = address.housenumber if address is not None else "" + postal_code = address.postal_code if address is not None else "" + place = address.place if address is not None else "" + Invoice.objects.filter(person=instance, status__in=("waiting", "input", "preauth")).update( billing_email=instance.email, billing_first_name=instance.first_name, billing_last_name=instance.last_name, - billing_address_1=f"{instance.street} {instance.housenumber}", - billing_postcode=instance.postal_code, - billing_city=instance.place, + billing_address_1=f"{street} {housenumber}", + billing_postcode=postal_code, + billing_city=place, )