Purchase Transactions
This document provides an overview of the operations available for the Purchase Transactions business entity. Please note that the queries shown below only present a subset of the fields.
For a full list of fields, please refer to our schema documentation provided within our API. See Explore the API.
Mutations
Create Purchase Transactions
To create new Purchase transactions within a Financials or Dimensions database, the Purchase Transaction bulk create endpoint can be used. This operation supports both batching and posting of transactions. You can create one or more of the following types of Purchase transactions using this operation:
- Purchase Invoice
- Purchase Credit Note
- Purchase Payment
- Purchase Debit Adjustment
- Purchase Credit Adjustment
Request
Here's an example of how you can use the create
mutation:
mutation (
$transactions: [PurchaseTransactionBulkInput!]!
$validateOnly: Boolean
) {
creditors {
transactions {
bulkTransactions {
bulkCreate(transactions: $transactions, validateOnly: $validateOnly) {
... on IntEntityIds {
...IntEntityIdDetails
}
... on FailedValidation {
...FailedValidationDetails
}
... on UnexpectedError {
...UnexpectedErrorDetails
}
}
}
}
}
}
fragment IntEntityIdDetails on IntEntityIds {
ids
}
fragment FailedValidationDetails on FailedValidation {
errors {
...ValidationItemDetails
}
warnings {
...ValidationItemDetails
}
}
fragment ValidationItemDetails on ValidationItem {
message
details {
primaryKey
field
value
}
}
fragment UnexpectedErrorDetails on UnexpectedError {
errorMessage
}
When you execute the create
mutation, it performs several steps to create new transactions:
-
Running business validations: The API performs a number of business validations on the input data to ensure that it meets the required criteria. These validations can include checks for things like valid Supplier information, correct gross amount, and any other business rules specific to your application. If any validation errors occur, the mutation will return a response with the details of the errors.
-
Calculating missing information: If any required information is missing from the input object, the mutation will calculate the missing values based on default settings or any other logic defined in the system. This ensures that the transaction has all the necessary data before it is created.
-
Saving the transaction: If all the necessary information is present and the business validations pass successfully, the mutation will save the transaction in the system and make it available for further processing or retrieval.
Parameters
Transaction [Required]
This mutation requires an input object of type PurchaseTransactionBulkInput
, which should contain all the necessary information to create the transaction.
Validate Only
This operation supports "validate only" mode by setting the validateOnly
parameter to true
. In this mode, the API will check your transaction against a number of business rules, but will not attempt to save the transaction to the database.
Response
After executing the create
mutation, you will receive a response containing the IDs of the updated transactions if the creation was successful. If any validation errors or unexpected errors occur during the operation, the response will include the details of those errors.
An example of the three response types provided by this request can be found below:
- Success
- Validation
- Unexpected Error
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkCreate": {
[100, 101, 102]
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkCreate": {
"errors": [
{
"message": "Supplier does not exist",
"details": [
{
"field": "Header.Supplier.Code",
"primaryKey": "",
"value": "ABC123"
}
]
},
{
"message": "Transaction must have at least 1 detail line",
"details": [
{
"field": null,
"primaryKey": "",
"value": null
}
]
}
]
}
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkCreate": {
"Unexpected error message"
}
}
}
}
}
}
Update Purchase Transactions
To update a Purchase transaction, you can use the bulk update
mutation. Like the transaction creation request, this mutation requires an input object of type PurchaseTransactionBulkInput
, which should contain the information you wish to update on the existing transaction.
It is only possible to update batched transactions via this operation.
Request
Here's an example of how you can use the update
mutation to update a Purchase transaction:
mutation (
$transactions: [PurchaseTransactionBulkInput!]!
$validateOnly: Boolean
) {
creditors {
transactions {
bulkTransactions {
bulkUpdate(transactions: $transactions, validateOnly: $validateOnly) {
... on IntEntityIds {
...IntEntityIdDetails
}
... on FailedValidation {
...FailedValidationDetails
}
... on UnexpectedError {
...UnexpectedErrorDetails
}
}
}
}
}
}
fragment IntEntityIdDetails on IntEntityIds {
ids
}
fragment FailedValidationDetails on FailedValidation {
errors {
...ValidationItemDetails
}
warnings {
...ValidationItemDetails
}
}
fragment ValidationItemDetails on ValidationItem {
message
details {
primaryKey
field
value
}
}
fragment UnexpectedErrorDetails on UnexpectedError {
errorMessage
}
When you execute the update
mutation, it performs the following steps to update the Purchase transaction:
- Finding the transaction: The mutation first finds the Purchase transaction in the system.
- Updating the information: The mutation then updates the transaction with the new information provided in the
PurchaseTransactionInput
object. You can modify any relevant fields such as Supplier information, transaction lines, or any other details specific to your application. - Recalculating missing information: If any required information is missing from the input object, the mutation will calculate the missing values based on default settings or any other logic defined in the system. This ensures that the transaction has all the necessary data before it is created.
- Running business validations: Similar to the
create
mutation, theupdate
mutation also performs business validations on the updated data to ensure it meets the required criteria. If any validation errors occur, the mutation will return a response with the details of the errors. - Saving the updated transaction: If all the necessary information is present and the business validations pass successfully, the mutation will save the updated transaction in the system. This means that the changes will be persisted and available for further processing or retrieval.
Parameters
Transaction [Required]
This mutation requires an input object of type PurchaseTransactionBulkInput
, which should contain all the necessary information to create the transaction.
Validate Only
This operation supports "validate only" mode by setting the validateOnly
parameter to true
, in this mode, the API will check your transaction against a number of business rules, but will not attempt to save the transaction to the database.
Response
After executing the update
mutation, you will receive a response containing the updated Purchase transaction's ID if the update was successful. If any validation errors or unexpected errors occur during the operation, the response will include the details of those errors.
An example of the three response types provided by this request can be found below:
- Success
- Validation
- Unexpected Error
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkUpdate": {
[100,101,102]
}
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkUpdate": {
"errors": [
{
"message": "Primary key must be specified when updating or deleting",
"details": [
{
"field": "Header.PrimaryKey",
"primaryKey": "",
"value": null
}
]
},
{
"message": "Transaction must have at least 1 detail line",
"details": [
{
"field": null,
"primaryKey": "",
"value": null
}
]
}
]
}
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"bulkTransactions": {
"bulkUpdate": {
"Unexpected error message"
}
}
}
}
}
}
Delete Purchase Transactions
To delete Purchase transactions, you can use the delete
mutation. This operation contains a mandatory primaryKeys
parameter which should be populated with the primary key of each transaction you want to delete.
Note this endpoint only supports the deletion of Purchase Transactions. For the removal of other transaction types, please refer to our API schema documentation: Explore the API
Here's an example of how you can use the delete
mutation to delete Purchase transactions:
mutation ($primaryKeys: [Int!]!) {
creditors {
transactions {
batchedTransactions {
delete(primaryKeys: $primaryKeys) {
... on Succeeded {
...SucceededDetails
}
... on FailedValidation {
...FailedValidationDetails
}
... on UnexpectedError {
...UnexpectedErrorDetails
}
}
}
}
}
}
fragment SucceededDetails on Succeeded {
succeeded
}
fragment FailedValidationDetails on FailedValidation {
errors {
...ValidationItemDetails
}
warnings {
...ValidationItemDetails
}
}
fragment ValidationItemDetails on ValidationItem {
message
details {
primaryKey
field
value
}
}
fragment UnexpectedErrorDetails on UnexpectedError {
errorMessage
}
In the above example, you need to provide the primaryKeys
array containing the primary keys of the transactions you want to delete. The mutation will then attempt to delete the specified transactions.
If the deletion is successful, the response will include a succeeded
field with a value of true
. If any validation errors occur during the deletion process, the response will include the details of those errors in the errors
field. Additionally, if there are any warnings related to the deletion, they will be included in the warnings
field. If an unexpected error occurs, the response will include an errorMessage
field with the details of the error.
An example of the three response types provided by this request can be found below:
- Success
- Validation
- Unexpected Error
{
"data": {
"creditors": {
"transactions": {
"batchedTransactions": {
"delete": {
"succeeded"
}
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"batchedTransactions": {
"delete": {
"errors": [
{
"message": "Transaction not found",
"details": [
{
"field": "Header.PrimaryKey",
"primaryKey": "1234567",
"value": "1234567"
}
]
}
],
"warnings": []
}
}
}
}
}
}
{
"data": {
"creditors": {
"transactions": {
"batchedTransactions": {
"delete": {
"Unexpected error occurred"
}
}
}
}
}
}
Queries
Get Batched Purchase Transaction
To retrieve information about a specific batched Purchase transaction, you can use the transactionEntry\header
query. This query requires an input parameter id
which represents the primary key of the transaction you want to retrieve.
Here's an example of how you can use the transactionEntry\header
query to get the details of a batched Purchase transaction:
- Request
- Response
query ($id: Int!) {
creditors {
transactions {
transactionEntry {
header(id: $id) {
transactionType
hasNextPage
header {
...HeaderDetails
}
detailLines {
...DetailLinesData
}
}
}
}
}
}
fragment HeaderDetails on PurchaseTransactionHeader {
primaryKey
headerReference
description
supplier {
code
name
anyCurrency
onStop
terms
taxRegistrationNumber
}
dates {
date
dueDate
anticipatedPaymentDate
}
values {
...TransactionValueData
}
period {
year
yearLabel
number
}
subLedger {
code
description
}
}
fragment DetailLinesData on PurchaseTransactionDetail {
primaryKey
detail
tax {
code
rate
type
}
values {
...TransactionValueData
}
costing {
project {
code
name
}
costCentre {
code
name
}
}
}
fragment TransactionValueData on TransactionValues {
net
tax
gross
currencyNet
currencyTax
currencyGross
}
{
"data": {
"creditors": {
"transactions": {
"transactionEntry": {
"header": {
"transactionType": "transaction",
"hasNextPage": false,
"header": {
"primaryKey": 158658,
"headerReference": "90052",
"description": "",
"Supplier": {
"code": "GB-12672",
"name": "Example Supplier",
"anyCurrency": false,
"onStop": false,
"terms": "",
"taxRegistrationNumber": "111 1234 93"
},
"dates": {
"date": "2024-04-29T00:00:00",
"dueDate": "2024-04-29T00:00:00",
"anticipatedPaymentDate": "2024-04-29T00:00:00"
},
"values": {
"net": 100,
"tax": 0,
"gross": 100,
"currencyNet": 0,
"currencyTax": 0,
"currencyGross": 0
},
"period": {
"year": "Next",
"yearLabel": "2025",
"number": 1
},
"subLedger": {
"code": "MLAC-1"
}
},
"detailLines": [
{
"primaryKey": 1000001,
"detail": "1",
"tax": {
"code": "V",
"rate": 20,
"type": "V"
},
"values": {
"net": 100,
"tax": 20,
"gross": 100,
"currencyNet": 0,
"currencyTax": 0,
"currencyGross": 0
},
},
{
"primaryKey": 1000002,
"detail": "7",
"tax": {
"code": "V",
"rate": 20,
"type": "V"
},
"values": {
"net": 0,
"tax": 0,
"gross": 0,
"currencyNet": 0,
"currencyTax": 0,
"currencyGross": 0
},
}
]
}
}
}
}
}
}
In this query, you need to provide the id
parameter with the primary key of the batched Purchase transaction you want to retrieve.
The response will include detailed information about the transaction, including the transaction type, header details, Supplier information,
dates, values, period, subledger details, and detail lines.
The query only returns first page of detail lines, to get additional pages please use transactionEntry/details
.
query (
$filter: PurchaseTransactionDetailFilterInput!
$sort: [PurchaseTransactionDetailSortSortByInput!]
$first: Int
) {
creditors {
transactions {
transactionEntry {
details(filter: $filter, sort: $sort, first: $first) {
items {
primaryKey
detail
analysis {
code
name
nominalUpdate {
debit {
code
name
}
credit {
code
name
}
tax {
code
name
}
}
}
tax {
code
rate
type
}
values {
net
tax
gross
currencyNet
currencyTax
currencyGross
}
costing {
project {
code
name
}
costCentre {
code
name
}
}
accrual {
accrueOverPeriods
defer
account {
code
name
}
}
}
}
}
}
}
}
Query Transaction Headers
To retrieve information about transaction headers, you can use the allTransactions\header
query. This query requires input parameters such as $first
, $sort
, $filter
to specify the number of results, sorting criteria, and filtering conditions.
Filter options vary from field to field based on the type of the field, see PurchaseTransactionEnquiryFilterInput
GraphQL type in API Reference.
Grouping by various columns is also possible. When a group column is specified, the result will be a unique list of values for the grouped column. It is possible to aggregate other columns as well by specifying $aggregate
.
$fieldSelection
is a parameter that can be used to specify which fields should be returned, it override the specification in the query. Fields selection can also be done through the query.
Here's an example of how you can use the header
query to get transaction header details:
query (
$first: Int
$filter: PurchaseTransactionEnquiryHeaderFilterInput!
$sort: [PurchaseTransactionEnquiryHeaderSortSortByInput!]
$group: PurchaseTransactionEnquiryHeaderSort
$aggregate: PurchaseTransactionEnquiryHeaderSortGroupByInput
$fieldSelection: [PurchaseTransactionEnquiryHeaderSort]
) {
creditors {
transactions {
allTransactions {
header(
first: $first
sort: $sort
filter: $filter
group: $group
aggregate: $aggregate
fieldSelection: $fieldSelection
) {
items {
accountCode
accountName
date
periodNumber
orderNumber
transactionType
headerRef
batched
net
tax
description
gross
outstanding
reconciled
auditNo
yearLabel
dueDate
dateEntered
batchRef
headerRef
headerKey
exchangeRate
sortKey
anticipatedPaymentDate
currencyGross
currencyNet
currencyOutstanding
currencySymbol
currencyTax
onDispute
subLedger
lastUpdatedBy
lastUpdatedDateTime
postedBy
postedDateTime
createdBy
createdDateTime
}
}
}
}
}
}
In the above query, you can customize the parameters $first
, $sort
, and $filter
to retrieve the desired number of results, apply sorting based on specific fields, and filter the transactions based on certain conditions.
The response will include an array of transaction headers, each containing various fields such as account code, account name, transaction date, etc.
Query Details
To retrieve detailed information about Purchase transactions, you can use the details
field within the allTransactions
query. This field requires the following input parameters:
$first
: Specifies the maximum number of results to retrieve.$sort
: Specifies the sorting order for the results based on specific fields.$filter
: Specifies the conditions to filter the transactions.
Here's an example of how you can use the details
field to retrieve detailed information about Purchase transactions:
query($first: Int, $sort: [PurchaseTransactionEnquiryDetailSortSortByInput!], $filter: PurchaseTransactionEnquiryDetailFilterInput!) {
creditors{
transactions{
allTransactions {
details (first: $first, sort: $sort, filter: $filter) {
items {
primaryKey
headerPrimary
analysisCode
analysisName
itemCode
projectCode
projectName
costCentreCode
costCentreName
orderNumber
net
taxCode
tax
gross
transactionAuditNumber
detail
costPrice
sellPrice
accountCode
accountName
currentSortKey
currencyGross
currencyNet
currencySymbol
currencyTax
dueDate
quantity
analysisType
}
}
}
}
}
}
In the above query, you can customize the parameters $first
, $sort
, and $filter
to retrieve the desired number of results, apply sorting based on specific fields, and filter the transactions based on certain conditions.
The response will include an array of transaction details, each containing various fields such as primary key, analysis code, item code, net amount, tax amount, etc.