Skip to content
campaiDeveloper
campai.com

Finance · Cash · Transactions

POST/{organizationId}/{mandateId}/finance/cash/transactions/rules/{cashTransactionRuleId}/update

Update cash transaction rule

Replaces the name, matching conditions (matcher), outcome and positions of an existing cash transaction rule in the mandate. The rule stays in its mandate. It acts on transactions that come in afterwards, and on existing ones only when it is run again. Proposals it already made stay as they are. Before saving, the new conditions and positions are checked against the mandate's bank accounts and the organization's accounting plan. Nothing is returned.

Permissions

Send an API key of the organization in the path, using the X-API-Key header.

Who may call it

  • Callers need the mandate.read and cashTransactionRule.edit permissions.
  • Rules apply automatically to new transactions. So the caller also needs the permissions that the chosen outcome (postingReceipt or donationProposal) requires.

Request

Path parameters

  • organizationIdidrequired
  • mandateIdidrequired

    The mandate the rule belongs to; if the rule is not in this mandate, the request fails as not found.

  • cashTransactionRuleIdidrequired

    The cash transaction rule to update.

Body

Content-Type: application/json

  • outcomestringrequired

    What the rule creates for a matching transaction: a posting receipt or a donation proposal, and the caller also needs the permissions that this outcome requires.

    postingReceipt donationProposal
  • namestringnullable

    The name of the rule, which is removed when this field is left out.

    1–100 characters

  • matcherobjectrequired

    The conditions a transaction must meet for the rule to apply, of which at least one must be set.

    6 properties
    • typeMatchstringrequired

      Whether the rule applies to revenue or expense transactions; with the postingReceipt outcome it also decides which kinds of account the positions may use.

      revenue expense
    • cashAccountidnullable

      The bank account whose transactions the rule applies to, which must belong to the rule's mandate; when left out, the rule is not tied to a bank account.

    • amountobject

      The condition on the transaction's amount.

      2 properties
      • valueintegerrequired

        The amount that the transaction's amount is compared against.

      • comparatorstringrequired

        How the transaction's amount is compared with value.

        equals lessThan lessEqual greaterThan greaterEqual
    • purposeobject

      The condition on the transaction's purpose.

    • counterpartNameobject

      The condition on the name of the transaction's counterpart.

    • counterpartAccountobject

      The condition on the account of the transaction's counterpart.

  • positionsobject[]required

    The positions the rule books for a matching transaction, which replace the rule's current positions.

    7 properties
    • accountintegerrequired

      The number of the counter account in the accounting plan, which must exist and be bookable; with the postingReceipt outcome it must be a cash, debtor or creditor account, or else a revenue account for revenue rules or an expense account for expense rules, and with the donationProposal outcome it must be an account that donations can use.

      1–999999999

    • taxCodestringrequirednullable

      The code of a tax from the accounting plan, which is refused when the cost center region of costCenter1 has no taxes.

      1–5 characters

    • taxRatenumbernullable

      The tax rate to apply, which is required when the tax of taxCode has no fixed rate and must be left out when that tax has a fixed rate or when no taxCode is given.

      at most 99

    • costCenter1numberrequirednullable

      The number of the first cost center, which must exist and be bookable; it is required when the accounting plan uses cost center regions, and then its first digit must be the digit of one of those regions.

      1–99999999

    • costCenter2numberrequirednullable

      The number of the second cost center, which must exist and be bookable.

      1–99999999

    • dimensionsobject[]required

      The dimension options chosen for the position, which may name each dimension only once and must include every active required dimension; with the donationProposal outcome, only dimensions that support donations apply.

      2 properties
      • dimensionIdidrequired

        The dimension that is chosen, which must be active.

      • optionKeystringrequired

        The key of the chosen option, which must be an active option of that dimension.

        1–64 characters

    • sharenumberrequired

      0–100

Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
  --request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/finance/cash/transactions/rules/YOUR_CASH_TRANSACTION_RULE_ID/update' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "name": "Spenden Eingang Bank",
  "matcher": {
    "typeMatch": "revenue",
    "cashAccount": null,
    "purpose": {
      "value": "Spende",
      "comparator": "equals"
    }
  },
  "outcome": "postingReceipt",
  "positions": [
    {
      "account": 4000,
      "taxCode": null,
      "taxRate": null,
      "costCenter1": null,
      "costCenter2": null,
      "dimensions": [
        {
          "dimensionId": "6b1353f9968718835b2ce0d0",
          "optionKey": "general"
        }
      ],
      "share": 100
    }
  ]
}'

A request the admin app sent for “Edit a booking rule”.

Response

200 Successful response

No response body is specified.

What else happens

  • The rule's name, matcher, positions and outcome are replaced with the values sent. Proposals the rule already made are not changed.

Errors

Caused by the request

StatusErrorWhen
400The bank account was not found or does not belong to this mandateIf matcher.cashAccount is set and that bank account does not exist or does not belong to the rule's mandate.
400At least one matching condition must be setIf no matching condition is set in matcher.
400Dimensions are not available for this productIf a position selects dimensions, which this product does not offer. Only region eu
400A dimension can only be selected onceIf a position selects the same dimension more than once. Only region us
400The selected dimension or option is inactive or does not belong to this organizationIf a position selects a dimension or option that is inactive or does not belong to the organization. For a donationProposal outcome, a dimension that does not apply to donations also counts as invalid. Only region us
400A tax rate requires a tax codeIf a position has a taxRate but no taxCode.
400Invalid tax code "tax code"If a position's taxCode is not in the accounting plan.
400The tax code "tax code" has a fixed rate and does not accept a tax rateIf a position gives a taxRate for a tax code that has a fixed rate.
400The tax code "tax code" requires a tax rateIf a position leaves out taxRate for a tax code that has no fixed rate.
400Invalid tax rate "tax rate"If a position's taxRate is not a valid tax rate.
400Cost centers are not available for this productIf a position sets costCenter1 or costCenter2, which this product does not offer. Only region us
400Regions in use so Cost-center 1 is requiredIf the accounting plan uses regions and a position has no costCenter1. Only region eu
400The Cost-center 1 first digit has to be within "regions digits"If the accounting plan uses regions and the first digit of a position's costCenter1 matches none of them. Only region eu
400The chosen region cost center region disallows taxesIf a position has a taxCode but the region of its costCenter1 does not allow taxes. Only region eu
400account name account number is invalidIf a position's account is not a valid account in the accounting plan.
400account name account number is not bookableIf a position's account is not bookable.
400The account is not a valid revenue accountIf outcome is postingReceipt, the matcher's typeMatch is revenue, and a position's account is not a revenue, cash, debtor or creditor account.
400The account is not a valid expense accountIf outcome is postingReceipt, the matcher's typeMatch is expense, and a position's account is not an expense, cash, debtor or creditor account.
400The account is not valid for donationsIf outcome is donationProposal and a position's account cannot be used for donations.
400A value is required for dimension "dimension"If a position does not select a value for an active dimension that the organization marks as required. For a donationProposal outcome, only dimensions that apply to donations count. Only region us
404Cash transaction rule not foundIf the cash transaction rule does not exist in the mandate.

Marked words such as tax code are filled in with the actual value when the error happens.

Caused by the organization's data

StatusErrorWhen
404A mandate needs to be providedIf the rule is not assigned to a mandate.
404Accounting plan is missing. Please make sure you have setup your finances app properly.If the organization has not set up its accounting plan.
1 rare error, such as when something changes at the same moment
StatusErrorWhen
404Mandate mandate ID not foundIf the rule's mandate can no longer be found.

Marked words such as mandate ID are filled in with the actual value when the error happens.

Errors nearly every request can meet are listed under Errors.