fix: don't allow negative rate (backport #36027) (#36465)

* fix: don't allow negative rates (#36027)

* fix: don't allow negative rate

* test: don't allow negative rate

* fix: only check for -rate on items child table

(cherry picked from commit dedf24b86d)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py

* chore: resolve merge conflict

---------

Co-authored-by: Devin Slauenwhite <devin.slauenwhite@gmail.com>
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
mergify[bot]
2023-08-02 17:13:22 +05:30
committed by GitHub
parent e6dca0668c
commit caa4f33169
2 changed files with 10 additions and 0 deletions

View File

@@ -233,6 +233,9 @@ class StatusUpdater(Document):
if hasattr(d, "qty") and d.qty > 0 and self.get("is_return"):
frappe.throw(_("For an item {0}, quantity must be negative number").format(d.item_code))
if hasattr(d, "item_code") and hasattr(d, "rate") and d.rate < 0:
frappe.throw(_("For an item {0}, rate must be a positive number").format(d.item_code))
if d.doctype == args["source_dt"] and d.get(args["join_field"]):
args["name"] = d.get(args["join_field"])