def test_payeevalidation(self):
        transaction = Transaction()
        transaction.ledger = self.ledger1
        account, _ = Account.objects.get_or_create(name='account',
                                                   ledger=self.ledger1)
        transaction.account = account
        payee, _ = Payee.objects.get_or_create(name='payee',
                                               ledger=self.ledger1)
        transaction.payee = payee
        transaction.date = timezone.now()
        transaction.amount = Decimal('1000')
        self.assertIsNone(transaction.save())

        transaction = Transaction()
        transaction.ledger = self.ledger1
        account, _ = Account.objects.get_or_create(name='account',
                                                   ledger=self.ledger1)
        transaction.account = account
        payee, _ = Payee.objects.get_or_create(name='payee',
                                               ledger=self.ledger2)
        transaction.payee = payee
        transaction.date = timezone.now()
        transaction.amount = Decimal('1000')

        with self.assertRaises(ValueError):
            transaction.save()
Exemple #2
0
 def test_getbalance(self):
     self.assertEqual(self.account.get_balance(), Decimal('0.00'))
     t = Transaction()
     t.ledger = self.ledger
     t.payee, _ = Payee.objects.get_or_create(name='', ledger=self.ledger)
     t.account = self.account
     t.date = timezone.now()
     t.amount = Decimal('1234.56')
     t.save()
     self.assertEqual(self.account.get_balance(), Decimal('1234.56'))
 def test_name(self):
     transaction = Transaction()
     transaction.ledger = self.ledger1
     account, _ = Account.objects.get_or_create(name='account',
                                                ledger=self.ledger1)
     transaction.account = account
     payee, _ = Payee.objects.get_or_create(name='payee',
                                            ledger=self.ledger1)
     transaction.payee = payee
     transaction.date = timezone.now()
     transaction.amount = Decimal('1000')
     transaction.save()
     self.assertEqual(str(transaction), transaction.memo)
Exemple #4
0
    def test_balance(self):
        t = Transaction()
        t.ledger = self.ledger
        t.payee, _ = Payee.objects.get_or_create(name='', ledger=self.ledger)
        t.account, _ = Account.objects.get_or_create(name='Cuenta',
                                                     ledger=self.ledger)
        t.date = timezone.now()
        t.amount = Decimal('1234.56')
        t.save()

        self.assertEqual(self.ledger.balance, Decimal('1234.56'))
        self.assertEqual(self.ledger.get_balance(), Decimal('1234.56'))
        self.assertEqual(self.ledger.balance, Decimal('1234.56'))
        balance = self.ledger.balance
        self.ledger.set_balance()
        self.assertEqual(self.ledger.balance, balance)
        self.assertEqual(self.ledger.get_balance(), balance)