Files
arrr-erp/app/modules/accounting/accounting_analytics_source.py
2026-09-20 16:36:14 +05:30

82 lines
2.9 KiB
Python

from __future__ import annotations
from typing import Any
from app.modules.accounting.accounting_mirror_service import (
cash_transactions,
daybook,
gst_history,
hsn_history,
inventory,
ledger_transactions,
mirror_exceptions,
mirror_query,
mirror_status,
stock_items,
trial_balance,
voucher,
)
class AccountingAnalyticsDataSource:
"""Common read-only data source for accounting/audit analytical procedures.
Read-only accounting/audit analysis is mirror-first. UI analysis workflows
resolve their Client/FY through AccountingMirrorRegistry before constructing
this source or invoking Local-Agent mirror commands. Live Tally remains a
bootstrap/write channel only; analytical reads use the registered .act mirror.
"""
def __init__(self, *, node_code: str, accounting_payload: dict[str, Any]):
self.node_code = str(node_code or "").strip()
self.accounting_payload = dict(accounting_payload or {})
if not self.node_code:
raise ValueError("node_code is required.")
def status(self):
return mirror_status(node_code=self.node_code, accounting_payload=self.accounting_payload)
def daybook(self, **kwargs):
return daybook(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def trial_balance(self, **kwargs):
return trial_balance(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def ledger_transactions(self, **kwargs):
return ledger_transactions(
node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs
)
def inventory(self, **kwargs):
return inventory(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def stock_items(self, **kwargs):
return stock_items(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def hsn_history(self, **kwargs):
return hsn_history(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def gst_history(self, **kwargs):
return gst_history(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def cash_transactions(self, **kwargs):
return cash_transactions(
node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs
)
def voucher(self, **kwargs):
return voucher(node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs)
def exceptions(self, **kwargs):
return mirror_exceptions(
node_code=self.node_code, accounting_payload=self.accounting_payload, **kwargs
)
def raw(self, query: str, filters: dict[str, Any] | None = None):
return mirror_query(
node_code=self.node_code,
accounting_payload=self.accounting_payload,
query=query,
filters=filters or {},
)