Fix live Purchase and Sales historical Tally sync

This commit is contained in:
A R R R Associates
2026-08-23 11:48:09 +05:30
parent 395f4eed1a
commit 6910b5b6b5
8 changed files with 293 additions and 68 deletions
@@ -2,7 +2,7 @@
{% block content %}
<div class="space-y-6">
<div class="flex flex-wrap items-start justify-between gap-4">
<div><p class="text-xs font-semibold uppercase tracking-[0.16em] text-brand-600">Tools · Accounting · Phase 5</p><h1 class="mt-1 text-2xl font-semibold text-slate-900">Historical Tally Learning</h1><p class="mt-1 text-sm text-slate-500">Uses synced Tally purchase history as evidence. No voucher is created or altered in this phase.</p></div>
<div><p class="text-xs font-semibold uppercase tracking-[0.16em] text-brand-600">Tools · Accounting · Phase 5</p><h1 class="mt-1 text-2xl font-semibold text-slate-900">Historical Tally Learning</h1><p class="mt-1 text-sm text-slate-500">Refreshes the selected client's Purchase vouchers directly from the currently connected Tally company, then builds historical evidence. The operation is read-only; no voucher is created or altered.</p></div>
<div class="flex gap-2"><a href="/tools/accounting/taxonomy" class="rounded-xl border border-slate-300 bg-white px-4 py-2 text-sm font-semibold text-slate-700">Accounting Taxonomy</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 text-slate-700">Back to Tally</a></div>
</div>
{% if collected %}<div class="rounded-xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-800">Historical evidence job queued. This page will ingest the result after the selected workstation completes it.</div>{% endif %}
@@ -19,7 +19,10 @@
{% if selected_client %}
<section class="rounded-2xl bg-white p-5 shadow-soft">
<h2 class="text-lg font-semibold text-slate-900">Collect Historical Purchase Evidence</h2>
<p class="mt-1 text-sm text-slate-500">Select the workstation that holds this client's synced .act data. The agent returns neutral ledger-history facts; classification stays on the ERP server.</p>
<p class="mt-1 text-sm text-slate-500">Select the connected ERP Local Agent workstation and currently open mapped Tally company. The agent refreshes the selected period read-only before returning neutral ledger-history facts; classification stays on the ERP server.</p>
{% if not workstations %}
<div class="mt-4 rounded-xl border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800">No recent ERP Local Agent workstation with Tally connected is advertising a company for this branch. Update/start the Local Agent, open the mapped company in TallyPrime, and refresh this page.</div>
{% endif %}
<form method="post" action="/tools/accounting/historical-learning/collect" class="mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-5">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"><input type="hidden" name="client_id" value="{{ selected_client.id }}">
<label class="text-sm font-medium text-slate-700 xl:col-span-2">Workstation / Tally Company<select id="wsCompany" class="mt-1 w-full rounded-xl border border-slate-300 px-3 py-2" required><option value="">Select</option>{% for w in workstations %}{% for company in workstation_companies.get(w.id,[]) %}<option value="{{ w.id }}|{{ company.get('guid','') }}|{{ company.get('name','') }}">{{ w.machine_name }} · {{ company.get('name','') }}{% if not w.tally_connected %} (Tally not connected){% endif %}</option>{% endfor %}{% endfor %}</select></label>
@@ -34,22 +34,25 @@
<section class="rounded-2xl bg-white p-5 shadow-soft">
<h2 class="font-semibold">Collect Historical Sales Evidence from Tally</h2>
<p class="mt-1 text-sm text-slate-500">Read-only. Uses the existing durable Local Agent job queue and only Sales voucher history. It does not create or alter Tally vouchers.</p>
<p class="mt-1 text-sm text-slate-500">Read-only. The selected workstation refreshes Sales vouchers from the currently open mapped Tally company for the chosen period, then stores neutral historical evidence. It does not create or alter Tally vouchers.</p>
{% if not workstations %}
<div class="mt-4 rounded-xl border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800">No recent ERP Local Agent workstation with Tally connected is advertising a company for this branch. Update/start the Local Agent, open the mapped company in TallyPrime, and refresh this page.</div>
{% endif %}
<form method="post" action="/tools/accounting/sales-learning/collect" class="mt-4 grid gap-3 md:grid-cols-5">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="client_id" value="{{ selected_client.id }}">
<label class="text-xs font-semibold md:col-span-2">Mapped Tally Company
<select name="tally_guid" required class="mt-1 w-full rounded-lg border border-slate-300 px-2 py-2">
<option value="">Select company</option>
{% for guid,name in tally_guids %}<option value="{{ guid }}">{{ name }}</option>{% endfor %}
</select>
</label>
<label class="text-xs font-semibold">Workstation
<select name="workstation_id" required class="mt-1 w-full rounded-lg border border-slate-300 px-2 py-2">
<option value="">Select</option>
{% for ws in workstations %}<option value="{{ ws.id }}">{{ ws.machine_name }}</option>{% endfor %}
<label class="text-xs font-semibold md:col-span-3">Workstation / Currently Open Tally Company
<select id="salesWsCompany" required class="mt-1 w-full rounded-lg border border-slate-300 px-2 py-2">
<option value="">Select workstation and company</option>
{% for ws in workstations %}
{% for company in workstation_companies.get(ws.id, []) %}
<option value="{{ ws.id }}|{{ company.get('guid','') }}">{{ ws.machine_name }} · {{ company.get('name','') }}</option>
{% endfor %}
{% endfor %}
</select>
</label>
<input type="hidden" name="workstation_id" id="salesWorkstationId">
<input type="hidden" name="tally_guid" id="salesTallyGuid">
<label class="text-xs font-semibold">From
<input type="date" name="date_from" class="mt-1 w-full rounded-lg border border-slate-300 px-2 py-2">
</label>
@@ -89,4 +92,21 @@
</section>
{% endif %}
</div>
<script>
(function () {
const combined = document.getElementById("salesWsCompany");
const ws = document.getElementById("salesWorkstationId");
const guid = document.getElementById("salesTallyGuid");
if (!combined || !ws || !guid) return;
function syncSelection() {
const parts = (combined.value || "").split("|");
ws.value = parts[0] || "";
guid.value = parts[1] || "";
}
combined.addEventListener("change", syncSelection);
const form = combined.closest("form");
if (form) form.addEventListener("submit", syncSelection);
syncSelection();
})();
</script>
{% endblock %}