def find_program_date(self): sql_request = 'SELECT date FROM jobs WHERE number="%s"' % (self.job_in) if exists(sql_request): data = pull_data(sql_request) return data[0][0] else: return None
def cc_acct(self): sql_request = 'SELECT full FROM cc_accts WHERE short="%s"' % (self.account) data = pull_data(sql_request) try: return data[0][0] except: raise Exception('CC Acct error: ', sql_request)
def find_short_job(self, job_in): sql_request = 'SELECT short FROM jobs WHERE number="%s"' % (job_in) if exists(sql_request): data = pull_data(sql_request) return data[0][0] else: self.missing_job = job_in return None
def find_location(self): sql_request = 'SELECT location FROM jobs WHERE number="%s"' % (self.job_in) data = pull_data(sql_request) try: return data[0][0] except: subjob_builder([self.job_in]) return None
def find_client(self, full_job): ''' Determines which client a job is associated with based on prefix. ''' if full_job: sql_request = 'SELECT full FROM clients WHERE short="%s"' % (full_job[:3]) if exists(sql_request): data = pull_data(sql_request) return data[0][0]
def find_person_class(self, person): ''' Returns a person's QB class based on full name ''' sql_request = 'SELECT quickbooks FROM names WHERE full="%s"' % (person) if exists(sql_request): data = pull_data(sql_request) return data[0][0] return 'ERROR'
def find_person(self, person): ''' Returns a person's full name, and QB class based on Amex name. ''' sql_request = 'SELECT Full, Quickbooks FROM names WHERE Airline="%s"' % (person) if exists(sql_request): data = pull_data(sql_request) return data[0] raise Exception('Add %s to the Name-Class Array' % (person))
def find_full_job_name_from_short(self, short_job): ''' Converts short job name --> long job name EXAMPLE: "KEM-P6189" --> "KEM-P6189 Norco bioequivalence" ''' if short_job == '-': return None sql_request = 'SELECT full FROM jobs WHERE Short="%s"' % (short_job) if exists(sql_request): data = pull_data(sql_request) return data[0][0] else: return None
def find_full_job_name(self, job_in): ''' Converts short job name --> long job name EXAMPLE: "P6189" --> "KEM-P6189 Norco bioequivalence" ''' if job_in == '-': return None sql_request = 'SELECT full FROM jobs WHERE number="%s"' % (job_in) if exists(sql_request): data = pull_data(sql_request) return data[0][0] else: return None
def create_gl_out(self, gl_in, client): ''' This method returns a string that is the final input into QB EXAMPLE: 'Fees' and 'XYZ Pharma' --> 'Meeting Costs:Fees:XYZ Pharma' ''' if gl_in == '': return None sql_request = 'SELECT full FROM general_ledger WHERE short="%s"' % (gl_in) data = pull_data(sql_request) if not data: raise Exception('GL issue with ', gl_in) gl_full = data[0][0] if client: return gl_full + client else: return gl_full