Unify accounting analysis on Client FY mirror registry
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
__version__ = "1.26.19"
|
||||
__version__ = "1.26.20"
|
||||
AGENT_NAME = "ERP Local Agent"
|
||||
|
||||
@@ -679,7 +679,10 @@ class AgentCommandProcessor:
|
||||
raise ValueError("Client GST and Accounting storage paths are required.")
|
||||
root = Path(self.config.storage_root)
|
||||
base_dir = root / Path(gst_relative_dir) / period
|
||||
mirror_db = root / Path(accounting_relative_dir) / f"client_{client_id:08d}_mirror.act"
|
||||
mirror_file_name = Path(str(payload.get("mirror_file_name") or f"client_{client_id:08d}_mirror.act")).name
|
||||
if not mirror_file_name.lower().endswith(".act"):
|
||||
raise ValueError("Registered Accounting Mirror filename is invalid.")
|
||||
mirror_db = root / Path(accounting_relative_dir) / mirror_file_name
|
||||
if not base_dir.exists():
|
||||
raise ValueError("GST data has not yet been downloaded for this client/period.")
|
||||
if not mirror_db.exists():
|
||||
@@ -4219,10 +4222,17 @@ class AgentCommandProcessor:
|
||||
client_id = int(payload.get("client_id") or 0)
|
||||
if client_id <= 0:
|
||||
raise ValueError("client_id is required.")
|
||||
filename = f"client_{client_id:08d}.act"
|
||||
mirror_filename = f"client_{client_id:08d}_mirror.act"
|
||||
accounting_filename = f"client_{client_id:08d}.act"
|
||||
items: list[dict[str, Any]] = []
|
||||
pattern = f"FY*/Clients/*/*/Accounting/{filename}"
|
||||
for path in sorted(self.store.storage_root.glob(pattern)):
|
||||
pattern = f"FY*/Clients/*/*/Accounting/{mirror_filename}"
|
||||
paths = sorted(self.store.storage_root.glob(pattern))
|
||||
# Legacy fallback: older workstations may have only the client accounting
|
||||
# database until the next full mirror refresh. Discovery still reports it,
|
||||
# but new/full exports register the actual *_mirror.act analytical source.
|
||||
if not paths:
|
||||
paths = sorted(self.store.storage_root.glob(f"FY*/Clients/*/*/Accounting/{accounting_filename}"))
|
||||
for path in paths:
|
||||
if not path.is_file():
|
||||
continue
|
||||
try:
|
||||
@@ -4254,7 +4264,8 @@ class AgentCommandProcessor:
|
||||
"client_id": client_id,
|
||||
"financial_year": fy,
|
||||
"accounting_relative_dir": relative,
|
||||
"accounting_db_path": str(path),
|
||||
"mirror_db_path": str(path),
|
||||
"accounting_db_path": str(path.parent / accounting_filename),
|
||||
"company_name": str(company.get("company_name") or "").strip(),
|
||||
"tally_guid": str(company.get("company_guid") or "").strip(),
|
||||
"mirror": {
|
||||
|
||||
Reference in New Issue
Block a user