chore: fix test case

This commit is contained in:
Rohit Waghchaure
2024-02-26 14:42:18 +05:30
parent c36a5d1ba3
commit 77349a0af6
2 changed files with 16 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
import frappe import frappe
from frappe.tests.utils import FrappeTestCase, change_settings from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.utils import add_days, cint, cstr, flt, today, nowtime from frappe.utils import add_days, cint, cstr, flt, nowtime, today
from pypika import functions as fn from pypika import functions as fn
import erpnext import erpnext

View File

@@ -1398,7 +1398,8 @@ def get_valuation_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 last_valuation_rate := frappe.db.sql( if not last_valuation_rate or last_valuation_rate[0][0] is None:
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
@@ -1409,7 +1410,9 @@ 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_datetime desc, name desc limit 1""", order by posting_datetime 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,