Exemplo n.º 1
0
    def tally_active_members(self):
        all_members = models.Member.objects
        active_members = all_members.filter(paused_date__isnull=True)

        for member in active_members:
            utils.tally_membership_months(member)

        return active_members.count()
Exemplo n.º 2
0
def create_member_dues_tx(t, member, num_months):
    transactions = models.Transaction.objects

    # new member 3 for 2 will have to be manual anyway
    if num_months == 11:
        num_months = 12

    user = getattr(member, 'user', None)

    tx = transactions.create(
        **build_tx(t),
        member_id=member.id,
        number_of_membership_months=num_months,
        user=user,
    )
    utils.tally_membership_months(member)
    return tx
Exemplo n.º 3
0
    def test_tally_membership_months_dont_run(self):
        member = self.get_member_clear_transactions()
        start_date = datetime.date.today()

        member.current_start_date = start_date
        member.paused_date = start_date
        member.save()

        result = utils.tally_membership_months(member)

        self.assertEqual(result, False)
Exemplo n.º 4
0
    def test_tally_membership_months_overdue(self):
        member = self.get_member_clear_transactions()
        test_num_months = 5
        start_date = datetime.date.today() - relativedelta.relativedelta(
            months=6, days=14)
        end_date = start_date + relativedelta.relativedelta(
            months=test_num_months)

        member.current_start_date = start_date
        member.save()

        for i in range(test_num_months):
            models.Transaction.objects.create(
                amount=0,
                member_id=member.id,
                number_of_membership_months=1,
            )

        result = utils.tally_membership_months(member)

        self.assertEqual(member.expire_date, end_date)
        self.assertEqual(member.status, 'Overdue')
Exemplo n.º 5
0
print('Faking membership months...')
members = models.Member.objects.all()
bad_count = 0

for m in members:
    old_status = m.status
    old_expire = m.expire_date

    if 'Former' in old_status:
        m.status = 'Old Portal ' + old_status
        m.save()
        continue
    if not m.current_start_date: continue

    tx, _ = utils.fake_missing_membership_months(m)
    utils.tally_membership_months(m, import_date)
    utils.gen_member_forms(m)

    if tx:
        print(m.first_name, m.last_name, tx.memo)

    if old_status != m.status or old_expire != m.expire_date:
        print('Expire / status mismatch member:', m.__dict__)
        print('New status:', m.status)
        print('Old status:', old_status)
        print('New expire:', m.expire_date)
        print('Old expire:', old_expire)
        print('')
        bad_count += 1

print('Import mismatch count:', bad_count)