Reuse opening balance Tally master flow for cash ledger selection
This commit is contained in:
@@ -252,7 +252,7 @@ def cash_payment_review(
|
||||
|
||||
@router.post("/ledgers")
|
||||
async def cash_payment_ledgers(request: Request):
|
||||
"""Load Cash-in-Hand ledgers directly; keep full-ledger sync only as manual fallback."""
|
||||
"""Load Cash ledgers using the same live Tally master snapshot path as Opening Balance Review."""
|
||||
form = await request.form()
|
||||
validate_csrf(request, str(form.get("csrf_token") or ""))
|
||||
db = CommonSessionLocal()
|
||||
@@ -287,23 +287,19 @@ async def cash_payment_ledgers(request: Request):
|
||||
"tally_guid": tally_guid,
|
||||
"company_name": company_name,
|
||||
}
|
||||
if ledger_scope == "all":
|
||||
# Explicit manual fallback preserves the existing full-master async flow.
|
||||
payload["force_refresh"] = force_refresh
|
||||
result = request_agent_command(
|
||||
node.node_code,
|
||||
"accounting_cash_payment_ledgers_start",
|
||||
payload,
|
||||
timeout_seconds=20,
|
||||
)
|
||||
else:
|
||||
# Normal path: small filtered Tally collection, no full ledger cache.
|
||||
result = request_agent_command(
|
||||
node.node_code,
|
||||
"accounting_cash_payment_cash_ledgers",
|
||||
payload,
|
||||
timeout_seconds=30,
|
||||
)
|
||||
# Use the same proven live Tally master-snapshot mechanism used by
|
||||
# Opening Balance Review. The Local Agent resolves the selected open
|
||||
# company, reads the standard Tally masters and returns either only
|
||||
# Cash-in-Hand ledgers or all ledgers for explicit manual selection.
|
||||
# No separate cash-ledger cache/job is required for this selector.
|
||||
payload["ledger_scope"] = ledger_scope
|
||||
payload["force_refresh"] = force_refresh
|
||||
result = request_agent_command(
|
||||
node.node_code,
|
||||
"accounting_cash_payment_cash_ledgers",
|
||||
payload,
|
||||
timeout_seconds=180,
|
||||
)
|
||||
except Exception as exc:
|
||||
return JSONResponse({"ok": False, "error": str(exc)}, status_code=502)
|
||||
if not result.get("ok"):
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<button type="button" id="cash-load-ledgers" class="rounded-xl border border-slate-300 bg-white px-3 py-2 text-xs font-semibold text-slate-700">Load Cash Ledgers</button>
|
||||
<button type="button" id="cash-refresh-ledgers" class="rounded-xl border border-slate-300 bg-white px-3 py-2 text-xs font-semibold text-slate-700">Refresh</button>
|
||||
</div>
|
||||
<p id="cash-ledger-help" class="mt-1 text-xs text-slate-500">By default only ledgers classified under Cash-in-Hand are shown. Choose “All Tally ledgers” only when you need to manually select a ledger that Tally has grouped differently.</p>
|
||||
<p id="cash-ledger-help" class="mt-1 text-xs text-slate-500">Uses the same live Tally master-reading mechanism as Opening Balance Review. By default only ledgers under Cash-in-Hand are shown; choose “All Tally ledgers” only for manual selection when required.</p>
|
||||
<div id="cash-ledger-progress" class="mt-2 hidden rounded-xl border border-sky-200 bg-sky-50 p-3">
|
||||
<div class="flex items-center justify-between text-xs font-semibold text-sky-900"><span id="cash-ledger-progress-stage">Preparing Cash ledger list…</span><span id="cash-ledger-progress-pct">0%</span></div>
|
||||
<div class="mt-2 h-2 overflow-hidden rounded-full bg-sky-100"><div id="cash-ledger-progress-bar" class="h-full rounded-full bg-sky-600 transition-all duration-500" style="width:0%"></div></div>
|
||||
@@ -311,8 +311,8 @@
|
||||
if(forceRefresh) fd.set('force_refresh','1');
|
||||
ledgerButton.disabled = true; if(ledgerRefreshButton) ledgerRefreshButton.disabled=true;
|
||||
ledgerHelp.textContent = selectedScope === 'all'
|
||||
? (forceRefresh ? 'Starting background full-ledger refresh from Tally…' : 'Loading the full ledger list for manual selection…')
|
||||
: 'Reading Cash-in-Hand ledgers directly from the selected Tally company…';
|
||||
? 'Reading all Tally ledgers using the proven master snapshot…'
|
||||
: 'Reading Tally masters and selecting Cash-in-Hand ledgers…';
|
||||
try {
|
||||
const response = await fetch('/tools/accounting/cash-payments/ledgers', {method:'POST', body:fd, headers:{'Accept':'application/json'}});
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user