Possible Major Bug - Mismatch between Revenue and Cost of Sales

Hello Everyone

Has anyone else noticed a major issue that occurs when Delivery note is raised in a different month from the associated Sales Invoice?

The Revenue is recognized by ERPNext when the sales invoice is submitted, but the cost of goods is recognized when the delivery note is submitted.

This causes a major distortion in the Profit and Loss Statement if the two documents are submitted in different months.

For you to encounter this problem you must make use of delivery notes AND you must experience a sizable time difference (at least a month) between when the Sales invoice is completed and when the delivery of the product is done.

This is totally against the matching concept in accounting which requires that revenues and any related expenses be recognized together in the same reporting period. This is one of the most important concepts in accounting and it appears that ERPNext is violating it in drawing up its P&L Statement.

Interestingly enough this is not affecting the standalone Gross Profit Report, the distortion is only in the P&L report.

In my opinion this is a major issue that requires the attention of the entire ERPNext team, hence am tagging everyone. I apologise in advance. @rmehta @Chude_Osiegbu @tundebabzy @wale @Fred1

Or am I missing something ?

Don’t think what system does is wrong. The goods are still part of inventory hence should be deducted only when consideration onto customer.

You could always pass an accrual entry when a sales invoice is raised. Hence the expense will show within same month. When DN is made the accrual entry is reversed. This way you have expenses in same month and goods deducted when delivered.

1 Like

I’m not sure there’s a bug. It’s a business process issue.

Sequence of events is important. Typically, the sequence is:

Sales Order > Delivery > Sales Invoice

In this case, if your delivery occurs in the current period and then your invoice is expected in the next month, you’d accrue for the revenue that should be linked with the delivery in the current period and reverse it in the next period waiting for the Sales Invoice to be submitted. You’d continue this accrual each following month until the Sales Invoice is actually submitted. ERPNext doesn’t currently have tools to automate this so your accountant would need to book these accruals manually.

Another case could be:

Sales Order > Sales Invoice > Delivery

In this case, you’re technically asking for a payment before the delivery is done. Meaning that you haven’t really earned the income. This could be taken as a request for an advance. If you have a reasonable expectation that the delivery will not take place in the same month as the booking of the invoice then the accurate way to book this would be

Sales Invoice - Month 1
Dr Customer
Cr Income recognised in advance

Delivery - Month 2
Dr Cost of sales
Cr Stock

Revenue Recognition by Accountant/System - Month 2
Dr Income recognised in advance
Cr Income

This way, income and expenses related to that income are recognised in the same period.

ERPNext could probably benefit from an Accrual Engine to automate these postings for both Sales and Purchase Goods-in-transit scenarios.

1 Like

Thanks Chude for the detailed response, much appreciated

My problem is not what the process but how the process is handled by the system.

I can see that you agree that the matching concept is been violated and your first solution based on the accounting entries you suggested is that the accountant raises manual entries to correct this.

Your second solution is a suggestion that ERPNext could probably benefit from an accrual Engine to automate the postings for both sales and purchase goods in transit. This is a huge understatement.

Your first solution is not practical in an organisation with hundreds of invoices and deliveries on a monthly basis, the system should handle this automatically. NO ERP SYSTEM SHOULD EXPECT THIS FROM AN ACCOUNTING DEPT

I will also like to call your attention to the Gross Profit report in ERPNext. This report handles the calculation of Gross profit accurately, matching the reenue with the appropriate COGS regardless of the months the invoice and delivery notes are raised. The solution should be that ERPNext adopts the same premise used in calculating the Gross Profit in this report to calculate the GP in the Profit and Loss Report.

And in my experience none of the other ERP solutions we seek to compete with have this issue/loophole/flaw. I stand to be corrected in this and I have used quite a few.

I still submit that this is a flaw in the system and not just a process issue,

Actually, many of them do this manually - even those using the bigger ERPs. In the case of sales, they’ll run a Sales Order report that shows, per Sales Order, quantity delivered in a given period vs quantity invoiced. If quantity delivered is greater than quantity invoiced, they generate the necessary accruals in Excel using the formula:

(delivered_quantity - invoiced_quantity) * price_per_unit_in_sales_order

The accrual posting would use the amount calculated above to post:

Dr Sales to be billed
Cr Income

These would then be uploaded into the system as a mass posting and would be reversed the first day of next month.

For the flip case where, per Sales Invoice, the invoices amount is greater than the delivered amount, the type of sale being done determines if you can automate it not. For example, if it’s a long term project based on milestone deliveries, then you probably have to follow the completion status manually and make the appropriate bookings manually. However, if it’s a delivery-based sale where the delivery is typically off by a month you can also accrue the cost of sales using the same logic shown above. But in this case, you’d be estimating your cost of sales to be accrued using the difference between sales invoice quantity and delivered quantity multiplied by the current valuation of the material in stock. You’d need two sets of postings:

Dr Cost of sales
Cr Accrued Stock

If your original sales invoice posted straight to the revenue account, you’d need to back some of that revenue out and post:

Dr Revenue
Cr Recent recognised in advance

Both these postings would then be reversed the first of the next month

All the postings suggested above can usually be generated using a sales order report and some formulas in Excel to make the job easier for the accountant at month end.

I haven’t looked at what this report is doing but I wouldn’t be surprised it’s making some assumptions based on sales invoice/delivery note quantities same as I’ve described above. Will confirm later.

Most of them don’t cater to it out of the box actually. Although they might give you an Accrual Engine to manage it. Usually, clients would build some bespoke program to automate.

Hi Chude

While I appreciate the accounting entries, those are not the issues here, am a rather seasoned ACA so raising and passing these entries is not an issue.

I will respectfully like to disagree with you on the statement that companies using bigger ERPs do this manually. This is not the case in my experience, and no reputable accounting department faced with this scenario will sign off on a system that requires this rather rigorous manual intervention.

Maybe we continue this conversation after you have reviewed the Gross Profit report in ERPNext ?

Looking forward to hearing from you then

No worries. Will have a look and revert. In the clients I’ve dealt with, the realisation of the matching concept has usually been dealt with manually or with bespoke programs - even when they had accrual engines at their disposal. Most of them use SAP and Oracle. I’m not an accountant myself :slight_smile: but the entries help me to anchor the concepts. Might be useful for others like me.

Thanks Chude

I really appreciate this conversation, I believe engagements like this will make ERPNext better.

And if am wrong I would also have learnt an important lesson.


As long time SAP consultant, I see SAP works like this also.

I agree that revenue and cogs should be booked in the same period following accounting best practice. My solution is you should create another warehouse and create Goods in transit account linked with it.

In delivery notes, use optional customer warehouse so upon submission the GL entry is only warehouse movement in balance sheet. So we assume the goods is still in transit.

On Sales Invoice you have to do some hacks via script to unlink delivery note validation and update stock option is checked. Upon submission Sales and Cogs is booked correctly. You select transit warehouse.

Hope this helps