Skip to content

Commit

Permalink
fix: sort before picking next stock reco
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed May 9, 2022
1 parent e89fa86 commit 4e7a92c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def setUpClass(cls):

def tearDown(self):
frappe.local.future_sle = {}
frappe.flags.pop("dont_execute_stock_reposts", None)

def test_reco_for_fifo(self):
self._test_reco_sle_gle("FIFO")
Expand Down Expand Up @@ -315,6 +316,8 @@ def test_backdated_stock_reco_qty_reposting(self):
item_code = make_item().name
warehouse = "_Test Warehouse - _TC"

frappe.flags.dont_execute_stock_reposts = True

pr1 = make_purchase_receipt(
item_code=item_code, warehouse=warehouse, qty=10, rate=100, posting_date=add_days(nowdate(), -3)
)
Expand Down
7 changes: 3 additions & 4 deletions erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
datetime_limit_condition = get_datetime_limit_condition(detail)

frappe.db.sql(
"""
f"""
update `tabStock Ledger Entry`
set qty_after_transaction = qty_after_transaction + {qty_shift}
where
Expand All @@ -1328,9 +1328,7 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
and timestamp(posting_date, time_format(posting_time, %(time_format)s))
> timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s))
{datetime_limit_condition}
""".format(
qty_shift=qty_shift, datetime_limit_condition=datetime_limit_condition
),
""",
args,
)

Expand Down Expand Up @@ -1381,6 +1379,7 @@ def get_next_stock_reco(args):
and creation > %(creation)s
)
)
order by timestamp(posting_date, posting_time) asc, creation asc
limit 1
""",
args,
Expand Down

0 comments on commit 4e7a92c

Please sign in to comment.