Fix depreciation mirror selection and TDS capital account exclusion

This commit is contained in:
A R R R Associates
2026-09-06 21:28:23 +05:30
parent f211d9e6a8
commit 5c19f23c2d
6 changed files with 153 additions and 34 deletions
+24 -10
View File
@@ -810,9 +810,10 @@ def depreciation_it_tool(
node = get_active_storage_node_for_branch(db, scope.tenant_id, scope.branch_id)
online = _node_online(node)
today = date.today()
start_year = today.year if today.month >= 4 else today.year - 1
start_text = fy_start or date(start_year, 4, 1).isoformat()
end_text = fy_end or date(start_year + 1, 3, 31).isoformat()
active_start_year = today.year if today.month >= 4 else today.year - 1
explicit_period = bool(str(fy_start or "").strip() and str(fy_end or "").strip())
start_text = fy_start or date(active_start_year, 4, 1).isoformat()
end_text = fy_end or date(active_start_year + 1, 3, 31).isoformat()
preview = None
depreciation_run = None
mirror_status = None
@@ -820,17 +821,30 @@ def depreciation_it_tool(
analysis_history = []
if selected_client and node and online:
storage_payload = _accounting_storage_payload(
selected_client, _financial_year_for_date(date.fromisoformat(start_text))
)
selected_fy=_financial_year_for_date(date.fromisoformat(start_text))
storage_payload=_accounting_storage_payload(selected_client,selected_fy)
try:
status_response = request_agent_command(
node.node_code, "accounting_mirror_status", storage_payload, timeout_seconds=20
status_response=request_agent_command(
node.node_code,"accounting_mirror_status",storage_payload,timeout_seconds=20
)
if status_response.get("ok"):
mirror_status = status_response.get("result") or {}
mirror_status=status_response.get("result") or {}
else:
command_error = str(status_response.get("error") or "Accounting Mirror status failed.")
command_error=str(status_response.get("error") or "Accounting Mirror status failed.")
if not explicit_period and not ((mirror_status or {}).get("mirror") or {}).get("ready_for_financial_year"):
prior_start_year=active_start_year-1
prior_start=date(prior_start_year,4,1)
prior_end=date(prior_start_year+1,3,31)
prior_fy=_financial_year_for_date(prior_start)
prior_payload=_accounting_storage_payload(selected_client,prior_fy)
prior_response=request_agent_command(
node.node_code,"accounting_mirror_status",prior_payload,timeout_seconds=20
)
prior_status=(prior_response.get("result") or {}) if prior_response.get("ok") else {}
if ((prior_status.get("mirror") or {}).get("ready_for_financial_year")):
start_text=prior_start.isoformat(); end_text=prior_end.isoformat()
storage_payload=prior_payload; mirror_status=prior_status
if mirror_status and (mirror_status.get("mirror") or {}).get("ready_for_financial_year"):
preview_response = request_agent_command(