Esempio n. 1
0
    def test_get_children_for(self):
        a1 = self.create_account()
        self.assertTrue(Account.get_children_for(self.store, a1).is_empty())

        a2 = self.create_account()
        a2.parent = a1
        self.assertEquals(Account.get_children_for(self.store, a1).one(), a2)

        a3 = self.create_account()
        self.assertEquals(Account.get_children_for(self.store, a1).one(), a2)
        a3.parent = a1
        self.assertEquals(set(Account.get_children_for(self.store, a1)),
                          set([a2, a3]))
Esempio n. 2
0
    def test_get_children_for(self):
        a1 = self.create_account()
        self.assertTrue(Account.get_children_for(self.store, a1).is_empty())

        a2 = self.create_account()
        a2.parent = a1
        self.assertEqual(Account.get_children_for(self.store, a1).one(), a2)

        a3 = self.create_account()
        self.assertEqual(Account.get_children_for(self.store, a1).one(), a2)
        a3.parent = a1
        self.assertEqual(
            set(Account.get_children_for(self.store, a1)),
            set([a2, a3]))
Esempio n. 3
0
    def test_get_children_for(self):
        a1 = self.create_account()
        self.assertTrue(Account.get_children_for(self.store, a1).is_empty())

        a2 = self.create_account()
        a2.parent = a1
        self.assertEquals(Account.get_children_for(self.store, a1).one(), a2)

        a3 = self.create_account()
        self.assertEquals(Account.get_children_for(self.store, a1).one(), a2)
        a3.parent = a1
        self.assertEquals(
            list(Account.get_children_for(self.store, a1).order_by(Account.id)),
            [a2, a3])
Esempio n. 4
0
    def get_data(self):
        sheets = {}
        for account in Account.get_children_for(self.store, parent=None):
            if sysparam.compare_object('IMBALANCE_ACCOUNT', account):
                continue

            columns = []
            for start, end in get_month_intervals_for_year(self.year):
                column = []
                self._prepare_items(column, account, start, end)
                columns.append(column)

            # Skip empty sheets
            if sum(item[1] for c in columns for item in c) == 0:
                continue

            sheets[account.description] = columns

        return sheets
Esempio n. 5
0
    def get_data(self):
        sysparam_ = sysparam(self.store)

        sheets = {}
        for account in Account.get_children_for(self.store, parent=None):
            if account.id == sysparam_.IMBALANCE_ACCOUNT.id:
                continue

            columns = []
            for start, end in get_month_intervals_for_year(self.year):
                column = []
                self._prepare_items(column, account, start, end)
                columns.append(column)

            # Skip empty sheets
            if sum(item[1] for c in columns for item in c) == 0:
                continue

            sheets[account.description] = columns

        return sheets
Esempio n. 6
0
    def _prepare_items(self, items, account, start, end):
        total = account.get_total_for_interval(start, end)
        items.append((account.description, total))

        for child in Account.get_children_for(self.store, parent=account):
            self._prepare_items(items, child, start, end)
Esempio n. 7
0
    def _prepare_items(self, items, account, start, end):
        total = account.get_total_for_interval(start, end)
        items.append((account.description, total))

        for child in Account.get_children_for(self.store, parent=account):
            self._prepare_items(items, child, start, end)