diff --git a/app/modules/clients/repository.py b/app/modules/clients/repository.py index 09c2aa2..dc6673f 100644 --- a/app/modules/clients/repository.py +++ b/app/modules/clients/repository.py @@ -107,7 +107,7 @@ def list_clients( client_type=client_type, client_group_id=client_group_id, include_archived=include_archived, ) total = db.execute(select(func.count()).select_from(stmt.subquery())).scalar_one() - per_page = min(max(int(per_page or 25), 1), 100) + per_page = min(max(int(per_page or 25), 1), 5000) pages = max(ceil(total / per_page), 1) page = min(max(int(page or 1), 1), pages) offset = (page - 1) * per_page diff --git a/app/modules/clients/templates/clients/list.html b/app/modules/clients/templates/clients/list.html index 3d3b6dc..8eadf9e 100644 --- a/app/modules/clients/templates/clients/list.html +++ b/app/modules/clients/templates/clients/list.html @@ -34,7 +34,7 @@ {% include "modules/clients/templates/clients/partials/table.html" %} - {% if meta %} + {% if meta and not partner_client_view %}
{% if meta.total > 0 %} diff --git a/app/modules/clients/templates/clients/partials/table.html b/app/modules/clients/templates/clients/partials/table.html index 6d89a8c..da038d8 100644 --- a/app/modules/clients/templates/clients/partials/table.html +++ b/app/modules/clients/templates/clients/partials/table.html @@ -1,3 +1,142 @@ +{% if partner_client_view %} +
+
+ + + + + +
+ +
+ {{ rows|length }} clients + Assigned and review-access clients only +
+ +
+ + + + + + + + + + + + + {% for row in rows %} + {% set row_status = (row.status or 'inactive')|lower %} + {% set row_group = (row.client_group_name or '')|lower %} + + + + + + + + + {% else %} + + {% endfor %} + + +
CodeClientGroupBranchStatus
{{ row.client_code }} +
{{ row.client_name }}
+
{{ row.pan or row.gstin or '-' }}
+
+ {% if row.client_group_name %} + {{ row.client_group_name }} +
{{ row.group_relationship or row.client_group_code }}
+ {% else %}-{% endif %} +
{{ row.branch_name or row.assoc_firm_branch_id or row.branch_id or '-' }} + {% if row_status == 'active' %}Active + {% elif row_status == 'archived' %}Archived + {% else %}Inactive{% endif %} + Open
No clients found.
+
+
+ +{% else %}
@@ -16,40 +155,16 @@ {% for row in rows %} - - - + + + - - + + - {% else %} - - - - {% endfor %} + {% else %}{% endfor %}
{{ row.client_code }} -
{{ row.client_name }}
-
{{ row.pan or row.gstin or '-' }}
-
- {% if row.client_group_name %} - {{ row.client_group_name }} -
{{ row.group_relationship or row.client_group_code }}
- {% else %}-{% endif %} -
-
{{ row.association_type or 'legacy_firm' }}
-
{{ row.assoc_created_source or 'legacy' }}
-
{{ row.client_name }}
{{ row.pan or row.gstin or '-' }}
{% if row.client_group_name %}{{ row.client_group_name }}
{{ row.group_relationship or row.client_group_code }}
{% else %}-{% endif %}
{{ row.association_type or 'legacy_firm' }}
{{ row.assoc_created_source or 'legacy' }}
{{ row.partner_name or row.effective_partner_id or '-' }} {{ row.branch_name or row.assoc_firm_branch_id or row.branch_id or '-' }} - {% if row.status == 'active' %} - Active - {% elif row.status == 'archived' %} - Archived - {% else %} - Inactive - {% endif %} - - Open - {% if row.status == 'active' %}Active{% elif row.status == 'archived' %}Archived{% else %}Inactive{% endif %}Open
No clients found.
No clients found.
+{% endif %} diff --git a/app/modules/clients/ui.py b/app/modules/clients/ui.py index 84c96f1..a64fb64 100644 --- a/app/modules/clients/ui.py +++ b/app/modules/clients/ui.py @@ -321,6 +321,7 @@ def clients_list( return _redirect_denied() role_names = _role_names(db, user) + partner_client_view = is_partner_role(role_names) scope = build_scope(request, user, has) scope = _apply_role_scope(scope, user, role_names) @@ -347,13 +348,13 @@ def clients_list( allow_all_clients=scope.allow_all_clients, partner_id=None if is_partner_role(role_names) else filters.partner_id, viewer_partner_id=_viewer_partner_id(user, role_names), - q=filters.q, - status=filters.status, - client_type=filters.client_type, - client_group_id=filters.client_group_id, + q="" if partner_client_view else filters.q, + status="" if partner_client_view else filters.status, + client_type="" if partner_client_view else filters.client_type, + client_group_id=None if partner_client_view else filters.client_group_id, include_archived=filters.include_archived, - page=filters.page, - per_page=filters.per_page, + page=1 if partner_client_view else filters.page, + per_page=5000 if partner_client_view else filters.per_page, sort_by=filters.sort_by, sort_order=filters.sort_order, ) @@ -369,6 +370,7 @@ def clients_list( can_create=has("clients.create"), can_export=has("clients.export"), can_import=has("clients.import"), + partner_client_view=partner_client_view, q=filters.q, status=filters.status, client_type=filters.client_type, diff --git a/app/modules/partner_dashboard/service.py b/app/modules/partner_dashboard/service.py index 496f6c9..7dcf50f 100644 --- a/app/modules/partner_dashboard/service.py +++ b/app/modules/partner_dashboard/service.py @@ -228,7 +228,7 @@ def _load_tasks(db: Session, tenant_id: int | None, branch_id: int | None, curre def _load_clients(db: Session, tenant_id: int | None, branch_id: int | None, current_user, roles: set[str]) -> list[dict[str, Any]]: stmt = _client_scope(select(Client), tenant_id, branch_id, current_user, roles) - clients = db.execute(stmt.order_by(Client.client_name.asc()).limit(100)).scalars().all() + clients = db.execute(stmt.order_by(Client.client_name.asc()).limit(5000)).scalars().all() out: list[dict[str, Any]] = [] for client in clients: task_count = _count(db, _task_scope(select(func.count(ClientServiceTaskInstance.id)), tenant_id, branch_id, current_user, roles).where(ClientServiceTaskInstance.client_id == client.id)) @@ -246,6 +246,7 @@ def _load_clients(db: Session, tenant_id: int | None, branch_id: int | None, cur "gstin": client.gstin, "email": client.email, "mobile": client.mobile, + "status": client.status or ("active" if client.is_active else "inactive"), "service_count": service_count, "task_count": task_count, "overdue_count": overdue_count, diff --git a/app/modules/partner_dashboard/templates/partner_dashboard/partials/clients.html b/app/modules/partner_dashboard/templates/partner_dashboard/partials/clients.html index e55fb44..f56985f 100644 --- a/app/modules/partner_dashboard/templates/partner_dashboard/partials/clients.html +++ b/app/modules/partner_dashboard/templates/partner_dashboard/partials/clients.html @@ -1,11 +1,101 @@ -
-

Assigned Clients

Owned clients and review-assigned clients, with service count, open tasks and overdue items.

Manage Clients
-
- {% for c in clients %} - -

{{ c.client_name }}

{{ c.client_code }}{% if c.gstin %} · {{ c.gstin }}{% elif c.pan %} · {{ c.pan }}{% endif %}

{% if c.overdue_count > 0 %}{{ c.overdue_count }} overdue{% endif %}
-
{{ c.service_count }}
Services
{{ c.task_count }}
Tasks
{{ c.overdue_count }}
Overdue
-
- {% else %}
No assigned or review clients found.
{% endfor %} +
+
+
+

Assigned Clients

+

Owned clients and review-assigned clients, with existing service, task and overdue totals.

+
+
+ {{ clients|length }} clients + Manage Clients +
+
+ +
+ + + +
+ +
+ + + + + + + + + + + + + + + {% for c in clients %} + {% set row_status = (c.status or 'active')|lower %} + + + + + + + + + + + {% else %} + + {% endfor %} + + +
CodeClientPAN / GSTINServicesTasksOverdueStatus
{{ c.client_code }}{{ c.client_name }}{{ c.pan or c.gstin or '-' }}{{ c.service_count }}{{ c.task_count }}{{ c.overdue_count }} + {% if row_status == 'active' %}Active + {% elif row_status == 'archived' %}Archived + {% else %}Inactive{% endif %} + Open
No assigned clients found.
+