Merge pull request #7583 from rohitwaghchaure/valuation_rate_issue
[Fix] Get valuation rate from item master and update stock value difference
This commit is contained in:
commit
355b4110c9
@ -9,6 +9,7 @@ import frappe.defaults
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
from erpnext.stock.stock_ledger import get_valuation_rate
|
||||
|
||||
class StockController(AccountsController):
|
||||
def validate(self):
|
||||
@ -51,8 +52,9 @@ class StockController(AccountsController):
|
||||
# from warehouse account
|
||||
|
||||
self.check_expense_account(item_row)
|
||||
|
||||
|
||||
if not sle.stock_value_difference:
|
||||
self.update_stock_ledger_entries(sle)
|
||||
self.validate_negative_stock(sle)
|
||||
|
||||
gl_list.append(self.get_gl_dict({
|
||||
@ -84,7 +86,15 @@ class StockController(AccountsController):
|
||||
"\n".join(warehouse_with_no_account))
|
||||
|
||||
return process_gl_map(gl_list)
|
||||
|
||||
|
||||
def update_stock_ledger_entries(self, sle):
|
||||
sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
|
||||
sle.voucher_type, sle.voucher_no)
|
||||
sle.stock_value = flt(sle.qty_after_transaction) * flt(sle.valuation_rate)
|
||||
sle.stock_value_difference = sle.stock_value
|
||||
sle.doctype="Stock Ledger Entry"
|
||||
frappe.get_doc(sle).db_update()
|
||||
|
||||
def validate_negative_stock(self, sle):
|
||||
if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
|
||||
frappe.throw(_("Valuation rate not found for the Item {0}, 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 {1} {2}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user