Fix existing GSTIN display in bulk registrations

This commit is contained in:
A R R R Associates
2026-08-10 12:33:08 +05:30
parent d8cb564dfc
commit 9aed9d31b9
2 changed files with 27 additions and 2 deletions
@@ -197,7 +197,7 @@
{% set client_businesses = businesses_by_client.get(client.id, []) %} {% set client_businesses = businesses_by_client.get(client.id, []) %}
{% set client_branches = branches_by_client.get(client.id, []) %} {% set client_branches = branches_by_client.get(client.id, []) %}
<tr class="client-row align-top" <tr class="client-row align-top"
data-search="{{ ((client.client_code or '') ~ ' ' ~ (client.client_name or '') ~ ' ' ~ (client.pan or '') ~ ' ' ~ (client.gstin or '') ~ ' ' ~ (client.trade_name or ''))|lower|e }}"> data-search="{{ ((client.client_code or '') ~ ' ' ~ (client.client_name or '') ~ ' ' ~ (client.pan or '') ~ ' ' ~ (gstins_by_client.get(client.id, [])|join(' ')) ~ ' ' ~ (client.trade_name or ''))|lower|e }}">
<td class="px-3 py-3"> <td class="px-3 py-3">
<input type="checkbox" name="client_ids" value="{{ client.id }}" <input type="checkbox" name="client_ids" value="{{ client.id }}"
class="client-checkbox rounded border-slate-300"> class="client-checkbox rounded border-slate-300">
@@ -208,7 +208,8 @@
</td> </td>
<td class="px-3 py-3 text-xs text-slate-600"> <td class="px-3 py-3 text-xs text-slate-600">
<div>PAN: {{ client.pan or '-' }}</div> <div>PAN: {{ client.pan or '-' }}</div>
<div>GSTIN: {{ client.gstin or '-' }}</div> {% set existing_gstins = gstins_by_client.get(client.id, []) %}
<div>GSTIN: {{ existing_gstins|join(', ') if existing_gstins else '-' }}</div>
</td> </td>
<td class="px-3 py-3"> <td class="px-3 py-3">
<input name="registration_number_{{ client.id }}" <input name="registration_number_{{ client.id }}"
+24
View File
@@ -101,6 +101,29 @@ def bulk_registration_page(
tenant_id = _tenant(request, user) tenant_id = _tenant(request, user)
branch_id = _branch(request, user) branch_id = _branch(request, user)
gstins_by_client = {}
gstin_rows = db.execute(
select(
ClientRegistration.client_id,
ClientRegistration.registration_number,
)
.join(
RegistrationType,
RegistrationType.id == ClientRegistration.registration_type_id,
)
.where(
ClientRegistration.tenant_id == tenant_id,
RegistrationType.code == "GSTIN",
)
.order_by(
ClientRegistration.client_id.asc(),
ClientRegistration.registration_number.asc(),
)
).all()
for gstin_client_id, gstin_number in gstin_rows:
number = (gstin_number or "").strip()
if number:
gstins_by_client.setdefault(int(gstin_client_id), []).append(number)
clients_query = select(Client).where( clients_query = select(Client).where(
Client.tenant_id == tenant_id, Client.tenant_id == tenant_id,
Client.is_active.is_(True), Client.is_active.is_(True),
@@ -186,6 +209,7 @@ def bulk_registration_page(
types=types, types=types,
rules=rules, rules=rules,
consultants=consultants, consultants=consultants,
gstins_by_client=gstins_by_client,
created=created, created=created,
skipped=skipped, skipped=skipped,
invalid=invalid, invalid=invalid,