diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 2a277ee..186dbb5 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -341,8 +341,7 @@
 		"erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.automatic_synchronization",
 		"erpnext.projects.doctype.project.project.hourly_reminder",
 		"erpnext.projects.doctype.project.project.collect_project_status",
-		"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
-		"erpnext.support.doctype.service_level_agreement.service_level_agreement.set_service_level_agreement_variance"
+		"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts"
 	],
 	"hourly_long": [
 		"erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.repost_entries"
diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
index a25608b..8646402 100644
--- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
@@ -10,7 +10,6 @@
 from frappe.model.document import Document
 from frappe.utils import (
 	add_to_date,
-	cint,
 	get_datetime,
 	get_datetime_str,
 	get_link_to_form,
@@ -350,86 +349,113 @@
 
 def apply(doc, method=None):
 	# Applies SLA to document on validate
-	if frappe.flags.in_patch or frappe.flags.in_migrate or frappe.flags.in_install or frappe.flags.in_setup_wizard or \
-		doc.doctype not in get_documents_with_active_service_level_agreement():
+	if (
+		frappe.flags.in_patch
+		or frappe.flags.in_migrate
+		or frappe.flags.in_install
+		or frappe.flags.in_setup_wizard
+		or doc.doctype not in get_documents_with_active_service_level_agreement()
+	):
 		return
 
 	service_level_agreement = get_active_service_level_agreement_for(doc)
 
-	print(service_level_agreement)
-
 	if not service_level_agreement:
 		return
 
-	set_sla_properties(doc, service_level_agreement)
+	process_sla(doc, service_level_agreement)
 
 
-def set_sla_properties(doc, service_level_agreement):
-	if frappe.db.exists(doc.doctype, doc.name):
-		from_db = frappe.get_doc(doc.doctype, doc.name)
-	else:
-		from_db = frappe._dict({})
-
-	meta = frappe.get_meta(doc.doctype)
-
-	if meta.has_field("customer") and service_level_agreement.customer and doc.get("customer") and \
-		not service_level_agreement.customer == doc.get("customer"):
-		frappe.throw(_("Service Level Agreement {0} is specific to Customer {1}").format(service_level_agreement.name,
-			service_level_agreement.customer))
-
-	doc.service_level_agreement = service_level_agreement.name
-	doc.priority = doc.get("priority") or service_level_agreement.default_priority
-	priority = get_priority(doc)
+def process_sla(doc, service_level_agreement):
 
 	if not doc.creation:
 		doc.creation = now_datetime(doc.get("owner"))
-
-		if meta.has_field("service_level_agreement_creation"):
+		if doc.meta.has_field("service_level_agreement_creation"):
 			doc.service_level_agreement_creation = now_datetime(doc.get("owner"))
 
+	doc.service_level_agreement = service_level_agreement.name
+	doc.priority = doc.get("priority") or service_level_agreement.default_priority
+
+	prev_status = frappe.db.get_value(doc.doctype, doc.name, 'status')
+	handle_status_change(doc, prev_status, service_level_agreement.apply_sla_for_resolution)
+	update_response_and_resolution_metrics(doc, service_level_agreement.apply_sla_for_resolution)
+	update_agreement_status(doc, service_level_agreement.apply_sla_for_resolution)
+
+
+def update_response_and_resolution_metrics(doc, apply_sla_for_resolution):
+	priority = get_response_and_resolution_duration(doc)
 	start_date_time = get_datetime(doc.get("service_level_agreement_creation") or doc.creation)
-
-	set_response_by_and_variance(doc, meta, start_date_time, priority)
-	if service_level_agreement.apply_sla_for_resolution:
-		set_resolution_by_and_variance(doc, meta, start_date_time, priority)
-
-	update_status(doc, from_db, meta)
+	set_response_by_and_variance(doc, start_date_time, priority)
+	if apply_sla_for_resolution:
+		set_resolution_by_and_variance(doc, start_date_time, priority)
 
 
-def update_status(doc, from_db, meta):
-	if meta.has_field("status"):
-		if meta.has_field("first_responded_on") and doc.status != "Open" and \
-			from_db.status == "Open" and not doc.first_responded_on:
+def get_fulfillment_statuses(service_level_agreement):
+	return [entry.status for entry in frappe.db.get_all("SLA Fulfilled On Status", filters={
+		"parent": service_level_agreement
+	}, fields=["status"])]
+
+
+def get_hold_statuses(service_level_agreement):
+	return [entry.status for entry in frappe.db.get_all("Pause SLA On Status", filters={
+		"parent": service_level_agreement
+	}, fields=["status"])]
+
+
+def handle_status_change(doc, prev_status, apply_sla_for_resolution):
+
+	if doc.status != "Open" and prev_status == "Open":
+		# status changed from Open to something else
+		if doc.meta.has_field("first_responded_on") and not doc.first_responded_on:
+			# status changed to something other than Open
 			doc.first_responded_on = frappe.flags.current_time or now_datetime(doc.get("owner"))
 
-		if meta.has_field("service_level_agreement") and doc.service_level_agreement:
-			# mark sla status as fulfilled based on the configuration
-			fulfillment_statuses = [entry.status for entry in frappe.db.get_all("SLA Fulfilled On Status", filters={
-				"parent": doc.service_level_agreement
-			}, fields=["status"])]
+	if doc.status == "Open" and prev_status != "Open":
+		# status changed from something else to Open
+		reset_resolution_metrics(doc)
 
-			if doc.status in fulfillment_statuses and from_db.status not in fulfillment_statuses:
-				apply_sla_for_resolution = frappe.db.get_value("Service Level Agreement", doc.service_level_agreement,
-					"apply_sla_for_resolution")
+	handle_fulfillment_status(doc, prev_status, apply_sla_for_resolution)
+	handle_hold_status(doc, prev_status)
 
-				if apply_sla_for_resolution and meta.has_field("resolution_date"):
-					doc.resolution_date = frappe.flags.current_time or now_datetime(doc.get("owner"))
 
-				if meta.has_field("agreement_status") and from_db.agreement_status == "Ongoing":
-					set_service_level_agreement_variance(doc.doctype, doc.name)
-					update_agreement_status(doc, meta)
+def handle_fulfillment_status(doc, prev_status, apply_sla_for_resolution):
+	fulfillment_statuses = get_fulfillment_statuses(doc.service_level_agreement)
+	if (
+		doc.status in fulfillment_statuses
+		and prev_status not in fulfillment_statuses
+		and apply_sla_for_resolution
+	):
+		# status changed to any fulfillment_statuses
+		if doc.meta.has_field("resolution_date"):
+			doc.resolution_date = frappe.flags.current_time or now_datetime(doc.get("owner"))
+		if doc.meta.has_field("resolution_time"):
+			doc.resolution_time = time_diff_in_seconds(doc.resolution_date, doc.creation)
+		set_user_resolution_time(doc)
 
-				if apply_sla_for_resolution:
-					set_resolution_time(doc, meta)
-					set_user_resolution_time(doc, meta)
 
-		if doc.status == "Open" and from_db.status != "Open":
-			# if no date, it should be set as None and not a blank string "", as per mysql strict config
-			# enable SLA and variance on Reopen
-			reset_metrics(doc, meta)
-			set_service_level_agreement_variance(doc.doctype, doc.name)
+def handle_hold_status(doc, prev_status):
+	hold_statuses = get_hold_statuses(doc.service_level_agreement)
+	if doc.status in hold_statuses:
+		# reset if status is a hold status, regardless of previous status
+		reset_expected_response_and_resolution(doc)
+		if prev_status not in hold_statuses:
+			# set on_hold_since status changed from any non-hold status
+			# for eg. doc.status changed from Open to Replied
+			if doc.meta.has_field("on_hold_since"):
+				doc.on_hold_since = frappe.flags.current_time or now_datetime(doc.get("owner"))
 
-	handle_hold_time(doc, meta, from_db.status)
+	if doc.status not in hold_statuses and prev_status in hold_statuses:
+		# status changed to any non-hold status
+		# for eg. doc.status changed from Replied to Closed
+		if doc.meta.has_field("on_hold_since") and doc.on_hold_since:
+			cumulate_hold_time(doc)
+			doc.on_hold_since = None
+
+
+def cumulate_hold_time(doc):
+	now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
+	on_hold_duration = time_diff_in_seconds(now_time, doc.on_hold_since)
+	doc.total_hold_time = (doc.total_hold_time or 0) + on_hold_duration
 
 
 def get_expected_time_for(parameter, service_level, start_date_time):
@@ -500,41 +526,9 @@
 	return support_days
 
 
-def set_service_level_agreement_variance(doctype, doc=None):
-
-	filters = {"status": "Open", "agreement_status": "Ongoing"}
-
-	if doc:
-		filters = {"name": doc}
-
-	for entry in frappe.get_all(doctype, filters=filters):
-		current_doc = frappe.get_doc(doctype, entry.name)
-		current_time = frappe.flags.current_time or now_datetime(current_doc.get("owner"))
-		apply_sla_for_resolution = frappe.db.get_value("Service Level Agreement", current_doc.service_level_agreement,
-			"apply_sla_for_resolution")
-
-		if not current_doc.first_responded_on: # first_responded_on set when first reply is sent to customer
-			variance = round(time_diff_in_seconds(current_doc.response_by, current_time), 2)
-		else:
-			variance = round(time_diff_in_seconds(current_doc.response_by, current_doc.first_responded_on), 2)
-
-		frappe.db.set_value(current_doc.doctype, current_doc.name, "response_by_variance", variance, update_modified=False)
-		if variance < 0:
-			frappe.db.set_value(current_doc.doctype, current_doc.name, "agreement_status", "Failed", update_modified=False)
-
-		if apply_sla_for_resolution and not current_doc.get("resolution_date"): # resolution_date set when issue has been closed
-			variance = round(time_diff_in_seconds(current_doc.resolution_by, current_time), 2)
-		elif apply_sla_for_resolution and current_doc.get("resolution_date"):
-			variance = round(time_diff_in_seconds(current_doc.resolution_by, current_doc.get("resolution_date")), 2)
-
-		frappe.db.set_value(current_doc.doctype, current_doc.name, "resolution_by_variance", variance, update_modified=False)
-		if variance < 0:
-			frappe.db.set_value(current_doc.doctype, current_doc.name, "agreement_status", "Failed", update_modified=False)
-
-
-def set_user_resolution_time(doc, meta):
+def set_user_resolution_time(doc):
 	# total time taken by a user to close the issue apart from wait_time
-	if not meta.has_field("user_resolution_time"):
+	if not doc.meta.has_field("user_resolution_time"):
 		return
 
 	communications = frappe.get_all("Communication", filters={
@@ -567,7 +561,7 @@
 			frappe.msgprint(_("Service Level Agreement has been changed to {0}.").format(self.service_level_agreement))
 
 
-def get_priority(doc):
+def get_response_and_resolution_duration(doc):
 	service_level_agreement = frappe.get_doc("Service Level Agreement", doc.service_level_agreement)
 	priority = service_level_agreement.get_service_level_agreement_priority(doc.priority)
 	priority.update({
@@ -596,115 +590,81 @@
 	doc.save()
 
 
-def reset_metrics(doc, meta):
-	if meta.has_field("resolution_date"):
+def reset_resolution_metrics(doc):
+	if doc.meta.has_field("resolution_date"):
 		doc.resolution_date = None
 
-	if not meta.has_field("resolution_time"):
+	if doc.meta.has_field("resolution_time"):
 		doc.resolution_time = None
 
-	if not meta.has_field("user_resolution_time"):
+	if doc.meta.has_field("user_resolution_time"):
 		doc.user_resolution_time = None
 
-	if meta.has_field("agreement_status"):
+	if doc.meta.has_field("agreement_status"):
 		doc.agreement_status = "Ongoing"
 
 
-def set_resolution_time(doc, meta):
-	# total time taken from issue creation to closing
-	if not meta.has_field("resolution_time"):
-		return
-
-	doc.resolution_time = time_diff_in_seconds(doc.resolution_date, doc.creation)
-
-
 # called via hooks on communication update
 def update_hold_time(doc, status):
+	if doc.communication_type == "Comment" or doc.sent_or_received != "Received":
+		return
+
 	parent = get_parent_doc(doc)
 	if not parent:
 		return
 
-	if doc.communication_type == "Comment":
+	if not parent.meta.has_field('service_level_agreement'):
 		return
 
-	status_field = parent.meta.get_field("status")
-	if status_field:
-		options = (status_field.options or "").splitlines()
+	apply_sla_for_resolution = frappe.db.get_value('Service Level Agreement', parent.service_level_agreement, 'apply_sla_for_resolution')
 
-		# if status has a "Replied" option, then handle hold time
-		if ("Replied" in options) and doc.sent_or_received == "Received":
-			meta = frappe.get_meta(parent.doctype)
-			handle_hold_time(parent, meta, 'Replied')
+	handle_status_change(parent, 'Replied', apply_sla_for_resolution)
+	update_response_and_resolution_metrics(parent, apply_sla_for_resolution)
+	update_agreement_status(parent, apply_sla_for_resolution)
+
+	parent.save()
 
 
-def handle_hold_time(doc, meta, status):
-	if meta.has_field("service_level_agreement") and doc.service_level_agreement:
-		# set response and resolution variance as None as the issue is on Hold for status as Replied
-		hold_statuses = [entry.status for entry in frappe.db.get_all("Pause SLA On Status", filters={
-				"parent": doc.service_level_agreement
-			}, fields=["status"])]
+def reset_expected_response_and_resolution(doc):
+	update_values = {}
 
-		if not hold_statuses:
-			return
-
-		if meta.has_field("status") and doc.status in hold_statuses and status not in hold_statuses:
-			apply_hold_status(doc, meta)
-
-		# calculate hold time when status is changed from any hold status to any non-hold status
-		if meta.has_field("status") and doc.status not in hold_statuses and status in hold_statuses:
-			reset_hold_status_and_update_hold_time(doc, meta)
-
-
-def apply_hold_status(doc, meta):
-	update_values = {'on_hold_since': frappe.flags.current_time or now_datetime(doc.get("owner"))}
-
-	if meta.has_field("first_responded_on") and not doc.first_responded_on:
+	if doc.meta.has_field("first_responded_on") and not doc.first_responded_on:
 		update_values['response_by'] = None
 		update_values['response_by_variance'] = 0
 
-	update_values['resolution_by'] = None
-	update_values['resolution_by_variance'] = 0
+	if doc.meta.has_field("resolution_by") and not doc.resolution_date:
+		update_values['resolution_by'] = None
+		update_values['resolution_by_variance'] = 0
 
 	doc.db_set(update_values)
 
 
-def reset_hold_status_and_update_hold_time(doc, meta):
-	hold_time = doc.total_hold_time if meta.has_field("total_hold_time") and doc.total_hold_time else 0
-	now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
-	last_hold_time = 0
-	update_values = {}
+def set_response_by_and_variance(doc, start_date_time, priority):
+	if doc.meta.has_field("response_by"):
+		doc.response_by = get_expected_time_for(parameter="response", service_level=priority, start_date_time=start_date_time)
+		if doc.meta.has_field("total_hold_time") and doc.total_hold_time:
+			doc.response_by = add_to_date(doc.response_by, seconds=round(doc.total_hold_time))
 
-	if meta.has_field("on_hold_since") and doc.on_hold_since:
-		# last_hold_time will be added to the sla variables
-		last_hold_time = time_diff_in_seconds(now_time, doc.on_hold_since)
-		update_values['total_hold_time'] = hold_time + last_hold_time
+	if doc.meta.has_field("response_by_variance") and not doc.get('first_responded_on'):
+		now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
+		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, now_time), 2)
 
-	# re-calculate SLA variables after issue changes from any hold status to any non-hold status
-	start_date_time = get_datetime(doc.get("service_level_agreement_creation") or doc.creation)
-	priority = get_priority(doc)
-	now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
+	if doc.meta.has_field("response_by_variance") and doc.get('first_responded_on'):
+		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, doc.get('first_responded_on')), 2)
 
-	# add hold time to response by variance
-	if meta.has_field("first_responded_on") and not doc.first_responded_on:
-		response_by = get_expected_time_for(parameter="response", service_level=priority, start_date_time=start_date_time)
-		response_by = add_to_date(response_by, seconds=round(last_hold_time))
-		response_by_variance = round(time_diff_in_seconds(response_by, now_time))
 
-		update_values['response_by'] = response_by
-		update_values['response_by_variance'] = response_by_variance + last_hold_time
+def set_resolution_by_and_variance(doc, start_date_time, priority):
+	if doc.meta.has_field("resolution_by"):
+		doc.resolution_by = get_expected_time_for(parameter="resolution", service_level=priority, start_date_time=start_date_time)
+		if doc.meta.has_field("total_hold_time") and doc.total_hold_time:
+			doc.resolution_by = add_to_date(doc.resolution_by, seconds=round(doc.total_hold_time))
 
-	# add hold time to resolution by variance
-	if frappe.db.get_value("Service Level Agreement", doc.service_level_agreement, "apply_sla_for_resolution"):
-		resolution_by = get_expected_time_for(parameter="resolution", service_level=priority, start_date_time=start_date_time)
-		resolution_by = add_to_date(resolution_by, seconds=round(last_hold_time))
-		resolution_by_variance = round(time_diff_in_seconds(resolution_by, now_time))
+	if doc.meta.has_field("resolution_by_variance") and not doc.get("resolution_date"):
+		now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
+		doc.resolution_by_variance = round(time_diff_in_seconds(doc.resolution_by, now_time), 2)
 
-		update_values['resolution_by'] = resolution_by
-		update_values['resolution_by_variance'] = resolution_by_variance + last_hold_time
-
-	update_values['on_hold_since'] = None
-
-	doc.db_set(update_values)
+	if doc.meta.has_field("resolution_by_variance") and doc.get('resolution_date'):
+		doc.resolution_by_variance = round(time_diff_in_seconds(doc.resolution_by, doc.get('resolution_date')), 2)
 
 
 def get_service_level_agreement_fields():
@@ -808,45 +768,37 @@
 
 	meta = frappe.get_meta(doc.doctype)
 	now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
-	if meta.has_field("first_responded_on") and not doc.first_responded_on:
+	if doc.meta.has_field("first_responded_on") and not doc.first_responded_on:
 		# first_responded_on set when first reply is sent to customer
 		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, now_time), 2)
 
-	if meta.has_field("first_responded_on") and doc.first_responded_on:
+	if doc.meta.has_field("first_responded_on") and doc.first_responded_on:
 		# first_responded_on set when first reply is sent to customer
 		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, doc.first_responded_on), 2)
 
-	if meta.has_field("resolution_date") and not doc.resolution_date:
+	if doc.meta.has_field("resolution_date") and not doc.resolution_date:
 		# resolution_date set when issue has been closed
 		doc.resolution_by_variance = round(time_diff_in_seconds(doc.resolution_by, now_time), 2)
 
-	if meta.has_field("resolution_date") and doc.resolution_date:
+	if doc.meta.has_field("resolution_date") and doc.resolution_date:
 		# resolution_date set when issue has been closed
 		doc.resolution_by_variance = round(time_diff_in_seconds(doc.resolution_by, doc.resolution_date), 2)
 
-	if meta.has_field("agreement_status"):
+	if doc.meta.has_field("agreement_status"):
 		doc.agreement_status = "Fulfilled" if doc.response_by_variance > 0 and doc.resolution_by_variance > 0 else "Failed"
 
 
-def update_agreement_status(doc, meta):
-	if meta.has_field("service_level_agreement") and meta.has_field("agreement_status") and \
-		doc.service_level_agreement and doc.agreement_status == "Ongoing":
-
-		apply_sla_for_resolution = frappe.db.get_value("Service Level Agreement", doc.service_level_agreement,
-			"apply_sla_for_resolution")
-
+def update_agreement_status(doc, apply_sla_for_resolution):
+	if (doc.meta.has_field("agreement_status")):
 		# if SLA is applied for resolution check for response and resolution, else only response
 		if apply_sla_for_resolution:
-			if meta.has_field("response_by_variance") and meta.has_field("resolution_by_variance"):
-				if cint(frappe.db.get_value(doc.doctype, doc.name, "response_by_variance")) < 0 or \
-					cint(frappe.db.get_value(doc.doctype, doc.name, "resolution_by_variance")) < 0:
-
+			if doc.meta.has_field("response_by_variance") and doc.meta.has_field("resolution_by_variance"):
+				if doc.response_by_variance < 0 or doc.resolution_by_variance < 0:
 					doc.agreement_status = "Failed"
 				else:
 					doc.agreement_status = "Fulfilled"
 		else:
-			if meta.has_field("response_by_variance") and \
-				cint(frappe.db.get_value(doc.doctype, doc.name, "response_by_variance")) < 0:
+			if doc.meta.has_field("response_by_variance") and doc.response_by_variance < 0:
 				doc.agreement_status = "Failed"
 			else:
 				doc.agreement_status = "Fulfilled"
@@ -862,25 +814,6 @@
 	return datetime.timedelta(hours=time.hour, minutes=time.minute, seconds=time.second)
 
 
-def set_response_by_and_variance(doc, meta, start_date_time, priority):
-	if meta.has_field("response_by"):
-		doc.response_by = get_expected_time_for(parameter="response", service_level=priority, start_date_time=start_date_time)
-
-	if meta.has_field("response_by_variance") and not doc.get('first_responded_on'):
-		now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
-		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, now_time), 2)
-	elif meta.has_field("response_by_variance") and doc.get('first_responded_on'):
-		doc.response_by_variance = round(time_diff_in_seconds(doc.response_by, doc.get('first_responded_on')), 2)
-
-def set_resolution_by_and_variance(doc, meta, start_date_time, priority):
-	if meta.has_field("resolution_by"):
-		doc.resolution_by = get_expected_time_for(parameter="resolution", service_level=priority, start_date_time=start_date_time)
-
-	if meta.has_field("resolution_by_variance") and not doc.get("resolution_date"):
-		now_time = frappe.flags.current_time or now_datetime(doc.get("owner"))
-		doc.resolution_by_variance = round(time_diff_in_seconds(doc.resolution_by, now_time), 2)
-
-
 def now_datetime(user):
 	dt = convert_utc_to_user_timezone(datetime.utcnow(), user)
 	return dt.replace(tzinfo=None)
