Use common SQLite master for cash payment workflow

This commit is contained in:
A R R R Associates
2026-09-04 22:23:17 +05:30
parent 7fadbb9f4b
commit 8536dc0457
5 changed files with 278 additions and 71 deletions
+11 -7
View File
@@ -252,7 +252,11 @@ def cash_payment_review(
@router.post("/ledgers")
async def cash_payment_ledgers(request: Request):
"""Load Cash ledgers using the same name-resolved live Tally master snapshot path as Opening Balance Review."""
"""Load Cash ledgers from the common client .act SQLite master snapshot.
Normal loads are local-only. A live Tally master refresh happens only when
the user explicitly clicks Refresh Master Data or when no local snapshot exists.
"""
form = await request.form()
validate_csrf(request, str(form.get("csrf_token") or ""))
db = CommonSessionLocal()
@@ -287,18 +291,18 @@ async def cash_payment_ledgers(request: Request):
"tally_guid": tally_guid,
"company_name": company_name,
}
# 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.
# Reuse the common accounting master tables already stored in the
# client .act SQLite file. This avoids repeatedly querying TallyPrime
# just to populate a ledger selector. The Local Agent performs a live
# master refresh only when force_refresh is explicitly requested, or
# when no usable local snapshot exists yet.
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,
timeout_seconds=180 if force_refresh else 45,
)
except Exception as exc:
return JSONResponse({"ok": False, "error": str(exc)}, status_code=502)