Exemple #1
0
def test_expiry_last(event):
    today = now()
    event.settings.set("payment_term_days", 5)
    event.settings.set("payment_term_last", now() + timedelta(days=3))
    order = _create_order(
        event, email="*****@*****.**", positions=[], dt=today, payment_provider=FreeOrderProvider(event), locale="de"
    )
    assert (order.expires - today).days == 3
    event.settings.set("payment_term_last", now() + timedelta(days=7))
    order = _create_order(
        event, email="*****@*****.**", positions=[], dt=today, payment_provider=FreeOrderProvider(event), locale="de"
    )
    assert (order.expires - today).days == 5
Exemple #2
0
def test_expiry_last(event):
    today = now()
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_last', now() + timedelta(days=3))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 3
    event.settings.set('payment_term_last', now() + timedelta(days=7))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 5
Exemple #3
0
def test_expiry_last(event):
    today = now()
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_weekdays', False)
    event.settings.set('payment_term_last', now() + timedelta(days=3))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 3
    event.settings.set('payment_term_last', now() + timedelta(days=7))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 5
Exemple #4
0
def test_expiry_last_relative_subevents(event):
    today = now()
    event.settings.set('payment_term_days', 100)
    event.settings.set('payment_term_weekdays', False)
    event.date_from = now() + timedelta(days=5)
    event.has_subevents = True
    event.save()
    tr7 = event.tax_rules.create(rate=Decimal('17.00'))
    ticket = Item.objects.create(event=event, name='Early-bird ticket', tax_rule=tr7,
                                 default_price=Decimal('23.00'), admission=True)

    se1 = event.subevents.create(name="SE1", date_from=now() + timedelta(days=10))
    se2 = event.subevents.create(name="SE2", date_from=now() + timedelta(days=8))

    cp1 = CartPosition.objects.create(
        item=ticket, price=23, expires=now() + timedelta(days=1), subevent=se1, event=event, cart_id="123"
    )
    cp2 = CartPosition.objects.create(
        item=ticket, price=23, expires=now() + timedelta(days=1), subevent=se2, event=event, cart_id="123"
    )

    event.settings.set('payment_term_last', RelativeDateWrapper(
        RelativeDate(days_before=2, time=None, base_date_name='date_from')
    ))
    order = _create_order(event, email='*****@*****.**', positions=[cp1, cp2],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 6
Exemple #5
0
def test_expiry_weekdays(event):
    today = make_aware(datetime(2016, 9, 20, 15, 0, 0, 0))
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_weekdays', True)
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 6
    assert order.expires.weekday() == 0

    today = make_aware(datetime(2016, 9, 19, 15, 0, 0, 0))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 7
    assert order.expires.weekday() == 0
Exemple #6
0
def test_grant_when_paid_and_changed(event, customer, granting_ticket):
    cp1 = CartPosition.objects.create(
        item=granting_ticket,
        price=0,
        expires=now() + timedelta(days=1),
        event=event,
        cart_id="123",
    )
    q = event.quotas.create(size=None, name="foo")
    q.items.add(granting_ticket)
    order = _create_order(event,
                          email='*****@*****.**',
                          positions=[cp1],
                          now_dt=now(),
                          payment_provider=BankTransfer(event),
                          locale='de',
                          customer=customer)[0]
    assert not customer.memberships.exists()

    order.payments.first().confirm()

    m = customer.memberships.get()
    assert m.granted_in == order.positions.first()
    assert m.membership_type == granting_ticket.grant_membership_type
    assert m.date_start == TZ.localize(datetime(2021, 4, 27, 10, 0, 0, 0))
    assert m.date_end == TZ.localize(datetime(2021, 4, 28, 10, 0, 0, 0))
Exemple #7
0
def test_expiry_days(event):
    today = now()
    event.settings.set('payment_term_days', 5)
    order = _create_order(event, email='*****@*****.**', positions=[],
                          dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 5
Exemple #8
0
def test_expiry_weekdays(event):
    today = make_aware(datetime(2016, 9, 20, 15, 0, 0, 0))
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_weekdays', True)
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 6
    assert order.expires.weekday() == 0

    today = make_aware(datetime(2016, 9, 19, 15, 0, 0, 0))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 7
    assert order.expires.weekday() == 0
Exemple #9
0
def test_expiry_days(event):
    today = now()
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_weekdays', False)
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 5
Exemple #10
0
def test_expiry_dst(event):
    event.settings.set('timezone', 'Europe/Berlin')
    tz = pytz.timezone('Europe/Berlin')
    utc = pytz.timezone('UTC')
    today = tz.localize(datetime(2016, 10, 29, 12, 0, 0)).astimezone(utc)
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    localex = order.expires.astimezone(tz)
    assert (localex.hour, localex.minute) == (23, 59)
Exemple #11
0
def test_expiry_last_relative(event):
    today = now()
    event.settings.set('payment_term_days', 5)
    event.settings.set('payment_term_weekdays', False)
    event.date_from = now() + timedelta(days=5)
    event.save()
    event.settings.set('payment_term_last', RelativeDateWrapper(
        RelativeDate(days_before=2, time=None, base_date_name='date_from')
    ))
    order = _create_order(event, email='*****@*****.**', positions=[],
                          now_dt=today, payment_provider=FreeOrderProvider(event),
                          locale='de')
    assert (order.expires - today).days == 3
Exemple #12
0
def test_use_membership(event, customer, membership, requiring_ticket):
    cp1 = CartPosition.objects.create(item=requiring_ticket,
                                      price=23,
                                      expires=now() + timedelta(days=1),
                                      event=event,
                                      cart_id="123",
                                      used_membership=membership)
    order = _create_order(event,
                          email='*****@*****.**',
                          positions=[cp1],
                          now_dt=now(),
                          payment_provider=BankTransfer(event),
                          locale='de',
                          customer=customer)[0]
    assert order.positions.first().used_membership == membership