Gross profit 100%

Hello everybody,

maybe someone could help me. I get gross profit as 100% even all prices are set correctly, every time I do same workflow. (sales order -> material request -> purchase order and then invoices). Maybe someone could tell me what is a problem?

Seems you haven’t mention Buying Cost or Valuation Rate, at the time of buying or reconciling.

There are costs of buying :confused: and all orders are linked by material request. Seems like all prices set, links are attached. Most interesting fact in some older orders I get correct Gross Profit. I tried to see whats differs, cannot find anything… :confused: please help.

Please share Stock Ledger report for Incomming Rate and Valuation Rate.

I don’t stock items, we resale them. Negative stock balance allowed. I believe I don’t understand STOCK LEDGER report. Any ideas what’s wrong ?

Maybe anyone has any slightest idea why this is happening ?

@nabinhait Can you check?


In your case, in gross profit report, buying amount is zero. There are 2 cases:

  1. If item is a non-stock item, then buying amount calculated based on average rate in Purchase Invoice. Please check if you mentioned proper rate in Purchase Invoice.

  2. In item is stock item, buying amount is calculated based on Stock Ledger Entry and as per FIFO. If quantity is negative, then it takes as per average rate in Stock Ledger Entries.

Do you make Purchase Receipts and Purchase Invoices?

Thank you for your concern. Yes i do Purchase Receipts and Purchase Invoices. All are linked together and I do them one after another (workflow). Interesting some of them shows gross profit (one of the first orders) and now it shows only 100% but nothing changed.

Yes it’s non stock item and rate is correct in Purchase Invoice. I tried everything what i can think about… lost & confused :confused:

It seem like I am having the same issue. Buying price is 0 for most of the items, even though I have entered Purchase receipt (and purchase invoice) accordingly. IS THERE A SOLUTION TO THIS? It is frustrating. Thanks.

If it’s a non-stock item, then purchase invoice first before sales.invoice.

If it’s a stock item, make sure you have set item rate on purchase receipt as valuation is calculated here. Purchase Invoice doesn’t update stock…

The rate is entered as standard buying rate (>0), for stock item. That is why I don’t understand why my buying price is 0 at the gross profit.

See the below link:

This post is from 2015, I’ve got a got similar issue in 2021. Maybe I am doing something wrong but after intensive testing, the Buying Amount for Non-Stock item remains at 0.00 and gross profit wrongly calculates to 100%.

I’ve tried your solutions and correctly put in rates in the purchase invoice but the issue remains. I checked the demo instance at and it shows a similar pattern.

I am sure there’s a solution to this. What am I missing here?

I replied on another similar post and got a solution to check for gross profit by projects but I don’t understand why the Buying Amount remains at zero for the non-stock items. If anyone’s reading this, this issue hasn’t been answered.

Any help would be immensely appreciated.

We faced same problem with stock items when the dn_detail is part of the Sales Invoice Item and it hits an unknown criteria in get_buying_amount

ERPNext: v13.8.0 (version-13)
Frappe Framework: v13.8.1 (version-13)

Hey akkvatech,

I looked at the code from what it looks like there is a part of the code where it changes the parent of a sales invoice item to the item code see below:


but then it will create a new key to store the parent_invoice

then there is this method get_buying_amount where it compares the stock ledger entries by the parent but since the item code is not used in the parent column it will not match anything leading to $0

so adding this logic:

fixes it and now I don’t have any zero valuation

Also found that there are cases where the parent stays the sames (meaning the name of the parenttype) and cases where it isn’t. Will need to dig deeper but adding the logic below seems to correct it.

parenttype, parent = row.parenttype, (row.parent_invoice if row.parenttype == “Sales Invoice” and row.parent_invoice else row.parent)

I wonder if this issue affects version-12. Any one on v12 having this issue?

Created a pull request for it

Also I’m on:
Frappe Framework: v13.15.0 (version-13)
ERPNext: v13.15.2 (version-13)

Can confirm it is in version 12 as well.
ERPNext: v12.26.0 (version-12)