chore: remove microsecond from posting_datetime

This commit is contained in:
Rohit Waghchaure 2024-02-21 17:32:02 +05:30
parent f37f7ca5c3
commit a73ba2c0d2
5 changed files with 8 additions and 21 deletions

View File

@ -1611,24 +1611,22 @@ class TestStockEntry(FrappeTestCase):
item_code = "Test Negative Item - 001" item_code = "Test Negative Item - 001"
item_doc = create_item(item_code=item_code, is_stock_item=1, valuation_rate=10) item_doc = create_item(item_code=item_code, is_stock_item=1, valuation_rate=10)
make_stock_entry( se1 = make_stock_entry(
item_code=item_code, item_code=item_code,
posting_date=add_days(today(), -3), posting_date=add_days(today(), -3),
posting_time="00:00:00", posting_time="00:00:00",
purpose="Material Receipt", target="_Test Warehouse - _TC",
qty=10, qty=10,
to_warehouse="_Test Warehouse - _TC", to_warehouse="_Test Warehouse - _TC",
do_not_save=True,
) )
make_stock_entry( se2 = make_stock_entry(
item_code=item_code, item_code=item_code,
posting_date=today(), posting_date=today(),
posting_time="00:00:00", posting_time="00:00:00",
purpose="Material Receipt", source="_Test Warehouse - _TC",
qty=8, qty=8,
from_warehouse="_Test Warehouse - _TC", from_warehouse="_Test Warehouse - _TC",
do_not_save=True,
) )
sr_doc = create_stock_reconciliation( sr_doc = create_stock_reconciliation(

View File

@ -1227,7 +1227,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin):
filters={"voucher_no": reciept1.name}, filters={"voucher_no": reciept1.name},
fields=["qty_after_transaction", "actual_qty"], fields=["qty_after_transaction", "actual_qty"],
) )
self.assertEqual(sle[0].qty_after_transaction, 105) self.assertEqual(sle[0].qty_after_transaction, 5)
self.assertEqual(sle[0].actual_qty, 5) self.assertEqual(sle[0].actual_qty, 5)
sle = frappe.get_all( sle = frappe.get_all(
@ -1235,7 +1235,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin):
filters={"voucher_no": reciept2.name}, filters={"voucher_no": reciept2.name},
fields=["qty_after_transaction", "actual_qty"], fields=["qty_after_transaction", "actual_qty"],
) )
self.assertEqual(sle[0].qty_after_transaction, 100) self.assertEqual(sle[0].qty_after_transaction, 105)
self.assertEqual(sle[0].actual_qty, 100) self.assertEqual(sle[0].actual_qty, 100)
@change_settings("System Settings", {"float_precision": 3, "currency_precision": 2}) @change_settings("System Settings", {"float_precision": 3, "currency_precision": 2})

View File

@ -11,7 +11,6 @@ from frappe import _, scrub
from frappe.model.meta import get_field_precision from frappe.model.meta import get_field_precision
from frappe.query_builder.functions import Sum from frappe.query_builder.functions import Sum
from frappe.utils import ( from frappe.utils import (
add_to_date,
cint, cint,
cstr, cstr,
flt, flt,
@ -637,7 +636,7 @@ class update_entries_after(object):
posting_datetime = %(posting_datetime)s posting_datetime = %(posting_datetime)s
) )
order by order by
posting_datetime ASC, creation ASC creation ASC
for update for update
""", """,
self.args, self.args,
@ -1403,17 +1402,12 @@ class update_entries_after(object):
def get_previous_sle_of_current_voucher(args, operator="<", exclude_current_voucher=False): def get_previous_sle_of_current_voucher(args, operator="<", exclude_current_voucher=False):
"""get stock ledger entries filtered by specific posting datetime conditions""" """get stock ledger entries filtered by specific posting datetime conditions"""
args["time_format"] = "%H:%i:%s"
if not args.get("posting_date"): if not args.get("posting_date"):
args["posting_datetime"] = "1900-01-01 00:00:00" args["posting_datetime"] = "1900-01-01 00:00:00"
if not args.get("posting_datetime"): if not args.get("posting_datetime"):
args["posting_datetime"] = get_combine_datetime(args["posting_date"], args["posting_time"]) args["posting_datetime"] = get_combine_datetime(args["posting_date"], args["posting_time"])
if operator == "<=":
# Add 1 second to handle millisecond for less than and equal to condition
args["posting_datetime"] = add_to_date(args["posting_datetime"], seconds=1)
voucher_condition = "" voucher_condition = ""
if exclude_current_voucher: if exclude_current_voucher:
voucher_no = args.get("voucher_no") voucher_no = args.get("voucher_no")
@ -1701,7 +1695,6 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
datetime_limit_condition = "" datetime_limit_condition = ""
qty_shift = args.actual_qty qty_shift = args.actual_qty
args["time_format"] = "%H:%i:%s"
args["posting_datetime"] = get_combine_datetime(args["posting_date"], args["posting_time"]) args["posting_datetime"] = get_combine_datetime(args["posting_date"], args["posting_time"])
# find difference/shift in qty caused by stock reconciliation # find difference/shift in qty caused by stock reconciliation

View File

@ -671,4 +671,4 @@ def get_combine_datetime(posting_date, posting_time):
if isinstance(posting_time, datetime.timedelta): if isinstance(posting_time, datetime.timedelta):
posting_time = (datetime.datetime.min + posting_time).time() posting_time = (datetime.datetime.min + posting_time).time()
return datetime.datetime.combine(posting_date, posting_time) return datetime.datetime.combine(posting_date, posting_time).replace(microsecond=0)

View File

@ -643,10 +643,6 @@ class TestSubcontractingReceipt(FrappeTestCase):
) )
scr = make_subcontracting_receipt(sco.name) scr = make_subcontracting_receipt(sco.name)
scr.save() scr.save()
for row in scr.supplied_items:
self.assertNotEqual(row.rate, 300.00)
self.assertFalse(row.serial_and_batch_bundle)
scr.submit() scr.submit()
scr.reload() scr.reload()