mortgage
mortgage copied to clipboard
Need prettier print representation of amortization schedule
Loan.schedule is fairly ugly right now. Need to format with header row and values in columns. Is current data structure {payment_number:{principal:'', interest:'', balance:''...} a good format for this? Should I switch the inner dictionary to be a named tuple or something else?
I like it the way it is, providing a list of installments which users of your package can format how they like. Here's one that works for me:
for installment in loan.schedule():
print('{:>4}: {:>10.02f} {:>10.02f} {:>10.02f} {:>10.02f}'.format(
installment.number, installment.payment, installment.interest, installment.principal, installment.balance))