Project

General

Profile

Download (1.19 KB) Statistics
| Branch: | Tag: | Revision:
358f0d96 David Sorber
#!/usr/bin/python3
import sys

# This script is for creating rows for the repayment schedule page:
# https://baranovich.homelinux.org:3268/schedule.html

PAYMENT_AMOUNT = 500
ROW_TEMPLATE = '<tr{:s}>\n <td class="align-center">{:d}</td>'\
'<td class="align-center">{:s}</td>'\
'<td class="align-right">{:s}</td>'\
'<td class="align-right">{:s}</td>'\
'<td class="align-right">{:s}</td>'\
'<td>{:s}</td>\n</tr>'

def main():
num_rows = 94
row_idx = 1
month_idx = 10
year_idx = 2018
principal = 47000

for idx in range(num_rows):
row = ((idx % 2 == 1) and ' class="even_row"' or '',
row_idx,
'{:02d}/{:d}'.format(month_idx, year_idx),
'${:,.2f}'.format(PAYMENT_AMOUNT),
'${:,.2f}'.format(principal - PAYMENT_AMOUNT),
'&nbsp;',
'&nbsp;')
print(ROW_TEMPLATE.format(*row))
row_idx += 1
month_idx += 1
if month_idx > 12:
month_idx = 1
year_idx += 1
principal -= PAYMENT_AMOUNT
if __name__ == '__main__':
sys.exit(main())