refactor: use db agnostic CombineDatetime
This commit is contained in:
parent
4ffea617ef
commit
e1c1687661
@ -8,9 +8,8 @@ from typing import Optional, Set, Tuple
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
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 CombineDatetime, Sum
|
||||||
from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, now, nowdate
|
from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, now, nowdate
|
||||||
from pypika import CustomFunction
|
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
from erpnext.stock.doctype.bin.bin import update_qty as update_bin_qty
|
from erpnext.stock.doctype.bin.bin import update_qty as update_bin_qty
|
||||||
@ -1158,16 +1157,15 @@ def get_batch_incoming_rate(
|
|||||||
item_code, warehouse, batch_no, posting_date, posting_time, creation=None
|
item_code, warehouse, batch_no, posting_date, posting_time, creation=None
|
||||||
):
|
):
|
||||||
|
|
||||||
Timestamp = CustomFunction("timestamp", ["date", "time"])
|
|
||||||
|
|
||||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||||
|
|
||||||
timestamp_condition = Timestamp(sle.posting_date, sle.posting_time) < Timestamp(
|
timestamp_condition = CombineDatetime(sle.posting_date, sle.posting_time) < CombineDatetime(
|
||||||
posting_date, posting_time
|
posting_date, posting_time
|
||||||
)
|
)
|
||||||
if creation:
|
if creation:
|
||||||
timestamp_condition |= (
|
timestamp_condition |= (
|
||||||
Timestamp(sle.posting_date, sle.posting_time) == Timestamp(posting_date, posting_time)
|
CombineDatetime(sle.posting_date, sle.posting_time)
|
||||||
|
== CombineDatetime(posting_date, posting_time)
|
||||||
) & (sle.creation < creation)
|
) & (sle.creation < creation)
|
||||||
|
|
||||||
batch_details = (
|
batch_details = (
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from typing import Dict, Optional
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.query_builder.functions import CombineDatetime
|
||||||
from frappe.utils import cstr, flt, get_link_to_form, nowdate, nowtime
|
from frappe.utils import cstr, flt, get_link_to_form, nowdate, nowtime
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@ -143,12 +144,10 @@ def get_stock_balance(
|
|||||||
|
|
||||||
|
|
||||||
def get_serial_nos_data_after_transactions(args):
|
def get_serial_nos_data_after_transactions(args):
|
||||||
from pypika import CustomFunction
|
|
||||||
|
|
||||||
serial_nos = set()
|
serial_nos = set()
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||||
Timestamp = CustomFunction("timestamp", ["date", "time"])
|
|
||||||
|
|
||||||
stock_ledger_entries = (
|
stock_ledger_entries = (
|
||||||
frappe.qb.from_(sle)
|
frappe.qb.from_(sle)
|
||||||
@ -157,7 +156,8 @@ def get_serial_nos_data_after_transactions(args):
|
|||||||
(sle.item_code == args.item_code)
|
(sle.item_code == args.item_code)
|
||||||
& (sle.warehouse == args.warehouse)
|
& (sle.warehouse == args.warehouse)
|
||||||
& (
|
& (
|
||||||
Timestamp(sle.posting_date, sle.posting_time) < Timestamp(args.posting_date, args.posting_time)
|
CombineDatetime(sle.posting_date, sle.posting_time)
|
||||||
|
< CombineDatetime(args.posting_date, args.posting_time)
|
||||||
)
|
)
|
||||||
& (sle.is_cancelled == 0)
|
& (sle.is_cancelled == 0)
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user