from flask_mail import Message from flask import current_app from app.extensions import mail import pandas as pd from io import BytesIO def get_report_data(): """ Fetch and return loan summary data. """ return [ {"Type": "Disbursement", "Count": 45}, {"Type": "Repayment", "Count": 32}, ] def send_report_email(report_data: list, recipients: list): """ Sends an HTML + Excel report to the given email recipients. """ df = pd.DataFrame(report_data) output = BytesIO() df.to_excel(output, index=False) output.seek(0) html_table = df.to_html(index=False, border=1) msg = Message( subject="Loan Report Summary", recipients=recipients, html=f"