Fix VPS async cash ledger loading

This commit is contained in:
A R R R Associates
2026-09-04 16:13:28 +05:30
parent 87bfc13cbd
commit d6ef57b434
6 changed files with 66 additions and 20 deletions
@@ -269,6 +269,7 @@ async def cash_payment_ledgers(request: Request):
if not selected_client:
return JSONResponse({"ok": False, "error": "Select a valid client."}, status_code=400)
tally_guid = str(form.get("tally_guid") or "").strip()
company_name = str(form.get("company_name") or "").strip()
date_from = str(form.get("date_from") or date.today().isoformat()).strip()
force_refresh = str(form.get("force_refresh") or "").strip().lower() in {"1","true","yes","on"}
if not tally_guid:
@@ -284,6 +285,7 @@ async def cash_payment_ledgers(request: Request):
{
**_accounting_storage_payload(selected_client, fy),
"tally_guid": tally_guid,
"company_name": company_name,
"force_refresh": force_refresh,
},
timeout_seconds=20,
@@ -36,7 +36,7 @@
<option value="">Select open/mapped company</option>
{% if live_result and live_result.accounting %}
{% for mapping in live_result.accounting.mappings or [] %}
<option value="{{ mapping.tally_guid }}" {% if selected_tally_guid == mapping.tally_guid %}selected{% endif %}>{{ mapping.company_name or mapping.tally_company_name or mapping.tally_guid }}</option>
<option value="{{ mapping.tally_guid }}" data-company-name="{{ mapping.company_name or mapping.tally_company_name or '' }}" {% if selected_tally_guid == mapping.tally_guid %}selected{% endif %}>{{ mapping.company_name or mapping.tally_company_name or mapping.tally_guid }}</option>
{% endfor %}
{% endif %}
</select>
@@ -259,6 +259,10 @@
const fd = new FormData(form);
if (!fd.get('client_id') || !fd.get('tally_guid')) { ledgerHelp.textContent = 'Select a client and Tally company first.'; return; }
fd.set('csrf_token', document.getElementById('cash-csrf-token').value);
const companySelect = form.querySelector('select[name="tally_guid"]');
const companyOption = companySelect && companySelect.options[companySelect.selectedIndex];
const companyName = companyOption ? String(companyOption.dataset.companyName || companyOption.textContent || '').trim() : '';
if (companyName) fd.set('company_name', companyName);
if(forceRefresh) fd.set('force_refresh','1');
ledgerButton.disabled = true; if(ledgerRefreshButton) ledgerRefreshButton.disabled=true;
ledgerHelp.textContent = forceRefresh ? 'Starting background refresh from Tally…' : 'Loading cached ledgers or starting background Tally sync…';