#!/usr/bin/env python3 """Calculate monthly fees from the FUJ Tuesday practice attendance sheet.""" from datetime import datetime from attendance import get_members_with_fees def main(): members, sorted_months = get_members_with_fees() if not members: print("No data.") return # Filter to adults only for display results = [(name, fees) for name, tier, fees in members if tier == "A"] # Format month labels month_labels = { m: datetime.strptime(m, "%Y-%m").strftime("%b %Y") for m in sorted_months } # Print table name_width = max((len(r[0]) for r in results), default=20) col_width = 15 header = f"{'Member':<{name_width}}" for m in sorted_months: header += f" | {month_labels[m]:>{col_width}}" print(header) print("-" * len(header)) monthly_totals = {m: 0 for m in sorted_months} for name, month_fees in results: line = f"{name:<{name_width}}" for m in sorted_months: fee, count = month_fees[m] monthly_totals[m] += fee cell = f"{fee} CZK ({count})" if count > 0 else "-" line += f" | {cell:>{col_width}}" print(line) # Totals row print("-" * len(header)) totals_line = f"{'TOTAL':<{name_width}}" for m in sorted_months: cell = f"{monthly_totals[m]} CZK" totals_line += f" | {cell:>{col_width}}" print(totals_line) if __name__ == "__main__": main()