fix: linters issues

This commit is contained in:
Rohit Waghchaure 2023-04-14 13:00:12 +05:30
parent 7bfc8f1236
commit d9dd64b4d2
2 changed files with 47 additions and 27 deletions

View File

@ -859,6 +859,8 @@ def is_reposting_pending():
def future_sle_exists(args, sl_entries=None): def future_sle_exists(args, sl_entries=None):
key = (args.voucher_type, args.voucher_no) key = (args.voucher_type, args.voucher_no)
if not hasattr(frappe.local, "future_sle"):
frappe.local.future_sle = {}
if validate_future_sle_not_exists(args, key, sl_entries): if validate_future_sle_not_exists(args, key, sl_entries):
return False return False
@ -892,6 +894,9 @@ def future_sle_exists(args, sl_entries=None):
) )
for d in data: for d in data:
if key not in frappe.local.future_sle:
frappe.local.future_sle[key] = frappe._dict({})
frappe.local.future_sle[key][(d.item_code, d.warehouse)] = d.total_row frappe.local.future_sle[key][(d.item_code, d.warehouse)] = d.total_row
return len(data) return len(data)
@ -903,6 +908,9 @@ def validate_future_sle_not_exists(args, key, sl_entries=None):
item_key = (args.get("item_code"), args.get("warehouse")) item_key = (args.get("item_code"), args.get("warehouse"))
if not sl_entries and hasattr(frappe.local, "future_sle"): if not sl_entries and hasattr(frappe.local, "future_sle"):
if key not in frappe.local.future_sle:
return False
if not frappe.local.future_sle.get(key) or ( if not frappe.local.future_sle.get(key) or (
item_key and item_key not in frappe.local.future_sle.get(key) item_key and item_key not in frappe.local.future_sle.get(key)
): ):
@ -910,11 +918,8 @@ def validate_future_sle_not_exists(args, key, sl_entries=None):
def get_cached_data(args, key): def get_cached_data(args, key):
if not hasattr(frappe.local, "future_sle"):
frappe.local.future_sle = {}
if key not in frappe.local.future_sle: if key not in frappe.local.future_sle:
frappe.local.future_sle[key] = frappe._dict({}) return False
if args.get("item_code"): if args.get("item_code"):
item_key = (args.get("item_code"), args.get("warehouse")) item_key = (args.get("item_code"), args.get("warehouse"))

View File

@ -1414,35 +1414,50 @@ def get_stock_reco_qty_shift(args):
return stock_reco_qty_shift return stock_reco_qty_shift
def get_next_stock_reco(args): def get_next_stock_reco(kwargs):
"""Returns next nearest stock reconciliaton's details.""" """Returns next nearest stock reconciliaton's details."""
return frappe.db.sql( sle = frappe.qb.DocType("Stock Ledger Entry")
"""
select query = (
name, posting_date, posting_time, creation, voucher_no, item_code, batch_no, actual_qty frappe.qb.from_(sle)
from .select(
`tabStock Ledger Entry` sle.name,
where sle.posting_date,
item_code = %(item_code)s sle.posting_time,
and warehouse = %(warehouse)s sle.creation,
and voucher_type = 'Stock Reconciliation' sle.voucher_no,
and voucher_no != %(voucher_no)s sle.item_code,
and is_cancelled = 0 sle.batch_no,
and batch_no = %(batch_no)s sle.actual_qty,
and (timestamp(posting_date, posting_time) > timestamp(%(posting_date)s, %(posting_time)s) )
or ( .where(
timestamp(posting_date, posting_time) = timestamp(%(posting_date)s, %(posting_time)s) (sle.item_code == kwargs.get("item_code"))
and creation > %(creation)s & (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): def get_datetime_limit_condition(detail):
return f""" return f"""