adamcharnock / django-hordak

Double entry accounting in Django
http://django-hordak.readthedocs.io
MIT License
231 stars 55 forks source link

Fixing `transfer_to` for Liability -> Cash account #81

Closed nitsujri closed 1 year ago

nitsujri commented 1 year ago

The function transfer_to's description, in the comments, is correct. It says:

Transfers from liability -> asset accounts should reduce both.

but in reality that only happens for expense accounts.

Adding Asset accounts to that.


@PetrDlouhy there were a few other specs that were failing, but I didn't touch them because they look like display bugs for the app and I'm unsure as to what the "spirit" of those were supposed to be.

======================================================================
FAIL: test_get (hordak.tests.views.test_accounts.AccountTransactionsViewTestCase.test_get)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/justin/dev/kaukau/django-hordak/hordak/tests/views/test_accounts.py", line 32, in test_get
    self.assertContains(response, "<h5>Balance: €&nbsp;10.00</h5>", html=True)
  File "/Users/justin/dev/kaukau/django-hordak/.venv/lib/python3.11/site-packages/django/test/testcases.py", line 660, in assertContains
    self.assertTrue(
AssertionError: False is not true : Couldn't find '<h5>Balance: €&nbsp;10.00</h5>' in response

======================================================================
FAIL: test_str_currency (hordak.tests.models.test_core.AccountTestCase.test_str_currency)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/justin/dev/kaukau/django-hordak/hordak/tests/models/test_core.py", line 61, in test_str_currency
    self.assertEqual(str(account), "0 Account 1 [€\xa00.00, £\xa00.00]")
AssertionError: '0 Account 1 [€0.00, £0.00]' != '0 Account 1 [€\xa00.00, £\xa00.00]'
- 0 Account 1 [€0.00, £0.00]
+ 0 Account 1 [€ 0.00, £ 0.00]
?               +       +

======================================================================
FAIL: test_str_currency_no_full_code (hordak.tests.models.test_core.AccountTestCase.test_str_currency_no_full_code)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/justin/dev/kaukau/django-hordak/hordak/tests/models/test_core.py", line 66, in test_str_currency_no_full_code
    self.assertEqual(str(account), "Account 1 [€\xa00.00, £\xa00.00]")
AssertionError: 'Account 1 [€0.00, £0.00]' != 'Account 1 [€\xa00.00, £\xa00.00]'
- Account 1 [€0.00, £0.00]
+ Account 1 [€ 0.00, £ 0.00]
?             +       +
nitsujri commented 1 year ago

Related old threads: https://github.com/adamcharnock/django-hordak/issues/23 https://github.com/adamcharnock/django-hordak/issues/26

nitsujri commented 1 year ago

I retract the above. I dug deeper and realized the underlying mechanism isn't correct. Specifically I have concerns about:

            # Transfers from liability -> asset accounts should reduce both.
            # For example, moving money from Rent Payable (liability) to your Rent (expense) account
            # should use the funds you've built up in the liability account to pay off the expense account.

I will open in a bug for discussion.