def post(self, customer_id):
   abort_if_customer_doesnt_exist(customer_id)
   parser.add_argument('acct_type')
   args = parser.parse_args()
   acct = AccountModel(customer_id=customer_id, acct_type=args['acct_type'])
   S.add(acct)
   S.commit()
   return acct.serialize
 def do_1(self, args):
   print "Please enter the following:"
   username_input = raw_input('Username: '******'Password: ')
   c = Customer(username=username_input, password=password_input)
   S.add(c)
   S.commit()
   print self.intro
   return
 def do_5(self, args):
   print "Please choose which customer to suspend:"
   display_customers()
   customers = S.query(Customer).all()
   customer_index = int(raw_input(">").strip())
   customer = customers[customer_index]
   customer.suspended = True
   S.commit()
   print self.intro
   return
 def do_2(self, args):
   print "Please enter the account number:"
   display_accounts(customer_id=login_manager.get_customer().customer_id)
   account_num = int(raw_input(">").strip())
   account = S.query(Account).filter(Account.acct_num==account_num).first()
   amount = float(raw_input("Please enter the amount to withdraw: ").strip())
   account.balance -= amount
   S.commit()
   create_transaction(from_acct=account, amount=amount, transaction_type="withdrawal", final_balance=account.balance)
   print self.intro
   return
 def do_1(self, args):
   print "Please enter the account number:"
   display_accounts(customer_id=login_manager.get_customer().customer_id)
   account_num = int(raw_input(">").strip())
   account = S.query(Account).filter(Account.acct_num==account_num).first()
   amount = float(raw_input("Please enter the amount to deposit: ").strip())
   account.balance += amount
   S.commit()
   create_transaction(to_acct=account, amount=amount, transaction_type="deposit")
   print self.intro
   return
 def do_3(self, args):
   print "Please enter the account number to transfer FROM:"
   display_accounts(customer_id=login_manager.get_customer().customer_id)
   account_num_from = int(raw_input(">").strip())
   account_from = S.query(Account).filter(Account.acct_num==account_num_from).first()
   display_accounts(customer_id=login_manager.get_customer().customer_id)
   print "Please enter the account number to transfer TO:"
   account_num_to = int(raw_input(">").strip())
   account_to = S.query(Account).filter(Account.acct_num==account_num_to).first()
   amount = float(raw_input("Please enter the amount to deposit: ").strip())
   account_from.balance -= amount
   account_to.balance += amount
   S.commit()
   create_transaction(from_acct=account_from, to_acct=account_to, amount=amount, transaction_type="transfer", final_balance=None)
   print self.intro
   return
 def do_2(self, args):
   print "Please choose which customer to add the account for:"
   customers = S.query(Customer).all()
   display_customers()
   customer_index = int(raw_input(">").strip())
   customer = customers[customer_index]
   acct_types = {
     0: 'checking',
     1: 'savings'
   }
   acct_type_prompt = "Please pick what type the account is:\n" + \
                      "  0. Checking\n" + \
                      "  1. Savings\n>"
   acct_type = acct_types[int(raw_input(acct_type_prompt).strip())]
   acct = Account(acct_type=acct_type, balance=0.0, customer=customer)
   S.add(acct)
   S.commit()
   print self.intro
   return
def create_transaction(from_acct=None, to_acct=None, transaction_type=None, amount=0.0, final_balance=None):
  t = Transaction(from_account=from_acct, to_account=to_acct, transaction_type=transaction_type, amount=amount, final_balance=final_balance, date=datetime.utcnow())
  S.add(t)
  S.commit()
def create_transaction(from_acct=None, to_acct=None, transaction_type=None, amount=0.0):
  t = Transaction(from_account=from_acct, to_account=to_acct, transaction_type=transaction_type, amount=amount)
  S.add(t)
  S.commit()
 def post(self):
   args = parser.parse_args()
   c = CustomerModel(username=args['username'], password=args['password'])
   S.add(c)
   S.commit()
   return c.serialize