Sales Invoice - Incorrect Number of GL Entries Found

We are getting the following error on a Sales Invoice:

Incorrect number of General Ledger Entries found. You might have selected a wrong Account in the transaction.

Another transaction with the exact same accounts went through, but this one is not going through.

Any thoughts about what could be happening?

Thanks

Jay

This error comes while posting GL Entries, if number of accounts are going either 0 or 1.

Have you done any server side customisation related to Sales Invoice / GL Entries?

To debug you should use “print” statement in the code. Please try to print gl entries values before and after process_gl_map() function in the accounts/general_ledger.py file ( https://github.com/frappe/erpnext/blob/master/erpnext/accounts/general_ledger.py#L17 ) and you will get an idea what is happening.

1 Like

Hi,

These are the entries showing in the gl_map when doing the debug on the particular transaction. Only 1 GL entry is showing but it has both debit and credit amount.

Before process_gl_map
[{u’account_currency’:
u’INR’, u’account’: u’Stock Received But Not Billed’,
u’party_type’: None, u’company’: u’Coir’, u’is_opening’: u’No’,
u’fiscal_year’: u’2016-2017’, u’against’: u’Meenakshipuram’,
u’debit_in_account_currency’: 222772.0, u’credit’: 222772.0,
u’voucher_type’: u’Purchase Receipt’, u’debit’: 222772.0, u’remarks’:
u’Accounting Entry for Stock’, u’party’: None, u’voucher_no’:
u’PREC-00184’, u’credit_in_account_currency’: 222772.0, u’cost_center’:
u’Main’, u’posting_date’: datetime.date(2016, 5, 26)}]

After process_gl_map
[{u’account_currency’:
u’INR’, u’account’: u’Stock Received But Not Billed,
u’party_type’: None, u’company’: u’Coir’, u’is_opening’: u’No’,
u’fiscal_year’: u’2016-2017’, u’against’: u’Meenakshipuram’,
u’debit_in_account_currency’: 222772.0, u’credit’: 222772.0,
u’voucher_type’: u’Purchase Receipt’, u’debit’: 222772.0, u’remarks’:
u’Accounting Entry for Stock’, u’party’: None, u’voucher_no’:
u’PREC-00184’, u’credit_in_account_currency’: 222772.0, u’cost_center’:
u’Main’, u’posting_date’: datetime.date(2016, 5, 26)}]

The issue is due to negative inventory. The fact is that when inventory goes into negative, system does not know the correct valuation rate for outgoing entry. The system just try to predict the outgoing rate based on previous valuation rate and books accounting entry based on that.

We strongly recommend to disable negative inventory if you want to activate perpetual inventory. Because accounting entry can go wrong if negative inventory is enabled. This problem is there in all other systems, whether it is SAP or Quickbooks, because you actually don’t know the rate in case of negative inventory.

But in this case, while submitting sales invoice, as it is a back dated entry, it also reposts all the future stock related transactions for related items. And in that process, Purchase Receipt is reposting and it does not get any stock value difference for the entry due to negative inventory. And thats why the problem is occurring.

There is an error in valuation rate calculation in case of negative inventory, I have fixed that. I have changed the calculation login and followed the procedure used by SAP.

Basically when stock remains in negative side, the valuation rate gets frozen and it remains the same valuation rate as last transaction in the positive side. And when it becomes from negative to positive, system takes the incoming rate of that entry as valuation rate. So, you can understand, while stock remains in negative, stock value difference due to the entry does not match with the transaction values.

I have written a patch to repost the valuation rate as per the new logic in case of negative stock. Please pull the fix and it should fix the issue.

2 Likes