diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index dd7a3830c9b..0fb3f048983 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -3,7 +3,7 @@ import json from collections import defaultdict import frappe -from frappe.query_builder.functions import CombineDatetime, Sum +from frappe.query_builder.functions import Sum from frappe.utils import flt, nowtime from pypika import Order from pypika.functions import Coalesce diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 79e9776b91c..62c4528f432 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -5,7 +5,7 @@ import frappe from frappe.model.document import Document from frappe.query_builder import Case, Order -from frappe.query_builder.functions import Coalesce, CombineDatetime, Sum +from frappe.query_builder.functions import Coalesce, Sum from frappe.utils import flt diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 5a749b31f62..d4307dbc7f7 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -12,7 +12,7 @@ import frappe.query_builder.functions from frappe import _, _dict, bold from frappe.model.document import Document from frappe.model.naming import make_autoname -from frappe.query_builder.functions import CombineDatetime, Sum +from frappe.query_builder.functions import Sum from frappe.utils import ( cint, cstr, diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index fa3cada5731..59683e87e3d 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -4,7 +4,7 @@ import frappe from frappe import _, bold, json, msgprint -from frappe.query_builder.functions import CombineDatetime, Sum +from frappe.query_builder.functions import Sum from frappe.utils import add_to_date, cint, cstr, flt, get_datetime, now import erpnext diff --git a/erpnext/stock/report/stock_analytics/stock_analytics.py b/erpnext/stock/report/stock_analytics/stock_analytics.py index 16dea3c2942..36f0f2e5be6 100644 --- a/erpnext/stock/report/stock_analytics/stock_analytics.py +++ b/erpnext/stock/report/stock_analytics/stock_analytics.py @@ -4,7 +4,6 @@ import datetime import frappe from frappe import _, scrub -from frappe.query_builder.functions import CombineDatetime from frappe.utils import get_datetime, get_first_day_of_week, get_quarter_start, getdate from frappe.utils import get_first_day as get_first_day_of_month from frappe.utils.nestedset import get_descendants_of diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py index b55a8e43f67..8e37799e8ce 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.py +++ b/erpnext/stock/report/stock_ledger/stock_ledger.py @@ -7,7 +7,7 @@ from collections import defaultdict import frappe from frappe import _ -from frappe.query_builder.functions import CombineDatetime, Sum +from frappe.query_builder.functions import Sum from frappe.utils import cint, flt, get_datetime from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py index 298cec2fa89..aee27b8a8d4 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -4,7 +4,7 @@ import frappe from frappe import _, bold from frappe.model.naming import NamingSeries, make_autoname, parse_naming_series from frappe.query_builder import Case -from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp +from frappe.query_builder.functions import Sum, Timestamp from frappe.utils import add_days, cint, cstr, flt, get_link_to_form, getdate, now, nowtime, today from pypika import Order from pypika.terms import ExistsCriterion diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 10b319325ae..7a9a2ad273a 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -1903,31 +1903,6 @@ def get_sle_by_voucher_detail_no(voucher_detail_no, excluded_sle=None): ) -def get_batch_incoming_rate(item_code, warehouse, batch_no, posting_date, posting_time, creation=None): - sle = frappe.qb.DocType("Stock Ledger Entry") - - timestamp_condition = sle.posting_datetime < get_combine_datetime(posting_date, posting_time) - if creation: - timestamp_condition |= (sle.posting_datetime == get_combine_datetime(posting_date, posting_time)) & ( - sle.creation < creation - ) - - batch_details = ( - frappe.qb.from_(sle) - .select(Sum(sle.stock_value_difference).as_("batch_value"), Sum(sle.actual_qty).as_("batch_qty")) - .where( - (sle.item_code == item_code) - & (sle.warehouse == warehouse) - & (sle.batch_no == batch_no) - & (sle.is_cancelled == 0) - ) - .where(timestamp_condition) - ).run(as_dict=True) - - if batch_details and batch_details[0].batch_qty: - return batch_details[0].batch_value / batch_details[0].batch_qty - - def get_valuation_rate( item_code, warehouse, diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 5367d67004c..7a60dcb64fc 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -6,7 +6,7 @@ import json import frappe from frappe import _ -from frappe.query_builder.functions import CombineDatetime, IfNull, Sum +from frappe.query_builder.functions import IfNull, Sum from frappe.utils import cstr, flt, get_link_to_form, get_time, getdate, nowdate, nowtime import erpnext @@ -331,34 +331,6 @@ def get_incoming_rate(args, raise_error_if_no_rate=True): return flt(in_rate) -def get_batch_incoming_rate(item_code, warehouse, batch_no, posting_date, posting_time, creation=None): - sle = frappe.qb.DocType("Stock Ledger Entry") - - timestamp_condition = CombineDatetime(sle.posting_date, sle.posting_time) < CombineDatetime( - posting_date, posting_time - ) - if creation: - timestamp_condition |= ( - CombineDatetime(sle.posting_date, sle.posting_time) == CombineDatetime(posting_date, posting_time) - ) & (sle.creation < creation) - - batch_details = ( - frappe.qb.from_(sle) - .select(Sum(sle.stock_value_difference).as_("batch_value"), Sum(sle.actual_qty).as_("batch_qty")) - .where( - (sle.item_code == item_code) - & (sle.warehouse == warehouse) - & (sle.batch_no == batch_no) - & (sle.serial_and_batch_bundle.isnull()) - & (sle.is_cancelled == 0) - ) - .where(timestamp_condition) - ).run(as_dict=True) - - if batch_details and batch_details[0].batch_qty: - return batch_details[0].batch_value / batch_details[0].batch_qty - - def get_avg_purchase_rate(serial_nos): """get average value of serial numbers"""