mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-26 01:58:31 +00:00
perf: avoid reposting of entries created after stock reco (#43950)
(cherry picked from commit 7cfe1c8d59)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -1275,6 +1275,60 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin):
|
|||||||
qty = get_batch_qty(batch_id, warehouse, batch_item_code)
|
qty = get_batch_qty(batch_id, warehouse, batch_item_code)
|
||||||
self.assertEqual(qty, 110)
|
self.assertEqual(qty, 110)
|
||||||
|
|
||||||
|
def test_skip_reposting_for_entries_after_stock_reco(self):
|
||||||
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
|
||||||
|
item_code = create_item("Test Item For Skip Reposting After Stock Reco", is_stock_item=1).name
|
||||||
|
|
||||||
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
make_stock_entry(
|
||||||
|
posting_date="2024-11-01",
|
||||||
|
posting_time="11:00",
|
||||||
|
item_code=item_code,
|
||||||
|
target=warehouse,
|
||||||
|
qty=10,
|
||||||
|
basic_rate=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
create_stock_reconciliation(
|
||||||
|
posting_date="2024-11-02",
|
||||||
|
posting_time="11:00",
|
||||||
|
item_code=item_code,
|
||||||
|
warehouse=warehouse,
|
||||||
|
qty=20,
|
||||||
|
rate=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
se = make_stock_entry(
|
||||||
|
posting_date="2024-11-03",
|
||||||
|
posting_time="11:00",
|
||||||
|
item_code=item_code,
|
||||||
|
source=warehouse,
|
||||||
|
qty=15,
|
||||||
|
)
|
||||||
|
|
||||||
|
stock_value_difference = frappe.db.get_value(
|
||||||
|
"Stock Ledger Entry", {"voucher_no": se.name, "is_cancelled": 0}, "stock_value_difference"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(stock_value_difference, 1500.00 * -1)
|
||||||
|
|
||||||
|
make_stock_entry(
|
||||||
|
posting_date="2024-10-29",
|
||||||
|
posting_time="11:00",
|
||||||
|
item_code=item_code,
|
||||||
|
target=warehouse,
|
||||||
|
qty=10,
|
||||||
|
basic_rate=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
stock_value_difference = frappe.db.get_value(
|
||||||
|
"Stock Ledger Entry", {"voucher_no": se.name, "is_cancelled": 0}, "stock_value_difference"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(stock_value_difference, 1500.00 * -1)
|
||||||
|
|
||||||
|
|
||||||
def create_batch_item_with_batch(item_name, batch_id):
|
def create_batch_item_with_batch(item_name, batch_id):
|
||||||
batch_item_doc = create_item(item_name, is_stock_item=1)
|
batch_item_doc = create_item(item_name, is_stock_item=1)
|
||||||
|
|||||||
@@ -623,9 +623,21 @@ class update_entries_after:
|
|||||||
if sle.dependant_sle_voucher_detail_no:
|
if sle.dependant_sle_voucher_detail_no:
|
||||||
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
||||||
|
|
||||||
|
if self.has_stock_reco_with_serial_batch(sle):
|
||||||
|
break
|
||||||
|
|
||||||
if self.exceptions:
|
if self.exceptions:
|
||||||
self.raise_exceptions()
|
self.raise_exceptions()
|
||||||
|
|
||||||
|
def has_stock_reco_with_serial_batch(self, sle):
|
||||||
|
if (
|
||||||
|
sle.vocher_type == "Stock Reconciliation"
|
||||||
|
and frappe.db.get_value(sle.voucher_type, sle.voucher_no, "set_posting_time") == 1
|
||||||
|
):
|
||||||
|
return not (sle.batch_no or sle.serial_no or sle.serial_and_batch_bundle)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def process_sle_against_current_timestamp(self):
|
def process_sle_against_current_timestamp(self):
|
||||||
sl_entries = self.get_sle_against_current_voucher()
|
sl_entries = self.get_sle_against_current_voucher()
|
||||||
for sle in sl_entries:
|
for sle in sl_entries:
|
||||||
|
|||||||
Reference in New Issue
Block a user