added mail
This commit was merged in pull request #40.
This commit is contained in:
@@ -10,6 +10,8 @@ from app.services.loan import LoanService
|
||||
from app.services.repayment import RepaymentService
|
||||
from app.services.salary import SalaryService
|
||||
from app.enums.loan_status import LoanStatus
|
||||
from app.utils.mail import send_report_email, get_report_data
|
||||
from app.config import settings
|
||||
|
||||
autocall_bp = Blueprint("autocall", __name__)
|
||||
|
||||
@@ -238,3 +240,19 @@ def process_salary_list():
|
||||
logger.info(f"Finished processing salary ID: {pending_salary.id}")
|
||||
|
||||
return ResponseHelper.success([], "Processed all pending salaries")
|
||||
|
||||
|
||||
|
||||
@autocall_bp.route("/report", methods=["GET"])
|
||||
def report():
|
||||
try:
|
||||
report_data = get_report_data()
|
||||
logger.info(f"Generated report data: {report_data}")
|
||||
send_report_email(
|
||||
report_data,
|
||||
recipients = [email.strip() for email in settings.MAIL_RECEIVER.split(",")])
|
||||
|
||||
return ResponseHelper.success(message="Report sent successfully",status_code=200)
|
||||
except Exception as e:
|
||||
logger.error(f"Error generating or sending report: {e}")
|
||||
return ResponseHelper.error("Failed to send report", status_code=500, error=str(e))
|
||||
|
||||
Reference in New Issue
Block a user