Beispiel #1
0
 def test003_create_transaction(self):
     result.transaction1_id = finac.transaction_create(
         'test.test',
         100,
         'test',
         'Test balance import',
         mark_completed=False)
     self.assertEqual(finac.account_balance('TEST.TEST'), 0)
     statement = list(
         finac.account_statement('TEST.TEST', '2019-01-01', pending=False))
     self.assertEqual(len(statement), 0)
     statement = list(
         finac.account_statement('test.test', '2019-01-01', pending=True))
     self.assertEqual(len(statement), 1)
Beispiel #2
0
 def test006_statement_tests(self):
     statement = list(finac.account_statement('test.test', '2019-01-01'))
     self.assertEqual(len(statement), 2)
     statement = list(finac.account_statement('TEST2.TEST'))
     self.assertEqual(len(statement), 1)
     statement = list(finac.account_statement('TEST.TEST', '2119-01-01'))
     self.assertEqual(len(statement), 0)
     statement = list(
         finac.account_statement('TEST.TEST', '2019-01-01', '2119-05-22'))
     self.assertEqual(len(statement), 2)
     statement = list(finac.account_statement('TEST.TEST',
                                              end='2119-05-22'))
     self.assertEqual(len(statement), 2)
     ss = finac.account_statement_summary('TEST.TEST', end='2119-05-22')
     self.assertEqual(ss['credit'], 25)
     self.assertEqual(ss['debit'], 100)
     self.assertEqual(ss['net'], 75)
Beispiel #3
0
 def test099_transact_update(self):
     finac.transaction_update(result.id4test099,
                              amount=555,
                              tag='loans2',
                              note='somenote')
     for t in finac.account_statement('TT1'):
         if t['id'] == result.id4test099:
             self.assertEqual(t['tag'], 'loans2')
             self.assertEqual(t['note'], 'somenote')
             self.assertEqual(t['amount'], 555)
Beispiel #4
0
    def test903_archive_account(self):
        finac.account_create('testa1', 'USD')
        finac.account_create('testa2', 'USD')
        finac.account_create('testa3', 'USD')
        finac.account_create('testap1', 'USD', passive=True)
        finac.tr('testa1', 10000)
        finac.tr('testa2', 10000)
        finac.mv(dt='testa1', ct='testa2', amount=2500)
        finac.mv(dt='testa1', ct='testa2', amount=2500)
        finac.mv(dt='testa1', ct='testa3', amount=2500)
        finac.mv(dt='testa1', ct='testa3', amount=2500)
        finac.mv(dt='testa1', ct='testap1', amount=2500)
        finac.mv(dt='testa1', ct='testap1', amount=2500)

        d = time.time()

        finac.mv(dt='testa1', ct='testa2', amount=500)
        finac.mv(dt='testa1', ct='testa2', amount=500)
        finac.mv(dt='testa1', ct='testa3', amount=500)
        finac.mv(dt='testa1', ct='testa3', amount=500)
        finac.mv(dt='testa1', ct='testap1', amount=500)
        finac.mv(dt='testa1', ct='testap1', amount=500)

        def _test_balances():
            self.assertEqual(finac.account_balance('testa1'), 28000)
            self.assertEqual(finac.account_balance('testa2'), 4000)
            self.assertEqual(finac.account_balance('testa3'), -6000)
            self.assertEqual(finac.account_balance('testap1'), 6000)

        self.assertEqual(len(list(finac.account_statement('testa1'))), 13)
        self.assertEqual(len(list(finac.account_statement('testa2'))), 5)
        self.assertEqual(len(list(finac.account_statement('testa3'))), 4)
        self.assertEqual(len(list(finac.account_statement('testap1'))), 4)
        _test_balances()
        for acc in ['testa1', 'testa2', 'testa3', 'testap1']:
            finac.archive_transactions(acc, due_date=d)
            _test_balances()
        self.assertEqual(len(list(finac.account_statement('testa1'))), 6)
        self.assertEqual(len(list(finac.account_statement('testa2'))), 2)
        self.assertEqual(len(list(finac.account_statement('testa3'))), 2)
        self.assertEqual(len(list(finac.account_statement('testap1'))), 2)
        finac.cleanup()
        finac.account_delete('testa1')
        finac.account_delete('testa2')
        finac.account_delete('testa3')
        finac.account_delete('testap1')
Beispiel #5
0
 def test070_test_targets_and_tags(self):
     finac.account_create('TT1', 'EUR', tp='credit')
     finac.account_create('TT2', 'EUR', tp='saving')
     finac.transaction_create('TT1', 1000)
     finac.transaction_create('TT2', 1000)
     self.assertEqual(finac.account_balance('TT1'), 1000)
     self.assertEqual(finac.account_balance('TT2'), 1000)
     finac.transaction_create('TT1', target=1500)
     finac.transaction_create('TT2', target=800)
     self.assertEqual(finac.account_balance('TT1'), 1500)
     self.assertEqual(finac.account_balance('TT2'), 800)
     finac.transaction_move('TT1', 'TT2', target_ct=700, tag='loans')
     self.assertEqual(finac.account_balance('TT1'), 1600)
     self.assertEqual(finac.account_balance('TT2'), 700)
     finac.transaction_move('TT2', 'TT1', target_dt=2000, tag='loans')
     self.assertEqual(finac.account_balance('TT1'), 300)
     self.assertEqual(finac.account_balance('TT2'), 2000)
     self.assertEqual(
         len(list(finac.account_statement('TT1', tag='lo;an"s'))), 2)
     print()
     finac.ls('TT2')
     print()
Beispiel #6
0
 def test004_transaction_complete(self):
     finac.transaction_complete(result.transaction1_id)
     self.assertEqual(finac.account_balance('test.test'), 100)
     statement = list(
         finac.account_statement('test.test', '2019-01-01', pending=True))
Beispiel #7
0
 def test401_account_statement_list_tag(self):
     d = finac.account_statement('MOVE.TEST', tag=['go ahead', 'ahead'])
     self.assertEqual(len(list(d)), 2)