[fix] Do not allow zero valuation rate for serial no and fetch previous valuation rate for serial no (#11817)

This commit is contained in:
rohitwaghchaure 2017-12-01 16:09:02 +05:30 committed by Nabin Hait
parent 7a294e6ef5
commit b1ac979ac5
2 changed files with 10 additions and 1 deletions

View File

@ -230,6 +230,13 @@ class update_entries_after(object):
# else it remains the same as that of previous entry
self.valuation_rate = new_stock_value / new_stock_qty
if not self.valuation_rate and sle.voucher_detail_no:
allow_zero_rate = self.check_if_allow_zero_valuation_rate(sle.voucher_type, sle.voucher_detail_no)
if not allow_zero_rate:
self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
sle.voucher_type, sle.voucher_no, self.allow_zero_rate,
currency=erpnext.get_company_currency(sle.company))
def get_moving_average_values(self, sle):
actual_qty = flt(sle.actual_qty)
new_stock_qty = flt(self.qty_after_transaction) + actual_qty

View File

@ -126,7 +126,7 @@ def update_bin(args, allow_negative_stock=False, via_landed_cost_voucher=False):
def get_incoming_rate(args):
"""Get Incoming Rate based on valuation method"""
from erpnext.stock.stock_ledger import get_previous_sle
if isinstance(args, basestring):
args = json.loads(args)
@ -141,6 +141,8 @@ def get_incoming_rate(args):
return 0.0
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]') or '[]')
in_rate = get_fifo_rate(previous_stock_queue, args.get("qty") or 0) if previous_stock_queue else 0
if not in_rate and not previous_stock_queue:
in_rate = previous_sle.get('valuation_rate') or 0
elif valuation_method == 'Moving Average':
in_rate = previous_sle.get('valuation_rate') or 0