Quotes to Order in Magento 2 — Negotiation, Permissions, Workflow
Core Entities
Negotiable quotes let B2B buyers request tailored pricing and terms before placing an order. Model the domain explicitly:
- Negotiable Quote: A wrapper around the standard quote capturing requested items, quantities, buyer notes, attachments, target date, and expiration.
- Quote Items: Carry list prices, requested discounts, and negotiated prices (unit and total). Include per‑item comments for context.
- Timeline & Comments: A message thread between buyer and sales rep with time stamps, system events, and state changes.
- Attachments: Optional files (specs, drawings, compliance) with virus scan & size limits.
- Constraints: Currency/website scope, price source snapshot, and tax/shipping estimation inputs.
- Expiration: A hard cutoff after which prices auto‑invalidate and the quote closes.
- Audit: Immutable log of who changed what and when (prices, terms, items, addresses).
- Locks: Pessimistic lock while a rep edits; optimistic version checks for concurrency on submit.
- States: draft → requested → negotiating → approved → accepted → converted (or declined/expired).
Roles & Permissions
- Company Users: Create and view quotes; permissions define who may submit/accept.
- Approvers: Company‑side approval before acceptance based on amount or category.
- Sales Reps: Adjust prices, add alternatives, set expiration and payment/shipping terms.
- Backoffice: Finance/Legal review clauses; pricing governance via discount policies.
End‑to‑End Workflow
- Request: Buyer creates quote from cart or PDP ("Add to Quote"). Provide fields for target date, notes, attachments.
- Triage: Auto‑route to a sales rep by rules (territory, segment, channel). Notify via email/webhook.
- Negotiate: Rep counter‑proposes prices, substitutions, MOQs, bundles; system enforces discount limits and margin floors.
- Internal Approvals: If thresholds exceeded (e.g., margin < policy), require manager sign‑off before sending to buyer.
- Buyer Approval: Company approver reviews per‑line changes and terms; may request edits.
- Accept & Convert: Buyer accepts; stock and tax/shipping recalculated; quote converts to order atomically; the quote locks and is archived.
- Post‑Order: Preserve the quote PDF and audit log; link them from the order detail.
Pricing, Taxes & Shipping Estimation
- Price Sources: Start from catalog/customer pricing; apply line‑level and header discounts under policy controls.
- Taxes: Estimate during negotiation; finalize on conversion using current tax rules.
- Shipping: Offer estimated methods/rates (table rates or carrier APIs) and lock method on acceptance, re‑rating if SLA or address changes.
UI Patterns (Storefront)
- Request Quote CTA: In cart and on product; guard behind B2B roles.
- Quote Detail: Line list with list price, proposed price, discount %, comments, attachments, and totals.
- Change Log: Collapsible timeline showing key state transitions and actor comments.
- Actions: Ask revision, accept, decline; show expiry countdown and warning banners.
Notifications
- Email on state changes (requested, counter‑proposed, approved, about‑to‑expire).
- Webhooks to CRM/ERP for pipeline and forecast updates.
APIs, Observers & Service Contracts
- Service contracts: QuoteRepository/NegotiableQuoteRepository; commands to propose, approve, accept.
- Observers: On submit/accept to recompute taxes/stock and to dispatch notifications.
- REST/GraphQL: Endpoints for headless UIs; include secure file upload for attachments.
Performance & Reliability
- Cache price breakdowns per version; invalidate on edits.
- Use DB transactions to convert quote→order; idempotency keys to avoid duplicate orders on retries.
- Archive old versions to a history table for light quotes index.
Rollout, Testing & KPIs
- KPIs: Time‑to‑first‑response, time‑to‑accept, acceptance rate, avg. discount, margin delta, quote expiry rate.
- Testing: Matrix of roles/policies, currency/tax zones, catalog/price updates mid‑negotiation, attachment sizes, email/webhook reliability.
- Pilot & Phasing: Start with a segment; enable via feature flags; train reps; publish governance rules.
