Skip to content

Sales Document Flow

Order-to-cash documents are enforced on Sales domain aggregates. Status names match API enums.

Hub: Target Document Flow. Overview: Sales.

#Chain overview

Document chain — quotation through AR

flowchart LR
  Q[Quotation] --> SO[Sales Order]
  SO --> DN[Delivery Note]
  SO --> AR[AR Invoice]
  SO --> SR[Sales Return]

  class Q egkDraft
  class SO,DN egkActive
  class AR egkSuccess
  class SR egkWarn
Quotation

#Statuses

Draft, Sent, Accepted, Rejected, Expired, Converted, Cancelled, Superseded

Quotation — send, respond, and convert

flowchart TB
  Start((Create)) --> Draft[Draft]
  Draft -->|Send| Sent[Sent]
  Sent -->|Accept| Accepted[Accepted]
  Sent -->|Reject| Rejected[Rejected]
  Sent -->|Expire| Expired[Expired]
  Accepted -->|Convert to order| Converted[Converted]

  class Start egkStart
  class Draft egkDraft
  class Sent egkActive
  class Accepted,Converted egkSuccess
  class Rejected egkError
  class Expired egkTerminal

Quotation — cancel from open statuses

flowchart TB
  Draft[Draft] -->|Cancel| Cancelled[Cancelled]
  Sent[Sent] -->|Cancel| Cancelled

  class Draft egkDraft
  class Sent egkActive
  class Cancelled egkTerminal
Sales Order

#Statuses

Draft, Confirmed, PartiallyDelivered, Delivered, PartiallyInvoiced, Invoiced, Completed, Cancelled

Discount approval (separate): SalesApprovalStatus = NotRequired, Pending, Approved, Rejected.

Sales Order — confirm through complete

flowchart TB
  Start((Create)) --> Draft[Draft]
  Draft -->|Confirm| Confirmed[Confirmed]
  Confirmed -->|Deliver partial| PartiallyDelivered[PartiallyDelivered]
  PartiallyDelivered -->|Deliver full| Delivered[Delivered]
  Confirmed -->|Deliver| Delivered
  Delivered -->|Invoice partial| PartiallyInvoiced[PartiallyInvoiced]
  PartiallyInvoiced -->|Invoice full| Invoiced[Invoiced]
  Invoiced -->|Complete| Completed[Completed]

  class Start egkStart
  class Draft egkDraft
  class Confirmed,PartiallyDelivered,PartiallyInvoiced egkActive
  class Delivered,Invoiced,Completed egkSuccess

Sales Order — cancel from draft

flowchart TB
  Start((Create)) --> Draft[Draft]
  Draft -->|Cancel| Cancelled[Cancelled]

  class Start egkStart
  class Draft egkDraft
  class Cancelled egkTerminal
Action (domain) Enabled when
Confirm Draft
Submit for approval Draft when discount approval required
Approve / Reject discount Approval Pending
Deliver / record partial delivery Not Draft / Cancelled
Mark invoiced Updates invoiced amounts and status
Complete Not Cancelled
Cancel Per cancel rules on open orders
Delivery Note

#Statuses

Draft, Shipped, Delivered, Cancelled

Delivery Note — ship and deliver

flowchart TB
  Start((Create)) --> Draft[Draft]
  Draft -->|Ship| Shipped[Shipped]
  Shipped -->|Deliver| Delivered[Delivered]

  class Start egkStart
  class Draft egkDraft
  class Shipped egkActive
  class Delivered egkSuccess

Delivery Note — cancel from open statuses

flowchart TB
  Draft[Draft] -->|Cancel| Cancelled[Cancelled]
  Shipped[Shipped] -->|Cancel| Cancelled
  Delivered[Delivered] -->|Cancel| Cancelled

  class Draft egkDraft
  class Shipped egkActive
  class Delivered egkSuccess
  class Cancelled egkTerminal
Action (domain) Gate
Ship / Deliver Advances toward Shipped / Delivered
Cancel Allowed unless IsInvoiced (throws if invoiced)
Sales Return

#Statuses

Draft, Confirmed, Cancelled

Sales Return — confirm return

flowchart TB
  Start((Create)) --> Draft[Draft]
  Draft -->|Confirm| Confirmed[Confirmed]

  class Start egkStart
  class Draft egkDraft
  class Confirmed egkSuccess

Sales Return — cancel from draft

flowchart TB
  Draft[Draft] -->|Cancel| Cancelled[Cancelled]

  class Draft egkDraft
  class Cancelled egkTerminal
Action (domain) Gate
Confirm Not Cancelled; requires lines; → Confirmed
Cancel Blocked if IsCredited; else → Cancelled
Hand-off to Accounts Receivable, GL and ETA

Sales never writes a receivable itself; it asks the AR invoice factory for one and links the result back onto the order / delivery. The factory is idempotent on the key Sales supplies, so a replayed event or a second click can never raise a second invoice.

Trigger Invoicing mode Idempotency key AR invoice fields set from Sales
Sales order confirmed OnConfirmation SO:{orderId} Company, branch, partner branch, currency, per-line taxes, SourceSalesOrderId, SourceQuotationId, credit-override flag
Delivery note invoiced OnDelivery DLV:{deliveryId} As above plus SourceDeliveryNoteId; order invoiced amounts roll up per delivered line
Recurring engine period either REC:{agreementId}:{yyyyMMdd} (invoice only) or the order/delivery keys above See Recurring Document Flow

Once the AR invoice is posted (Sent), the AR module continues the cycle on its own:

One sale, one invoice, one journal, one e-invoice

flowchart LR
  DN[Delivery Note shipped] -->|DLV key| AR[AR Invoice Sent]
  AR -->|ArInvoiceSentEvent| GL[GL journal AR:{id}:InvoiceSent]
  AR -->|ArInvoicePostedIntegrationEvent| ETA[ETA e-invoice draft]
  ETA -->|Valid / Cancelled / Rejected| AR

  class DN egkActive
  class AR,GL egkSuccess
  class ETA egkWarn
  • The GL journal is Dr AR control / Cr revenue (per line) / Cr tax liability on the invoice date, keyed AR:{invoiceId}:InvoiceSent; a redelivered event returns already posted.
  • The ETA draft is raised only when the company has an enabled ETA bridge setting; it carries the AR invoice number as internalID, links back through ArInvoiceId, and is validated / submitted per the setting.
  • An ETA Cancelled on an unpaid invoice cancels the AR invoice; Cancelled with receipts, Rejected or Invalid flag it for review and notify the creator — no document is ever re-created.
  • Document flow (Actions menu on quotation, order and delivery) shows the full lineage: quotation → order → deliveries → AR invoices → e-invoices → receipts.

#Post-action sync

Sales screens reload entity tables after workflow commands. Status chips and action visibility follow the aggregate status returned by the API. Failed transitions throw conflict/domain errors with no status change.

#Scenarios

Scenario Outcome
Confirm draft order Confirmed
Partial delivery PartiallyDelivered
Full invoice Invoiced
Cancel draft Cancelled
Reject quotation Rejected
Cancel invoiced delivery Domain error
Cancel credited return Domain error

Reconnecting…

This page stays right here while we reconnect.

Reload