Skip to main content
Avalara Help Center

Create an advanced tax rule to find and replace transaction values

This article applies to:AvaTax

Create an advanced rule to find and replace transaction values before or after tax calculation based on other transaction data, such as the Tax Code field or the sum of certain transaction lines.

For particularly complex find and replace scenarios, use aggregates and expressions to define variables and apply functions to your transaction data before find and replace operations occur. They make it possible to swap address values under unique circumstances or change taxability based on a specific threshold (such as Ireland's two-thirds rule).

Before you begin

Advanced rules for marketplace transactions are available to all users. To use find and replace or allocation rules, contact your account manager.

If the rule you want to create applies to a custom tax code, create the custom tax code first.

Steps

  1. In AvaTax, go to Settings > All AvaTax Settings.
  2. Next to Custom Rules, select Manage.
  3. Select the Advanced Rules tab and then select Add an Advanced Rule.
  4. Select the appropriate Find and Replace rule.
    • Before calculation means the transaction is modified before it's processed by AvaTax, so the rule is applied before tax is calculated. 
    • After calculation means the API response is modified, so the rule is applied after tax is calculated. Use this to return modified data to your business application. 
  5. Enter the rule information.
    • Select a Find and Replace rule. 
    • Select an effective date when the rule should start applying to your transactions. Select an expiration date if this rule should only be used for a certain period of time.
    • Enter a descriptive name that makes the rule easy to find.
    • Check the document types this rule should apply to.
    • If this rule should be applied before or after another rule, select the order and search for the tax rule by its name.
  6. Add aggregates and expressions to define variables or apply functions to your transaction data. They're not required for all find and replace rules.
  7. Under When, set the conditions that trigger the rule. If you add multiple conditions, all of them have to be true for the rule to trigger.
    • Expression:
      • Expression: The name of your expression as you defined it under Aggregates. Ignore this if you aren't using aggregates.
      • Operator: A mathematical measurement of the value. For example, greater than or less than.
      • Value: The field value that's measured by the operator. If you need to include a large number of values, upload them in a .csv file and reference them here. If you need this to be a value from the transaction, you can enter document or line-level fields with the format Document.FieldName or Line.FieldName (for example, Document.CustomerCode or Line.CustomerCode would make the rule look at the customer code on the transaction or its line items).
    • Document level:
      • Field: A document-level field in your transaction data.
      • Operator: A mathematical measurement of the value. For example, greater than, equals, or contains.
      • Value: The field value that's measured by the operator.
    • Line level:
      • Scope: An identifying function for limiting your condition to specific transaction lines. For example, all of, none of, some of, or one of. 
      • Field: The transaction field that's identified by the scope.
      • Operator:  A mathematical measurement of the value. For example, greater than, equals, or contains.
      • Value: The field value that's measured by the operator.
  8. Under Replace, define which value should be replaced with a new one.
    • Document level:
      • Field: A document-level field in your transaction data.
      • Value: Replace the existing transaction value with this one. Similar to condition values, If you need to include a large number of values, upload them in a .csv file and reference them here.
    • Line level:
      • Scope: The number of lines that should be changed. For example, all lines, matched lines, or non-matching lines.
      • Field: A line-level field in your transaction data.
      • Value: Replace the existing transaction value with this one.
  9. Select Save Advanced Transaction Rule.
  10. Use the tax calculator to test your tax rule.

To apply your rule to past transactions, save your sales data again or recalculate the transaction.

Add or edit invoice messages

Remember the following when adding or updating invoice messages using the Find and Replace after calculation rule:

  • Invoice messages created by advanced rules do not replace the existing invoice messages, but instead add new ones.
  • The newly added invoice message is not saved with the transaction data in AvaTax. Only connectors and API users can access this message. 

See also

Test your setup