Context

In Sage Active, sales documents follow a natural business lifecycle.
A document can be transformed into another while preserving the functional link between them.

This transformation mechanism is not handled by a dedicated mutation.
Instead, it relies on the standard creation mutations while providing origin metadata that allows the API to:

Supported transformation paths

From → To SalesQuote SalesOrder DeliveryNote Invoice
SalesQuote
SalesOrder
DeliveryNote

Principle

To transform a document, you do not use a specific transformation mutation.

You use the usual mutations:

And you provide three additional fields on each line to indicate the origin of the created lines.

Field Type Description
originType
  • DELIVERY_NOTE
  • ORDER
  • QUOTE
Type of the source document
originId UUID Identifier of the source document
originLineId UUID Identifier of the source document line

Because these fields are available at line level, a target document can be created from multiple source documents.

This enables advanced scenarios such as:

Each line keeps its own origin, ensuring full traceability and correct quantity management.

These fields allow the API to automatically:

  • create a RelatedSalesDocument link
  • reduce the remaining quantity on the origin document line
  • ensure consistency of the sales flow

GraphQL mutation

mutation ($values: SalesOrderCreateGLDtoInput!) {
  createSalesOrder(input: $values) {
    id
    operationalNumber
  }
}

Variables

{
  "values": {
    "customerId": "{{customerId}}",
    "lines": [
      {
        "productId": "{{productId_1}}",
        "totalQuantity": 2,
        "unitPrice": 11,
        "originType": "QUOTE",
        "originId": "{{salesQuoteId}}",
        "originLineId": "{{salesQuoteLineId}}"
      }
    ]
  }
}

GraphQL mutation

mutation ($values: SalesDeliveryNoteCreateGLDtoInput!) {
  createSalesDeliveryNote(input: $values) {
    id
    operationalNumber
  }
}

Variables

{
  "values": {
    "customerId": "{{customerId}}",
    "lines": [
      {
        "productId": "{{productId_1}}",
        "totalQuantity": 5,
        "unitPrice": 20,
        "originType": "ORDER",
        "originId": "{{salesOrderId_1}}",
        "originLineId": "{{salesOrderLineId_1}}"
      },
      {
        "productId": "{{productId_2}}",
        "totalQuantity": 3,
        "unitPrice": 18,
        "originType": "ORDER",
        "originId": "{{salesOrderId_2}}",
        "originLineId": "{{salesOrderLineId_2}}"
      }
    ]
  }
}

GraphQL mutation

mutation ($values: SalesInvoiceCreateGLDtoInput!) {
  createSalesInvoice(input: $values) {
    id
    operationalNumber
  }
}

Variables

{
  "values": {
    "customerId": "{{customerId}}",
    "lines": [
      {
        "productId": "{{productId_1}}",
        "totalQuantity": 5,
        "unitPrice": 20,
        "originType": "DELIVERY_NOTE",
        "originId": "{{deliveryNoteId}}",
        "originLineId": "{{deliveryNoteLineId}}"
      }
    ]
  }
}

Important behavior

When using originType, originId, and originLineId on lines:

Recommendation

Always use these fields on lines when creating a document that originates from another sales document. Failing to do so will create a standalone document with no traceability and no quantity control against the source document.