[Error] Warehouse balance not matching account balance

Hi,

The values in my warehouse tree do not seem to be updating. When I move something from one warehouse to another, the balance is still shown in the source warehouse. As a result, the warehouse balances in my chart of accounts and warehouse tree aren’t matching. I have tried reloading the page and emptying the browser cache. I’m also seeing this message when making changes to account settings.

Thanks

My ‘All Warehouses’ Account does not seem to be linked to ‘All Warehouses’. When I try to link them I’m receiving the following error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 264, in _save
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 667, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 890, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 873, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 661, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py", line 38, in validate
    self.validate_warehouse_account()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py", line 192, in validate_warehouse_account
    .format(fmt_money(account_balance, self.account_currency),
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py", line 363, in fmt_money
    amount = '%.*f' % (precision, flt(amount))
TypeError: * wants int

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 56, 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 42, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 907, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 231, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 264, in _save
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 667, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 890, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 873, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 661, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py", line 38, in validate
    self.validate_warehouse_account()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/account.py", line 192, in validate_warehouse_account
    .format(fmt_money(account_balance, self.account_currency),
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py", line 363, in fmt_money
    amount = '%.*f' % (precision, flt(amount))
TypeError: * wants int

Any help would be greatly appreciated since this is our production server.
Thanks

Have you associated each warehouse with an appropriate account? In Parent Account. Just check if the upgrade messed it up.

Hope this helps

Thanks

Jay

Hello Jay. I checked all the accounts and most of the parent accounts were messed up. But I have since corrected them and downloaded the data using the data import tool to verify they haven’t changed again.

Thanks

You may have to redo the Stock Reconciliation and ensure that it’s all the correct valuation.

Thanks

Jay

Ok. If I have stock entries for the warehouses for the reconciliation, would I have to delete those as well before redoing the stock reconciliation?

Thanks

The Stock Balance Report total balance amount for ‘All Warehouses’, however, is matching with my Chart of Accounts balance. It’s just the Warehouse Tree where it is shown incorrectly.

No, just download the Tools Stock Reconciliation, correct the valuation, put the difference account into a temporary account, and submit the stock reconciliation.

Once you get every other account on your trial balance right, the temporary account should get to a zero balance if everything goes well.

Thanks

Jay

Ok. Shall try that and post here tomorrow. Thanks for the help :slight_smile:

Its probably parked into a default account because you didn’t have an account for your warehouses. Getting an export of your stock balance report and just giving it the once over might give you a quick idea about what’s wrong.

Cheers

Jay

I checked my stock balance report and the general ledger. Both seem to be correct. The warehouse tree, however, is showing incorrect balances on my test server as well.

On demo.erpnext.com also, the warehouse tree balances and account tree balances don’t seem to match for warehouses. Unless my understanding of how they’re supposed to work is wrong.

I tried to query database with the sql found in stock_get_stock_value_on() method.
this query sum up all tabStock Ledger Entry.stock_value to get the value of stock_value by warehouse. the value is compared to linked account balance.

On my test server, I have made a purchase receipt (incoming item) and a transfert stock entry (outgoing item).Now, two entries are in table tabStock Ledger Entry

item goes in:
voucher_no;stock_value
PREC-00030; 448.0000

item goes out:
voucher_no ;stock_value
STE-01357; 0.00000

sum(stock_value) = 448.0000

the linked account has got a balance of €0.00. Unable to know what is wrong. I suppose some negative entries are missing for the sum to equal 0.

Just came across the same TypeError: * wants int.

Fixed the type error in validate_warehouse_account in account.py line 192

if account_balance != stock_balance:
					frappe.throw(_('Account balance ({0}) and stock value ({1}) must be same')\
						.format(fmt_money(account_balance, self.account_currency),
							fmt_money(stock_balance, self.account_currency)))

Should be:

if account_balance != stock_balance:
					frappe.throw(_('Account balance ({0}) and stock value ({1}) must be same')\
						.format(fmt_money(account_balance, currency=self.account_currency),
							fmt_money(stock_balance, currency=self.account_currency)))

As for the balances, I think the stock_value field is actually a balance value. It’s labelled as such in the stock ledger report. So if stock_get_stock_value_on is adding up all the stock_value fields, the final result would be incorrect.

have u figured out what is wrong , i have the same problem

I am facing the same problem. Does anyone have an update to solve this problem?