mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
committed by
Mergify
parent
a981b79865
commit
c53dc06f80
@@ -1414,35 +1414,50 @@ def get_stock_reco_qty_shift(args):
|
||||
return stock_reco_qty_shift
|
||||
|
||||
|
||||
def get_next_stock_reco(args):
|
||||
def get_next_stock_reco(kwargs):
|
||||
"""Returns next nearest stock reconciliaton's details."""
|
||||
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select
|
||||
name, posting_date, posting_time, creation, voucher_no, item_code, batch_no, actual_qty
|
||||
from
|
||||
`tabStock Ledger Entry`
|
||||
where
|
||||
item_code = %(item_code)s
|
||||
and warehouse = %(warehouse)s
|
||||
and voucher_type = 'Stock Reconciliation'
|
||||
and voucher_no != %(voucher_no)s
|
||||
and is_cancelled = 0
|
||||
and batch_no = %(batch_no)s
|
||||
and (timestamp(posting_date, posting_time) > timestamp(%(posting_date)s, %(posting_time)s)
|
||||
or (
|
||||
timestamp(posting_date, posting_time) = timestamp(%(posting_date)s, %(posting_time)s)
|
||||
and creation > %(creation)s
|
||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(sle)
|
||||
.select(
|
||||
sle.name,
|
||||
sle.posting_date,
|
||||
sle.posting_time,
|
||||
sle.creation,
|
||||
sle.voucher_no,
|
||||
sle.item_code,
|
||||
sle.batch_no,
|
||||
sle.actual_qty,
|
||||
)
|
||||
.where(
|
||||
(sle.item_code == kwargs.get("item_code"))
|
||||
& (sle.warehouse == kwargs.get("warehouse"))
|
||||
& (sle.voucher_type == "Stock Reconciliation")
|
||||
& (sle.voucher_no != kwargs.get("voucher_no"))
|
||||
& (sle.is_cancelled == 0)
|
||||
& (
|
||||
(
|
||||
CombineDatetime(sle.posting_date, sle.posting_time)
|
||||
> CombineDatetime(kwargs.get("posting_date"), kwargs.get("posting_time"))
|
||||
| (
|
||||
(
|
||||
CombineDatetime(sle.posting_date, sle.posting_time)
|
||||
== CombineDatetime(kwargs.get("posting_date"), kwargs.get("posting_time"))
|
||||
)
|
||||
& (sle.creation > kwargs.get("creation"))
|
||||
)
|
||||
)
|
||||
)
|
||||
order by timestamp(posting_date, posting_time) asc, creation asc
|
||||
limit 1
|
||||
""",
|
||||
args,
|
||||
as_dict=1,
|
||||
)
|
||||
)
|
||||
|
||||
if kwargs.get("batch_no"):
|
||||
query.where(sle.batch_no == kwargs.get("batch_no"))
|
||||
|
||||
return query.run(as_dict=True)
|
||||
|
||||
|
||||
def get_datetime_limit_condition(detail):
|
||||
return f"""
|
||||
|
||||
Reference in New Issue
Block a user