From 41d4a7b647e00124a8e5dc1b531621953c57a148 Mon Sep 17 00:00:00 2001 From: A R R R Associates Date: Mon, 7 Sep 2026 14:43:33 +0530 Subject: [PATCH] Restore local accounting active mapping compatibility --- app/modules/documents/agent_package.py | 2 +- .../erp_local_agent/__init__.py | 2 +- .../erp_local_agent/accounting_store.py | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/modules/documents/agent_package.py b/app/modules/documents/agent_package.py index 666e8ec..d183230 100644 --- a/app/modules/documents/agent_package.py +++ b/app/modules/documents/agent_package.py @@ -4,7 +4,7 @@ import io from pathlib import Path import zipfile -ERP_LOCAL_AGENT_VERSION = "1.26.1" +ERP_LOCAL_AGENT_VERSION = "1.26.2" ERP_LOCAL_AGENT_NAME = "ERP Local Agent" RUNTIME_ROOT = Path(__file__).resolve().parent / "local_agent_runtime" _DETERMINISTIC_ZIP_TIMESTAMP = (2026, 1, 1, 0, 0, 0) diff --git a/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py b/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py index ee5681a..759f64f 100644 --- a/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py +++ b/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py @@ -1,2 +1,2 @@ -__version__ = "1.26.1" +__version__ = "1.26.2" AGENT_NAME = "ERP Local Agent" diff --git a/app/modules/documents/local_agent_runtime/erp_local_agent/accounting_store.py b/app/modules/documents/local_agent_runtime/erp_local_agent/accounting_store.py index a062417..a3fb826 100644 --- a/app/modules/documents/local_agent_runtime/erp_local_agent/accounting_store.py +++ b/app/modules/documents/local_agent_runtime/erp_local_agent/accounting_store.py @@ -597,6 +597,27 @@ class LocalAccountingStore: raise ValueError("The selected open Tally company is not mapped to this ERP client. Complete Phase 2 mapping first.") return dict(row) + def list_active_mappings(self, client_id: int) -> list[dict]: + """Return all active Tally mappings for the client. + + Existing command handlers use this when the mirror already identifies the + company but a GUID-specific lookup is unavailable or when a posting tool + needs to resolve the client's sole active mapping. Keeping this operation + in LocalAccountingStore makes Depreciation and Cash Payment Allocation use + the same mapping table as the existing Tally mapping workflow. + """ + if not self.exists(client_id): + return [] + with self.connect(client_id) as db: + rows = db.execute( + """SELECT * + FROM tally_company_mapping + WHERE client_id=? AND is_active=1 + ORDER BY id DESC""", + (int(client_id),), + ).fetchall() + return [dict(row) for row in rows] + def unmap_company(self, client_id: int, mapping_id: int, unmapped_by_user_id: int | None = None) -> dict: if not self.exists(client_id): raise ValueError("Accounting storage is not initialized for this client.")