From 2afb9b96cd2a92beeb39e6c8e8bd35276a58cc9f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 28 Apr 2017 15:18:26 +0530 Subject: [PATCH] pricing rule fix --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 ++ .../employee_loan_application.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 967f23c4bc..b913b6b632 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -201,6 +201,8 @@ def remove_pricing_rule_for_item(pricing_rule, item_details): item_details.margin_rate_or_amount = 0.0 item_details.margin_type = None + if item_details.pricing_rule: + item_details.pricing_rule = None return item_details @frappe.whitelist() diff --git a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py index 74a65e2b57..357571e2a3 100644 --- a/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py +++ b/erpnext/hr/doctype/employee_loan_application/employee_loan_application.py @@ -28,8 +28,12 @@ class EmployeeLoanApplication(Document): if self.repayment_method == "Repay Fixed Amount per Period": monthly_interest_rate = flt(self.rate_of_interest) / (12 *100) - self.repayment_periods = math.ceil((math.log(self.repayment_amount) - math.log(self.repayment_amount - \ - (self.loan_amount*monthly_interest_rate)))/(math.log(1+monthly_interest_rate))) + if monthly_interest_rate: + self.repayment_periods = math.ceil((math.log(self.repayment_amount) - + math.log(self.repayment_amount - (self.loan_amount*monthly_interest_rate))) / + (math.log(1 + monthly_interest_rate))) + else: + self.repayment_periods = self.loan_amount / self.repayment_amount self.total_payable_amount = self.repayment_amount * self.repayment_periods self.total_payable_interest = self.total_payable_amount - self.loan_amount