def unittest(execute=False):
with timetravel(datetime(2017,03,01)) as now:
loan2 = compute_loan(user, {'product_id': 1,
'frequency': '1week',
'first_debit_date': now })
if not execute:
print('You are wrong')
pass
else:
field_list = CustomerProduct._meta.get_fields()
mylist = []
exclude = ['id','contract', 'actor_actions',
'locked', 'description', 'target_actions',
'action_object_actions', 'created', 'modified',
'request', 'withdrawal_first_date', 'deposit_date']
table = Texttable(max_width = 6000)
for field in field_list:
if field.name not in exclude:
mylist.append([field.name, getattr(loan2.request.customer_product, field.name)])
table.add_rows(mylist)
print(table.draw())
With this function, I created a list of list containing field.name
and getattr(loan2.request.customer_product, field.name)
. For example,
+----------------------------------------------------+---------+
| debit_frequency | 1week |
+----------------------------------------------------+---------+
| broker_pmt | 17.865 |
+----------------------------------------------------+---------+
| broker_pre_withdrawal_daily_interest_rate | 0.001 |
+----------------------------------------------------+---------+
| broker_total_post_pre_withdrawal_interest_amount | 139.908 |
+----------------------------------------------------+---------+
The problem is I prefer something like
+----------------------------------------------------+-----------------+
| debit_frequency | u'1week' |
+----------------------------------------------------+-----------------+
| broker_pmt | 17.865903434 |
+----------------------------------------------------+-----------------+
| broker_pre_withdrawal_daily_interest_rate | 0.0014348934 |
+----------------------------------------------------+-----------------+
| broker_total_post_pre_withdrawal_interest_amount | 139.9083498304 |
+----------------------------------------------------+-----------------+
In fact, those values are the same when I query the database with something like
In [7]: loaner.request.customer.sum_new_pmt
Out[7]: 56.000121522936645
I would like the returning value from the interactive shell. Could anyone help me with this issue? What could I modify in the code?
Thanks!
P.S. Please let me know if the question is unclear.