mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-25 14:11:45 +01:00
fix: stock reservation issue while making Purchase Invoice
(cherry picked from commit 64985bffe0)
This commit is contained in:
committed by
Mergify
parent
0f86ed28bc
commit
8bd71954f3
@@ -561,12 +561,28 @@ class update_entries_after:
|
|||||||
self.new_items_found = False
|
self.new_items_found = False
|
||||||
self.distinct_item_warehouses = args.get("distinct_item_warehouses", frappe._dict())
|
self.distinct_item_warehouses = args.get("distinct_item_warehouses", frappe._dict())
|
||||||
self.affected_transactions: set[tuple[str, str]] = set()
|
self.affected_transactions: set[tuple[str, str]] = set()
|
||||||
self.reserved_stock = flt(self.args.reserved_stock)
|
self.reserved_stock = self.get_reserved_stock()
|
||||||
|
|
||||||
self.data = frappe._dict()
|
self.data = frappe._dict()
|
||||||
self.initialize_previous_data(self.args)
|
self.initialize_previous_data(self.args)
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
|
def get_reserved_stock(self):
|
||||||
|
sre = frappe.qb.DocType("Stock Reservation Entry")
|
||||||
|
posting_datetime = get_combine_datetime(self.args.posting_date, self.args.posting_time)
|
||||||
|
query = (
|
||||||
|
frappe.qb.from_(sre)
|
||||||
|
.select(Sum(sre.reserved_qty) - Sum(sre.delivered_qty))
|
||||||
|
.where(
|
||||||
|
(sre.item_code == self.item_code)
|
||||||
|
& (sre.warehouse == self.args.warehouse)
|
||||||
|
& (sre.docstatus == 1)
|
||||||
|
& (sre.creation <= posting_datetime)
|
||||||
|
)
|
||||||
|
).run()
|
||||||
|
|
||||||
|
return flt(query[0][0]) if query else 0.0
|
||||||
|
|
||||||
def set_precision(self):
|
def set_precision(self):
|
||||||
self.flt_precision = cint(frappe.db.get_default("float_precision")) or 2
|
self.flt_precision = cint(frappe.db.get_default("float_precision")) or 2
|
||||||
self.currency_precision = get_field_precision(
|
self.currency_precision = get_field_precision(
|
||||||
|
|||||||
Reference in New Issue
Block a user