Ejemplo n.º 1
0
    def testAccountPrefix(self):
        ledger = self.parser.parse_ledger(fixture_path("simple.dat"))
        processor = LedgerProcessor(ledger, self.rules)
        collector = TransactionCollector()
        processor.add_listener(collector)

        processor.add_account_prefix("Business")
        processor.run()

        for transaction, entries in collector.transactions:
            for entry in entries:
                self.assertEqual("Business", entry.account.root().name)
Ejemplo n.º 2
0
    def testRemoveAccountPrefix(self):
        ledger = self.parser.parse_ledger(fixture_path("simple.dat"))
        processor = LedgerProcessor(ledger, self.rules)
        collector = TransactionCollector()
        processor.add_listener(collector)

        self.assertEqual(2, len(ledger.transactions))

        processor.add_account_prefix("Business")
        ledger.transactions[0].execute(processor)

        for transaction, entries in collector.transactions:
            for entry in entries:
                self.assertEqual("Business", entry.account.root().name)

        collector.transactions = []
        processor.remove_account_prefix()

        ledger.transactions[0].execute(processor)

        for transaction, entries in collector.transactions:
            for entry in entries:
                self.assertNotEqual("Business", entry.account.root().name)