mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
[fix] Do not allow zero valuation rate for serial no and fetch previous valuation rate for serial no (#11817)
This commit is contained in:
committed by
Nabin Hait
parent
7a294e6ef5
commit
b1ac979ac5
@@ -230,6 +230,13 @@ class update_entries_after(object):
|
|||||||
# else it remains the same as that of previous entry
|
# else it remains the same as that of previous entry
|
||||||
self.valuation_rate = new_stock_value / new_stock_qty
|
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):
|
def get_moving_average_values(self, sle):
|
||||||
actual_qty = flt(sle.actual_qty)
|
actual_qty = flt(sle.actual_qty)
|
||||||
new_stock_qty = flt(self.qty_after_transaction) + actual_qty
|
new_stock_qty = flt(self.qty_after_transaction) + actual_qty
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ def update_bin(args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
|||||||
def get_incoming_rate(args):
|
def get_incoming_rate(args):
|
||||||
"""Get Incoming Rate based on valuation method"""
|
"""Get Incoming Rate based on valuation method"""
|
||||||
from erpnext.stock.stock_ledger import get_previous_sle
|
from erpnext.stock.stock_ledger import get_previous_sle
|
||||||
|
|
||||||
if isinstance(args, basestring):
|
if isinstance(args, basestring):
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
|
|
||||||
@@ -141,6 +141,8 @@ def get_incoming_rate(args):
|
|||||||
return 0.0
|
return 0.0
|
||||||
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]') or '[]')
|
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
|
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':
|
elif valuation_method == 'Moving Average':
|
||||||
in_rate = previous_sle.get('valuation_rate') or 0
|
in_rate = previous_sle.get('valuation_rate') or 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user