from typing import Dict, Any, List class EmailTemplateService: @staticmethod def quotation_email(data: Dict[str, Any]) -> str: quote_number = data.get("quote_number", "SQ-2026-000") customer_name = data.get("customer_name", "Valued Customer") customer_phone = data.get("customer_phone", "N/A") customer_email = data.get("customer_email", "N/A") quote_title = data.get("quote_title", "CRM Service & Repair Quotation") items: List[Dict[str, Any]] = data.get("items", []) subtotal = float(data.get("subtotal", 0.0)) tax_amount = float(data.get("tax_amount", 0.0)) grand_total = float(data.get("grand_total", 0.0)) terms = data.get("terms", "6-Month IMEI Warranty included. Valid for 15 days from issue date.") terms_html = terms.replace('\n', '
') if isinstance(terms, str) else str(terms) items_rows_html = "" for idx, item in enumerate(items, 1): desc = item.get("description", "Item") sku = item.get("sku", "PART/SVC") qty = int(item.get("quantity", item.get("qty", 1))) unit_price = float(item.get("unit_price", 0.0)) line_total = qty * unit_price items_rows_html += f""" {idx}. {desc}
SKU: {sku} {qty} ₹{unit_price:,.2f} ₹{line_total:,.2f} """ html_content = f""" Quotation #{quote_number} - iFixKart

iFixKart

Unified Enterprise Commerce & Repair Platform

OFFICIAL QUOTATION

PREPARED FOR

{customer_name}

📞 {customer_phone}

{f'

✉️ {customer_email}

' if customer_email and customer_email != 'N/A' else ''}

QUOTE REFERENCE

{quote_number}

Subject: {quote_title}

{items_rows_html}
Description / Product / Service Qty Unit Price Amount
Subtotal: ₹{subtotal:,.2f}
GST Tax (18%): ₹{tax_amount:,.2f}
Grand Total: ₹{grand_total:,.2f}

WARRANTY & GUARANTEE TERMS

{terms_html}

iFixKart Unified Commerce & Enterprise Service Platform

For queries regarding this quotation, reply to this email or call our support desk.

""" return html_content @staticmethod def invoice_email(data: Dict[str, Any]) -> str: invoice_number = data.get("invoice_number", "INV-2026-000") customer_name = data.get("customer_name", "Valued Customer") grand_total = float(data.get("grand_total", 0.0)) payment_status = data.get("payment_status", "PAID") return f"""

iFixKart Tax Invoice - #{invoice_number}

Hello {customer_name},

Thank you for choosing iFixKart! Your GST invoice has been generated.

Invoice Number: {invoice_number}

Amount Paid: ₹{grand_total:,.2f}

Payment Status: {payment_status}

All repairs come with standard iFixKart warranty coverage.

""" @staticmethod def repair_ticket_email(data: Dict[str, Any]) -> str: ticket_number = data.get("ticket_number", "REP-2026-000") customer_name = data.get("customer_name", "Valued Customer") device = data.get("device", "Mobile Device") issue = data.get("issue", "Repair Inspection") status = data.get("status", "IN_DIAGNOSIS") return f"""

iFixKart Repair Ticket #{ticket_number}

Hello {customer_name},

Your repair booking status has been updated.

You can track real-time progress on your iFixKart account portal.

""" @staticmethod def lead_qualification_email(data: Dict[str, Any]) -> str: customer_name = data.get("customer_name", "Valued Client") lead_title = data.get("lead_title", "Enterprise Requirement") assigned_agent = data.get("assigned_agent", "Support Desk") return f"""

Requirement Qualified - iFixKart CRM

Hello {customer_name},

Your requirement ({lead_title}) has been qualified by our technical team.

Assigned Account Representative: {assigned_agent}

Our representative will reach out to send a customized formal quotation.

""" @staticmethod def simple_notification_email(data: Dict[str, Any]) -> str: title = data.get("title", "Notification from iFixKart") customer_name = data.get("customer_name", "Valued Customer") message = data.get("message", "") return f"""

{title}

Hello {customer_name},

{message}

Thank you for choosing iFixKart!

""" @staticmethod def order_invoice_email(data: Dict[str, Any]) -> str: order_no = data.get("order_no", "ORD-000") invoice_no = data.get("invoice_no", "INV-000") customer_name = data.get("customer_name", "Valued Customer") items: List[Dict[str, Any]] = data.get("items", []) subtotal = float(data.get("subtotal", 0.0)) tax_amount = float(data.get("tax_amount", 0.0)) final_amount = float(data.get("final_amount", 0.0)) payment_status = data.get("payment_status", "PAID") pdf_url = data.get("pdf_url", "#") store_logo_url = data.get("store_logo_url", "https://admin.trionixsolution.com/images/logo/ifixkart-logo.webp") items_rows_html = "" for idx, item in enumerate(items, 1): name = item.get("product_name", "Product") sku = item.get("sku", "") qty = int(item.get("quantity", item.get("qty", 1))) unit_price = float(item.get("unit_price", 0.0)) line_total = qty * unit_price items_rows_html += f""" {idx}. {name}
SKU: {sku} {qty} ₹{unit_price:,.2f} ₹{line_total:,.2f} """ return EmailTemplateService.order_invoice_email_wrapper( body_content=f"""

Dear {customer_name},

Thank you for your order! Your Tax Invoice #{invoice_no} (Order Ref: {order_no}) is attached as a PDF to this email.

""", data=data, items_rows_html=items_rows_html ) @staticmethod def order_invoice_email_wrapper(body_content: str, data: Dict[str, Any], items_rows_html: str = "") -> str: order_no = data.get("order_no", "ORD-000") invoice_no = data.get("invoice_no", "INV-000") subtotal = float(data.get("subtotal", 0.0)) tax_amount = float(data.get("tax_amount", 0.0)) final_amount = float(data.get("final_amount", 0.0)) payment_status = data.get("payment_status", "PAID") pdf_url = data.get("pdf_url", "#") store_logo_url = data.get("store_logo_url", "https://admin.trionixsolution.com/images/logo/ifixkart-logo.webp") if not items_rows_html: items = data.get("items", []) for idx, item in enumerate(items, 1): name = item.get("product_name", "Product") sku = item.get("sku", "") qty = int(item.get("quantity", item.get("qty", 1))) unit_price = float(item.get("unit_price", 0.0)) line_total = qty * unit_price items_rows_html += f""" {idx}. {name}
SKU: {sku} {qty} ₹{unit_price:,.2f} ₹{line_total:,.2f} """ return f""" Order Invoice #{invoice_no} - iFixKart
iFixKart ORDER CONFIRMED
{body_content}
{items_rows_html}
Product Qty Unit Price Total

Subtotal: ₹{subtotal:,.2f}

GST Tax (18%): ₹{tax_amount:,.2f}

Grand Total: ₹{final_amount:,.2f}

{f'
Download PDF Invoice
' if pdf_url != '#' else ''}
""" @staticmethod def service_invoice_email(data: dict) -> str: job_no = data.get("job_no", "JOB-XXXX") invoice_no = data.get("invoice_no", "INV-XXXX") customer_name = data.get("customer_name", "Valued Customer") service_name = data.get("service_name", "Repair Service") subtotal = data.get("subtotal", 0.0) paid_amount = data.get("paid_amount", 0.0) balance = data.get("balance", 0.0) pdf_url = data.get("pdf_url", "#") store_logo_url = data.get("store_logo_url", "https://admin.trionixsolution.com/images/logo/ifixkart-logo.webp") # Determine tag based on balance if balance <= 0: status_tag = 'SERVICE READY' else: status_tag = 'SERVICE BOOKED' return f''' Service Invoice #{invoice_no} - iFixKart
iFixKart {status_tag}

Dear {customer_name},

Your service job update has been processed successfully. Your tax invoice #{invoice_no} (Job Ref: {job_no}) is attached as a PDF to this email.

Service Details Total Amount
{service_name} ₹{subtotal:,.2f}

Total Amount: ₹{subtotal:,.2f}

Total Paid: ₹{paid_amount:,.2f}

Balance Due: ₹{balance:,.2f}

{f'
Download PDF Invoice
' if pdf_url != '#' else ''}
'''