from django.shortcuts import render
from django.utils import timezone
import decimal

def index(request):
    """Render the main analytics dashboard."""
    # Dummy data for the dashboard cards
    total_spend_ytd = decimal.Decimal('125432.50')
    total_invoices = 1342
    avg_invoice_value = total_spend_ytd / total_invoices if total_invoices > 0 else 0

    context = {
        'total_spend_ytd': total_spend_ytd,
        'total_invoices': total_invoices,
        'documents_uploaded': 1500,
        'avg_invoice_value': avg_invoice_value,
    }
    return render(request, 'core/index.html', context)
