from dbConn import conn, cursor
from custInfo import getID, getInv

address = "46523 INVERNESS"
date = '20140611'
getCCID = getID(address, date)
# if (getCCID == '') or (getCCID == None) or len(getCCID) < 2:
	# print 'not found'
# else:
	# print "'"+getID(address, date) + "'"

# return ('MS5618', '725908', 'HC')
print getInv("77433")
# return ('', 'JM7840', 'IW')
						pos-=1
					pos+=1
				
				for result in tempList:	
					#get invoice info 
					invNumber = getInv(result)
					
					if invNumber != None:
						invNumberFromInv =  str(invNumber[0])
						salesPersonFromInv = str(invNumber[2])					
				
					# check if no customerCode, then check database to retrieve one
					if record[2] == '': 
						address = str(record[8])
						date = str(record[16])
						getCCID = getID(address, date)
						
						if (getCCID == '') or (getCCID == None) or len(getCCID) < 2:
							# check invoice # if customerCode can be found for the last time!!
							if invNumber == None:
								invNumberResult = "CC Not Found!"
							else:
								# add CC if found after search using invNumber
								record[2] = str(invNumber[1])
							
						else:
							ccID = getID(address, date)[0]
							record[2] = ccID
						
					# don't write to file if Salesperson is 'RM'
					if not "RM" in salesPersonFromInv and not len(salesPersonFromInv) > 2: