from django.utils import unittest
from accounting.models import Account, Transaction
from main.models import Relation
from datetime import datetime

class AccountTestCase(unittest.TestCase):
    def setUp(self):
        self.banking_account = Account.objects.create(
                number = '12345',
                name = 'banking_account',
                account_type = '02')

        self.expenses_account = Account.objects.create(
                number = '54321',
                name = 'expenses_account',
                account_type = '40')

        self.relation = Relation.objects.create(
                displayname = 'Henk de Vries')

    def tearDown(self):
        self.banking_account.delete()
        self.expenses_account.delete()
        self.relation.delete()

    def test_account_start_balance_is_zero(self):
        self.assertEqual(self.banking_account.balance, 0.0)
        self.assertEqual(self.expenses_account.balance, 0.0)

    def test_transaction_from_banking_to_expenses_account(self):
        transaction = Transaction()
        transaction.relation = self.relation
        transaction.date = datetime.strptime('2012-01-01:00:00:00', '%Y-%m-%d:%H:%M:%S')
        transaction.account = self.banking_account
        transaction.transfer = self.expenses_account
        transaction.description = 'Monies!'
        transaction.amount = -10.0
        transaction.save()

        self.assertEqual(self.banking_account.balance, -10.0)
        self.assertEqual(self.expenses_account.balance, 10.0)

@@ -1,12 +1,833 @@
+# -*- coding: utf-8 -*-%0A%22%22%22%0ASynLogistics accounting tests%0A%22%22%22%0A#%0A# Copyright (C) by Kristian Vlaardingerbroek %3Ckristian.vlaardingerbroek@gmail.com%3E 2012%0A#   %0A# This program is free software; you can redistribute it and/or modify%0A# it under the terms of the GNU Affero General Public License as published by%0A# the Free Software Foundation; either version 3 of the License, or%0A# (at your option) any later version.%0A#   %0A# This program is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU Affero General Public License for more details.%0A#   %0A# You should have received a copy of the GNU Affero General Public License%0A# along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A#%0A%0A
 from django.

Add copyright