Skip to main content

Overview

The Orden Compra queries allow you to retrieve purchase order information from the system. These queries provide access to order details, beneficiary relationships, and financial data.

Available Queries

GetOCByCodigoBeneficiario

Retrieve all purchase orders associated with a specific beneficiary code.

Query Definition

query GetOCByCodigoBeneficiario($id_beneficiario: Int!) {
  getOCByCodigoBeneficiario(id_beneficiario: $id_beneficiario) {
    idOrdenCompra
    codigo
    valorCompra
    beneficiario {
      idbeneficiario
      nombreBeneficiario
      codigoBeneficiario
    }
  }
}

Parameters

id_beneficiario
Int
required
The unique identifier of the beneficiary whose purchase orders you want to retrieve.

Response Fields

idOrdenCompra
Int
Unique identifier for the purchase order.
codigo
String
The purchase order code or reference number.
valorCompra
Decimal
The total value of the purchase order in the system’s base currency.
beneficiario
IndAntBeneficiarioDTO
Information about the beneficiary associated with this purchase order.

Example Request

query {
  getOCByCodigoBeneficiario(id_beneficiario: 12345) {
    idOrdenCompra
    codigo
    valorCompra
    beneficiario {
      idbeneficiario
      nombreBeneficiario
      codigoBeneficiario
    }
  }
}

Example Response

{
  "data": {
    "getOCByCodigoBeneficiario": [
      {
        "idOrdenCompra": 1001,
        "codigo": "OC-2024-001",
        "valorCompra": 15000.50,
        "beneficiario": {
          "idbeneficiario": 12345,
          "nombreBeneficiario": "Supplier ABC Inc.",
          "codigoBeneficiario": "SUP-12345"
        }
      },
      {
        "idOrdenCompra": 1002,
        "codigo": "OC-2024-002",
        "valorCompra": 8500.00,
        "beneficiario": {
          "idbeneficiario": 12345,
          "nombreBeneficiario": "Supplier ABC Inc.",
          "codigoBeneficiario": "SUP-12345"
        }
      }
    ]
  }
}

Use Cases

Beneficiary Order History

Retrieve all purchase orders for a specific supplier or beneficiary to:
  • Track order history and patterns
  • Calculate total purchase volume
  • Audit supplier relationships
  • Monitor outstanding orders

Financial Reporting

Query purchase orders to generate:
  • Spending reports by beneficiary
  • Budget tracking and allocation
  • Purchase order summaries
  • Financial audits

Integration Points

This query is commonly used in conjunction with:
  • Anticipos: To verify purchase orders when processing advance payments
  • Supply Management: To check order status before creating new requisitions
  • Reembolsos: To validate orders during reimbursement processing

Data Source

The query retrieves data from:
  • Table: ind_ant_orden_compra
  • Repository: IndAntOrdenCompraRepository (Services/IndAntOrdenCompra/IndAntOrdenCompraRepository.cs:20)
  • Includes: Beneficiary relationship data via Entity Framework navigation properties

Notes

The query includes related beneficiary information through an Entity Framework Include statement, providing a complete view of the purchase order relationship.
Ensure the beneficiary ID exists in the system before querying. Non-existent IDs will return an empty array rather than an error.