Fix GST reconciliation blank query parameter handling

This commit is contained in:
A R R R Associates
2026-09-12 16:43:58 +05:30
parent db8c27ae3c
commit f87ee1f904
@@ -388,14 +388,18 @@ def _merge_gstr3b_itc(payloads: list[object]) -> dict[str, float]:
return totals
@router.get("")
def page(request: Request, client_id: int | None = None, registration_id: int | None = None, period: str = "", financial_year: str = "", download_mode: str = "single", message: str = "", error: str = ""):
def page(request: Request, client_id: str = "", registration_id: str = "", period: str = "", financial_year: str = "", download_mode: str = "single", message: str = "", error: str = ""):
db = CommonSessionLocal()
try:
user, response = _require_partner(request, db, "accounting.learning.view")
if response:
return response
clients, scope = _visible_clients(db, request, user)
selected = next((c for c in clients if client_id and int(c.id) == int(client_id)), None)
client_id_text = str(client_id or "").strip()
registration_id_text = str(registration_id or "").strip()
client_id_value = int(client_id_text) if client_id_text.isdigit() else None
registration_id_value = int(registration_id_text) if registration_id_text.isdigit() else None
selected = next((c for c in clients if client_id_value and int(c.id) == client_id_value), None)
registrations=[]; selected_reg=None; credentials=[]; node=None
if not financial_year:
financial_year = str(request.session.get("active_financial_year") or request.session.get("active_fy") or "2025-26")
@@ -403,7 +407,7 @@ def page(request: Request, client_id: int | None = None, registration_id: int |
download_mode = "single"
if selected:
registrations=[(r,t) for r,t in _gst_regs(db,scope.tenant_id,selected.id) if _is_gstin(r,t)]
selected_reg=next((r for r,t in registrations if registration_id and int(r.id)==int(registration_id)),None)
selected_reg=next((r for r,t in registrations if registration_id_value and int(r.id)==registration_id_value),None)
if not selected_reg and registrations:
selected_reg=registrations[0][0]
selected_gstin = _norm_gstin(getattr(selected_reg, "registration_number", "")) if selected_reg else ""