codacy review
diff --git a/erpnext/accounts/doctype/subscriber/subscriber.js b/erpnext/accounts/doctype/subscriber/subscriber.js
index ba5cdf9..f5ea804 100644
--- a/erpnext/accounts/doctype/subscriber/subscriber.js
+++ b/erpnext/accounts/doctype/subscriber/subscriber.js
@@ -1,8 +1,2 @@
 // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
-
-frappe.ui.form.on('Subscriber', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/accounts/doctype/subscriber/subscriber.py b/erpnext/accounts/doctype/subscriber/subscriber.py
index c0aabcf..03eb0f5 100644
--- a/erpnext/accounts/doctype/subscriber/subscriber.py
+++ b/erpnext/accounts/doctype/subscriber/subscriber.py
@@ -3,7 +3,6 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
 from frappe.model.document import Document
 
 class Subscriber(Document):
diff --git a/erpnext/accounts/doctype/subscriber/test_subscriber.py b/erpnext/accounts/doctype/subscriber/test_subscriber.py
index e8684c3..3e2fc07 100644
--- a/erpnext/accounts/doctype/subscriber/test_subscriber.py
+++ b/erpnext/accounts/doctype/subscriber/test_subscriber.py
@@ -3,7 +3,6 @@
 # See license.txt
 from __future__ import unicode_literals
 
-import frappe
 import unittest
 
 class TestSubscriber(unittest.TestCase):
diff --git a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.js b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.js
index 40f9af3..f5ea804 100644
--- a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.js
+++ b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.js
@@ -1,8 +1,2 @@
 // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
-
-frappe.ui.form.on('Subscription Invoice', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py
index 69ff3e5..6f459b4 100644
--- a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py
+++ b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py
@@ -3,7 +3,6 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
 from frappe.model.document import Document
 
 class SubscriptionInvoice(Document):
diff --git a/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py b/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py
index 1d542b0..e60a4ee 100644
--- a/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py
+++ b/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py
@@ -3,7 +3,6 @@
 # See license.txt
 from __future__ import unicode_literals
 
-import frappe
 import unittest
 
 class TestSubscriptionInvoice(unittest.TestCase):
diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.js b/erpnext/accounts/doctype/subscription_plan/subscription_plan.js
index 9baacdd..f5ea804 100644
--- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.js
+++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.js
@@ -1,8 +1,2 @@
 // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
-
-frappe.ui.form.on('Subscription Plan', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py b/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py
index 4a9b578..73afbf6 100644
--- a/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py
+++ b/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py
@@ -3,7 +3,6 @@
 # See license.txt
 from __future__ import unicode_literals
 
-import frappe
 import unittest
 
 class TestSubscriptionPlan(unittest.TestCase):
diff --git a/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py b/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py
index 04ec4af..1d9606f 100644
--- a/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py
+++ b/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py
@@ -3,7 +3,6 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
 from frappe.model.document import Document
 
 class SubscriptionPlanDetail(Document):
diff --git a/erpnext/accounts/doctype/subscription_settings/subscription_settings.js b/erpnext/accounts/doctype/subscription_settings/subscription_settings.js
index c4541c3..f5ea804 100644
--- a/erpnext/accounts/doctype/subscription_settings/subscription_settings.js
+++ b/erpnext/accounts/doctype/subscription_settings/subscription_settings.js
@@ -1,8 +1,2 @@
 // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
-
-frappe.ui.form.on('Subscription Settings', {
-	refresh: function(frm) {
-
-	}
-});
diff --git a/erpnext/accounts/doctype/subscription_settings/subscription_settings.py b/erpnext/accounts/doctype/subscription_settings/subscription_settings.py
index 3d382a7..cc378e4 100644
--- a/erpnext/accounts/doctype/subscription_settings/subscription_settings.py
+++ b/erpnext/accounts/doctype/subscription_settings/subscription_settings.py
@@ -3,7 +3,6 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import frappe
 from frappe.model.document import Document
 
 class SubscriptionSettings(Document):
diff --git a/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py b/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py
index b9592d3..82c7e1d 100644
--- a/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py
+++ b/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py
@@ -3,7 +3,6 @@
 # See license.txt
 from __future__ import unicode_literals
 
-import frappe
 import unittest
 
 class TestSubscriptionSettings(unittest.TestCase):
diff --git a/erpnext/accounts/doctype/subscriptions/subscriptions.py b/erpnext/accounts/doctype/subscriptions/subscriptions.py
index 2fd2fd6..ed1d353 100644
--- a/erpnext/accounts/doctype/subscriptions/subscriptions.py
+++ b/erpnext/accounts/doctype/subscriptions/subscriptions.py
@@ -29,9 +29,8 @@
 
 	def set_current_invoice_start(self, date=None):
 		"""
-		This sets the date of the beginning of the current billing period. 
-		
-		If the `date` parameter is not given , it will be automatically set as today's 
+		This sets the date of the beginning of the current billing period.
+		If the `date` parameter is not given , it will be automatically set as today's
 		date.
 		"""
 		if self.trial_period_start and self.is_trialling():
@@ -49,7 +48,7 @@
 		trial period.
 
 		If is not in a trial period, it will be `x` days from the beginning of the
-		current billing period where `x` is the billing interval from the 
+		current billing period where `x` is the billing interval from the
 		`Subscription Plan` in the `Subscription`.
 		"""
 		if self.is_trialling():
@@ -63,7 +62,7 @@
 
 	def get_billing_cycle(self):
 		"""
-		Returns a dict containing billing cycle information deduced from the 
+		Returns a dict containing billing cycle information deduced from the
 		`Subscription Plan` in the `Subscription`.
 		"""
 		return self.get_billing_cycle_data()
@@ -125,7 +124,7 @@
 		"""
 		Sets the `Subscription` `status` based on the preference set in `Subscription Settings`.
 
-		Used when the `Subscription` needs to decide what to do after the current generated 
+		Used when the `Subscription` needs to decide what to do after the current generated
 		invoice is past it's due date and grace period.
 		"""
 		subscription_settings = frappe.get_single('Subscription Settings')
@@ -262,7 +261,7 @@
 
 		# Due date
 		invoice.append(
-			'payment_schedule', 
+			'payment_schedule',
 			{
 				'due_date': add_days(self.current_invoice_end, cint(self.days_until_due)),
 				'invoice_portion': 100
@@ -276,8 +275,7 @@
 		if self.additional_discount_amount:
 			invoice.additional_discount_amount = self.additional_discount_amount
 
-		if (self.additional_discount_percentage or self.additional_discount_amount) \
-			and not self.apply_additional_discount:
+		if not self.apply_additional_discount and (self.additional_discount_percentage or self.additional_discount_amount):
 			self.apply_additional_discount = 'Grand Total'
 
 		invoice.save()
@@ -331,7 +329,7 @@
 
 	def process_for_active(self):
 		"""
-		Called by `process` if the status of the `Subscription` is 'Active'. 
+		Called by `process` if the status of the `Subscription` is 'Active'.
 		
 		The possible outcomes of this method are:
 		1. Generate a new invoice
@@ -359,8 +357,8 @@
 
 	def process_for_past_due_date(self):
 		"""
-		Called by `process` if the status of the `Subscription` is 'Past Due Date'. 
-		
+		Called by `process` if the status of the `Subscription` is 'Past Due Date'.
+
 		The possible outcomes of this method are:
 		1. Change the `Subscription` status to 'Active'
 		2. Change the `Subscription` status to 'Canceled'
diff --git a/erpnext/accounts/doctype/subscriptions/test_subscriptions.py b/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
index 627ebdd..ad1eb21 100644
--- a/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
+++ b/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
@@ -10,45 +10,48 @@
 from frappe.utils.data import nowdate, add_days, add_to_date, add_months, date_diff
 
 
+def create_plan():
+	if not frappe.db.exists('Subscription Plan', '_Test Plan Name'):
+		plan = frappe.new_doc('Subscription Plan')
+		plan.plan_name = '_Test Plan Name'
+		plan.item = '_Test Non Stock Item'
+		plan.cost = 900
+		plan.billing_interval = 'Month'
+		plan.billing_interval_count = 1
+		plan.insert()
+
+	if not frappe.db.exists('Subscription Plan', '_Test Plan Name 2'):
+		plan = frappe.new_doc('Subscription Plan')
+		plan.plan_name = '_Test Plan Name 2'
+		plan.item = '_Test Non Stock Item'
+		plan.cost = 1999
+		plan.billing_interval = 'Month'
+		plan.billing_interval_count = 1
+		plan.insert()
+
+	if not frappe.db.exists('Subscription Plan', '_Test Plan Name 3'):
+		plan = frappe.new_doc('Subscription Plan')
+		plan.plan_name = '_Test Plan Name 3'
+		plan.item = '_Test Non Stock Item'
+		plan.cost = 1999
+		plan.billing_interval = 'Day'
+		plan.billing_interval_count = 14
+		plan.insert()
+
+
+def create_subscriber():
+	if not frappe.db.exists('Subscriber', '_Test Customer'):
+		subscriber = frappe.new_doc('Subscriber')
+		subscriber.subscriber_name = '_Test Customer'
+		subscriber.customer = '_Test Customer'
+		subscriber.insert()
+
+
 class TestSubscriptions(unittest.TestCase):
-	def create_plan(self):
-		if not frappe.db.exists('Subscription Plan', '_Test Plan Name'):
-			plan = frappe.new_doc('Subscription Plan')
-			plan.plan_name = '_Test Plan Name'
-			plan.item = '_Test Non Stock Item'
-			plan.cost = 900
-			plan.billing_interval = 'Month'
-			plan.billing_interval_count = 1
-			plan.insert()
-
-		if not frappe.db.exists('Subscription Plan', '_Test Plan Name 2'):
-			plan = frappe.new_doc('Subscription Plan')
-			plan.plan_name = '_Test Plan Name 2'
-			plan.item = '_Test Non Stock Item'
-			plan.cost = 1999
-			plan.billing_interval = 'Month'
-			plan.billing_interval_count = 1
-			plan.insert()
-
-		if not frappe.db.exists('Subscription Plan', '_Test Plan Name 3'):
-			plan = frappe.new_doc('Subscription Plan')
-			plan.plan_name = '_Test Plan Name 3'
-			plan.item = '_Test Non Stock Item'
-			plan.cost = 1999
-			plan.billing_interval = 'Day'
-			plan.billing_interval_count = 14
-			plan.insert()
-
-	def create_subscriber(self):
-		if not frappe.db.exists('Subscriber', '_Test Customer'):
-			subscriber = frappe.new_doc('Subscriber')
-			subscriber.subscriber_name = '_Test Customer'
-			subscriber.customer = '_Test Customer'
-			subscriber.insert()
 
 	def setUp(self):
-		self.create_plan()
-		self.create_subscriber()
+		create_plan()
+		create_subscriber()
 
 	def test_create_subscription_with_trial_with_correct_period(self):
 		subscription = frappe.new_doc('Subscriptions')
@@ -161,7 +164,7 @@
 
 		self.assertEqual(subscription.status, 'Past Due Date')
 
-		subscription.process()	
+		subscription.process()
 		# This should change status to Canceled since grace period is 0
 		self.assertEqual(subscription.status, 'Canceled')
 
@@ -245,7 +248,7 @@
 		self.assertEqual(subscription.current_invoice_start, nowdate())
 		self.assertEqual(subscription.current_invoice_end, add_to_date(nowdate(), months=1, days=-1))
 		self.assertEqual(len(subscription.invoices), 0)
-		
+
 		subscription.process()		# no changes expected still
 		self.assertEqual(subscription.status, 'Active')
 		self.assertEqual(subscription.current_invoice_start, nowdate())
@@ -358,7 +361,7 @@
 		self.assertEqual(subscription.status, 'Past Due Date')
 		self.assertEqual(len(subscription.invoices), invoices)
 
-		subscription.cancel_subscription()	
+		subscription.cancel_subscription()
 		self.assertEqual(subscription.status, 'Canceled')
 		self.assertEqual(len(subscription.invoices), invoices)