Skip to content

Auto-advance pipeline status when contract events occur #348

@Starefossen

Description

@Starefossen

Problem

The CRM has three independent status dimensions that are updated separately:

  1. Pipeline status (status): prospectcontactednegotiatingclosed-won / closed-lost
  2. Contract status (contractStatus): noneverbal-agreementregistration-sentcontract-sentcontract-signed
  3. Invoice status (invoiceStatus): separate dimension

When key contract events occur, only contractStatus is updated — the pipeline status is never automatically advanced. For example:

  • sendContract sets contractStatus: 'contract-sent' but doesn't move the pipeline to closed-won, even though sending a contract implies the deal is won.
  • sendPortalInvite sets contractStatus: 'registration-sent' but doesn't touch the pipeline status.
  • submitSignature (signing router) sets contractStatus: 'contract-signed' and signatureStatus: 'signed' but doesn't advance the pipeline either.

This means organizers must manually drag sponsors through the pipeline board even after contract actions have been taken, which is error-prone and leads to stale pipeline views.

Proposed solution

Implement automatic pipeline status promotion when certain contract events occur:

Contract Event Contract Status Pipeline Auto-Promotion
Portal invite sent registration-sent No change (still negotiating)
Contract sent contract-sent closed-won (if not already closed-won)
Contract signed contract-signed closed-won (if not already closed-won)
Registration completed No change (handled by contract flow)

Implementation notes

  • Auto-promotion should only advance forward, never regress (e.g. don't move closed-won back to negotiating)
  • Log the status change via logStageChange() with the actor being the same user/system that triggered the contract event
  • Apply in all code paths: sendContract (sponsor.ts), generateAndSendContract (contract-send.ts), submitSignature (signing.ts), and the Adobe Sign webhook handler
  • Consider making this configurable per conference if some organizers prefer manual pipeline management

Files to modify

  • src/server/routers/sponsor.tssendContract mutation
  • src/lib/sponsor-crm/contract-send.tsgenerateAndSendContract (automated flow)
  • src/server/routers/signing.tssubmitSignature mutation
  • src/app/api/webhooks/adobe-sign/route.ts — webhook handler for AGREEMENT_WORKFLOW_COMPLETED

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions