Files
arrr-erp/app/modules/accounting/templates/accounting/ai_dashboard.html
T
2026-08-22 21:52:44 +05:30

62 lines
5.0 KiB
HTML

{% extends "ui/templates/base/layout.html" %}
{% block content %}
<div class="space-y-6">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<p class="text-xs font-semibold uppercase tracking-[0.16em] text-brand-600">Accounting Intelligence · Phase 12</p>
<h1 class="mt-1 text-2xl font-semibold text-slate-900">Server AI Semantic Layer</h1>
<p class="mt-1 max-w-4xl text-sm text-slate-500">AI is a fallback only. Confirmed mappings, historical evidence and deterministic rules remain primary. AI can select only an existing Accounting Nature; it cannot create ledgers or post to Tally.</p>
</div>
<div class="flex gap-2"><a href="/tools/accounting/internal-model" class="rounded-xl border border-emerald-300 bg-emerald-50 px-4 py-2 text-sm font-semibold text-emerald-800">Internal Model</a><a href="/tools/tally{% if selected_client %}?client_id={{ selected_client.id }}{% endif %}" class="rounded-xl border border-slate-300 bg-white px-4 py-2 text-sm font-semibold">Back to Tally</a></div>
</div>
<section class="rounded-2xl bg-white p-5 shadow-soft">
<div class="grid gap-4 md:grid-cols-4">
<div><div class="text-xs uppercase text-slate-500">Provider</div><div class="mt-1 font-semibold">{{ provider_status.provider or 'Not configured' }}</div></div>
<div><div class="text-xs uppercase text-slate-500">Model</div><div class="mt-1 font-semibold">{{ provider_status.model or '—' }}</div></div>
<div><div class="text-xs uppercase text-slate-500">AI Gate</div><div class="mt-1 font-semibold">&lt; {{ provider_status.gate }}% deterministic confidence</div></div>
<div><div class="text-xs uppercase text-slate-500">Status</div><div class="mt-1 font-semibold {% if provider_status.configured %}text-emerald-700{% else %}text-amber-700{% endif %}">{{ 'Configured' if provider_status.configured else 'Disabled until server key/model are configured' }}</div></div>
</div>
<p class="mt-3 text-xs text-slate-500">Server environment: ACCOUNTING_AI_PROVIDER, ACCOUNTING_AI_MODEL, OPENAI_API_KEY. API keys are never displayed in the ERP UI or sent to Local Agents.</p>
</section>
<form method="get" class="rounded-2xl bg-white p-5 shadow-soft">
<label class="text-sm font-semibold">Client
<select name="client_id" class="mt-1 w-full max-w-xl rounded-xl border border-slate-300 bg-white px-3 py-2">
<option value="">All visible clients</option>
{% for c in clients %}<option value="{{ c.id }}" {% if selected_client and selected_client.id == c.id %}selected{% endif %}>{{ c.client_name }}</option>{% endfor %}
</select>
</label>
<button class="mt-3 rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white">Apply</button>
</form>
<section class="grid gap-4 sm:grid-cols-2 xl:grid-cols-6">
{% for label,value in [('AI Calls',summary.total),('Completed',summary.completed),('Reviewed',summary.reviewed),('Accepted',summary.accepted),('Corrected',summary.corrected),('Acceptance %',summary.acceptance_rate)] %}
<div class="rounded-2xl bg-white p-4 shadow-soft"><div class="text-xs font-semibold uppercase text-slate-500">{{ label }}</div><div class="mt-2 text-2xl font-semibold">{{ value }}</div></div>
{% endfor %}
</section>
<section class="rounded-2xl bg-white shadow-soft">
<div class="border-b border-slate-200 px-5 py-4"><h2 class="font-semibold">Recent AI decisions</h2><p class="text-sm text-slate-500">Input tokens {{ summary.input_tokens }} · Output tokens {{ summary.output_tokens }}</p></div>
<div class="overflow-x-auto">
<table class="min-w-full text-sm">
<thead><tr class="border-b bg-slate-50 text-left text-xs uppercase text-slate-500"><th class="px-3 py-3">When</th><th class="px-3 py-3">Source</th><th class="px-3 py-3">Model</th><th class="px-3 py-3">AI</th><th class="px-3 py-3">Confidence</th><th class="px-3 py-3">Review</th><th class="px-3 py-3">Reason</th></tr></thead>
<tbody>
{% for d in decisions %}
<tr class="border-b border-slate-100 align-top">
<td class="px-3 py-3 whitespace-nowrap">{{ d.created_at_utc }}</td>
<td class="px-3 py-3">{{ d.source_type }} #{{ d.source_record_id }}</td>
<td class="px-3 py-3">{{ d.model_name }}</td>
<td class="px-3 py-3">{{ d.ai_nature_code or '—' }}</td>
<td class="px-3 py-3">{{ d.ai_confidence }}% AI · {{ d.combined_confidence }}% combined</td>
<td class="px-3 py-3">{% if d.suggestion_accepted is sameas true %}<span class="text-emerald-700">Accepted</span>{% elif d.suggestion_accepted is sameas false %}<span class="text-amber-700">Corrected</span>{% elif d.status=='failed' %}<span class="text-red-700">Failed</span>{% else %}Pending{% endif %}</td>
<td class="px-3 py-3 max-w-xl">{{ d.concise_reason or d.error_message or '—' }}</td>
</tr>
{% else %}<tr><td colspan="7" class="px-4 py-10 text-center text-slate-500">No AI decisions yet.</td></tr>{% endfor %}
</tbody>
</table>
</div>
</section>
</div>
{% endblock %}