コード例 #1
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_get_account_details_flip_balance(self):
        """
        The helper function should return the correct information if the
        Account is an Asset, Expense or Equity.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        in_range_entry = create_entry(today, "In the default report range")
        create_transaction(in_range_entry, self.asset_account, 15)

        asset_info = {'name': "Asset Account",
                      'number': "1-00001",
                      'beginning_balance': 25,
                      'total_debits': 0,
                      'total_credits': 15,
                      'net_change': 15,
                      'ending_balance': 10,
                      'url': self.asset_account.get_absolute_url()}

        result = _get_account_details(self.asset_account, first_of_year, today)

        self.assertEqual(result, asset_info)
コード例 #2
0
    def test_get_account_details_flip_balance(self):
        """
        The helper function should return the correct information if the
        Account is an Asset, Expense or Equity.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        in_range_entry = create_entry(today, "In the default report range")
        create_transaction(in_range_entry, self.asset_account, 15)

        asset_info = {
            'name': "Asset Account",
            'number': "1-00001",
            'beginning_balance': 25,
            'total_debits': 0,
            'total_credits': 15,
            'net_change': 15,
            'ending_balance': 10,
            'url': self.asset_account.get_absolute_url()
        }

        result = _get_account_details(self.asset_account, first_of_year, today)

        self.assertEqual(result, asset_info)
コード例 #3
0
    def test_initial(self):
        """
        A `GET` to the `trial_balance_report` view should return a
        DateRangeForm, start/stop dates and a list of Account dictionaries,
        each dictionary should contain a number, name, beginning balance, total
        debit, total credit, net change and ending balance.

        The start date should be the beginning of the current year and the stop
        date should be the current date.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        create_transaction(past_entry, self.liability_account, 25)

        in_range_entry = create_entry(today, "In the default report range")
        create_transaction(in_range_entry, self.asset_account, 15)
        create_transaction(in_range_entry, self.liability_account, -15)

        response = self.client.get(
            reverse('reports.views.trial_balance_report'))

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'reports/trial_balance.html')
        self.assertEqual(response.context['start_date'], first_of_year)
        self.assertEqual(response.context['stop_date'], today)
        self.assertIsInstance(response.context['form'], DateRangeForm)
        self.assertTrue(isinstance(response.context['accounts'], list))
        self.assertTrue(isinstance(response.context['accounts'][0], dict))

        # Balances are value balances so the asset's are flipped
        asset_info = {
            'name': "Asset Account",
            'number': "1-00001",
            'beginning_balance': 25,
            'total_debits': 0,
            'total_credits': 15,
            'net_change': 15,
            'ending_balance': 10,
            'url': self.asset_account.get_absolute_url()
        }

        liability_info = {
            'name': "Liability Account",
            'number': "2-00001",
            'beginning_balance': 25,
            'total_debits': -15,
            'total_credits': 0,
            'net_change': -15,
            'ending_balance': 10,
            'url': self.liability_account.get_absolute_url()
        }

        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #4
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_initial(self):
        """
        A `GET` to the `trial_balance_report` view should return a
        DateRangeForm, start/stop dates and a list of Account dictionaries,
        each dictionary should contain a number, name, beginning balance, total
        debit, total credit, net change and ending balance.

        The start date should be the beginning of the current year and the stop
        date should be the current date.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        create_transaction(past_entry, self.liability_account, 25)

        in_range_entry = create_entry(today, "In the default report range")
        create_transaction(in_range_entry, self.asset_account, 15)
        create_transaction(in_range_entry, self.liability_account, -15)

        response = self.client.get(
            reverse('reports.views.trial_balance_report'))

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'reports/trial_balance.html')
        self.assertEqual(response.context['start_date'], first_of_year)
        self.assertEqual(response.context['stop_date'], today)
        self.assertIsInstance(response.context['form'], DateRangeForm)
        self.assertTrue(isinstance(response.context['accounts'], list))
        self.assertTrue(isinstance(response.context['accounts'][0], dict))

        # Balances are value balances so the asset's are flipped
        asset_info = {'name': "Asset Account",
                      'number': "1-00001",
                      'beginning_balance': 25,
                      'total_debits': 0,
                      'total_credits': 15,
                      'net_change': 15,
                      'ending_balance': 10,
                      'url': self.asset_account.get_absolute_url()}

        liability_info = {'name': "Liability Account",
                          'number': "2-00001",
                          'beginning_balance': 25,
                          'total_debits': -15,
                          'total_credits': 0,
                          'net_change': -15,
                          'ending_balance': 10,
                          'url': self.liability_account.get_absolute_url()}

        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #5
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_get_profit_loss_header_totals_flipped(self):
        """
        The totals for Expenses, Cost of Goods Sold and Other Expenses should
        display the value total, not the credit/debit total.
        """
        child_header = create_header("Child Expense", self.expense_header, 6)
        gchild_account = create_account("GrandChild Expense", child_header,
                                        0, 6)
        gchild_header = create_header("Grandchild Expense", child_header, 6)
        ggchild_account = create_account("Great Grandchild Expense",
                                         gchild_header, 0, 6)

        entry = create_entry(datetime.date.today(), "test entry")
        create_transaction(entry, self.expense_account, 25)
        create_transaction(entry, gchild_account, 47)
        create_transaction(entry, ggchild_account, 82)

        start_date = datetime.date(1, 1, 1)
        stop_date = datetime.date.today()

        root_header = _get_profit_loss_header_totals(6, start_date, stop_date)
        child_header_result = root_header.descendants[0]
        gchild_header_result = child_header_result.descendants[0]

        self.assertEqual(root_header.total, -154)
        self.assertSequenceEqual(root_header.descendants, [child_header])
        self.assertEqual(child_header_result.total, -129)
        self.assertSequenceEqual(child_header_result.descendants,
                                 [gchild_header])
        self.assertEqual(gchild_header_result.total, -82)
コード例 #6
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_get_profit_loss_header_totals(self):
        """
        The function should return a root Header with the descendants and
        total attributes.
        """
        child_header = create_header("Child Income", self.income_header, 4)
        gchild_account = create_account("GrandChild Income", child_header,
                                        0, 4)
        gchild_header = create_header("Grandchild Income", child_header, 4)
        ggchild_account = create_account("Great Grandchild Income",
                                         gchild_header, 0, 4)

        entry = create_entry(datetime.date.today(), "test entry")
        create_transaction(entry, self.income_account, 25)
        create_transaction(entry, gchild_account, 47)
        create_transaction(entry, ggchild_account, 82)

        start_date = datetime.date(1, 1, 1)
        stop_date = datetime.date.today()

        root_header = _get_profit_loss_header_totals(4, start_date, stop_date)
        child_header_result = root_header.descendants[0]
        gchild_header_result = child_header_result.descendants[0]

        self.assertEqual(root_header.total, 154)
        self.assertSequenceEqual(root_header.descendants, [child_header])
        self.assertEqual(child_header_result.total, 129)
        self.assertSequenceEqual(child_header_result.descendants,
                                 [gchild_header])
        self.assertEqual(gchild_header_result.total, 82)
コード例 #7
0
    def test_account_with_no_transactions(self):
        """
        An Account with no Transactions in the date range should return the a
        start balance and end balance of the balance at the beginning of the
        period and a debit/credit total and netchange of 0.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        create_transaction(past_entry, self.liability_account, 25)

        asset_info = {
            'name': "Asset Account",
            'number': "1-00001",
            'beginning_balance': 25,
            'total_debits': 0,
            'total_credits': 0,
            'net_change': 0,
            'ending_balance': 25,
            'url': self.asset_account.get_absolute_url()
        }
        liability_info = {
            'name': "Liability Account",
            'number': "2-00001",
            'beginning_balance': 25,
            'total_debits': 0,
            'total_credits': 0,
            'net_change': 0,
            'ending_balance': 25,
            'url': self.liability_account.get_absolute_url()
        }

        response = self.client.get(
            reverse('reports.views.trial_balance_report'))

        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #8
0
    def test_get_profit_loss_header_totals_flipped(self):
        """
        The totals for Expenses, Cost of Goods Sold and Other Expenses should
        display the value total, not the credit/debit total.
        """
        child_header = create_header("Child Expense", self.expense_header, 6)
        gchild_account = create_account("GrandChild Expense", child_header, 0,
                                        6)
        gchild_header = create_header("Grandchild Expense", child_header, 6)
        ggchild_account = create_account("Great Grandchild Expense",
                                         gchild_header, 0, 6)

        entry = create_entry(datetime.date.today(), "test entry")
        create_transaction(entry, self.expense_account, 25)
        create_transaction(entry, gchild_account, 47)
        create_transaction(entry, ggchild_account, 82)

        start_date = datetime.date(1, 1, 1)
        stop_date = datetime.date.today()

        root_header = _get_profit_loss_header_totals(6, start_date, stop_date)
        child_header_result = root_header.descendants[0]
        gchild_header_result = child_header_result.descendants[0]

        self.assertEqual(root_header.total, -154)
        self.assertSequenceEqual(root_header.descendants, [child_header])
        self.assertEqual(child_header_result.total, -129)
        self.assertSequenceEqual(child_header_result.descendants,
                                 [gchild_header])
        self.assertEqual(gchild_header_result.total, -82)
コード例 #9
0
    def test_get_profit_loss_header_totals(self):
        """
        The function should return a root Header with the descendants and
        total attributes.
        """
        child_header = create_header("Child Income", self.income_header, 4)
        gchild_account = create_account("GrandChild Income", child_header, 0,
                                        4)
        gchild_header = create_header("Grandchild Income", child_header, 4)
        ggchild_account = create_account("Great Grandchild Income",
                                         gchild_header, 0, 4)

        entry = create_entry(datetime.date.today(), "test entry")
        create_transaction(entry, self.income_account, 25)
        create_transaction(entry, gchild_account, 47)
        create_transaction(entry, ggchild_account, 82)

        start_date = datetime.date(1, 1, 1)
        stop_date = datetime.date.today()

        root_header = _get_profit_loss_header_totals(4, start_date, stop_date)
        child_header_result = root_header.descendants[0]
        gchild_header_result = child_header_result.descendants[0]

        self.assertEqual(root_header.total, 154)
        self.assertSequenceEqual(root_header.descendants, [child_header])
        self.assertEqual(child_header_result.total, 129)
        self.assertSequenceEqual(child_header_result.descendants,
                                 [gchild_header])
        self.assertEqual(gchild_header_result.total, 82)
コード例 #10
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_account_with_no_transactions(self):
        """
        An Account with no Transactions in the date range should return the a
        start balance and end balance of the balance at the beginning of the
        period and a debit/credit total and netchange of 0.
        """
        today = datetime.date.today()
        first_of_year = datetime.date(today.year, 1, 1)

        past_entry = create_entry(first_of_year - datetime.timedelta(days=1),
                                  "Before the default report range")
        create_transaction(past_entry, self.asset_account, -25)
        create_transaction(past_entry, self.liability_account, 25)

        asset_info = {'name': "Asset Account",
                      'number': "1-00001",
                      'beginning_balance': 25,
                      'total_debits': 0,
                      'total_credits': 0,
                      'net_change': 0,
                      'ending_balance': 25,
                      'url': self.asset_account.get_absolute_url()}
        liability_info = {'name': "Liability Account",
                          'number': "2-00001",
                          'beginning_balance': 25,
                          'total_debits': 0,
                          'total_credits': 0,
                          'net_change': 0,
                          'ending_balance': 25,
                          'url': self.liability_account.get_absolute_url()}

        response = self.client.get(
            reverse('reports.views.trial_balance_report'))

        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #11
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_date_range(self):
        """
        A `GET` with valid DateRangeForm data should only use Transactions in
        the submitted date range for calculations.
        """
        start_date = datetime.date(2014, 2, 3)
        stop_date = datetime.date(2014, 5, 3)

        before_range = datetime.date(2014, 1, 12)
        in_range = datetime.date(2014, 3, 25)
        after_range = datetime.date(2014, 9, 22)

        past_entry = create_entry(before_range, "Before the report range")
        create_transaction(past_entry, self.asset_account, -50)
        create_transaction(past_entry, self.liability_account, 50)

        in_range_entry = create_entry(in_range, "In the report range")
        create_transaction(in_range_entry, self.asset_account, 23)
        create_transaction(in_range_entry, self.liability_account, -23)

        future_entry = create_entry(after_range, "After the report range")
        create_transaction(future_entry, self.asset_account, 100)
        create_transaction(future_entry, self.liability_account, -100)

        asset_info = {'name': "Asset Account",
                      'number': "1-00001",
                      'beginning_balance': 50,
                      'total_debits': 0,
                      'total_credits': 23,
                      'net_change': 23,
                      'ending_balance': 27,
                      'url': self.asset_account.get_absolute_url()}
        liability_info = {'name': "Liability Account",
                          'number': "2-00001",
                          'beginning_balance': 50,
                          'total_debits': -23,
                          'total_credits': 0,
                          'net_change': -23,
                          'ending_balance': 27,
                          'url': self.liability_account.get_absolute_url()}

        response = self.client.get(
            reverse('reports.views.trial_balance_report'),
            data={'start_date': start_date,
                  'stop_date': stop_date}
        )

        self.assertEqual(response.context['start_date'], start_date)
        self.assertEqual(response.context['stop_date'], stop_date)
        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #12
0
ファイル: tests.py プロジェクト: clehner/AcornAccounting
    def test_date_range(self):
        """A valid `GET` request will only use Transactions in the range."""
        start_date = datetime.date(2014, 2, 3)
        stop_date = datetime.date(2014, 5, 3)

        before_range = datetime.date(2014, 1, 12)
        in_range = datetime.date(2014, 3, 25)
        after_range = datetime.date(2014, 9, 22)

        past_entry = create_entry(before_range, "Before the report range")
        create_transaction(past_entry, self.income_account, -50)
        create_transaction(past_entry, self.expense_account, 50)

        in_range_entry = create_entry(in_range, "In the report range")
        create_transaction(in_range_entry, self.income_account, 23)
        create_transaction(in_range_entry, self.expense_account, -23)

        future_entry = create_entry(after_range, "After the report range")
        create_transaction(future_entry, self.income_account, 100)
        create_transaction(future_entry, self.expense_account, -100)

        response = self.client.get(reverse('reports.views.profit_loss_report'),
                                   data={'start_date': start_date,
                                         'stop_date': stop_date})

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['headers']['income'].total, 23)
        self.assertEqual(response.context['headers']['expenses'].total, 23)
コード例 #13
0
    def test_date_range(self):
        """
        A `GET` with valid DateRangeForm data should only use Transactions in
        the submitted date range for calculations.
        """
        start_date = datetime.date(2014, 2, 3)
        stop_date = datetime.date(2014, 5, 3)

        before_range = datetime.date(2014, 1, 12)
        in_range = datetime.date(2014, 3, 25)
        after_range = datetime.date(2014, 9, 22)

        past_entry = create_entry(before_range, "Before the report range")
        create_transaction(past_entry, self.asset_account, -50)
        create_transaction(past_entry, self.liability_account, 50)

        in_range_entry = create_entry(in_range, "In the report range")
        create_transaction(in_range_entry, self.asset_account, 23)
        create_transaction(in_range_entry, self.liability_account, -23)

        future_entry = create_entry(after_range, "After the report range")
        create_transaction(future_entry, self.asset_account, 100)
        create_transaction(future_entry, self.liability_account, -100)

        asset_info = {
            'name': "Asset Account",
            'number': "1-00001",
            'beginning_balance': 50,
            'total_debits': 0,
            'total_credits': 23,
            'net_change': 23,
            'ending_balance': 27,
            'url': self.asset_account.get_absolute_url()
        }
        liability_info = {
            'name': "Liability Account",
            'number': "2-00001",
            'beginning_balance': 50,
            'total_debits': -23,
            'total_credits': 0,
            'net_change': -23,
            'ending_balance': 27,
            'url': self.liability_account.get_absolute_url()
        }

        response = self.client.get(
            reverse('reports.views.trial_balance_report'),
            data={
                'start_date': start_date,
                'stop_date': stop_date
            })

        self.assertEqual(response.context['start_date'], start_date)
        self.assertEqual(response.context['stop_date'], stop_date)
        self.assertEqual(response.context['accounts'],
                         [asset_info, liability_info])
コード例 #14
0
    def test_date_range(self):
        """A valid `GET` request will only use Transactions in the range."""
        start_date = datetime.date(2014, 2, 3)
        stop_date = datetime.date(2014, 5, 3)

        before_range = datetime.date(2014, 1, 12)
        in_range = datetime.date(2014, 3, 25)
        after_range = datetime.date(2014, 9, 22)

        past_entry = create_entry(before_range, "Before the report range")
        create_transaction(past_entry, self.income_account, -50)
        create_transaction(past_entry, self.expense_account, 50)

        in_range_entry = create_entry(in_range, "In the report range")
        create_transaction(in_range_entry, self.income_account, 23)
        create_transaction(in_range_entry, self.expense_account, -23)

        future_entry = create_entry(after_range, "After the report range")
        create_transaction(future_entry, self.income_account, 100)
        create_transaction(future_entry, self.expense_account, -100)

        response = self.client.get(reverse('reports.views.profit_loss_report'),
                                   data={
                                       'start_date': start_date,
                                       'stop_date': stop_date
                                   })

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['headers']['income'].total, 23)
        self.assertEqual(response.context['headers']['expenses'].total, 23)