def get_loan(msg): loan_number = msg['loanNum'] loan = loansDB.get_loan(loan_number) for p in loan: if type(loan[p]) == dict: for p2 in loan[p]: if type(loan[p][p2]) == date: loan[p][p2] = format_date(loan[p][p2]) # print '1',type(loan[p]) if type(loan[p]) == list: for p2 in range(len(loan[p])): # print '2',type(loan[p][p2]),loan[p][p2] if type(loan[p][p2]['date']) == date: loan[p][p2]['date'] = format_date(loan[p][p2]['date']) return json.dumps(loan)
def add_loan(loan): print 'adding' loan_number = loan['loanNum'] ln = loansDB.get_loan(loan_number) if ln: print 'error, loan already exists', loan_number loan_number = 'L'+ '{0:04d}'.format(int(loan_number[1:])+1) print 'assigning it loan number', loan_number loan['loanNum'] = loan_number add_loan(loan) return loansDB.add_loan(loan['loanNum'], loan['name'], loan['file'], deformat_date(loan['loanDate']), loan['amount'], loan['age'], loan['gender'], loan['business'], loan['location']) for p in loan['payments']: loansDB.add_scheduled_payment(loan['loanNum'], deformat_date(p['date']), p['amount'])