Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to post a LedgerEntry with cash and long-term notes payable #240

Open
iocampomx opened this issue Jan 13, 2025 · 9 comments
Open
Assignees
Labels
good first issue Good for newcomers

Comments

@iocampomx
Copy link

iocampomx commented Jan 13, 2025

Describe the bug
When trying to post a ledger entry that involves one cash account and one long-term note payable, it throws the error: Multiple activities detected in roles JE {'lia_ltl_notes'}.

To Reproduce
Steps to reproduce the behavior:

  1. Add a long-term notes payable account (credit)
  2. Try to post a ledger entry which involves a cash and the new long-term notes payable account
  3. See the error

Expected behavior
The ledger entry should be able to be posted without any error

Additional context
LIABILITY_LTL_NOTES_PAYABLE (lia_ltl_notes) is defined in:

GROUP_LT_LIABILITIES
LIABILITY_LTL_NOTES_PAYABLE
GROUP_CFS_INV_LTD_OF_SECURITIES

Within the get_activity_from_roles method the following three conditions raises True:

is_investing_for_ppe, which checks for GROUP_CFS_INVESTING_PPE

is_investing_for_securities, which checks for GROUP_CFS_INVESTING_SECURITIES

is_financing_lt_debt, which checks for GROUP_CFS_FIN_LT_DEBT_PAYMENTS

LIABILITY_LTL_NOTES_PAYABLE is directly and indirectly included in GROUP_CFS_INVESTING_PPE, GROUP_CFS_INVESTING_SECURITIES and GROUP_CFS_FIN_LT_DEBT_PAYMENTS

As such, the get_activity_from_roles function is raising the Multiple activities detected in roles JE {lia_ltl_notes}. exception.

I don't have the accounting background to come-up with a recommendation, but I hope this helps @elarroba or someone else to fix it :). Thanks!

@iocampomx
Copy link
Author

@iocampomx
Copy link
Author

iocampomx commented Jan 13, 2025

One idea is to enhance the logic below:

# no roles involved
if not len(role_set):
return

With something like:

 # no roles involved or there is only one role
 if not len(role_set) or len(role_set) == 1: 
     return 

But it will return with no activity set, which is better than through the unexpected exception. Later we can enhance the logic to come up with a better way to determine the activity type.

The other option is to pass the activity parameter into the get_activity_from_roles function.

@iocampomx
Copy link
Author

(This isn't happening with short-term notes payable accounts, I will use those for now)

@elarroba elarroba self-assigned this Jan 16, 2025
@elarroba
Copy link
Member

elarroba commented Jan 16, 2025

Hello. This is not a bug. Since this is a cash transaction, just by selecting cash and Long Term Notes the software is unable to determine the type of activity associated with the Journal Entry. There are many scenarios why you would increase/decrease debt using cash.

In order to post this journal entry you will need to add more context to it. For instance, if you are reducing debt, you must add another transaction with 'ex_interest' role with zero value (either credit or debit).

With this information, an activity can be determined and the Journal Entry can be validated and posted.

Image

Evidently a better message providing more context to the user to make pertinent adjustments would be appropriate in this case.

@elarroba
Copy link
Member

@iocampomx

But it will return with no activity set, which is better than through the unexpected exception. Later we can enhance the logic to come up with a better way to determine the activity type.

This is not an option. Every single Journal Entry that involves cash must have an activity. Otherwise it is not possible to produce an accurate statement of cash flows.

@elarroba elarroba added the good first issue Good for newcomers label Jan 16, 2025
@iocampomx
Copy link
Author

Thanks for the accounting education, @elarroba. It makes sense! In that case, I can prepare and submit a PR, with few comments just before raising the exception, with the reasoning and recommendation, so that others can understand why and what can they do.

@iocampomx
Copy link
Author

Hi @elarroba, there is a validation rule that raise exception when an amount is 0 (reference), so your proposal make sense but isn't feasible with current validations.

@iocampomx
Copy link
Author

I actually added an entry twice to by-pass the validation and keeping the balance 0, as follows:

    blueprint.credit(  # Hack to let django ledger know that this is a loan
        account_code="6131",
        amount=1,
    )
    blueprint.debit(  # Hack to let django ledger know that this is a loan
        account_code="6131",
        amount=1,
    )

@elarroba
Copy link
Member

@iocampomx Have you tried instead of 1, to use 0.001? If I remember correctly the tolerance system should interpret that as a 0.00 in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants