refactor: replaced db.sql with qb
(cherry picked from commit deb6b38fab)
This commit is contained in:
@@ -115,14 +115,25 @@ def get_stock_balance(item_code, warehouse, posting_date=None, posting_time=None
|
|||||||
return last_entry.qty_after_transaction if last_entry else 0.0
|
return last_entry.qty_after_transaction if last_entry else 0.0
|
||||||
|
|
||||||
def get_serial_nos_data_after_transactions(args):
|
def get_serial_nos_data_after_transactions(args):
|
||||||
|
from pypika import CustomFunction
|
||||||
|
|
||||||
serial_nos = []
|
serial_nos = []
|
||||||
data = frappe.db.sql(""" SELECT serial_no, actual_qty
|
args = frappe._dict(args)
|
||||||
FROM `tabStock Ledger Entry`
|
sle = frappe.qb.DocType('Stock Ledger Entry')
|
||||||
WHERE
|
Timestamp = CustomFunction('timestamp', ['date', 'time'])
|
||||||
item_code = %(item_code)s and warehouse = %(warehouse)s
|
|
||||||
and timestamp(posting_date, posting_time) < timestamp(%(posting_date)s, %(posting_time)s)
|
data = frappe.qb.from_(
|
||||||
and is_cancelled = 0
|
sle
|
||||||
order by posting_date, posting_time asc """, args, as_dict=1)
|
).select(
|
||||||
|
'serial_no','actual_qty'
|
||||||
|
).where(
|
||||||
|
(sle.item_code == args.item_code)
|
||||||
|
& (sle.warehouse == args.warehouse)
|
||||||
|
& (Timestamp(sle.posting_date, sle.posting_time) < Timestamp(args.posting_date, args.posting_time))
|
||||||
|
& (sle.is_cancelled == 0)
|
||||||
|
).orderby(
|
||||||
|
sle.posting_date, sle.posting_time
|
||||||
|
).run(as_dict=1)
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
if d.actual_qty > 0:
|
if d.actual_qty > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user