diff --git a/registrasion/controllers/invoice.py b/registrasion/controllers/invoice.py index a25221f1..f7ae13e5 100644 --- a/registrasion/controllers/invoice.py +++ b/registrasion/controllers/invoice.py @@ -73,6 +73,11 @@ class InvoiceController(object): # Never generate a due time that is before the issue time due = max(issued, reservation_limit) + # Get the invoice recipient + profile = rego.AttendeeProfileBase.objects.get_subclass( + id=cart.user.attendee.attendeeprofilebase.id, + ) + recipient = profile.invoice_recipient() invoice = rego.Invoice.objects.create( user=cart.user, cart=cart, @@ -81,7 +86,7 @@ class InvoiceController(object): value=Decimal(), issue_time=issued, due_time=due, - recipient="BOB_THOMAS", # TODO: add recipient generating code + recipient=recipient, ) product_items = rego.ProductItem.objects.filter(cart=cart) diff --git a/registrasion/tests/test_cart.py b/registrasion/tests/test_cart.py index 10ba10d2..e87ef37e 100644 --- a/registrasion/tests/test_cart.py +++ b/registrasion/tests/test_cart.py @@ -23,6 +23,9 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase): @classmethod def setUpTestData(cls): + + super(RegistrationCartTestCase, cls).setUpTestData() + cls.USER_1 = User.objects.create_user( username='testuser', email='test@example.com', @@ -33,6 +36,15 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase): email='test2@example.com', password='top_secret') + attendee1 = rego.Attendee.get_instance(cls.USER_1) + attendee1.save() + profile1 = rego.AttendeeProfileBase.objects.create(attendee=attendee1) + profile1.save() + attendee2 = rego.Attendee.get_instance(cls.USER_2) + attendee2.save() + profile2 = rego.AttendeeProfileBase.objects.create(attendee=attendee2) + profile2.save() + cls.RESERVATION = datetime.timedelta(hours=1) cls.categories = []