fix: Share existing condition logic
diff --git a/erpnext/accounts/doctype/share_transfer/share_transfer.py b/erpnext/accounts/doctype/share_transfer/share_transfer.py
index 456f2ba..65f248e 100644
--- a/erpnext/accounts/doctype/share_transfer/share_transfer.py
+++ b/erpnext/accounts/doctype/share_transfer/share_transfer.py
@@ -109,12 +109,12 @@
 		if self.transfer_type == 'Issue':
 			# validate share doesn't exist in company
 			ret_val = self.share_exists(self.get_company_shareholder().name)
-			if ret_val:
+			if ret_val in ('Complete', 'Partial'):
 				frappe.throw(_('The shares already exist'), frappe.DuplicateEntryError)
 		else:
 			# validate share exists with from_shareholder
 			ret_val = self.share_exists(self.from_shareholder)
-			if not ret_val:
+			if ret_val in ('Outside', 'Partial'):
 				frappe.throw(_("The shares don't exist with the {0}")
 					.format(self.from_shareholder), ShareDontExists)
 
@@ -159,11 +159,13 @@
 				entry.to_no < self.from_no:
 				continue # since query lies outside bounds
 			elif entry.from_no <= self.from_no and entry.to_no >= self.to_no: #both inside
-				return True # absolute truth!
-			elif (entry.from_no <= self.from_no <= self.to_no) or entry.from_no <= self.to_no and entry.to_no:
-				return True
+				return 'Complete' # absolute truth!
+			elif entry.from_no <= self.from_no <= self.to_no:
+				return 'Partial'
+			elif entry.from_no <= self.to_no <= entry.to_no:
+				return 'Partial'
 
-		return False
+		return 'Outside'
 
 	def folio_no_validation(self):
 		shareholders = ['from_shareholder', 'to_shareholder']
diff --git a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py
index 910dfd0..2ff9b02 100644
--- a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py
+++ b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py
@@ -15,73 +15,73 @@
 		frappe.db.sql("delete from `tabShare Balance`")
 		share_transfers = [
 			{
-				"doctype"					 : "Share Transfer",
-				"transfer_type"				 : "Issue",
-				"date"						 : "2018-01-01",
-				"to_shareholder"			 : "SH-00001",
-				"share_type"				 : "Equity",
-				"from_no"					 : 1,
-				"to_no"						 : 500,
-				"no_of_shares"				 : 500,
-				"rate"						 : 10,
-				"company"					 : "_Test Company",
-				"asset_account"				 : "Cash - _TC",
+				"doctype": "Share Transfer",
+				"transfer_type": "Issue",
+				"date": "2018-01-01",
+				"to_shareholder": "SH-00001",
+				"share_type": "Equity",
+				"from_no": 1,
+				"to_no": 500,
+				"no_of_shares": 500,
+				"rate": 10,
+				"company": "_Test Company",
+				"asset_account": "Cash - _TC",
 				"equity_or_liability_account": "Creditors - _TC"
 			},
 			{
-				"doctype"					 : "Share Transfer",
-				"transfer_type"				 : "Transfer",
-				"date"						 : "2018-01-02",
-				"from_shareholder"			 : "SH-00001",
-				"to_shareholder"			 : "SH-00002",
-				"share_type"				 : "Equity",
-				"from_no"					 : 101,
-				"to_no"						 : 200,
-				"no_of_shares"				 : 100,
-				"rate"						 : 15,
-				"company"					 : "_Test Company",
+				"doctype": "Share Transfer",
+				"transfer_type": "Transfer",
+				"date": "2018-01-02",
+				"from_shareholder": "SH-00001",
+				"to_shareholder": "SH-00002",
+				"share_type": "Equity",
+				"from_no": 101,
+				"to_no": 200,
+				"no_of_shares": 100,
+				"rate": 15,
+				"company": "_Test Company",
 				"equity_or_liability_account": "Creditors - _TC"
 			},
 			{
-				"doctype"					 : "Share Transfer",
-				"transfer_type"				 : "Transfer",
-				"date"						 : "2018-01-03",
-				"from_shareholder"			 : "SH-00001",
-				"to_shareholder"			 : "SH-00003",
-				"share_type"				 : "Equity",
-				"from_no"					 : 201,
-				"to_no"						 : 500,
-				"no_of_shares"				 : 300,
-				"rate"						 : 20,
-				"company"					 : "_Test Company",
+				"doctype": "Share Transfer",
+				"transfer_type": "Transfer",
+				"date": "2018-01-03",
+				"from_shareholder": "SH-00001",
+				"to_shareholder": "SH-00003",
+				"share_type": "Equity",
+				"from_no": 201,
+				"to_no": 500,
+				"no_of_shares": 300,
+				"rate": 20,
+				"company": "_Test Company",
 				"equity_or_liability_account": "Creditors - _TC"
 			},
 			{
-				"doctype"					 : "Share Transfer",
-				"transfer_type"				 : "Transfer",
-				"date"						 : "2018-01-04",
-				"from_shareholder"			 : "SH-00003",
-				"to_shareholder"			 : "SH-00002",
-				"share_type"				 : "Equity",
-				"from_no"					 : 201,
-				"to_no"						 : 400,
-				"no_of_shares"				 : 200,
-				"rate"						 : 15,
-				"company"					 : "_Test Company",
+				"doctype": "Share Transfer",
+				"transfer_type": "Transfer",
+				"date": "2018-01-04",
+				"from_shareholder": "SH-00003",
+				"to_shareholder": "SH-00002",
+				"share_type": "Equity",
+				"from_no": 201,
+				"to_no": 400,
+				"no_of_shares": 200,
+				"rate": 15,
+				"company": "_Test Company",
 				"equity_or_liability_account": "Creditors - _TC"
 			},
 			{
-				"doctype"					 : "Share Transfer",
-				"transfer_type"				 : "Purchase",
-				"date"						 : "2018-01-05",
-				"from_shareholder"			 : "SH-00003",
-				"share_type"				 : "Equity",
-				"from_no"					 : 401,
-				"to_no"						 : 500,
-				"no_of_shares"				 : 100,
-				"rate"						 : 25,
-				"company"					 : "_Test Company",
-				"asset_account"				 : "Cash - _TC",
+				"doctype": "Share Transfer",
+				"transfer_type": "Purchase",
+				"date": "2018-01-05",
+				"from_shareholder": "SH-00003",
+				"share_type": "Equity",
+				"from_no": 401,
+				"to_no": 500,
+				"no_of_shares": 100,
+				"rate": 25,
+				"company": "_Test Company",
+				"asset_account": "Cash - _TC",
 				"equity_or_liability_account": "Creditors - _TC"
 			}
 		]
@@ -91,33 +91,33 @@
 
 	def test_invalid_share_transfer(self):
 		doc = frappe.get_doc({
-			"doctype"					 : "Share Transfer",
-			"transfer_type"				 : "Transfer",
-			"date"						 : "2018-01-05",
-			"from_shareholder"			 : "SH-00003",
-			"to_shareholder"			 : "SH-00002",
-			"share_type"				 : "Equity",
-			"from_no"					 : 1,
-			"to_no"						 : 100,
-			"no_of_shares"				 : 100,
-			"rate"						 : 15,
-			"company"					 : "_Test Company",
+			"doctype": "Share Transfer",
+			"transfer_type": "Transfer",
+			"date": "2018-01-05",
+			"from_shareholder": "SH-00003",
+			"to_shareholder": "SH-00002",
+			"share_type": "Equity",
+			"from_no": 1,
+			"to_no": 100,
+			"no_of_shares": 100,
+			"rate": 15,
+			"company": "_Test Company",
 			"equity_or_liability_account": "Creditors - _TC"
 		})
 		self.assertRaises(ShareDontExists, doc.insert)
 
 		doc = frappe.get_doc({
-			"doctype"					 : "Share Transfer",
-			"transfer_type"				 : "Purchase",
-			"date"						 : "2018-01-02",
-			"from_shareholder"			 : "SH-00001",
-			"share_type"				 : "Equity",
-			"from_no"					 : 1,
-			"to_no"						 : 200,
-			"no_of_shares"				 : 200,
-			"rate"						 : 15,
-			"company"					 : "_Test Company",
-			"asset_account"				 : "Cash - _TC",
+			"doctype": "Share Transfer",
+			"transfer_type": "Purchase",
+			"date": "2018-01-02",
+			"from_shareholder": "SH-00001",
+			"share_type": "Equity",
+			"from_no": 1,
+			"to_no": 200,
+			"no_of_shares": 200,
+			"rate": 15,
+			"company": "_Test Company",
+			"asset_account": "Cash - _TC",
 			"equity_or_liability_account": "Creditors - _TC"
 		})
 		self.assertRaises(ShareDontExists, doc.insert)