Add phase 1 client consultant referral and linkage
This commit is contained in:
@@ -76,6 +76,7 @@ from app.modules.billing.client_portal_service import (
|
||||
from app.modules.billing.services import build_invoice_print_context, create_cashfree_transaction, create_payumoney_transaction, process_cashfree_return, process_cashfree_webhook, process_payumoney_response
|
||||
from app.modules.email_integration.services import send_auth_otp_email
|
||||
from app.modules.documents.models import PermanentClientDocument
|
||||
from app.modules.consultants.service import list_consultants, get_primary_client_consultant_link, get_client_consultant_summary
|
||||
from app.modules.documents.services import (
|
||||
get_permanent_version,
|
||||
get_version,
|
||||
@@ -173,6 +174,12 @@ def _build_form_payload(request: Request, user, scope, *, include_client_code: b
|
||||
"branch_id": branch_id,
|
||||
"partner_id": partner_id,
|
||||
"default_review_partner_user_id": int(form.get("default_review_partner_user_id")) if form.get("default_review_partner_user_id") not in (None, "", "None") else None,
|
||||
"referred_by_consultant_id": int(form.get("referred_by_consultant_id")) if form.get("referred_by_consultant_id") not in (None, "", "None") else None,
|
||||
"primary_consultant_id": int(form.get("primary_consultant_id")) if form.get("primary_consultant_id") not in (None, "", "None") else None,
|
||||
"referral_date": form.get("referral_date") or None,
|
||||
"referral_reference": form.get("referral_reference"),
|
||||
"referral_status": form.get("referral_status") or "active",
|
||||
"communication_routing_mode": form.get("communication_routing_mode") or "client_and_consultant",
|
||||
"engagement_mode": form.get("engagement_mode") or "internal_managed",
|
||||
"client_name": form.get("client_name", ""),
|
||||
"trade_name": form.get("trade_name"),
|
||||
@@ -252,6 +259,7 @@ def _form_options(db, scope, form_mode: str):
|
||||
"review_partners": repository.list_all_partners(db),
|
||||
"active_tenant_id": tenant_id,
|
||||
"active_branch_id": branch_id,
|
||||
"consultants": list_consultants(db, tenant_id=tenant_id, include_inactive=False) if tenant_id else [],
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -262,6 +270,7 @@ def _form_options(db, scope, form_mode: str):
|
||||
tenant_id=tenant_id,
|
||||
branch_id=None if scope.allow_cross_branch else branch_id,
|
||||
),
|
||||
"consultants": list_consultants(db, tenant_id=tenant_id, branch_id=branch_id, include_inactive=False),
|
||||
"review_partners": repository.list_partners_for_scope(
|
||||
db,
|
||||
tenant_id=tenant_id,
|
||||
@@ -572,6 +581,8 @@ def client_new_page(request: Request):
|
||||
"acceptance_status": "pending_review",
|
||||
"acceptance_required": True,
|
||||
"engagement_letter_required": True,
|
||||
"referral_status": "active",
|
||||
"communication_routing_mode": "client_and_consultant",
|
||||
}
|
||||
|
||||
return _render(
|
||||
@@ -685,6 +696,7 @@ def client_detail(request: Request, client_id: int):
|
||||
can_activate=has("clients.activate"),
|
||||
can_archive=has("clients.archive"),
|
||||
can_restore=has("clients.restore"),
|
||||
consultant_summary=get_client_consultant_summary(db, tenant_id=int(row["tenant_id"]), client_id=client_id),
|
||||
can_manage_acceptance=has("clients.acceptance.manage"),
|
||||
can_approve_acceptance=has("clients.acceptance.approve"),
|
||||
)
|
||||
@@ -725,7 +737,7 @@ def client_edit_page(request: Request, client_id: int):
|
||||
user,
|
||||
title=f"Edit Client • {row.client_name}",
|
||||
row=row,
|
||||
form_data=row,
|
||||
form_data={**row.__dict__, "primary_consultant_id": getattr(get_primary_client_consultant_link(db, tenant_id=row.tenant_id, client_id=row.id), "consultant_id", None)},
|
||||
form_errors=[],
|
||||
scope=scope,
|
||||
form_options=_form_options(db, scope, form_mode),
|
||||
|
||||
Reference in New Issue
Block a user