Skip to content
Developer home
X3

Example GraphQL queries for Purchasing

  Less than to read

Read purchase order with their status

{
  sage {
      x3Purchasing {
        purchaseOrder(filter: "{isClosed : 'false', purchaseSite : 'FR011'}") {
            edges {
              node {
                  id
                  orderDate
                  purchaseSite {
                    code
                  }
                  orderFromSupplier {
                    code
                  }
                  orderFromSupplierCompanyNames
                  isClosed
                  invoiceStatus
                  receiptStatus
                  signatureStatus
                  currency {
                    code
                  }
                  taxExcludedTotalAmount
              }
            }
        }
      }
  }
}

Try it on our demo endpoint

Read purchase order with invoicing elements

{
  sage {
      x3Purchasing {
        purchaseOrder(
            filter: "{isClosed : 'false', purchaseSite : 'FR011', orderFromSupplier : 'FR053'}"
        ) {
            edges {
              node {
                  id
                  orderDate
                  purchaseSite {
                    code
                  }
                  orderFromSupplier {
                    code
                  }
                  orderFromSupplierCompanyNames
                  isClosed
                  invoiceStatus
                  receiptStatus
                  signatureStatus
                  currency {
                    code
                  }
                  taxExcludedTotalAmount
                  taxExcludedLinesAmount
                  taxIncludedTotalAmount
                  documentFooters {
                    edges {
                        node {
                          documentType
                          documentNumber
                          invoicingElement {
                              code
                          }
                          percentageOrAmount
                          taxExcludedOrderAmount
                          tax
                          taxAmount
                        }
                    }
                  }
              }
            }
        }
      }
  }
}

Try it on our demo endpoint

Read purchase order with global taxes amount

{
  sage {
    x3Purchasing {
      purchaseOrder(filter: "{isClosed : 'false', purchaseSite : 'FR011', orderFromSupplier : 'FR053'}")
      {
        edges {
          node {
              id
              orderDate
              purchaseSite {
                code
              }
              orderFromSupplier {
                code
              }
              orderFromSupplierCompanyNames
              isClosed
              invoiceStatus
              receiptStatus
              signatureStatus
              currency {
                code
              }
              taxExcludedTotalAmount
              taxExcludedLinesAmount
              taxIncludedTotalAmount
              documentTaxes {
                edges {
                    node {
                      documentType
                      documentNumber
                      taxCode
                      purchaseType
                      taxRate
                      taxBasisAmountIncludingInvoicingElement
                      taxAmountIncludingInvoicingElement
                      deductibleTaxAmount
                    }
                }
              }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase order with lines and analytical dimensions

{
  sage {
    x3Purchasing {
      purchaseOrder(filter: "{purchaseSite : 'FR011', orderFromSupplier : 'FR053', isClosed: {$ne: 'yes'}}") {
        edges {
          node {
            id
            orderDate
            receiptSite {
              code
            }
            orderFromSupplier {
              code
            }
            shipFromSupplierCompanyNames
            isClosed
            invoiceStatus
            receiptStatus
            signatureStatus
            currency {
              code
            }
            taxExcludedTotalAmount
            analyticalDimensions {
              edges {
                node {
                  type {
                    code
                  }
                  value {
                    code
                  }
                }
              }
            }
            lines {
              edges {
                node {
                  lineNumber
                  product {
                    code
                  }
                  productDescriptionInUserLanguage
                  quantityInOrderUnitOrdered
                  orderUnit {
                    code
                  }
                  netPrice
                  discountCharge1
                  discountCharge2
                  discountCharge3
                  analyticalDimensions {
                    edges {
                      node {
                        lineNumber
                        quantityInNonFinancialUnit
                        nonFinancialUnit {
                          code
                        }
                        amount
                        analyticalDimensions {
                          edges {
                            node {
                              type {
                                code
                              }
                              value {
                                code
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

{
  sage {
    x3Purchasing {
      purchaseDocumentFooter(filter: "{documentType : 8, documentNumber : 'FAP-ES01112-000001'}") {
        edges {
          node {
            documentType
            documentNumber
            index
            invoicingElement {
              code
            }
            increaseOrDecrease
            percentageOrAmount
            taxExcludedInvoicedAmount
            tax
            type
            taxAmount
            deductibleTax
            analyticalDimensions {
              edges {
                node {
                  quantityInNonFinancialUnit
                  nonFinancialUnit {
                    code
                  }
                  amount
                  ledgers {
                    edges {
                      node {
                        chartOfAccounts {
                          code
                        }
                      }
                    }
                  }
                  analyticalDimensions {
                    edges {
                      node {
                        type {
                          code
                        }
                        value {
                          code
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase document tax for a dedicated purchase invoice

{
  sage {
    x3Purchasing {
      purchaseDocumentTax(filter: "{documentType : 8, documentNumber : 'FAP-ES01112-000001'}") {
        edges {
          node {
            documentType
            documentNumber
            index
            taxCode
            taxType
            taxRate
            taxBasisAmountIncludingInvoicingElement
            taxAmountIncludingInvoicingElement
            deductibleTaxAmount
            otherTaxAmount
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase receipt with lines and stock detailed

{
  sage {
    x3Purchasing {
      purchaseReceipt(filter: "{receiptSite : 'FR011', invoicedStatus: {$ne: 'completely'}}") {
        edges {
          node {
            id
            receiptDate
            receiptSite {
              code
            }
            supplier {
              code
            }
            shipFromSupplierCompanyNames
            invoicedStatus
            isPosted
            isIntersites
            isIntercompany
            currency {
              code
            }
            taxExcludedTotalAmount
            lines {
              edges {
                node {
                  lineNumber
                  product {
                    code
                  }
                  productDescriptionInUserLanguage
                  quantityInReceiptUnitReceived
                  receiptUnit {
                    code
                  }
                  netPrice
                  discountCharge1
                  discountCharge2
                  discountCharge3
                  stockDetails {
                    edges {
                      node {
                        quantityInPackingUnit
                        packingUnit {
                          code
                        }
                        location {
                          code
                        }
                        lot
                        sublot
                        serialNumber
                        status
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase receipt with invoicing elements

{
  sage {
    x3Purchasing {
      purchaseReceipt(filter: "{receiptSite : 'FR011', supplier : 'FR053', invoicedStatus: {$ne: 'completely'}}") {
        edges {
          node {
            id
            receiptDate
            receiptSite {
              code
            }
            supplier {
              code
            }
            shipFromSupplierCompanyNames
            invoicedStatus
            isPosted
            isIntersites
            isIntercompany
            currency {
              code
            }
            taxExcludedTotalAmount
            taxExcludedLinesAmount
            taxIncludedTotalAmount
            documentFooters {
              edges {
                node {
                  documentType
                  documentNumber
                  invoicingElement {
                    code
                  }
                  percentageOrAmount
                  taxExcludedOrderAmount
                  tax
                  taxAmount
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase receipt with global taxes amount

{
  sage {
    x3Purchasing {
      purchaseReceipt(filter: "{receiptSite : 'FR011', supplier : 'FR053', invoicedStatus: {$ne: 'completely'}}") {
        edges {
          node {
            id
            receiptDate
            receiptSite {
              code
            }
            supplier {
              code
            }
            shipFromSupplierCompanyNames
            invoicedStatus
            isPosted
            isIntersites
            isIntercompany
            currency {
              code
            }
            taxExcludedTotalAmount
            taxExcludedLinesAmount
            taxIncludedTotalAmount
            documentTaxes {
              edges {
                node {
                  documentType
                  documentNumber
                  taxCode
                  purchaseType
                  taxRate
                  taxBasisAmountIncludingInvoicingElement
                  taxAmountIncludingInvoicingElement
                  deductibleTaxAmount
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Read purchase receipt with lines and analytical dimensions

{
  sage {
    x3Purchasing {
      purchaseReceipt(filter: "{receiptSite : 'FR011', invoicedStatus: {$ne: 'completely'}}") {
        edges {
          node {
            id
            receiptDate
            receiptSite {
              code
            }
            supplier {
              code
            }
            shipFromSupplierCompanyNames
            invoicedStatus
            isPosted
            isIntersites
            isIntercompany
            currency {
              code
            }
            taxExcludedTotalAmount
            analyticalDimensions {
              edges {
                node {
                  type {
                    code
                  }
                  value {
                    code
                  }
                }
              }
            }
            lines {
              edges {
                node {
                  lineNumber
                  product {
                    code
                  }
                  productDescriptionInUserLanguage
                  quantityInReceiptUnitReceived
                  receiptUnit {
                    code
                  }
                  netPrice
                  discountCharge1
                  discountCharge2
                  discountCharge3
                  analyticalDimensions {
                    edges {
                      node {
                        lineNumber
                        quantityInNonFinancialUnit
                        nonFinancialUnit {
                          code
                        }
                        amount
                        analyticalDimensions {
                          edges {
                            node {
                              type {
                                code
                              }
                              value {
                                code
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Create a multi-line ADC Purchase receipt (not executable on the read-only demo endpoint)

mutation {
  sage {
    x3Purchasing {
      purchaseReceipt {
        create(data: {receiptSite: "NA011", supplier: "CN001", receiptDate: "2020-01-30", lines: [{purchaseOrder: "PO00126", purchaseOrderLineNumber: 1000, product: "RAW040", receiptUnit: "M3", quantityInReceiptUnitReceived: 3, stockDetails: [{packingUnit: "M2", quantityInPackingUnit: 36, status: "A", lot: "LO1012", supplierLot: "SUPLOT1", expirationDate: "2020-07-31"}]}, {purchaseOrder: "PO00126", purchaseOrderLineNumber: 2000, product: "RAW046", receiptUnit: "UN", quantityInReceiptUnitReceived: 6, stockDetails: [{packingUnit: "UN", quantityInPackingUnit: 6, status: "A", location: "LOC01", lot: "LO99", sublot: "00001", serialNumber: "8100", majorVersion: "A", minorVersion: "01"}]}]}) {
          id
        }
      }
    }
  }
}