fix: update Stock Reconciliation document while reposting
(cherry picked from commit cc95cedfee3c09037a97574ca1a04b2d98c72965)
This commit is contained in:
parent
ebf03a51f3
commit
88a3f65d3d
@ -861,6 +861,8 @@ class update_entries_after(object):
|
|||||||
self.update_rate_on_purchase_receipt(sle, outgoing_rate)
|
self.update_rate_on_purchase_receipt(sle, outgoing_rate)
|
||||||
elif flt(sle.actual_qty) < 0 and sle.voucher_type == "Subcontracting Receipt":
|
elif flt(sle.actual_qty) < 0 and sle.voucher_type == "Subcontracting Receipt":
|
||||||
self.update_rate_on_subcontracting_receipt(sle, outgoing_rate)
|
self.update_rate_on_subcontracting_receipt(sle, outgoing_rate)
|
||||||
|
elif sle.voucher_type == "Stock Reconciliation":
|
||||||
|
self.update_rate_on_stock_reconciliation(sle)
|
||||||
|
|
||||||
def update_rate_on_stock_entry(self, sle, outgoing_rate):
|
def update_rate_on_stock_entry(self, sle, outgoing_rate):
|
||||||
frappe.db.set_value("Stock Entry Detail", sle.voucher_detail_no, "basic_rate", outgoing_rate)
|
frappe.db.set_value("Stock Entry Detail", sle.voucher_detail_no, "basic_rate", outgoing_rate)
|
||||||
@ -928,6 +930,38 @@ class update_entries_after(object):
|
|||||||
for d in scr.items:
|
for d in scr.items:
|
||||||
d.db_update()
|
d.db_update()
|
||||||
|
|
||||||
|
def update_rate_on_stock_reconciliation(self, sle):
|
||||||
|
if not sle.serial_no and not sle.batch_no:
|
||||||
|
sr = frappe.get_doc("Stock Reconciliation", sle.voucher_no, for_update=True)
|
||||||
|
|
||||||
|
for item in sr.items:
|
||||||
|
# Skip for Serial and Batch Items
|
||||||
|
if item.serial_no or item.batch_no:
|
||||||
|
continue
|
||||||
|
|
||||||
|
previous_sle = get_previous_sle(
|
||||||
|
{
|
||||||
|
"item_code": item.item_code,
|
||||||
|
"warehouse": item.warehouse,
|
||||||
|
"posting_date": sr.posting_date,
|
||||||
|
"posting_time": sr.posting_time,
|
||||||
|
"sle": sle.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
item.current_qty = previous_sle.get("qty_after_transaction") or 0.0
|
||||||
|
item.current_valuation_rate = previous_sle.get("valuation_rate") or 0.0
|
||||||
|
item.current_amount = flt(item.current_qty) * flt(item.current_valuation_rate)
|
||||||
|
|
||||||
|
item.amount = flt(item.qty) * flt(item.valuation_rate)
|
||||||
|
item.amount_difference = item.amount - item.current_amount
|
||||||
|
else:
|
||||||
|
sr.difference_amount = sum([item.amount_difference for item in sr.items])
|
||||||
|
sr.db_update()
|
||||||
|
|
||||||
|
for item in sr.items:
|
||||||
|
item.db_update()
|
||||||
|
|
||||||
def get_serialized_values(self, sle):
|
def get_serialized_values(self, sle):
|
||||||
incoming_rate = flt(sle.incoming_rate)
|
incoming_rate = flt(sle.incoming_rate)
|
||||||
actual_qty = flt(sle.actual_qty)
|
actual_qty = flt(sle.actual_qty)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user