Merge pull request #49722 from rohitwaghchaure/fixed-test-case-test_backdated_stock_reco_entry

chore: fixed test case test_backdated_stock_reco_entry
This commit is contained in:
ruthra kumar
2025-09-25 17:02:44 +05:30
committed by GitHub
3 changed files with 22 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
from typing import TYPE_CHECKING, overload
import frappe
from frappe.utils import cint, flt
from frappe.utils import cint, flt, today
import erpnext
from erpnext.stock.utils import get_combine_datetime
@@ -77,6 +77,9 @@ def make_stock_entry(**args):
if args.inspection_required:
s.inspection_required = args.inspection_required
if not args.posting_date:
s.posting_date = today()
# map names
if args.from_warehouse:
args.source = args.from_warehouse
@@ -142,8 +145,8 @@ def make_stock_entry(**args):
batches = args.batches
posting_datetime = None
if args.posting_date and args.posting_time:
posting_datetime = get_combine_datetime(args.posting_date, args.posting_time)
if s.posting_date and s.posting_time:
posting_datetime = get_combine_datetime(s.posting_date, s.posting_time)
bundle_id = (
SerialBatchCreation(

View File

@@ -25,7 +25,12 @@ from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import (
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
from erpnext.stock.stock_ledger import get_previous_sle, update_entries_after
from erpnext.stock.tests.test_utils import StockTestMixin
from erpnext.stock.utils import get_incoming_rate, get_stock_value_on, get_valuation_method
from erpnext.stock.utils import (
get_combine_datetime,
get_incoming_rate,
get_stock_value_on,
get_valuation_method,
)
class TestStockReconciliation(IntegrationTestCase, StockTestMixin):
@@ -716,6 +721,13 @@ class TestStockReconciliation(IntegrationTestCase, StockTestMixin):
rate=100,
)
stock_reco.reload()
stock_reco_sabb = stock_reco.items[0].serial_and_batch_bundle
posting_datetime = frappe.db.get_value("Serial and Batch Bundle", stock_reco_sabb, "posting_datetime")
self.assertEqual(
posting_datetime, get_combine_datetime(stock_reco.posting_date, stock_reco.posting_time)
)
sle = frappe.get_all(
"Stock Ledger Entry",
filters={"is_cancelled": 0, "voucher_no": stock_reco.name, "actual_qty": ("<", 0)},

View File

@@ -241,12 +241,12 @@ def get_incoming_rate(args, raise_error_if_no_rate=True):
"""Get Incoming Rate based on valuation method"""
from erpnext.stock.stock_ledger import get_previous_sle, get_valuation_rate
if not args.get("posting_datetime") and args.get("posting_date"):
args["posting_datetime"] = get_combine_datetime(args.get("posting_date"), args.get("posting_time"))
if isinstance(args, str):
args = json.loads(args)
if not args.get("posting_datetime") and args.get("posting_date"):
args["posting_datetime"] = get_combine_datetime(args.get("posting_date"), args.get("posting_time"))
in_rate = None
item_details = frappe.get_cached_value(