fix: inventory dimension negative stock validation (#39149)
This commit is contained in:
parent
68c0e188e8
commit
bae7c64964
@ -305,7 +305,7 @@ def get_evaluated_inventory_dimension(doc, sl_dict, parent_doc=None):
|
|||||||
dimensions = get_document_wise_inventory_dimensions(doc.doctype)
|
dimensions = get_document_wise_inventory_dimensions(doc.doctype)
|
||||||
filter_dimensions = []
|
filter_dimensions = []
|
||||||
for row in dimensions:
|
for row in dimensions:
|
||||||
if row.type_of_transaction:
|
if row.type_of_transaction and row.type_of_transaction != "Both":
|
||||||
if (
|
if (
|
||||||
row.type_of_transaction == "Inward"
|
row.type_of_transaction == "Inward"
|
||||||
if doc.docstatus == 1
|
if doc.docstatus == 1
|
||||||
|
|||||||
@ -429,6 +429,14 @@ class TestInventoryDimension(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
warehouse = create_warehouse("Negative Stock Warehouse")
|
warehouse = create_warehouse("Negative Stock Warehouse")
|
||||||
|
|
||||||
|
doc = make_stock_entry(item_code=item_code, source=warehouse, qty=10, do_not_submit=True)
|
||||||
|
doc.items[0].inv_site = "Site 1"
|
||||||
|
self.assertRaises(frappe.ValidationError, doc.submit)
|
||||||
|
doc.reload()
|
||||||
|
if doc.docstatus == 1:
|
||||||
|
doc.cancel()
|
||||||
|
|
||||||
doc = make_stock_entry(item_code=item_code, target=warehouse, qty=10, do_not_submit=True)
|
doc = make_stock_entry(item_code=item_code, target=warehouse, qty=10, do_not_submit=True)
|
||||||
|
|
||||||
doc.items[0].to_inv_site = "Site 1"
|
doc.items[0].to_inv_site = "Site 1"
|
||||||
|
|||||||
@ -111,13 +111,17 @@ class StockLedgerEntry(Document):
|
|||||||
"posting_date": self.posting_date,
|
"posting_date": self.posting_date,
|
||||||
"posting_time": self.posting_time,
|
"posting_time": self.posting_time,
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
|
"sle": self.name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
sle = get_previous_sle(kwargs, extra_cond=extra_cond)
|
sle = get_previous_sle(kwargs, extra_cond=extra_cond)
|
||||||
if sle:
|
qty_after_transaction = 0.0
|
||||||
flt_precision = cint(frappe.db.get_default("float_precision")) or 2
|
flt_precision = cint(frappe.db.get_default("float_precision")) or 2
|
||||||
diff = sle.qty_after_transaction + flt(self.actual_qty)
|
if sle:
|
||||||
|
qty_after_transaction = sle.qty_after_transaction
|
||||||
|
|
||||||
|
diff = qty_after_transaction + flt(self.actual_qty)
|
||||||
diff = flt(diff, flt_precision)
|
diff = flt(diff, flt_precision)
|
||||||
if diff < 0 and abs(diff) > 0.0001:
|
if diff < 0 and abs(diff) > 0.0001:
|
||||||
self.throw_validation_error(diff, dimensions)
|
self.throw_validation_error(diff, dimensions)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user