ERPNext Conference 2019* ERPNext.com Blog

Valuation Rate not found for warehouse


#1

Since upgrading along the way I am now getting the following errors. This is stopping me submitting sales invoices and purchase receipts.

For the Item ITEM-02245, valuation rate not found for warehouse XXX. To be able to do accounting entries (for booking expenses), we need valuation rate for item ITEM-02245. Please create an incoming stock transaction, on or before 2016-10-20 14:46:41, and then try submiting SINV-01038-1.

Previously, I had no problems with creating sales invoices before creating purchase receipts for items. But now I get the above error. (Possibly, as all Items were zero cost in my case)

Also, it won’t allow me to submit purchase receipts either. In some cases, when trying to submit a PREC, the error is coming up for sales invoices which have already been submitted and paid.

Anybody know why this is happening now?

Anyway of disabling this check?


#2

In the latest version, you can set valuation rate in item master. The system picks the rate from there, when it does not get any incoming entry for a item to find its purchase cost.


[Version 11] Valuation rate from Item Master not working
#3

Hi nabinhait,

Thanks for the reply. Unfortunately, it does not seem to be picking up the valuation_rate in item master but is looking for an incoming entry (which does not exist).

I really don’t want to have to submit PREC’s before invoices. Plus, also, system is actually blocking me from doing so as there are linked sales invoices to items in prec’s . So I’m really in a bind :frowning:


I do have valuation_rates set for all items ( set as 0.0) in item master. e.g.

select item_code, valuation_rate, default_warehouse, last_purchase_rate from tabItem limit 3;
±-------------------------------------------------------------------±---------------±------------------±-------------------+
| item_code | valuation_rate | default_warehouse | last_purchase_rate |
±-------------------------------------------------------------------±---------------±------------------±-------------------+
| 1949 Vintage Medical… | 0.000000 | Mamhilad - URTL | 0.000000 |
| 1987 Vintage… | 0.000000 | Mamhilad - URTL | 0.000000 |
| 30 Wooden Tables | 0.000000 | Mamhilad - URTL | 0.000000 |
±-------------------------------------------------------------------±---------------±------------------±-------------------+
3 rows in set (0.00 sec)

Doing a bit more digging around. I am able to submit a sales invoice if I remove “update stock” so it is definitely something to do with stock valuations rather than some other error.

Also, for information, relevant system settings:

Latest version (non-develop) Erpnext.
Default Valuation Method: FIFO
Default Warehouse: Mamhilad - URTL
Allow Negative Stock: True
Auto insert price list rate if missing: True

Make Accounting Entry For Every Stock Movement: True

Thanks

Ben


#4

@bglazier – I had the same issue and I resolved it by creating a material receipt for 1 unit with the valuation rate entered and made sure that the default warehouse was filled.

NOTE: Even though you enter the default warehouse in the list, for some reason you also have make sure it entered on the material receipt form as well.

Hope this helps.

Regards
Said


#5

Hi Said,

Thanks for the reply @saidsl . Unfortunately, that didn’t solve it for me. Still strange things going on.

For example, for my PREC-0056, I did the following as per your instruction.

For Purchase Receipt Items the Warehouse is set correctly:

select pri.warehouse from tabPurchase Receipt Item pri where pri.parent = ‘PREC-00056’;
±----------------+
| warehouse |
±----------------+
| Mamhilad - URTL |
| Mamhilad - URTL |
| Mamhilad - URTL |

Supplier warehouse for PREC was not set:

select pr.supplier_warehouse from tabPurchase Receipt pr where pr.name = ‘PREC-00056’;
±-------------------+
| supplier_warehouse |
±-------------------+
| NULL |
±-------------------+
1 row in set (0.00 sec)

So, set warehouse for PREC 56.
update tabPurchase Receipt pr set pr.supplier_warehouse = ‘Mamhilad - URTL’ where pr.name = ‘PREC-00056’;

On submitting PREC, throws same valuation_rate error, below.

But strange thing is ITEM-02245 isn’t even on the PREC in question.

Valuation rate not found for the Item ITEM-02245, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting None None

Regards

Ben


#6

That’s strange cause the message you are getting is exactly the same as I got and when I created a material receipt for the item in question, it solved the issue.

Regards
Said


#7

@saidsl, thanks for the help on this, having done some more further work on this I am a little further on.

But, unfortunately, Erpnext is not working in line with @nabinhait 's post above. Setting valuation rate in item master has no effect and the system is not picking up that rate.

Creating Purchase Receipts is solving some of the blocked entries but Erpnext is also blocking me from submitting some Purchase Receipts also, throwing the same error, mainly because of Items occurring on sales invoices but in some cases for strange reasons.

Previously, Erpnext was super flexible, allowing creation of Sales Invoices before submitting PREC’S, etc. Now it’s inflexible and in some cases inconsistent - I am sure this has happened since an update in mid Dec as I never had problems like this before.


With a mounting backlog of a couple of hundred draft invoices and a dozen unsubmittable Prec’s. I’m going to have to start digging around in the code to solve this. :frowning:

Many thanks

Ben


#8

Guys,

Thankfully, I have found a fix.

set:
allow_zero_rate = True
in stock_ledger.py

Removed:
def validate_negative_stock(self, sle)
in stock_controller.py

Also, none of the sql queries for last_valuation_rate allow for instances where valuation is 0.0 which applies in my case although probably not in many other businesses.


#9

There is some issue in picking up valuation rate from Item master, if the questioned item is not present in the submitted PR. We will push a fix by tomorrow.


#10

@nabinhait , ah brilliant. I’m glad it is actually an issue that can be resolved. :slight_smile:

For your information,

In stock_ledger.py, near line 430, the following line appears to returns Null if valuation_rate = 0.0 but if changed to 0.00001, then the value is returned.

	valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate")  #NOT RETURNING 0.00
	if valuation_rate: frappe.msgprint ("Valuation rate obtained from Item: ", valuation_rate) 
	else: frappe.msgprint ("valuation rate null")

and for items that have an sle entry, in stock_controller.py, line 89, the condition
sle.qty_after_transaction < 0 and sle.actual_qty < 0,
always returns False even though I have “Allow Negative Stock” set in settings.

Also, on line 415, 423 in stock_ledger.py,
the sql only returns valuation_rates greater than zero, whereas, possible this should be >=0
although, I am not sure this may be the right approach or have any effect.

Many thanks

Ben


#11

Hi @nabinhait

Wondering if there has been any progress on this. I noticed an update to stock_controller.py over the weekend, but issue is still there.

Thanks

Ben


#12

Hi @bglazier,

We have fixed this issue, did you still facing the same problem?


#13

Hi @rohit_w,

I’m also having the same issue even after updating:

Valuation rate not found for the Item XXXXXXXX, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting None None

Thanks

Enric


#14

Hi @rohit_w

Thanks for the reply.

No, unfortunately, I still have the problem.

Looking at the code, valuation_rate is now returned correctly as 0.0 from frappe.db.get_value(“Item”, item_code, “valuation_rate”), whereas this wasn’t working properly before.

But, I’m still getting the same errors.

I have to add the line, allow_zero_rate = True to get past frappe.throw(_("Valuation rate not found in stock_ledger
but then it falls down again in stock_controller.py:100.

However, commenting out frappe.throw in stock_controller enables me to actually submit the sales invoice.

Regards

Ben


#15

Hi @enric,

Did you set valuation rate in the item master for the respective item


#16

Hi,

No. I don’t have the option to add Valuation Rate in the item master for products with a BOM.

Until the last week everything worked fine without a valuation.

Now I have many manufacturing orders with an old BOM with valuation rate 0, which I can’t finish.


#17

I have the same problem, please teach me how to setup for this isssue, and I have another problem I want to update my rate in quotation even I setup my Precision as “9” it still doesn’t work…


#18

Hi @Chih_Hsien_Chiang, @bglazier

It will be helpful for us if you provide the browser’s console log.
I hope you have defined the valuation rate on the item master

Thanks


#19

@rohit_w

Console log as requested:

Valuation_rate = 0.0 on item_master, because the item is a no cost item and has a valuation of zero.

[Log] Traceback (most recent call last): (desk.min.js, line 1531)
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 40, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 897, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 19, in savedocs
doc.submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 723, in submit
self._submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 712, in _submit
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 223, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 269, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 771, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 651, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 858, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 841, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 645, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 118, in on_submit
self.make_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 538, in make_gl_entries
gl_entries = self.get_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 572, in get_gl_entries
self.make_item_gl_entries(gl_entries)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 649, in make_item_gl_entries
gl_entries += super(SalesInvoice, self).get_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 57, in get_gl_entries
self.update_stock_ledger_entries(sle)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 92, in update_stock_ledger_entries
sle.voucher_type, sle.voucher_no)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/stock_ledger.py”, line 438, in get_valuation_rate
.format(item_code, voucher_type, voucher_no))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 309, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 302, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 275, in _raise_exception
raise raise_exception, encode(msg)
ValidationError: Valuation rate not found for the Item ITEM-01377, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting None None


#20

Have you making back dated entries? Kindly add the valuation rate for stock item