Update Account Determination Rule
PATCH /inventory/account-determination-rules/{id}
Group: Inventory › Account Determination Rules · Operation ID: updateAccountDeterminationRule
Updates the account determination rule with the given identifier. Only the fields in the request body change.
Everything omitted from the request body is left as it was, at every level. Omit accounts and all of them stay as they are. Include accounts and omit one account inside it, and only that one stays as it is. null clears, and it means different things by field. On a matching dimension, null widens the rule to every value of that dimension. On an account, null unassigns it, so a less specific rule decides that posting. The entity cannot be changed. To move a rule, create it under the other entity and delete this one. Changing a dimension re-runs the duplicate check against the whole resulting combination, so widening one dimension can collide with a rule the request never mentioned, and DUPLICATE_RULE_TUPLE names it. The overrides take three arrays: createReasonCodeOverrides, updateReasonCodeOverrides keyed by each override's id, and deleteReasonCodeOverrides taking ids. Omit all three to leave them unchanged. They apply in the order delete, update, then create, so one call can retire an override and add a replacement for the same reason code. The response is only the rule's id. Read the updated rule with GET inventory/account-determination-rules/:id.
Open in the interactive reference
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Api-Version |
header | "v1" |
yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1. |
Idempotency-Key |
header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored. |
id |
path | string | yes | The unique identifier for the rule to update. |
Request body
Required, application/json: updateAccountDeterminationRuleInput.
| Field | Type | Required | Description |
|---|---|---|---|
ruleName |
string | no | A free-text label for the rule. Omit to leave it unchanged. |
priority |
number | no | The tie-breaker between rules of equal specificity. The lower number wins. Omit to leave it unchanged. |
isActive |
boolean | no | Whether the rule takes part in account determination. Omit to leave it unchanged. Set it to false to retire a rule without deleting it. |
matching |
object | no | Changes to the dimensions this rule is pinned to. There is no entityId here, because a rule cannot change entity. Passing null for a dimension widens the rule to every value of it. Any change re-runs the duplicate check against the whole resulting combination. |
matching.bookId |
string or null | no | The accounting book this rule is pinned to. See id on GET accounting/books/:id. Omit to leave it unchanged. Pass null to widen the rule to every value of this dimension. |
matching.itemTypeId |
string or null | no | The item type this rule is pinned to. See id on GET inventory/item-types/:id. Omit to leave it unchanged. Pass null to widen the rule to every value of this dimension. |
matching.itemCategoryId |
string or null | no | The item category this rule is pinned to. See id on GET inventory/item-categories/:id. Omit to leave it unchanged. Pass null to widen the rule to every value of this dimension. |
matching.locationId |
string or null | no | The warehouse location this rule is pinned to. See id on GET inventory/warehouses/:id. Omit to leave it unchanged. Pass null to widen the rule to every value of this dimension. |
matching.inventoryLocationType |
string or null | no | An advisory classification of the location. It is stored on the rule and never read when matching, so it does not affect which rule the posting selects. Omit to leave it unchanged. Pass null to clear it. |
matching.transactionTypeContext |
string, one of "RECEIPT", "SHIPMENT", "SALES_RETURN", "SALES_INVOICE", "SALES_CREDIT_MEMO", "PURCHASE_RETURN", "PURCHASE_INVOICE", "PURCHASE_CREDIT_MEMO", "INVENTORY_INCREASE", "INVENTORY_DECREASE", "INVENTORY_REVALUATION", "WAREHOUSE_TRANSFER", "INTERCOMPANY_TRANSFER", "DEFAULT" or null |
no | The document kind this rule is pinned to. Omit to leave it unchanged. DEFAULT and null are both the wildcard that matches every transaction type. WAREHOUSE_TRANSFER and INTERCOMPANY_TRANSFER are the kinds used for transfer postings. |
accounts |
object | no | Changes to the GL accounts this rule assigns. Omit the whole object to leave all of them unchanged. Omit one account to leave it unchanged. Pass null for one to unassign it, so a less specific rule decides that posting. |
accounts.inventoryAssetAccountId |
string or null | no | The account for inventory value on the balance sheet. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.cogsAccountId |
string or null | no | The cost of goods sold account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.cogsClearingAccountId |
string or null | no | The cost of goods sold clearing account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.deferredCogsAccountId |
string or null | no | The deferred cost of goods sold account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.salesRevenueAccountId |
string or null | no | The sales revenue account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.salesReturnAccountId |
string or null | no | The sales return account. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.salesStockInTransitAccountId |
string or null | no | The sales stock-in-transit account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.grniClearingAccountId |
string or null | no | The goods-received-not-invoiced clearing account, for inventory items. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.grncClearingAccountId |
string or null | no | The goods-returned-not-credited clearing account. It is the offset leg booked on purchase returns and credit memos. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.servicesReceivedNotInvoicedAccountId |
string or null | no | The clearing account for services received but not yet invoiced, for non-inventory items. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.expenseAccountId |
string or null | no | The expense account for non-inventory items and description lines. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.purchasePriceVarianceAccountId |
string or null | no | The purchase price variance account, under standard costing. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.inventoryAdjustmentGainAccountId |
string or null | no | The account for positive inventory count and adjustment differences. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.inventoryAdjustmentLossAccountId |
string or null | no | The account for negative inventory count and adjustment differences. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.revaluationGainAccountId |
string or null | no | The account for gains from inventory revaluation. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.revaluationLossAccountId |
string or null | no | The account for losses from inventory revaluation. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.soldQuantitiesRevaluationAccountId |
string or null | no | The account for the revaluation of quantities already sold. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.purchaseReturnVarianceGainAccountId |
string or null | no | The account for gains on purchase returns. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.purchaseReturnVarianceLossAccountId |
string or null | no | The account for losses on purchase returns. See id on GET accounting/accounts/:id. It can be overridden per reason code. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
accounts.fxRateDiffAccountId |
string or null | no | The account that absorbs FX rate differences between receipt and invoice posting. See id on GET accounting/accounts/:id. Omit to leave it unchanged. Pass null to unassign it, so a less specific rule decides that posting. |
createReasonCodeOverrides |
array of object | no | Reason-code overrides to add. Each is a full override with no id, because the row does not exist yet. |
createReasonCodeOverrides[].reasonCodeId |
string | yes | The reason code that triggers this override. See id on GET inventory/reason-codes/:id. |
createReasonCodeOverrides[].accountId |
string | yes | The account to post instead of the rule account. See id on GET accounting/accounts/:id. |
createReasonCodeOverrides[].parentAccountType |
string, one of "inventoryAdjustmentGainAccount", "inventoryAdjustmentLossAccount", "salesReturnAccount", "purchaseReturnVarianceGainAccount", "purchaseReturnVarianceLossAccount", "grncClearingAccount" |
yes | Which rule account this override replaces. Only six of the twenty accounts can be overridden. |
updateReasonCodeOverrides |
array of object | no | Reason-code overrides to change, each keyed by the override's own id. An override id belonging to another rule fails with OVERRIDE_NOT_FOUND. |
updateReasonCodeOverrides[].id |
string | yes | The unique identifier for the override to change. Read it from the override's id on GET inventory/account-determination-rules/:id. |
updateReasonCodeOverrides[].accountId |
string | no | The account to post instead of the rule account. See id on GET accounting/accounts/:id. Omit to leave it unchanged. |
updateReasonCodeOverrides[].parentAccountType |
string, one of "inventoryAdjustmentGainAccount", "inventoryAdjustmentLossAccount", "salesReturnAccount", "purchaseReturnVarianceGainAccount", "purchaseReturnVarianceLossAccount", "grncClearingAccount" |
no | Which rule account this override replaces. Only six of the twenty accounts can be overridden. Omit to leave it unchanged. |
deleteReasonCodeOverrides |
array of string | no | The unique identifiers for the reason-code overrides to remove. They are applied before createReasonCodeOverrides, so one call can retire an override and add a replacement for the same reason code. |
Example:
{
"ruleName": "<ruleName>",
"priority": 0,
"isActive": true,
"matching": {
"bookId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"itemTypeId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"itemCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"locationId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"inventoryLocationType": "<inventoryLocationType>",
"transactionTypeContext": "RECEIPT"
},
"accounts": {
"cogsAccountId": "9a4d18e2-70bc-4f51-8d36-2e0b74f9a3c1"
},
"createReasonCodeOverrides": [
{
"reasonCodeId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"accountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"parentAccountType": "inventoryAdjustmentGainAccount"
}
],
"updateReasonCodeOverrides": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"accountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"parentAccountType": "inventoryAdjustmentGainAccount"
}
],
"deleteReasonCodeOverrides": [
"<deleteReasonCodeOverrides>"
]
}
Response
200 Success
Under data (updateAccountDeterminationRuleOutput):
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | yes | The unique identifier for the rule. |
Response headers
Idempotency-Replayed— Present andtrueonly when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent asfalse.
Errors
| Code | Status |
|---|---|
NOT_FOUND |
400 |
REFERENCE_NOT_FOUND |
400 |
DUPLICATE_RULE_TUPLE |
400 |
OVERRIDE_NOT_FOUND |
400 |
UNKNOWN_PARENT_ACCOUNT_TYPE |
400 |
IDEMPOTENCY_KEY_CONFLICT |
409 |
IDEMPOTENCY_PAYLOAD_MISMATCH |
422 |
Statuses
400— Invalid request or business failure. Codes: NOT_FOUND, REFERENCE_NOT_FOUND, DUPLICATE_RULE_TUPLE, OVERRIDE_NOT_FOUND, UNKNOWN_PARENT_ACCOUNT_TYPE401— Missing or invalid access token403— Not authorized404— Not found409— The Idempotency-Key is still being processed by another request.422— The Idempotency-Key was already used with a different request payload.429— Too many requests500— Internal server error