[fix] validate negative quantity while creating purchase receipt
This commit is contained in:
@@ -306,6 +306,7 @@ class BuyingController(StockController):
|
||||
# validate accepted and rejected qty
|
||||
def validate_accepted_rejected_qty(self):
|
||||
for d in self.get("items"):
|
||||
self.validate_negative_quantity(d, ["received_qty","qty", "rejected_qty"])
|
||||
if not flt(d.received_qty) and flt(d.qty):
|
||||
d.received_qty = flt(d.qty) - flt(d.rejected_qty)
|
||||
|
||||
@@ -319,6 +320,16 @@ class BuyingController(StockController):
|
||||
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
||||
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
|
||||
|
||||
def validate_negative_quantity(self, item_row, field_list):
|
||||
if self.is_return:
|
||||
return
|
||||
|
||||
item_row = item_row.as_dict()
|
||||
for fieldname in field_list:
|
||||
if flt(item_row[fieldname]) < 0:
|
||||
frappe.throw(_("Row #{0}: {1} can not be negative for item {2}".format(item_row['idx'],
|
||||
frappe.get_meta(item_row.doctype).get_label(fieldname), item_row['item_code'])))
|
||||
|
||||
def update_stock_ledger(self, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||
self.update_ordered_qty()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user