fix: adjustment entry

This commit is contained in:
Rohit Waghchaure
2025-10-15 15:17:59 +05:30
parent 9c014c7ba4
commit c0851abaee

View File

@@ -900,7 +900,11 @@ class update_entries_after:
if sle.is_adjustment_entry and flt(sle.qty_after_transaction, self.flt_precision) == 0:
sle.stock_value_difference = (
get_stock_value_difference(
sle.item_code, sle.warehouse, sle.posting_date, sle.posting_time, sle.voucher_no
sle.item_code,
sle.warehouse,
sle.posting_date,
sle.posting_time,
voucher_detail_no=sle.voucher_detail_no,
)
* -1
)
@@ -2341,7 +2345,9 @@ def is_internal_transfer(sle):
return True
def get_stock_value_difference(item_code, warehouse, posting_date, posting_time, voucher_no=None):
def get_stock_value_difference(
item_code, warehouse, posting_date, posting_time, voucher_no=None, voucher_detail_no=None
):
table = frappe.qb.DocType("Stock Ledger Entry")
posting_datetime = get_combine_datetime(posting_date, posting_time)
@@ -2356,7 +2362,10 @@ def get_stock_value_difference(item_code, warehouse, posting_date, posting_time,
)
)
if voucher_no:
if voucher_detail_no:
query = query.where(table.voucher_detail_no != voucher_detail_no)
elif voucher_no:
query = query.where(table.voucher_no != voucher_no)
difference_amount = query.run()