ZuloOne
English
Sign inTry it
Menu

Opportunity — for the developer

Updated

← Developer wiki

The opportunity is the CRM 4.4.0 document. It sits between a qualified SalesLead and a Draft SalesQuotation. It is not a rename of the lead and not a Salesforce Opportunity object (no stage dictionary, no probability). The journal can open as a kanban of Open / Won / Lost; a drop runs the same commands as the card.

User: win a deal. Inbox contract: office work items.

Objects#

Name Kind
Opportunity a document with no table part
Subtypes Open / Won / Lost
IPipelineService CreateFromLeadAsync(Guid) / CreateQuotationAsync(Guid) → id or Empty
CreateOpportunity on SalesLead Qualified → new Open Opportunity
WinOpportunity Open → Won + a Draft quotation
LoseOpportunity Open → Lost
SalesQuotation.SourceOpportunity a Guid on the quotation (the CRM model), the idempotency key

There are no transaction scripts. requiresPosting: true is there only so that the subtype change goes through the posting pipeline.

The service is named PipelineService, not Opportunity: otherwise the service class would collide with the Opportunity document.

There are no public DTOs in IPipelineService. No customer / contract / cell / delivery date (Year < 1902) — Guid.Empty.

Idempotency: one Open Opportunity per SourceLead; CountDocumentsAsync<SalesQuotation>("SourceOpportunity = '…'"). The field lives on SalesQuotation in CRM (same owner as SourceLead).

ILeadService.CreateQuotationAsync still serves the field path. If an Open Opportunity exists for that lead, it wins that deal instead of minting a second quotation. ConvertLead without an Opportunity is unchanged.

Do not call CreateQuotationAsync from OnAfterPost — the quotation is created by the command.

Work item key: WinOpportunity:{opportunityMetaId}. No UserId on the agent → no work item. LoseOpportunity runs CancelBySourceAsync.

Customer 360#

The Pipeline tile on Inventory Customer lists SalesLead, Opportunity, SalesQuotation, SalesOrder.

The OpportunityTest test (the Business layer.Sales and receivables group).

Reports (CRM 4.8.0)#

The live board is the journal list presentation (kanban by subtype). These reports are the year cut:

Report What it counts
PipelineConversion This year's leads, related opportunities (SourceLead), related quotations (SalesQuotation.SourceLead), rates by agent
OpportunityWinLoss Opportunities by Open / Won / Lost, expected amount, quotations from a win, LossReason

Ribbon: CRM → Inquiries → Pipeline, and the same two leaves under Sales → Inquiries → Orders and quotations. Quote → order remains Sales QuotationConversion.

Public collection Opportunities is read-only (CRM 4.9.0). Win and lose stay document commands.

What not to do#

  • Do not create a SalesOrder from an opportunity — only a Draft SalesQuotation.
  • Do not write Stock / Receivable / tax from this document.
  • Do not add a /kanban route or a stage dictionary. The journal presentation is the board.
  • Do not force field users through Opportunity: ConvertLead stays.
  • Do not LoseLead when the deal is lost — the lead can still convert.

Same topic for other readers: User

Where next#

Was this page helpful?