Exemple #1
0
    def test_update_account_goal_community(self):
        """The account current, goal, and community should be set, as they can
        change with each pull from the financial system."""
        acc222 = Account.objects.create(
            name='Account222', code='111-222', category=Account.PROJECT,
            current=4500, goal=10000, community_contribution=5000)

        row = {'LAST_UPDATED_FROM_PAYGOV': '', 'PROJ_REQ': '90.00',
               'UNIDENT_BAL': '10', 'OVERS_PART': '25.75'}
        sync.update_account(row, acc222)
        latest = Account.objects.get(pk=acc222.pk)
        self.assertEqual(9000, latest.goal)
        self.assertEqual(8000, latest.current)
        self.assertEqual(2575, latest.community_contribution)
        acc222.delete()
    def test_update_account(self):
        """Use fake data to verify that amount fields are updated and old
        transactions are deleted"""
        acc222 = Account.objects.create(name='Account222',
                                        code='111-222',
                                        category=Account.PROJECT)

        tz = timezone('US/Eastern')
        before_donation = Donation.objects.create(account=acc222, amount=5432)
        before_donation.time = tz.localize(datetime(2009, 12, 14, 23, 59, 59))
        before_donation.save()
        after_donation = Donation.objects.create(account=acc222, amount=5432)
        after_donation.time = tz.localize(datetime(2009, 12, 15))
        after_donation.save()

        # First test with an empty LAST_UPDATED value
        row = {
            'LAST_UPDATED_FROM_PAYGOV': '',
            'PROJ_REQ': '444',
            'UNIDENT_BAL': '110.7'
        }
        sync.update_account(row, acc222)
        # All donations should remain
        self.assertNotEqual(
            None,
            Donation.objects.filter(pk=before_donation.pk).first())
        self.assertNotEqual(
            None,
            Donation.objects.filter(pk=after_donation.pk).first())
        # amount donated to should be updated
        self.assertEqual(33330, Account.objects.get(pk=acc222.pk).current)

        row = {
            'LAST_UPDATED_FROM_PAYGOV': '2009-12-14T00:00:00',
            'PROJ_REQ': '5,555.55',
            'UNIDENT_BAL': '4,321.32'
        }
        sync.update_account(row, acc222)
        # before_donation should be deleted, but after_donation not
        self.assertEqual(
            None,
            Donation.objects.filter(pk=before_donation.pk).first())
        self.assertNotEqual(
            None,
            Donation.objects.filter(pk=after_donation.pk).first())

        # amount donated to should also be updated
        self.assertEqual(123423, Account.objects.get(pk=acc222.pk).current)
    def test_update_account(self):
        """Use fake data to verify that amount fields are updated and old
        transactions are deleted"""
        acc222 = Account.objects.create(
            name='Account222', code='111-222', category=Account.PROJECT)

        tz = timezone('US/Eastern')
        before_donation = Donation.objects.create(account=acc222, amount=5432)
        before_donation.time = tz.localize(datetime(2009, 12, 14, 23, 59, 59))
        before_donation.save()
        after_donation = Donation.objects.create(account=acc222, amount=5432)
        after_donation.time = tz.localize(datetime(2009, 12, 15))
        after_donation.save()

        # First test with an empty LAST_UPDATED value
        row = {'LAST_UPDATED_FROM_PAYGOV': '', 'PROJ_REQ': '444',
               'UNIDENT_BAL': '110.7'}
        sync.update_account(row, acc222)
        # All donations should remain
        self.assertNotEqual(
            None, Donation.objects.filter(pk=before_donation.pk).first())
        self.assertNotEqual(
            None, Donation.objects.filter(pk=after_donation.pk).first())
        # amount donated to should be updated
        self.assertEqual(33330, Account.objects.get(pk=acc222.pk).current)

        row = {'LAST_UPDATED_FROM_PAYGOV': '2009-12-14T00:00:00',
               'PROJ_REQ': '5,555.55', 'UNIDENT_BAL': '4,321.32'}
        sync.update_account(row, acc222)
        # before_donation should be deleted, but after_donation not
        self.assertEqual(
            None, Donation.objects.filter(pk=before_donation.pk).first())
        self.assertNotEqual(
            None, Donation.objects.filter(pk=after_donation.pk).first())

        # amount donated to should also be updated
        self.assertEqual(123423, Account.objects.get(pk=acc222.pk).current)