#!/usr/bin/python3
import sys

# This script is for creating rows for the repayment schedule page:
# https://phalanx.homelinuxserver.org/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 = 68
    row_idx = 23
    month_idx = 8
    year_idx = 2020
    principal = 34000

    for idx in range(num_rows):
        row = ((row_idx % 2 == 0) 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())
