Esempio n. 1
0
def test_uniform_no_overdue(uniform_transactions_zerosum):
    member, cutoff = uniform_transactions_zerosum
    assert member.creditor_transactions.count() > 0
    assert member.credit >= 0
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert not overdue
Esempio n. 2
0
def test_nonuniform_no_overdue(nonuniform_transactions_zerosum):
    member, cutoff = nonuniform_transactions_zerosum
    assert member.creditor_transactions.count() > 0
    assert member.credit >= 0
    # Make sure the distribution is non-uniform
    debits = member.creditor_transactions.filter(amount__lt=0)
    credits = member.creditor_transactions.filter(amount__gt=0)
    assert debits.count() != credits.count()
    # Make sure nothing is overdue
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert not overdue
Esempio n. 3
0
def test_nonuniform_adjustment_zerosum(nonuniform_transactions_zerosum):
    member, cutoff = nonuniform_transactions_zerosum
    adjtag = TransactionTagFactory(label='Adjustment', tmatch='')
    all_debits_as_list = list(
        member.creditor_transactions.filter(amount__lt=0).order_by('stamp'))
    first_half = all_debits_as_list[:int(len(all_debits_as_list) / 2)]
    credit_sum = 0
    for trans in first_half:
        credit_sum += trans.amount
        trans.delete()

    newest = member.creditor_transactions.filter(
        amount__lt=0).order_by('-stamp')[0]
    oldest = member.creditor_transactions.filter(
        amount__lt=0).order_by('stamp')[0]

    odd_sum = TransactionFactory(owner=member,
                                 reference=oldest.reference + ' adjust',
                                 amount=credit_sum,
                                 tag=adjtag,
                                 stamp=oldest.stamp)

    debit = TransactionFactory(owner=member,
                               reference=newest.reference,
                               amount=newest.amount,
                               tag=newest.tag,
                               stamp=cutoff + datetime.timedelta(days=20))

    # First check we have overdue without tag filter
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert overdue

    # Then check that we don't have overdue with tag filter
    settings.VELKOJA_EXCLUDE_TAGS = ['Adjustment']
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert not overdue
Esempio n. 4
0
def test_uniform_no_overdue_after_cutoff(uniform_transactions_zerosum):
    member, cutoff = uniform_transactions_zerosum
    old_count = member.creditor_transactions.count()
    assert old_count > 0
    templ = member.creditor_transactions.filter(
        amount__lt=0).order_by('-stamp')[0]
    debit = TransactionFactory(owner=member,
                               reference=templ.reference,
                               amount=templ.amount,
                               tag=templ.tag,
                               stamp=cutoff + datetime.timedelta(days=20))
    assert member.creditor_transactions.count() > old_count
    assert member.credit < 0
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert not overdue
Esempio n. 5
0
def test_nonuniform_overdue(nonuniform_transactions_zerosum):
    member, cutoff = nonuniform_transactions_zerosum
    old_count = member.creditor_transactions.count()
    assert old_count > 0
    newest = member.creditor_transactions.filter(
        amount__lt=0).order_by('-stamp')[0]
    oldest = member.creditor_transactions.filter(
        amount__lt=0).order_by('stamp')[0]
    debit = TransactionFactory(owner=member,
                               reference=oldest.reference,
                               amount=oldest.amount,
                               tag=oldest.tag,
                               stamp=oldest.stamp -
                               datetime.timedelta(days=60))
    assert member.creditor_transactions.count() > old_count
    assert member.credit < 0
    handler = NordeaOverdueInvoicesHandler()
    overdue = handler.list_overdue()
    assert overdue
    # The overdue one should be the one with the newest stamp
    assert overdue[0].unique_id == newest.unique_id