chore(stock_ledger): drop redundant check

Commit c2d7461d3cac639778e7740c4b08e459332a6b14 dropped a usage of
`last_valuation_rate` around this code block. After that, it was always checked
although the value would be None as it was being explicitly set above.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2023-09-26 13:45:39 +05:30
parent 656c758263
commit dd911aa521
No known key found for this signature in database
GPG Key ID: 9DCC61E211BF645F

View File

@ -1464,8 +1464,6 @@ def get_valuation_rate(
if not company: if not company:
company = frappe.get_cached_value("Warehouse", warehouse, "company") company = frappe.get_cached_value("Warehouse", warehouse, "company")
last_valuation_rate = None
# Get moving average rate of a specific batch number # Get moving average rate of a specific batch number
if warehouse and serial_and_batch_bundle: if warehouse and serial_and_batch_bundle:
batch_obj = BatchNoValuation( batch_obj = BatchNoValuation(
@ -1482,8 +1480,7 @@ def get_valuation_rate(
return batch_obj.get_incoming_rate() return batch_obj.get_incoming_rate()
# Get valuation rate from last sle for the same item and warehouse # Get valuation rate from last sle for the same item and warehouse
if not last_valuation_rate or last_valuation_rate[0][0] is None: if last_valuation_rate := frappe.db.sql(
last_valuation_rate = frappe.db.sql(
"""select valuation_rate """select valuation_rate
from `tabStock Ledger Entry` force index (item_warehouse) from `tabStock Ledger Entry` force index (item_warehouse)
where where
@ -1494,9 +1491,7 @@ def get_valuation_rate(
AND NOT (voucher_no = %s AND voucher_type = %s) AND NOT (voucher_no = %s AND voucher_type = %s)
order by posting_date desc, posting_time desc, name desc limit 1""", order by posting_date desc, posting_time desc, name desc limit 1""",
(item_code, warehouse, voucher_no, voucher_type), (item_code, warehouse, voucher_no, voucher_type),
) ):
if last_valuation_rate:
return flt(last_valuation_rate[0][0]) return flt(last_valuation_rate[0][0])
# If negative stock allowed, and item delivered without any incoming entry, # If negative stock allowed, and item delivered without any incoming entry,