fix: Item Rate within Update Items in Sales order (#19172)
Blocked negative discount percentage, which affected the item rate every time Update Items action was taken
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 37548ea..31a78c3 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -143,7 +143,7 @@
if not self.cash_bank_account:
# show message that the amount is not paid
frappe.throw(_("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified"))
-
+
if cint(self.is_return) and self.grand_total > self.paid_amount:
self.paid_amount = flt(flt(self.grand_total), self.precision("paid_amount"))
@@ -1195,8 +1195,10 @@
child_item.rate = flt(d.get("rate"))
if flt(child_item.price_list_rate):
- child_item.discount_percentage = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0, \
+ discount = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
child_item.precision("discount_percentage"))
+ if discount > 0:
+ child_item.discount_percentage = discount
child_item.flags.ignore_validate_update_after_submit = True
if new_child_flag:
@@ -1220,7 +1222,6 @@
parent.update_status_updater()
else:
parent.check_credit_limit()
-
parent.save()
if parent_doctype == 'Purchase Order':