def test_viewable_by__public_unpublished__owner(self):
     event = EventFactory(is_published=False, privacy=Event.PUBLIC)
     person = PersonFactory()
     OrganizationMember.objects.create(
         person=person,
         organization=event.organization,
         role=OrganizationMember.OWNER,
     )
     self.assertTrue(event.viewable_by(person))
Пример #2
0
    def test_dwolla_charge__user(self):
        event = EventFactory(api_type=Event.TEST,
                             application_fee_percent=Decimal('2.5'))
        self.assertTrue(event.dwolla_connected())
        dwolla_prep(Event.TEST)

        person = PersonFactory()
        order = OrderFactory(person=person, event=event)
        charge = dwolla_charge(
            sender=person,
            amount=42.15,
            order=order,
            event=event,
            pin=settings.DWOLLA_TEST_USER_PIN,
            source='Balance',
        )

        self.assertIsInstance(charge, dict)
        self.assertEqual(charge["Type"], "money_received")
        self.assertEqual(len(charge['Fees']), 2)
        self.assertEqual(charge["Notes"], "Order {} for {}".format(order.code, event.name))

        txn = Transaction.from_dwolla_charge(charge, event=event)
        # 42.15 * 0.025 = 1.05
        self.assertEqual(Decimal(txn.application_fee), Decimal('1.05'))
        # 0.25
        self.assertEqual(Decimal(txn.processing_fee), Decimal('0.25'))

        refund = dwolla_refund(
            order=order,
            event=event,
            payment_id=txn.remote_id,
            amount=txn.amount,
            pin=settings.DWOLLA_TEST_ORGANIZATION_PIN
        )

        self.assertIsInstance(refund, dict)
        self.assertEqual(refund["Amount"], txn.amount)

        refund_info = transactions.info(
            tid=str(refund['TransactionId']),
            alternate_token=dwolla_get_token(event.organization, event.api_type)
        )
        self.assertEqual(refund_info["Notes"], "Order {} for {}".format(order.code, event.name))

        refund_txn = Transaction.from_dwolla_refund(refund, txn, event=event)
        self.assertEqual(refund_txn.amount, -1 * txn.amount)
        self.assertEqual(refund_txn.application_fee, 0)
        self.assertEqual(refund_txn.processing_fee, 0)
Пример #3
0
    def test_charge__customer(self):
        event = EventFactory(api_type=Event.TEST,
                             application_fee_percent=Decimal('2.5'))
        order = OrderFactory(event=event)
        self.assertTrue(event.stripe_connected())
        stripe_prep(Event.TEST)

        token = stripe.Token.create(
            card={
                "number": '4242424242424242',
                "exp_month": 12,
                "exp_year": 2050,
                "cvc": '123'
            },
        )
        customer = stripe.Customer.create(
            card=token,
        )
        card = customer.default_card
        charge = stripe_charge(
            card,
            amount=42.15,
            event=event,
            order=order,
            customer=customer
        )
        self.assertIsInstance(charge.balance_transaction, stripe.StripeObject)
        self.assertEqual(charge.balance_transaction.object, "balance_transaction")
        self.assertEqual(len(charge.balance_transaction.fee_details), 2)
        self.assertEqual(charge.metadata, {'order': order.code, 'event': event.name})

        txn = Transaction.from_stripe_charge(charge, api_type=event.api_type, event=event)
        # 42.15 * 0.025 = 1.05
        self.assertEqual(txn.application_fee, Decimal('1.05'))
        # (42.15 * 0.029) + 0.30 = 1.52
        self.assertEqual(txn.processing_fee, Decimal('1.52'))

        refund = stripe_refund(
            order=order,
            event=event,
            payment_id=txn.remote_id,
            amount=txn.amount
        )
        self.assertEqual(refund['refund'].metadata, {'order': order.code, 'event': event.name})

        refund_txn = Transaction.from_stripe_refund(refund, api_type=event.api_type, related_transaction=txn, event=event)
        self.assertEqual(refund_txn.amount, -1 * txn.amount)
        self.assertEqual(refund_txn.application_fee, -1 * txn.application_fee)
        self.assertEqual(refund_txn.processing_fee, -1 * txn.processing_fee)
Пример #4
0
 def setUp(self):
     self.person = PersonFactory()
     self.event = EventFactory()
     self.item = ItemFactory(event=self.event, name='Multipass')
     self.order = OrderFactory(event=self.event, person=self.person)
     self.item_option1 = ItemOptionFactory(price=100,
                                           item=self.item,
                                           name='Gold')
     self.item_option2 = ItemOptionFactory(price=100,
                                           item=self.item,
                                           name='Gold')
     self.bought_item1 = BoughtItem.objects.create(
         item_option=self.item_option1,
         order=self.order,
         price=Decimal(0),
         status=BoughtItem.BOUGHT)
     self.bought_item2 = BoughtItem.objects.create(
         item_option=self.item_option2,
         order=self.order,
         price=Decimal(0),
         status=BoughtItem.BOUGHT)
     self.txn = TransactionFactory(amount=Decimal("20"), order=self.order)
     self.txn.bought_items.add(self.bought_item1, self.bought_item2)
Пример #5
0
    def test_summary_data__discount(self):
        """
        Test that get_summary_data returns correct values for savings and
        total cost.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20,
                                   event=event,
                                   item_options=[item_option])

        order.add_to_cart(item_option)
        order.add_discount(discount)
        order.mark_cart_paid(transaction)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)
Пример #6
0
    def setUp(self):
        self.factory = RequestFactory()

        event = EventFactory()
        self.order = OrderFactory(event=event, email='*****@*****.**')
        self.transaction = TransactionFactory(
            event=event, order=self.order, amount=130,
            method=Transaction.CHECK, is_confirmed=False)
        item = ItemFactory(event=event, name='Multipass')
        item_option1 = ItemOptionFactory(price=100, item=item, name='Gold')
        item_option2 = ItemOptionFactory(price=60, item=item, name='Silver')

        discount = DiscountFactory(amount=30, discount_type='percent',
                                   event=event, item_options=[item_option1])

        self.order.add_to_cart(item_option1)
        self.order.add_to_cart(item_option2)
        self.order.add_discount(discount)
        self.order.mark_cart_paid(self.transaction)

        order2 = OrderFactory(event=event, email='*****@*****.**')
        order2.add_to_cart(item_option2)
        transaction2 = TransactionFactory(event=event, order=self.order,
                                          amount=130, method=Transaction.CHECK,
                                          is_confirmed=True)
        order2.mark_cart_paid(transaction2)

        self.order3 = OrderFactory(event=event, email='*****@*****.**')
        self.order3.add_to_cart(item_option1)
        transaction3 = TransactionFactory(event=event, order=self.order3,
                                          amount=130, method=Transaction.CHECK,
                                          is_confirmed=True)
        self.order3.mark_cart_paid(transaction3)

        self.viewset = ItemOptionViewSet()
        self.viewset.request = self.factory.get('/')
        self.viewset.request.user = self.order.person
Пример #7
0
    def test_attendee_count__no_housing(self):
        """Attendee count should be present & accurate; housing data shouldn't."""
        event = EventFactory(collect_housing_data=False)
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

        order.add_to_cart(item_option)
        order.add_to_cart(item_option)
        order.mark_cart_paid(transaction)

        AttendeeFactory(order=order, bought_items=order.bought_items.all())

        view = EventSummaryView()
        view.request = self.factory.get('/')
        view.request.user = AnonymousUser()
        view.event = event
        context_data = view.get_context_data()

        self.assertEqual(context_data['attendee_count'], 1)
        self.assertNotIn('attendee_requesting_count', context_data)
        self.assertNotIn('attendee_arranged_count', context_data)
        self.assertNotIn('attendee_home_count', context_data)
Пример #8
0
    def setUp(self):
        self.person = PersonFactory()
        event = EventFactory()
        owner = PersonFactory()
        OrganizationMember.objects.create(
            person=owner,
            organization=event.organization,
            role=OrganizationMember.OWNER,
        )
        self.order = OrderFactory(event=event, person=self.person)
        transaction = TransactionFactory(event=event,
                                         order=self.order,
                                         amount=130)
        item = ItemFactory(event=event, name='Multipass')
        item_option1 = ItemOptionFactory(price=100, item=item, name='Gold')
        item_option2 = ItemOptionFactory(price=60, item=item, name='Silver')

        discount = DiscountFactory(amount=30,
                                   discount_type='percent',
                                   event=event,
                                   item_options=[item_option1])

        self.order.add_to_cart(item_option1)
        self.order.add_to_cart(item_option2)
        self.order.add_discount(discount)
        self.order.mark_cart_paid(transaction)

        self.mailer = OrderAlertMailer(transaction,
                                       site='dancerfly.com',
                                       secure=True)
        self.event_name = event.name
        self.discount_amount = format_money(discount.amount, event.currency)
        self.total_amount = format_money(transaction.amount, event.currency)
        self.option1 = '{0} ({1})'.format(item.name, item_option1.name)
        self.option2 = '{0} ({1})'.format(item.name, item_option1.name)
        self.item_price = format_money(item_option1.price, event.currency)
Пример #9
0
    def setUp(self):
        event = EventFactory()
        self.order = OrderFactory(event=event, email='*****@*****.**')
        transaction = TransactionFactory(event=event,
                                         order=self.order,
                                         amount=130)
        item = ItemFactory(event=event, name='Multipass')
        item_option1 = ItemOptionFactory(price=100, item=item, name='Gold')
        item_option2 = ItemOptionFactory(price=60, item=item, name='Silver')

        discount = DiscountFactory(amount=30,
                                   discount_type='percent',
                                   event=event,
                                   item_options=[item_option1])

        self.order.add_to_cart(item_option1)
        self.order.add_to_cart(item_option2)
        self.order.add_discount(discount)
        self.order.mark_cart_paid(transaction)

        self.mailer = OrderAlertMailer(transaction,
                                       site='dancerfly.com',
                                       secure=True)
        self.event_name = event.name
Пример #10
0
 def test_liability_waiver_subsitutes_event_name(self):
     event = EventFactory()
     event.liability_waiver = '{event} bears no responsibility for anything.'
     self.assertIn(event.name, event.get_liability_waiver())
    def setUp(self):
        event = EventFactory(collect_housing_data=True,
                             start_date=now().date() + timedelta(days=2),
                             end_date=now().date() + timedelta(days=2))
        order = OrderFactory(event=event, providing_housing=False)
        housing = EventHousingFactory(event=event,
                                      order=order,
                                      contact_name='Zardoz',
                                      contact_email='*****@*****.**',
                                      contact_phone='111-111-1111',
                                      public_transit_access=True,
                                      person_prefer='Han Solo',
                                      person_avoid='Greedo')
        HousingSlotFactory(eventhousing=housing,
                           date=event.start_date,
                           spaces=1,
                           spaces_max=1)
        HousingSlotFactory(eventhousing=housing,
                           date=event.start_date - timedelta(days=1),
                           spaces=1,
                           spaces_max=1)
        housing.ef_present.add(EnvironmentalFactorFactory(name='Carbonite'))
        housing.ef_present.add(EnvironmentalFactorFactory(name='Sandbarges'))
        housing.ef_avoid.add(EnvironmentalFactorFactory(name='Jedi'))
        housing.ef_avoid.add(EnvironmentalFactorFactory(name='Droids'))
        housing.housing_categories.add(HousingCategoryFactory(name='Palace'))
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

        order.add_to_cart(item_option)
        order.mark_cart_paid(transaction)

        self.attendee = AttendeeFactory(
            order=order,
            bought_items=order.bought_items.all(),
            housing_status='have',
            email='*****@*****.**',
            other_needs='99 mattresses',
            person_avoid='Darth Vader',
            person_prefer='Lando Calrissian',
        )
        self.attendee.ef_cause = [
            EnvironmentalFactorFactory(name='Laughter'),
            EnvironmentalFactorFactory(name='Confusion'),
        ]
        self.attendee.housing_prefer = [
            HousingCategoryFactory(name='Yurt'),
        ]
        self.attendee.ef_avoid = [
            EnvironmentalFactorFactory(name='Ontology'),
            EnvironmentalFactorFactory(name='Gnosticism'),
        ]
        self.attendee.nights.add(
            HousingRequestNightFactory(date=event.start_date))

        housing_form = CustomFormFactory(event=event, form_type='hosting')
        field = CustomFormFieldFactory(form=housing_form, name='bed condition')
        self.custom_key = field.key
        entry2 = CustomFormEntry.objects.create(
            related_ct=ContentType.objects.get(model='eventhousing'),
            related_id=housing.pk,
            form_field=field)
        entry2.set_value('unmade')
        entry2.save()

        self.event = event
        self.order = order
    def test_duplication(self):
        """Passing in a template_event should result in settings and relevant related objects being copied"""
        threedays = timedelta(days=3)
        template = EventFactory(
            start_date=timezone.now() - threedays,
            end_date=timezone.now() - threedays,
        )
        item = ItemFactory(event=template)
        ItemOptionFactory(item=item)
        ItemImageFactory(item=item)
        DiscountFactory(event=template)
        SavedReportFactory(event=template)
        custom_form = CustomFormFactory(event=template)
        CustomFormFieldFactory(form=custom_form)

        request = self.factory.post(
            '/', {
                'name': 'New event',
                'slug': 'new-event',
                'start_date': timezone.now().strftime("%Y-%m-%d"),
                'end_date': timezone.now().strftime("%Y-%m-%d"),
                'organization': str(template.organization.pk),
                'template_event': str(template.pk),
            })
        owner = PersonFactory()
        OrganizationMember.objects.create(
            person=owner,
            organization=template.organization,
            role=OrganizationMember.OWNER,
        )
        request.user = owner
        form = EventCreateForm(request, data=request.POST)
        self.assertFalse(form.errors)
        event = form.save()

        # Get a refreshed version from the db
        event = Event.objects.get(pk=event.pk)

        fields = (
            'description',
            'website_url',
            'banner_image',
            'city',
            'state_or_province',
            'country',
            'timezone',
            'currency',
            'has_dances',
            'has_classes',
            'liability_waiver',
            'privacy',
            'collect_housing_data',
            'collect_survey_data',
            'cart_timeout',
            'check_postmark_cutoff',
            'transfers_allowed',
            'facebook_url',
        )
        self.assertEqual(dict((f, getattr(event, f)) for f in fields),
                         dict((f, getattr(template, f)) for f in fields))
        # Make sure things haven't been moved off old events.
        self.assertEqual(template.items.count(), 1)
        item = template.items.all()[0]
        self.assertEqual(item.options.count(), 1)
        self.assertEqual(template.discount_set.count(), 1)
        self.assertEqual(template.savedreport_set.count(), 1)
        self.assertEqual(template.forms.count(), 1)
        custom_form = template.forms.all()[0]
        self.assertEqual(custom_form.fields.count(), 1)

        # Make sure things have been copied to new event.
        self.assertEqual(event.items.count(), 1)
        item = event.items.all()[0]
        self.assertEqual(item.options.count(), 1)
        self.assertEqual(event.discount_set.count(), 1)
        self.assertEqual(event.savedreport_set.count(), 1)
        self.assertEqual(event.forms.count(), 1)
        custom_form = event.forms.all()[0]
        self.assertEqual(custom_form.fields.count(), 1)

        # Check that dates have been adjusted properly.
        old_item = template.items.all()[0]
        old_option = old_item.options.all()[0]
        new_item = event.items.all()[0]
        new_option = new_item.options.all()[0]
        self.assertEqual(
            new_option.available_start - old_option.available_start, threedays)

        old_discount = template.discount_set.all()[0]
        new_discount = event.discount_set.all()[0]
        self.assertEqual(
            new_discount.available_start - old_discount.available_start,
            threedays)
Пример #13
0
    def test_partial_refunds(self):
        event = EventFactory(api_type=TEST,
                             application_fee_percent=Decimal('2.5'))
        order = OrderFactory(event=event)
        self.assertTrue(event.stripe_connected())
        stripe_prep(TEST)
        stripe.api_key = event.organization.stripe_test_access_token

        token = stripe.Token.create(
            card={
                "number": '4242424242424242',
                "exp_month": 12,
                "exp_year": 2050,
                "cvc": '123'
            },
        )
        charge = stripe_charge(
            token,
            amount=42.15,
            order=order,
            event=event,
        )
        self.assertIsInstance(charge.balance_transaction, stripe.StripeObject)
        self.assertEqual(charge.balance_transaction.object, "balance_transaction")
        self.assertEqual(len(charge.balance_transaction.fee_details), 2)
        self.assertEqual(charge.metadata, {'order': order.code, 'event': event.name})

        txn = Transaction.from_stripe_charge(charge, api_type=event.api_type, event=event)
        # 42.15 * 0.025 = 1.05
        self.assertEqual(txn.application_fee, Decimal('1.05'))
        # (42.15 * 0.029) + 0.30 = 1.52
        self.assertEqual(txn.processing_fee, Decimal('1.52'))

        refund1_amount = 10
        refund1 = stripe_refund(
            order=order,
            event=event,
            payment_id=txn.remote_id,
            amount=refund1_amount
        )
        self.assertEqual(refund1['refund'].metadata, {'order': order.code, 'event': event.name})

        refund1_txn = Transaction.from_stripe_refund(refund1, api_type=event.api_type, related_transaction=txn, event=event)

        self.assertEqual(refund1_txn.amount, Decimal('-10.00'))
        # 10.00 * 0.025 = 0.25
        self.assertEqual(refund1_txn.application_fee, Decimal('-0.25'))
        # 10.00 * 0.029 = 0.29
        self.assertEqual(refund1_txn.processing_fee, Decimal('-0.29'))

        refund2_amount = 20
        refund2 = stripe_refund(
            order=order,
            event=event,
            payment_id=txn.remote_id,
            amount=refund2_amount
        )
        self.assertEqual(refund2['refund'].metadata, {'order': order.code, 'event': event.name})

        refund2_txn = Transaction.from_stripe_refund(refund2, api_type=event.api_type, related_transaction=txn, event=event)

        self.assertEqual(refund2_txn.amount, Decimal('-20.00'))
        # 20.00 * 0.025 = 0.50
        self.assertEqual(refund2_txn.application_fee, Decimal('-0.50'))
        # 20.00 * 0.029 = 0.58
        self.assertEqual(refund2_txn.processing_fee, Decimal('-0.58'))
Пример #14
0
 def test_liability_waiver_subsitutes_org_name(self):
     event = EventFactory()
     self.assertIn(event.organization.name, event.get_liability_waiver())
Пример #15
0
 def test_viewable_by__invited_published__invited(self):
     event = EventFactory(is_published=True, privacy=Event.INVITED)
     person = PersonFactory()
     OrderFactory(event=event, person=person)
     self.assertTrue(event.viewable_by(person))
Пример #16
0
 def test_viewable_by__invited_published__anon(self):
     event = EventFactory(is_published=True, privacy=Event.INVITED)
     person = AnonymousUser()
     self.assertFalse(event.viewable_by(person))
Пример #17
0
 def setUp(self):
     self.event = EventFactory(api_type=TEST)
     self.order = OrderFactory(event=self.event)
     self.person = PersonFactory()
     self.token = 'FAKE_TOKEN'
Пример #18
0
 def test_viewable_by__public_unpublished__authed(self):
     event = EventFactory(is_published=False, privacy=Event.PUBLIC)
     person = PersonFactory()
     self.assertFalse(event.viewable_by(person))
Пример #19
0
 def test_viewable_by__public_unpublished__anon(self):
     event = EventFactory(is_published=False, privacy=Event.PUBLIC)
     person = AnonymousUser()
     self.assertFalse(event.viewable_by(person))
Пример #20
0
 def setUp(self):
     self.order = OrderFactory(code='TK421')
     self.event = EventFactory()
     self.transactions = [TransactionFactory(order=self.order)]
     self.table = FinanceTable(self.event, self.transactions)
Пример #21
0
 def _get_fake_content(self):
     return EventFactory.build()
Пример #22
0
 def _get_fake_content(self):
     return EventFactory.build()
Пример #23
0
    def test_partial_refunds(self):
        event = EventFactory(api_type=TEST,
                             application_fee_percent=Decimal('2.5'))
        order = OrderFactory(event=event)
        self.assertTrue(event.stripe_connected())
        stripe_prep(TEST)
        stripe.api_key = event.organization.stripe_test_access_token

        token = stripe.Token.create(card={
            "number": '4242424242424242',
            "exp_month": 12,
            "exp_year": 2050,
            "cvc": '123'
        }, )
        charge = stripe_charge(
            token,
            amount=42.15,
            order=order,
            event=event,
        )
        self.assertIsInstance(charge.balance_transaction, stripe.StripeObject)
        self.assertEqual(charge.balance_transaction.object,
                         "balance_transaction")
        self.assertEqual(len(charge.balance_transaction.fee_details), 2)
        self.assertEqual(charge.metadata, {
            'order': order.code,
            'event': event.name
        })

        txn = Transaction.from_stripe_charge(charge,
                                             api_type=event.api_type,
                                             event=event)
        # 42.15 * 0.025 = 1.05
        self.assertEqual(txn.application_fee, Decimal('1.05'))
        # (42.15 * 0.029) + 0.30 = 1.52
        self.assertEqual(txn.processing_fee, Decimal('1.52'))

        refund1_amount = 10
        refund1 = stripe_refund(order=order,
                                event=event,
                                payment_id=txn.remote_id,
                                amount=refund1_amount)
        self.assertEqual(refund1['refund'].metadata, {
            'order': order.code,
            'event': event.name
        })

        refund1_txn = Transaction.from_stripe_refund(refund1,
                                                     api_type=event.api_type,
                                                     related_transaction=txn,
                                                     event=event)

        self.assertEqual(refund1_txn.amount, Decimal('-10.00'))
        # 10.00 * 0.025 = 0.25
        self.assertEqual(refund1_txn.application_fee, Decimal('-0.25'))
        # 10.00 * 0.029 = 0.29
        self.assertEqual(refund1_txn.processing_fee, Decimal('-0.29'))

        refund2_amount = 20
        refund2 = stripe_refund(order=order,
                                event=event,
                                payment_id=txn.remote_id,
                                amount=refund2_amount)
        self.assertEqual(refund2['refund'].metadata, {
            'order': order.code,
            'event': event.name
        })

        refund2_txn = Transaction.from_stripe_refund(refund2,
                                                     api_type=event.api_type,
                                                     related_transaction=txn,
                                                     event=event)

        self.assertEqual(refund2_txn.amount, Decimal('-20.00'))
        # 20.00 * 0.025 = 0.50
        self.assertEqual(refund2_txn.application_fee, Decimal('-0.50'))
        # 20.00 * 0.029 = 0.58
        self.assertEqual(refund2_txn.processing_fee, Decimal('-0.58'))
Пример #24
0
 def test_liability_waiver_accepts_bracketed_words(self):
     event = EventFactory()
     event.liability_waiver = '{event} bears {no} responsibility for anything.'
     self.assertIn('{no}', event.get_liability_waiver())
Пример #25
0
    def test_summary_data__transfer(self):
        """Items sent or received in a transfer shouldn't count towards net cost and savings"""
        event = EventFactory()
        order = OrderFactory(
            event=event,
            person=PersonFactory(),
        )
        person2 = PersonFactory()
        transaction = TransactionFactory(
            event=event,
            order=order,
            is_confirmed=True,
            transaction_type=Transaction.PURCHASE,
            amount=80,
        )
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20,
                                   event=event,
                                   item_options=[item_option])

        order.add_to_cart(item_option)
        order.add_discount(discount)
        order.mark_cart_paid(transaction)

        bought_item = transaction.bought_items.get()
        invite = TransferInvite.get_or_create(
            request=Mock(user=person2, session={}),
            email=person2.email,
            content=bought_item,
        )[0]
        invite.accept()

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['total_refunds'], 0)
        self.assertEqual(summary_data['total_payments'], 80)
        self.assertEqual(summary_data['net_cost'], 80)
        self.assertEqual(summary_data['net_balance'], 0)
        self.assertEqual(summary_data['unconfirmed_check_payments'], False)
        transactions = summary_data['transactions']
        self.assertEqual(len(transactions), 2)
        transfer_txn, transfer_txn_dict = transactions.items()[0]
        self.assertEqual(transfer_txn.transaction_type, Transaction.TRANSFER)
        self.assertEqual(transfer_txn_dict['items'], [bought_item])
        self.assertEqual(transfer_txn_dict['gross_cost'], 0)
        self.assertEqual(transfer_txn_dict['discounts'], [])
        self.assertEqual(transfer_txn_dict['total_savings'], 0)
        self.assertEqual(transfer_txn_dict['net_cost'], 0)
        purchase_txn, purchase_txn_dict = transactions.items()[1]
        self.assertEqual(purchase_txn.transaction_type, Transaction.PURCHASE)
        self.assertEqual(purchase_txn_dict['items'], [bought_item])
        self.assertEqual(purchase_txn_dict['gross_cost'], 100)
        self.assertEqual(purchase_txn_dict['discounts'],
                         [bought_item.discounts.first()])
        self.assertEqual(purchase_txn_dict['total_savings'], -20)
        self.assertEqual(purchase_txn_dict['net_cost'], 80)

        order2 = Order.objects.get(event=event, person=person2)
        summary_data2 = order2.get_summary_data()
        self.assertEqual(summary_data2['gross_cost'], 0)
        self.assertEqual(summary_data2['total_savings'], 0)
        self.assertEqual(summary_data2['total_refunds'], 0)
        self.assertEqual(summary_data2['total_payments'], 0)
        self.assertEqual(summary_data2['net_cost'], 0)
        self.assertEqual(summary_data2['net_balance'], 0)
        self.assertEqual(summary_data2['unconfirmed_check_payments'], False)
        transactions2 = summary_data2['transactions']
        self.assertEqual(len(transactions2), 1)
        transfer_txn2, transfer_txn2_dict = transactions.items()[0]
        self.assertEqual(transfer_txn2.transaction_type, Transaction.TRANSFER)
        self.assertEqual(transfer_txn2_dict['items'], [bought_item])
        self.assertEqual(transfer_txn2_dict['gross_cost'], 0)
        self.assertEqual(transfer_txn2_dict['discounts'], [])
        self.assertEqual(transfer_txn2_dict['total_savings'], 0)
        self.assertEqual(transfer_txn2_dict['net_cost'], 0)