From 23d7b09389f52f39d24129041271b353e807099d Mon Sep 17 00:00:00 2001 From: Marica Date: Wed, 25 Sep 2019 17:17:36 +0530 Subject: [PATCH] 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 --- erpnext/controllers/accounts_controller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 37548ea9b8..31a78c3625 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -143,7 +143,7 @@ class AccountsController(TransactionBase): 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 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil 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 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil parent.update_status_updater() else: parent.check_credit_limit() - parent.save() if parent_doctype == 'Purchase Order':