Update an account determination rule

Operation ID: updateAccountDeterminationRule

Group: Inventory › Account Determination Rules

Open in the interactive reference

PATCH /inventory/account-determination-rules/{id}

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Updates an account determination rule with the fields you send. A field you leave out keeps its current value, including inside matching and accounts.

To clear a field in matching or accounts, send null. The book is the exception: you can change it, but not remove it.

Reason-code overrides change through three arrays: createReasonCodeOverrides, updateReasonCodeOverrides, and deleteReasonCodeOverrides.

You cannot change the rule's legal entity. To move a rule to another legal entity, create a new rule there and delete the old one.

The response is only the rule's id. To see the updated rule, use GET inventory/account-determination-rules/:id.

Parameters

Name In Type Required Description
Api-Version header string · 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 of the rule you want to update. Format: UUID.

Request body

Required, application/json: updateAccountDeterminationRuleInput.

Field Type Required Description
ruleName string no The name of the rule. It does not have to be unique.
priority number no The priority of the rule. When two matching rules are equally specific, the one with the lower number is used.
isActive boolean no Whether the rule is active.
matching object no Changes to the dimensions this rule applies to. Send null for the item type, item category, location, or transaction type to make the rule apply to every value of it.
matching.bookId string | null no The unique identifier of the accounting book this rule applies to. Format: UUID. To move the rule to another book, send that book's identifier. Every rule must have a book. See id on GET accounting/books/:id (getBook).
matching.itemTypeId string | null no The unique identifier of the item type this rule applies to. Format: UUID. See id on GET inventory/item-types/:id (getItemType).
matching.itemCategoryId string | null no The unique identifier of the item category this rule applies to. Format: UUID. The rule also matches items in child categories of this category. See id on GET inventory/item-categories/:id (getItemCategory).
matching.locationId string | null no The unique identifier of the warehouse location this rule applies to. Format: UUID. See id on GET inventory/warehouses/:id (getWarehouse).
matching.inventoryLocationType string | null no The type of location this rule is meant for, such as a warehouse or a store. It is for reference only and does not affect which rule is used.
matching.transactionTypeContext any | null no The type of transaction this rule applies to, such as 'RECEIPT' or 'SHIPMENT'. 'DEFAULT' applies to every transaction type, the same as sending null. Some journal entries use a different type from their document. For example, a purchase return looks up its goods-returned-not-credited account as 'RECEIPT'. Transfers use 'WAREHOUSE_TRANSFER' or 'INTERCOMPANY_TRANSFER'. 'SALES_INVOICE', 'SALES_CREDIT_MEMO', and 'PURCHASE_INVOICE' are accepted, but no journal entry uses them.
accounts object no The general ledger accounts that journal entries use when this rule matches. Example: {"cogsAccountId":"9a4d18e2-70bc-4f51-8d36-2e0b74f9a3c1"}.
accounts.inventoryAssetAccountId string | null no The unique identifier of the balance sheet account for inventory value. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.cogsAccountId string | null no The unique identifier of the cost of goods sold account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.cogsClearingAccountId string | null no The unique identifier of the cost of goods sold clearing account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.deferredCogsAccountId string | null no The unique identifier of the deferred cost of goods sold account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.salesRevenueAccountId string | null no The unique identifier of the sales revenue account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.salesReturnAccountId string | null no The unique identifier of the sales return account. Format: UUID. A reason-code override in reasonCodeOverrides can replace it. See id on GET accounting/accounts/:id (getAccount).
accounts.salesStockInTransitAccountId string | null no The unique identifier of the sales stock-in-transit account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.grniClearingAccountId string | null no The unique identifier of the goods-received-not-invoiced clearing account, for inventory items. Format: UUID. A receipt uses it to hold the value of goods received until the vendor bill arrives. See id on GET accounting/accounts/:id (getAccount).
accounts.grncClearingAccountId string | null no The unique identifier of the goods-returned-not-credited clearing account. Format: UUID. A purchase return uses it to hold the value of goods returned to a vendor until the vendor's credit arrives. Set it on a rule for 'RECEIPT', not 'PURCHASE_RETURN', because purchase returns look it up with 'RECEIPT'. A reason-code override in reasonCodeOverrides can replace it. See id on GET accounting/accounts/:id (getAccount).
accounts.servicesReceivedNotInvoicedAccountId string | null no The unique identifier of the clearing account for services received but not yet invoiced, and for non-inventory items. Format: UUID. A receipt uses it to hold the value of services and non-inventory items received until the vendor bill arrives. For a receipt line with no item, it comes from the general rule for the legal entity and accounting book. If there are several general rules, the one with the lowest priority number is used, whatever its transaction type. See id on GET accounting/accounts/:id (getAccount).
accounts.expenseAccountId string | null no The unique identifier of the expense account for non-inventory items. Format: UUID. An account on a receipt line for a service or expense replaces it for that line. See id on GET accounting/accounts/:id (getAccount).
accounts.purchasePriceVarianceAccountId string | null no The unique identifier of the purchase price variance account, under standard costing. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.inventoryAdjustmentGainAccountId string | null no The unique identifier of the account for the value of stock added by an inventory increase, including one created from an inventory count. Format: UUID. Two things can replace it: a reason-code override in reasonCodeOverrides, or an offset account on an inventory increase created by manufacturing. When both apply, the offset account is used. See id on GET accounting/accounts/:id (getAccount).
accounts.inventoryAdjustmentLossAccountId string | null no The unique identifier of the account for the value of stock removed by an inventory decrease, including one created from an inventory count. Format: UUID. Two things can replace it: a reason-code override in reasonCodeOverrides, or an offset account on an inventory decrease created by manufacturing. When both apply, the offset account is used. See id on GET accounting/accounts/:id (getAccount).
accounts.revaluationGainAccountId string | null no The unique identifier of the account for gains from inventory revaluation. Format: UUID. When an inventory revaluation's costingValuationType is 'directCostCapitalisation', its capitalisationExpenseAccountId replaces it. See costingValuationType on GET inventory/inventory-revaluations/:id (getInventoryRevaluation). See id on GET accounting/accounts/:id (getAccount).
accounts.revaluationLossAccountId string | null no The unique identifier of the account for losses from inventory revaluation. Format: UUID. When an inventory revaluation's costingValuationType is 'directCostCapitalisation', its capitalisationExpenseAccountId replaces it. See costingValuationType on GET inventory/inventory-revaluations/:id (getInventoryRevaluation). See id on GET accounting/accounts/:id (getAccount).
accounts.soldQuantitiesRevaluationAccountId string | null no The unique identifier of the account for the revaluation of quantities already sold. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
accounts.purchaseReturnVarianceGainAccountId string | null no The unique identifier of the account for gains on purchase returns. Format: UUID. A purchase return uses it when the goods returned are worth more than their original cost. A reason-code override in reasonCodeOverrides can replace it. See id on GET accounting/accounts/:id (getAccount).
accounts.purchaseReturnVarianceLossAccountId string | null no The unique identifier of the account for losses on purchase returns. Format: UUID. A purchase return uses it when the goods returned are worth less than their original cost. A reason-code override in reasonCodeOverrides can replace it. See id on GET accounting/accounts/:id (getAccount).
accounts.fxRateDiffAccountId string | null no The unique identifier of the account for exchange rate differences between the receipt and the vendor bill. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
createReasonCodeOverrides array<object> no The reason-code overrides to add to the rule. Each combination of reasonCodeId and parentAccountType can appear only once on a rule.
createReasonCodeOverrides[].reasonCodeId string yes The unique identifier of the reason code that triggers this override. Format: UUID. See id on GET inventory/reason-codes/:id (getReasonCode).
createReasonCodeOverrides[].accountId string yes The unique identifier of the account the journal entry uses instead of the rule's account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
createReasonCodeOverrides[].parentAccountType any yes Which rule account this override replaces. Only six of the twenty accounts can be overridden. One of: "inventoryAdjustmentGainAccount", "inventoryAdjustmentLossAccount", "salesReturnAccount", "purchaseReturnVarianceGainAccount", "purchaseReturnVarianceLossAccount", "grncClearingAccount".
updateReasonCodeOverrides array<object> no The reason-code overrides to change. Each item names an existing override by its id and can change its accountId or parentAccountType. To change an override's reasonCodeId, delete the override and add a new one.
updateReasonCodeOverrides[].id string yes The unique identifier of the override you want to change. Format: UUID. See reasonCodeOverrides[].id on GET inventory/account-determination-rules/:id (getAccountDeterminationRule).
updateReasonCodeOverrides[].accountId string no The unique identifier of the account the journal entry uses instead of the rule's account. Format: UUID. See id on GET accounting/accounts/:id (getAccount).
updateReasonCodeOverrides[].parentAccountType any no Which rule account this override replaces. Only six of the twenty accounts can be overridden. One of: "inventoryAdjustmentGainAccount", "inventoryAdjustmentLossAccount", "salesReturnAccount", "purchaseReturnVarianceGainAccount", "purchaseReturnVarianceLossAccount", "grncClearingAccount".
deleteReasonCodeOverrides array<string> no The unique identifiers of the reason-code overrides to delete. Format: UUID. Deletions happen before the additions in createReasonCodeOverrides, so one request can replace an override with a new one for the same reasonCodeId and parentAccountType.
{
  "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. Format: UUID. Example: "8d3f1a60-4c27-4e95-b013-6f2a89d47c5e".
{
  "data": {
    "id": "8d3f1a60-4c27-4e95-b013-6f2a89d47c5e"
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

Errors

Code Status
NOT_FOUND 400
REFERENCE_NOT_FOUND 400
BOOK_REQUIRED 400
DUPLICATE_RULE_TUPLE 400
OVERRIDE_NOT_FOUND 400
UNKNOWN_PARENT_ACCOUNT_TYPE 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses