def deposit_amount(self, amount, customer: Customer): daoObj = TransactionDAO() if customer != None and amount > 0: flagDeposited = daoObj.deposit_amount(amount, customer) if flagDeposited: customer.set_account_balance(customer.get_account_balance() + amount) return customer
def delete_payee(self, customer: Customer, payee_account): daoObj = PayeeDAO() flagDeleted = daoObj.delete_payee(payee_account) if flagDeleted: for payees in customer.get_payees(): if payees.get_account_number() == payee_account: customer.remove_payee(payees) return customer return customer
def add_payee(self, customer: Customer, payee: Payee): daoObj = PayeeDAO() if customer == None or payee == None: print( "Unable to add Payee, returned from service, either customer or payee is None" ) return customer flag_payee_added = daoObj.add_payee(customer, payee) if flag_payee_added: print("payee added successfully") customer.add_payee(payee) return customer else: print("payee was not added, due to some problem in DAO") return customer
def transfer_amount(self, amount, customer: Customer, payee_account_number): daoObj = TransactionDAO() if customer == None and amount <= 0 and payee_account_number == None: print( "Unable to transfer amount, either Customer, payee or amount to transfer is none" ) return customer flag_tranfered = daoObj.transfer_amount(amount, customer, payee_account_number) if flag_tranfered: customer.set_account_balance(customer.get_account_balance() - amount) return customer
def set_forgot_password(self, Customer): found = False account_number = Customer.get_account_number() account_password = Customer.get_account_password() dbObj = MySQLDB() con = dbObj.get_connection() updateStatement = "UPDATE customer set account_password = '******' where account_no=" + str(account_number) cursor = con.cursor() cursor.execute(updateStatement) con.commit() rows_affected = cursor.rowcount dbObj.close_connection() if rows_affected == 0: return None else: return True
def set_forgot_password(self, customer_account_number, customer_new_password): daoObj = LoginDAO() customer = Customer() customer.set_account_number(customer_account_number) customer.set_account_password(customer_new_password) return daoObj.set_forgot_password(customer)
def deposit_amount(self, amount, customer: Customer): if amount == None or amount <= 0: return False dbObj = MySQLDB() con = dbObj.get_connection() upadateStatement = "UPDATE customer set account_balance = account_balance+'" + str( amount) + "' where account_no=" + str( customer.get_account_number()) cursor = con.cursor() cursor.execute(upadateStatement) con.commit() rows_affected = cursor.rowcount dbObj.close_connection() if rows_affected == 0: return False else: return True
def validate_login(self, Customer): found = False account_number = Customer.get_account_number() account_password = Customer.get_account_password() dbObj = MySQLDB() con = dbObj.get_connection() sql = "SELECT * FROM customer" con.query(sql) all_recs = con.store_result() no_of_recs = all_recs.num_rows() rec = all_recs.fetch_row() while (rec): for account_no, account_name, account_balance, account_password in rec: account_no = account_no print(account_no, '->', account_password) if Customer.get_account_number() == int( account_no) and Customer.get_account_password( ) == account_password: payeeList = self.get_payees(Customer.get_account_number()) Customer.set_account_name(account_name) Customer.set_account_balance(account_balance) Customer.set_payees(payeeList) print(len(payeeList)) found = True rec = all_recs.fetch_row() dbObj.close_connection() if found: return Customer else: return None
def transfer_amount(self, amount, customer: Customer, payee_account_number): flag_payee_found = False flag_sufficient_amount = False if amount == None or amount <= 0: return False dbObj = MySQLDB() con = dbObj.get_connection() #payee saerch from here sql = "SELECT account_number FROM testpythondb.payees p where customer_account=" + str( customer.get_account_number()) con.query(sql) all_recs = con.store_result() no_of_recs = all_recs.num_rows() rec = all_recs.fetch_row() while (rec): for account_number in rec: print(account_number[0]) if account_number[0] == payee_account_number: print("Payee found in database") flag_payee_found = True break rec = all_recs.fetch_row() if flag_payee_found: break if flag_payee_found != True: print( "Unable to find payee with provided account number so can't transfer the amount" ) return False #payee search upto here #check balance frmo here sql = "select account_balance from customer where account_no=" + str( customer.get_account_number()) con.query(sql) all_recs = con.store_result() no_of_recs = all_recs.num_rows() rec = all_recs.fetch_row() while (rec): for account_balance in rec: balance = account_balance[0] print(balance) if balance >= amount: print("account balance is sufficient to tranfer") flag_sufficient_amount = True break rec = all_recs.fetch_row() break if flag_sufficient_amount != True: print( "Unable to transfer amount due to insufficient account balance" ) return False # check balance upto here upadateStatement = "UPDATE customer set account_balance = account_balance-'" + str( amount) + "' where account_no=" + str( customer.get_account_number()) cursor = con.cursor() cursor.execute(upadateStatement) con.commit() rows_affected = cursor.rowcount dbObj.close_connection() if rows_affected == 0: return False else: return True
from Controls.CustomerActions import CustomerActions from Entities.Customer import Customer customer = Customer(fname="Josh", lname="Santos") customer_actions = CustomerActions() first = raw_input("Enter the first name: ") last = raw_input("Enter the last name: ") customer_actions.create(fname=first, lname=last) print customer_actions.save(1)
def read(self, sheet): dataRows = [] df = pd.read_excel(self.filename, sheetname=sheet) for i in df.index: policy = Policy() policy.number = str(df['policy_no'][i]) policy.issue_date = df['po_issue_date'][i].date() policy.premium_method = df['PremiumPaidmethod'][i] policy.medical_exam = df['medicalExam_required'][i] policy.decision = df['underwriting_decision'][i] policy.channel_code = df['channel_code'][i] dt = df['lapse_date'][i] policy.lapsed_date = None if pd.isnull(dt) else dt.date() policy.is_lapsed = not pd.isnull(dt) dt = df['reinstatment_date'][i] policy.reinstate_date = None if pd.isnull(dt) else dt.date() policy.is_reinstated = not pd.isnull(dt) dt = df['autopaiddate'][i] policy.autopaid_date = None if pd.isnull(dt) else dt.date() policy.is_autopaid = not pd.isnull(dt) policy.inforce_year = str(df['policyInforce_year'][i]) policy.premium_frequency = str(df['PremiumPaidFrequencyPeryear'][i]) policy.face_amount = df['face_amt'][i] policy.total_premium = df['Total_prem'][i] claim = Claim() claim.receipt_no = str(df['claim_rece_no'][i]) claim.claim_no = str(df['claim_no'][i]) claim.app_date = df['Claimappl_date'][i].date() claim.start_date = df['claim_date_start'][i].date() claim.end_date = df['claim_date_end'][i].date() claim.benf_days = df['claim_benef_days'][i] claim.amount_paid = df['amount'][i] claim.process_date = df['process_date'][i].date() dt = df['docter_proof_date'][i] claim.doctor_proof_date = None if pd.isnull(dt) else dt.date() claim.have_proof = not pd.isnull(dt) event = Event() event.date = df['event_date'][i].date() event.zip = df['zip'][i] event.type = str(df['event_type'][i]) customer = Customer() customer.ID = str(df['insuredID'][i]) s = df['Insured_sex'][i] customer.sex = None if pd.isnull(s) else str(s) customer.age = df['Insured_age'][i] s = df['marriage'][i] customer.marriage = None if pd.isnull(s) else str(s) s = df['education'][i] customer.education = None if pd.isnull(s) else str(s) s = df['occupation_class'][i] customer.occupation = None if pd.isnull(s) else str(s) agent = Agent() agent.ID = df['agentid'][i] agent.officeID = df['agentin_center'][i] visitation = Visitation() visitation.reason = str(df['visit reasons_type'][i]) visitation.urgency = str(df['ride_type'][i]) hospital = Hospital() hospital.ID = str(df['hospital_num'][i]) hospital.type = df['hosp_class'][i] hospital.dept1 = str(df['hospital_dept_1'][i]) s = df['hospital_dept_2'][i] hospital.dept2 = None if pd.isnull(s) else str(s) surgery = Surgery() s = df['surgery_code (Insurer)'][i] surgery.code = None if pd.isnull(s) else str(s) surgery.date = df['surgery_date'][i].date() s = df['major_Surgery'][i] surgery.number_of_major_surgery = 0 if pd.isnull(s) else s surgery.start_date = df['surgey_date_start'][i].date() surgery.end_date = df['surgery_date_end'][i].date() doctor = Doctor() doctor.ID = df['doctor_num'][i] illness = Illness() illness.code = str(df['diag_code'][i]) dataRow = DataRow() dataRow.id = i+1 dataRow.agent = agent dataRow.claim = claim dataRow.customer = customer dataRow.doctor = doctor dataRow.event = event dataRow.hospital = hospital dataRow.illness = illness dataRow.policy = policy dataRow.surgery = surgery dataRow.visitation = visitation dataRows.append(dataRow) return dataRows
def validate_login(self, customer_account_number, customer_password): daoObj = LoginDAO() customer = Customer() customer.set_account_number(customer_account_number) customer.set_account_password(customer_password) return daoObj.validate_login(customer)