[fix] [minor] pull credit days from customer, update credit days in account of customer
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 87afd74..c9059cc 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -250,10 +250,15 @@
 
 	def get_cust_and_due_date(self):
 		"""Set Due Date = Posting Date + Credit Days"""
+		if self.doc.debit_to:
+			self.doc.customer = webnotes.conn.get_value('Account', self.doc.debit_to, 'master_name')
+			
 		if self.doc.posting_date:
 			credit_days = 0
 			if self.doc.debit_to:
 				credit_days = webnotes.conn.get_value("Account", self.doc.debit_to, "credit_days")
+			if self.doc.customer and not credit_days:
+				credit_days = webnotes.conn.get_value("Customer", self.doc.customer, "credit_days")
 			if self.doc.company and not credit_days:
 				credit_days = webnotes.conn.get_value("Company", self.doc.company, "credit_days")
 				
@@ -261,9 +266,6 @@
 				self.doc.due_date = add_days(self.doc.posting_date, credit_days)
 			else:
 				self.doc.due_date = self.doc.posting_date
-		
-		if self.doc.debit_to:
-			self.doc.customer = webnotes.conn.get_value('Account',self.doc.debit_to,'master_name')
 
 	def get_barcode_details(self, barcode):
 		return get_obj('Sales Common').get_barcode_details(barcode)
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index f516ef2..2eabf12 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -77,9 +77,9 @@
 			msgprint("Please Select Company under which you want to create account head")
 
 	def update_credit_days_limit(self):
-		sql("""update tabAccount set credit_days = %s, credit_limit = %s 
-			where name = %s""", (self.doc.credit_days or 0, self.doc.credit_limit or 0, 
-				self.doc.name + " - " + self.get_company_abbr()))
+		webnotes.conn.sql("""update tabAccount set credit_days = %s, credit_limit = %s 
+			where master_type='Customer' and master_name = %s""", 
+			(self.doc.credit_days or 0, self.doc.credit_limit or 0, self.doc.name))
 
 	def create_lead_address_contact(self):
 		if self.doc.lead_name: