Fix cash payment company resolver across all cash paths

This commit is contained in:
A R R R Associates
2026-09-04 21:11:35 +05:30
parent deeebc01be
commit 7fadbb9f4b
3 changed files with 25 additions and 5 deletions
@@ -1,2 +1,2 @@
__version__ = "1.22.20"
__version__ = "1.22.21"
AGENT_NAME = "ERP Local Agent"
@@ -178,6 +178,7 @@ class AgentCommandProcessor:
"cash_payment_ledger_cache_capability": True,
"cash_payment_open_company_selection_capability": True,
"cash_payment_opening_balance_master_path_capability": True,
"cash_payment_selected_company_resolver_capability": True,
"opening_balance_balance_sheet_only_capability": True,
"tally_writeback_capability": True,
}
@@ -1039,8 +1040,21 @@ class AgentCommandProcessor:
# Potentially slow Tally status/preflight is deliberately inside the
# worker so it can never delay the ERP command acknowledgement.
company, live_company_name = self._resolve_open_company(payload)
company_name = live_company_name
# Cash Payment must resolve the company the same way as Opening Balance
# Review. The generic GUID/current-company resolver is intentionally not
# used here because Tally CURRENTCOMPANY can refer to the focused company
# while another explicitly selected company is also open.
company, resolved_guid, _guid_refreshed = self._cash_payment_selected_company(payload)
company_name = str(company.name or "").strip()
if resolved_guid and resolved_guid != tally_guid:
tally_guid = resolved_guid
payload["tally_guid"] = resolved_guid
with self.store.connect(client_id) as db:
db.execute(
"UPDATE cash_payment_ledger_jobs SET tally_guid=?, company_name=? WHERE job_id=?",
(tally_guid, company_name, job_id),
)
db.commit()
with self.store.connect(client_id) as db:
db.execute(
"UPDATE cash_payment_ledger_jobs SET company_name=?,stage=?,percent=? WHERE job_id=?",
@@ -1793,7 +1807,13 @@ class AgentCommandProcessor:
from collections import defaultdict
from datetime import date as _date
company, company_name = self._resolve_open_company(payload)
# Read-only Cash Payment review follows the Opening Balance company resolver.
# Do not reject an explicitly selected loaded company merely because another
# open Tally company currently has UI focus.
company, resolved_guid, _guid_refreshed = self._cash_payment_selected_company(payload)
company_name = str(company.name or "").strip()
if resolved_guid:
payload["tally_guid"] = resolved_guid
date_from = str(payload.get("date_from") or "").strip()
date_to = str(payload.get("date_to") or "").strip()
cash_limit = round(float(payload.get("cash_limit") or 10000.0), 2)