Business workflows
Purpose: the cross-module journeys that matter, as implemented. Each states the starting point, the state changes, who does what, what is automatic, and how it fails.
Automated steps run in the backend (and sometimes in a background worker). "Manual" means a person must click an action.
For step-by-step process guides, see Workflow guides: lead conversion, quote to invoice, invoice to payment, project delivery, procure to pay, and how stock becomes available.
1. Enquiry to cash
Starting point. A lead exists — typed in, captured by a public lead form, or imported from CSV.
| # | Step | Who | State change | Manual/Auto |
|---|---|---|---|---|
| 1 | Lead created | USER+ | Lead NEW | Manual (or automatic from a form submission) |
| 2 | Work the lead; log calls/notes; send email | USER+ | Status CONTACTED/QUALIFIED | Manual |
| 3 | Associate the lead with an account (or let conversion create one) | USER+ | lead.company set | Manual |
| 4 | Convert lead | OWNER/ADMIN (crm.lead.convert) | Lead CONVERTED + converted_at; Opportunity created and linked one-to-one; account created or reused | Manual, single transaction |
| 5 | Move the opportunity through pipeline stages | OWNER/ADMIN (crm.opportunity.move_stage) | Opportunity stage/pipeline | Manual |
| 6 | Create a quote for the opportunity | USER+ | Quote DRAFT, QT-YYYY-… | Manual |
| 7 | Send the quote | OWNER/ADMIN (q2c.quote.send) | SENT + sent_at | Manual |
| 8 | Customer decides | OWNER/ADMIN | ACCEPTED / REJECTED, or EXPIRED after valid_until | Manual (expiry automatic) |
| 9 | Convert accepted quote | OWNER/ADMIN (q2c.quote.convert) | Sales order DRAFT, SO-YYYY-…, snapshots quote data | Manual, quote locked |
| 10 | Confirm the order | OWNER/ADMIN (q2c.sales_order.confirm) | CONFIRMED + confirmed_at | Manual |
| 11 | Convert confirmed order | OWNER/ADMIN (q2c.sales_order.convert) | Invoice DRAFT, INV-YYYY-…, snapshots order data | Manual, one invoice per order |
| 12 | Issue the invoice | OWNER/ADMIN (q2c.invoice.issue) | ISSUED + issued_at | Manual |
| 13 | Record payment | OWNER/ADMIN (q2c.payment.record) | ISSUED → PARTIALLY_PAID → PAID; amount_paid recomputed | Manual, invoice row locked |
| 14 | Correct a payment | OWNER/ADMIN | REVERSED/CANCELLED payment; invoice balance restored | Manual, same transaction |
Completion condition. Invoice PAID (or fully settled by adjustments outside V1).
Failure and exception scenarios.
- Conversion is attempted twice → rejected by a one-to-one relation; there is no second order/invoice from the same source.
- Quote expired before acceptance → EXPIRED; create a new quote.
- Totals sent by the browser disagree with line items → ignored; the backend recomputes.
- Payment exceeds outstanding → rejected.
- Two payments recorded concurrently → the invoice row lock serialises them; one RECORDED payment per invoice is enforced.
- Cancelling an order/invoice after issue → allowed only through its dedicated action, and recorded as a terminal state.
Automation. Quote expiry (expire_due_quotes), invoice overdue scan, and
due-date reminders exist as scheduled/background tasks. Notifications and emails
are queued after commit.
2. Buying from suppliers
Starting point. A need is identified by a department or a project.
Requisition → Approval → RFQ (invite suppliers) → Supplier quotes → Select quote
→ Purchase order → PO approval → Send to supplier
→ Goods receipt (full/partial/rejected) → Supplier bill
→ Three-way match (PO ↔ receipt ↔ bill) → Payment / Credit note / Refund| Step | State change | Notes |
|---|---|---|
| Requisition | DRAFT → submitted → APPROVED / REJECTED | Approval policy decides who must approve (thresholds not documented — see DG-24). |
| RFQ | DRAFT → ISSUED → closed/cancelled | Invitations tracked per supplier. |
| Supplier quote | received → SELECTED / rejected | One quote is selected per RFQ. |
| Purchase order | DRAFT → pending approval → APPROVED → sent → partially/fully received → CLOSED / CANCELLED | Revisions are recorded; re-approval supported. |
| Goods receipt | pending → ACCEPTED / PARTIAL / REJECTED, reversible | Reversal restores received quantities. |
| Supplier bill | DRAFT → ISSUED → paid/partly paid → CANCELLED | Three-way match exceptions must be resolved or accepted. |
| Supplier payment | RECORDED → REVERSED / CANCELLED | Cannot exceed the bill's outstanding amount. |
| Credit note | issued and applied against bills | Refunds/advances tracked separately. |
Who. USER creates records; approval, receipt reversal, and payment actions need their own grants (OWNER/ADMIN, MANAGER for some).
Automation. Scheduled reminders for expiring contracts, stale approvals, overdue supplier bills, and past-due RFQs.
Failure scenarios. Receiving more than ordered → blocked. Receiving a cancelled PO → blocked. Paying before the bill is issued → blocked. Match exception left open → bill cannot proceed until handled.
3. Delivering a project
Starting point. A sold engagement. A project is created (optionally referencing the customer account), members are added, and milestones are dated.
| Step | State change | Notes |
|---|---|---|
| Create project | DRAFT/planned | Dates define the valid range for milestones and tasks |
| Activate | ACTIVE | projects.project.activate |
| Add tasks | status open → in progress → done | Board and list views |
| Log time | time entries with start/stop, optionally linked to a task | One running timer per user |
| Manage budget and expenses | budget draft → approved; expenses submitted → approved/reversed | financials.* grants |
| Complete | COMPLETED | projects.project.complete; archived projects cannot be completed |
| Cancel | CANCELLED | projects.project.cancel |
What is automatic. Overdue-task reminders, due-date notifications, project financial snapshots, profitability calculations.
Failure scenarios. Milestone or task dates outside the project range → rejected (SF-016). Completing an archived project → rejected. Expense above budget → flagged; approval policy decides the outcome (thresholds undocumented).
4. Running a marketing campaign (Reach)
Contacts (import/manual) → Consent + suppression check → Audience
→ Template → Campaign → Approval → Schedule → Send → Events/Analytics| Step | Who | Notes |
|---|---|---|
| Import/build contacts | USER+ | Suppressed addresses are excluded |
| Build audience | USER+ | Static membership |
| Create campaign | USER+ | Chooses audience, template, sender |
| Approve | OWNER/ADMIN (reach.campaign.approve) | When approval is required is a product rule not yet documented (DG-25) |
| Schedule/send | OWNER/ADMIN or MANAGER | Pause and cancel supported |
| Review events | USER+ | Delivered, opened, clicked, bounced, complained |
Failure scenarios. Unverified sender domain → sending is not allowed. Suppressed contact in audience → excluded. Provider outage → messages remain with a failure status and can be retried where supported.
5. Inviting a teammate
- OWNER/ADMIN opens Control → Users → Invite (or Invitations).
- Enters email and role. The backend creates a single-use token (stored hashed, default 7-day expiry) and supersedes any pending invitation for that email.
- Email is queued after the transaction commits.
- The invitee opens the link. If they have no account, one is created; the membership becomes ACTIVE in the same transaction. If they already have an account, the membership is added to it.
- Seat limits from the plan are enforced at acceptance.
Failure scenarios. Invitation expired, revoked, already used, or organization suspended → acceptance fails with a clear reason. Duplicate pending invitation → the newest wins. Seat limit reached → acceptance refused until a seat is freed.
6. Automating a follow-up
- OWNER/ADMIN creates a workflow: one trigger (record created/updated/deleted, status changed, assignment changed, or a schedule), conditions (AND/OR), ordered actions.
- Enable it. Only enabled workflows run.
- A business service fires the event inside its transaction; a PENDING execution row is written and the worker is dispatched after commit.
- The worker claims the execution, evaluates conditions, runs actions in order, writes an immutable step log, and marks SUCCEEDED / FAILED / SKIPPED.
workflow_executed/workflow_failedactivities are recorded.
Guarantees and limits. The business transaction never fails because automation failed. In-flight executions are deduplicated per (workflow, target), which also prevents recursion. A failed execution is retried by the worker and remains visible in execution history.
Failure scenarios. Conditions never match → execution SKIPPED. Action targets a record the workflow's own action changed → recursion is blocked by the dedupe constraint. Worker unavailable → executions wait in PENDING.
7. Becoming a customer of SahajFlow (tenant onboarding)
Sign up → verify email → sign in → choose/create workspace → land on dashboard- Signup creates a login only; it creates no organization.
- Creating a workspace provisions, in one transaction: the organization, the OWNER membership, a subscription plan (Starter by default, or the chosen launch plan), a default CRM pipeline with standard stages, and the owner's employee profile.
- Invited users skip workspace creation and land in the inviter's workspace.
Failure scenarios. Unverified email → sign-in blocked with EMAIL_NOT_VERIFIED.
No membership → the app routes to workspace selection instead of a broken dashboard.
Suspended tenant → every tenant endpoint fails with a suspension error until
platform staff reactivate it.
8. What is not an implemented workflow
Documented elsewhere or assumed by users, but not built:
- Lead → Contact → Opportunity with people records (no CRM Contact model).
- Quote → Razorpay/UPI collection link (no payment gateway integration in Q2C).
- Two-way Google Calendar sync (import only).
- Tally or GST-return export (roadmap only).
- Customer self-service portal.
- Mobile app or offline mode.
Module overview
One section per module that exists in the product. Each states purpose, what it holds, who can use it, what it depends on, and whether it is usable today.
Sign in and create your workspace
The first ten minutes: create your login, verify your email, and open the workspace your team will use.