Show all open Tally companies in cash payment review

This commit is contained in:
A R R R Associates
2026-09-04 16:33:53 +05:30
parent d6ef57b434
commit 9a6b35c19b
5 changed files with 52 additions and 16 deletions
@@ -1,2 +1,2 @@
__version__ = "1.22.16"
__version__ = "1.22.17"
AGENT_NAME = "ERP Local Agent"
@@ -174,6 +174,7 @@ class AgentCommandProcessor:
"cash_payment_dual_progress_capability": True,
"cash_payment_async_ledger_master_capability": True,
"cash_payment_ledger_cache_capability": True,
"cash_payment_open_company_selection_capability": True,
"opening_balance_balance_sheet_only_capability": True,
"tally_writeback_capability": True,
}
@@ -518,7 +519,7 @@ class AgentCommandProcessor:
def _resolve_open_company(self, payload: dict[str, Any]) -> tuple[dict[str, Any], str]:
requested_guid = str(payload.get("tally_guid") or "").strip()
if not requested_guid:
raise ValueError("Mapped Tally company GUID is required.")
raise ValueError("Open Tally company GUID is required.")
tally_status = self.tally.status()
if not tally_status.get("connected"):
raise ValueError(str(tally_status.get("error") or "TallyPrime is not connected."))
@@ -801,7 +802,7 @@ class AgentCommandProcessor:
client_id = int(payload.get("client_id"))
tally_guid = str(payload.get("tally_guid") or "").strip()
if not tally_guid:
raise ValueError("Mapped Tally company GUID is required.")
raise ValueError("Open Tally company GUID is required.")
company_name = str(payload.get("company_name") or "").strip()
cached = self._cash_payment_cached_ledgers(client_id, tally_guid)
if cached:
@@ -827,7 +828,7 @@ class AgentCommandProcessor:
client_id = int(payload.get("client_id"))
tally_guid = str(payload.get("tally_guid") or "").strip()
if not tally_guid:
raise ValueError("Mapped Tally company GUID is required.")
raise ValueError("Open Tally company GUID is required.")
expected_company_name = str(payload.get("company_name") or "").strip()
self._ensure_cash_ledger_schema(client_id)
@@ -891,12 +892,12 @@ class AgentCommandProcessor:
with self.store.connect(client_id) as db:
db.execute(
"UPDATE cash_payment_ledger_jobs SET status='running',stage=?,percent=? WHERE job_id=?",
("Validating mapped company with Tally", 8, job_id),
("Validating selected open company with Tally", 8, job_id),
)
db.commit()
_cash_progress_snapshot({
"job_id": job_id, "job_kind": "ledger_master", "status": "running",
"stage": "Validating mapped company with Tally", "percent": 8,
"stage": "Validating selected open company with Tally", "percent": 8,
"company_name": company_name, "ledger_count": 0,
})
@@ -1127,7 +1128,7 @@ class AgentCommandProcessor:
date_from = str(payload.get("date_from") or "").strip()
date_to = str(payload.get("date_to") or "").strip()
if not tally_guid:
raise ValueError("Select a mapped Tally company before starting extraction.")
raise ValueError("Select an open Tally company before starting extraction.")
selected_cash_ledgers = [str(x or "").strip() for x in (payload.get("cash_ledger_names") or []) if str(x or "").strip()]
single_cash_ledger = str(payload.get("cash_ledger_name") or "").strip()
if single_cash_ledger and single_cash_ledger not in selected_cash_ledgers:
@@ -1224,10 +1225,19 @@ class AgentCommandProcessor:
if not self.store.exists(client_id):
raise ValueError("Accounting local storage is not initialized for this client.")
self._ensure_cash_cache_schema(client_id)
mapping = self.store.get_active_mapping_by_guid(client_id, tally_guid)
company_name = str(mapping.get("company_name") or "").strip()
mapping = self.store.get_active_mapping_by_guid(client_id, tally_guid) or {}
company_name = str(payload.get("company_name") or mapping.get("company_name") or "").strip()
if not company_name:
raise ValueError("The mapped Tally company name is not available in local accounting storage. Refresh the Tally mapping first.")
# Read-only cash compliance may work against any company that is currently
# open in TallyPrime. Do not create or alter the client's permanent mapping.
company, live_company_name = self._resolve_open_company(payload)
company_name = live_company_name
mapping = {
"tally_guid": str(company.get("guid") or tally_guid),
"company_name": company_name,
"gstin": str(company.get("gstin") or ""),
"transient_open_company": True,
}
# Reuse a paused/interrupted identical cache only inside the worker.
with self.store.connect(client_id) as db: