avatax 26.8.3 → 26.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3e1472788c94b587248cf0936bd15f9a5dce475f72f8f3917612403e8b7b087
4
- data.tar.gz: 717b166329c75462d34f9e47f852955980f1d51c4bfead90510d54edb03cf62c
3
+ metadata.gz: 1f8c336e3e4831d44fedfc0d6eee6bf8b7e35a974e70e82bfa734de622db387e
4
+ data.tar.gz: 695e3da045223f974a6d7c7e944cd72e96d0e3bd806cb372ac65c4b66e30c169
5
5
  SHA512:
6
- metadata.gz: 05725ffcfaf3235c09db4cce6b5d1e7a29c8ba67ecdcd64f847aadf047de8a1e733f6725249205bd794a4b5eb69c99fcf64953e5311962b8defee288b4fc724f
7
- data.tar.gz: b0af7834d8f9b22a7bfac90edbbd81a7d48aa620366985c4c7da6b0c85a949166e0fe214146077b9c4adf237acdfebb986182a64692959a87cb22e9e2ef6dfa0
6
+ metadata.gz: a0dac95a96ab41465b170b50cd2f639d664be9974caf6bf52dca327d36f0e37b0b916dc96d95ddc45afcd8637f6054f9b34734f90fd2f1518d83777a46baa48e
7
+ data.tar.gz: bb7f1ad8b523207136cf74e960542cc489166e49d864a1b4244ab5c4d36d3a9c81305ae3b8fac43817301d820ddae643f18d4a329a36e6c38a14643bf677c12e
@@ -69,10 +69,6 @@ module AvaTax
69
69
  # required, please use the
70
70
  # [CreateTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/).
71
71
  #
72
- # Set `skipTransactionValidation` to true to defer transaction type, company code, and
73
- # nested model validation until BatchV2 processes each transaction. Per-transaction
74
- # validation failures are then written to the batch error file without blocking upload.
75
- #
76
72
  # The maximum content length of the request body is limited to 28.6 MB. If this limit
77
73
  # is exceeded, a 404 Not Found status will be returned (possibly with a CORS error if
78
74
  # the API is called from a browser). In this situation, please split the request into
@@ -88,6 +84,33 @@ module AvaTax
88
84
  def create_batches(companyId, model) path = "/api/v2/companies/#{companyId}/batches"
89
85
  post(path, model, {}, AvaTax::VERSION) end
90
86
 
87
+ # Create custom rules import batch.
88
+ #
89
+ # Create a new custom rules import batch object attached to this company.
90
+ #
91
+ # The batch payload is the Custom Rules export envelope (tax rules, custom rules, and
92
+ # advanced rules). It is stored as JSON and processed downstream by BatchV2.
93
+ #
94
+ # When a custom rules import batch is created, it is added to the AvaTax Batch v2 Queue and will be
95
+ # processed in the order it was received. To check the
96
+ # status of a batch, fetch the batch and retrieve the results of the batch
97
+ # operation.
98
+ #
99
+ # The maximum content length of the request body is limited to 28.6 MB. If this limit
100
+ # exceeds then a 404 Not Found status is returned (possibly with a CORS error if
101
+ # the API is called from a browser). In this situation, please split the request into
102
+ # smaller batches.
103
+ #
104
+ # ### Security Policies
105
+ #
106
+ # * This API requires one of the following user roles: AccountAdmin, AccountOperator, AvaTaxOnlyAccountAdmin, AvaTaxOnlyCompanyAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, FirmAdmin, SSTAdmin, SystemAdmin, SystemOperator, TechnicalSupportAdmin.
107
+ # Swagger Name: AvaTaxClient
108
+ # @param companyId [Integer] The ID of the company that owns this batch.
109
+ # @param model [Object] The custom rules import batch you wish to create.
110
+ # @return [Object]
111
+ def create_custom_rules_batch(companyId, model) path = "/api/v2/companies/#{companyId}/batches/customrules"
112
+ post(path, model, {}, AvaTax::VERSION) end
113
+
91
114
  # Create item import batch.
92
115
  #
93
116
  # Create a new item import batch objects attached to this company.
@@ -127,6 +150,10 @@ module AvaTax
127
150
  # required, please use the
128
151
  # [CreateTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/).
129
152
  #
153
+ # Set `skipTransactionValidation` to true to defer transaction type, company code, and
154
+ # nested model validation until BatchV2 processes each transaction. Per-transaction
155
+ # validation failures are then written to the batch error file without blocking upload.
156
+ #
130
157
  # The maximum content length of the request body is limited to 28.6 MB. If this limit
131
158
  # is exceeded, a 404 Not Found status will be returned (possibly with a CORS error if
132
159
  # the API is called from a browser). In this situation, please split the request into
@@ -0,0 +1,493 @@
1
+ module AvaTax
2
+ class Client
3
+ module CustomRules
4
+
5
+
6
+ # Create a new custom rule
7
+ #
8
+ # Creates a new custom rule object attached to this company.
9
+ #
10
+ # Custom rules modify the default AvaTax behavior during tax calculation, customizing it to
11
+ # match requirements specific to your business. Rules can be used to change the taxability of
12
+ # an item, change the tax base of an item, alter the tax rate, modify transaction fields
13
+ # and addresses, allocate and split line items, update the location code, and more.
14
+ #
15
+ # Please use custom rules carefully and ensure they match the behavior agreed upon with your
16
+ # auditor, legal representative, and accounting team.
17
+ #
18
+ # ---
19
+ #
20
+ # Rules are built from modular _components_. A component can be a rule-wide variable or a
21
+ # _node_ in the directed acyclic graph defining the rule's behavior. To build a rule from scratch,
22
+ # start with `GetCustomRuleComponents` to retrieve supported components and the JSON `dataSchema` for each.
23
+ #
24
+ # Ensure each component has a unique `id` (for _Variable_ components, this is its name) and that its `data` field conforms to the node subtype's `dataSchema`.
25
+ # The `data` must be a single-escaped JSON string, not a nested object. Do not quote numbers or booleans, use only valid enumeration values, and keep
26
+ # arrays arrays even if they only contain a single element.
27
+ #
28
+ # _Nodes_ may be _Conditions_ or _Actions_. When deciding which node to use, prefer nodes for specific use cases,
29
+ # such as `MatchAddress` and `UpdateAddress`, over generic ones `MatchField` and `UpdateField` when possible.
30
+ #
31
+ # Use the `GetCustomRuleFields` endpoint to query the fields that can be used in nodes which accept arbitrary fields, such as `MatchField` and `UpdateField`.
32
+ #
33
+ # Each node defines its outgoing edges by specifying its child node IDs in the `next` array. The result of a node execution is a set of matches
34
+ # (e.g. which lines on the document met the criteria). Node results behave as follows:
35
+ # - Sequences *intersect* their results ("AND")
36
+ # - Branches *propagate* their results as the input to each child
37
+ # - Merges *union* their results ("OR")
38
+ #
39
+ # The `scope` of a condition is what part of the transaction it operates on: `Document`, `SomeLines`, `OneLine`, `AllLines`, or `NoLines`.
40
+ # The `scope` of an action determines what part of the transaction to apply changes to: `Document`, `MatchedLines`, `NotMatchedLines`, or `AllLines`.
41
+ #
42
+ # When using a rule to adjust taxability,
43
+ # - To exempt a line from tax entirely, use an `UpdateField` node to set its tax code to `NT` (Avalara's standard non-taxable code).
44
+ # - Place the UpdateField early in the rule so it takes effect pre-calculation.
45
+ # - To impact tax details, the MatchTax condition node is required to match on jurisdiction + tax type combinations.
46
+ # - There can only be one MatchTax node per rule, but it can have more than one criteria set.
47
+ # - Each criteria set has `matchTaxId` (unique identifier), `country`, `region`, `jurisdictionTypeId`, `jurisCode`, `taxTypeCode`, `taxSubType`, and `rateTypeCode`.
48
+ # - Tax subtypes and rate types may be wildcard (`*` or `ALL`) for most rule types.
49
+ # - Always use full names for `jurisdictionTypeId` (`Country`, `State`, `City`, `County`, `Special`) instead of their abbreviations.
50
+ # - A wildcard jurisdiction code (`*` or `ALL`) applies the treatment to all jurisdictions of the given `jurisdictionTypeId`.
51
+ # - `TaxRule*` action nodes define how the tax is to be adjusted.
52
+ # - `TaxRuleProductTaxability`: sets an item's taxability and assigns its rate type, so it requires a specific (non-wildcard) `rateTypeCode`.
53
+ # - `TaxRuleRateOverride`: overrides Avalara's tax rate.
54
+ # - `TaxRuleBaseOverride`: changes the tax base as a proportion of the original amount (e.g. `0.5` = 50% taxable).
55
+ # - `TaxRuleExemptEntity`: exempts the matched line for the jurisdiction and tax type; typically paired with a MatchEntityUseCode condition.
56
+ # - Caps and thresholds can be applied with the `TaxRuleProductTaxability` or `TaxRuleRateOverride` actions.
57
+ # - A threshold buckets amounts up to and including the threshold as non-taxable.
58
+ # - A cap limits the taxable amount (per unit by default, multiplied by quantity); amounts above the cap become non-taxable.
59
+ # - Add the `Document` option to apply the cap across all matching lines of the document.
60
+ # - A `default` value must be provided in `TaxRule*` nodes. Overrides for specific jurisdictions are optional and provided in an `overrides` array (NOT a dictionary).
61
+ # - If the tax treatment (rate, taxability, etc.) is the same for all configured jurisdictions, set only the `default` value and omit `overrides`.
62
+ # - You only need to set overrides for values that differ from the default.
63
+ # - If a `matchTaxId` member is present in an override, it will apply to the corresponding criteria in the MatchTax node.
64
+ # - If a `matchTaxId` member is NOT present in an override, pattern matching is performed on the override criteria fields with omitted fields treated as wildcards.
65
+ # - When multiple tax rules apply, a more specific tax type/subtype beats a wildcard, and the latest effective date wins.
66
+ # - A Tax Code and Tariff Code condition are mutually exclusive.
67
+ # - Expressions cannot be used in nodes which directly affect tax treatment.
68
+ #
69
+ # Some nodes support _expressions_, which may have variable values evaluated at transaction time.
70
+ # Expression-supporting fields should be indicated on the node's data schema. Expressions allow
71
+ # formulas using arithmetic, substitutions, and references to transaction fields; for example:
72
+ # - `{{Document.TotalAmount}} * 0.1` (10% of the total document amount)
73
+ # - `{{Line.UserDefinedFields.Udf8}}` (Line-level user-defined field 8)
74
+ # - `{{Line.Ref1}}{{Line.Ref2}}` (A line's Ref1 and Ref2 values concatenated)
75
+ # - `2 + {{MyVar}}` (The value of the "MyVar" variable defined elsewhere in the rule, plus 2)
76
+ #
77
+ # Use the `GetCustomRuleTokens` endpoint to enumerate or search for valid tokens that can be used in expressions.
78
+ #
79
+ # Lookup files / reference lists may be used where expressions are supported. Use the syntax `{{FileName.ColumnName}}` to match against
80
+ # a column in a Condition and use the value from another column in the matched row in an Action. Matching scopes must be compatible -
81
+ # line-level matches cannot be used to update a document-level field.
82
+ #
83
+ # Rule nodes are assigned execution steps based on their contents and surrounding nodes. For instance, nodes that follow tax
84
+ # rule actions (`TaxRule*`) or require a calculated field (such as taxable amount) are executed after tax calculation instead
85
+ # of before calculation. Not every node type may execute in every step. Place them accordingly to their `validSteps`.
86
+ # A rule will be rejected if an ordering cannot be resolved. Rules execute in the following stages:
87
+ # - `OnRequest`: On the API request values, before document validation.
88
+ # - `AfterAddressValidation`: After addresses have been geo-coded / validated once.
89
+ # - `AfterSourcing`: After jurisdictions and tax types have been evaluated, but before tax calculation.
90
+ # - `AfterDetails`: After tax calculation details have been generated.
91
+ # - `OnResponse`: After the document has been saved, if applicable; on the API response only.
92
+ #
93
+ # ---
94
+ #
95
+ # It is recommended to validate the rule with the `ValidateCustomRule` endpoint before creating it.
96
+ # This will let you review the rule's execution plan and any associated diagnostic information before saving it.
97
+ #
98
+ # ### Security Policies
99
+ #
100
+ # * This API requires one of the following user roles: AccountAdmin, AvaTaxOnlyAccountAdmin, AvaTaxOnlyCompanyAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, SSTAdmin, TechnicalSupportAdmin.
101
+ # Swagger Name: AvaTaxClient
102
+ # @param companyId [Integer] The ID of the company to create the rule for.
103
+ # @param model [Object] The rule you wish to create.
104
+ # @return [Object]
105
+ def create_custom_rule(companyId, model) path = "/api/v2/companies/#{companyId}/customrules"
106
+ post(path, model, {}, AvaTax::VERSION) end
107
+
108
+ # Delete a custom rule
109
+ #
110
+ # Delete a single custom rule object attached to this company.
111
+ #
112
+ # To maintain tax calculation consistency for recalculation of backdated transactions, it is
113
+ # recommended to expire a rule (set a definite end date) instead of deleting it when the rule
114
+ # requirements remain accurate for a past time period. This will keep the old version of the
115
+ # rule active for that time period so historical transactions re-calculate with the appropriate rule.
116
+ #
117
+ # If only minor changes are required (i.e. the overall purpose of the rule does not change),
118
+ # and historical transactions would not be significantly impacted by the update, prefer using
119
+ # the UpdateCustomRule operation instead of deleting and re-creating the rule.
120
+ #
121
+ # Please use custom rules carefully and ensure they match the behavior agreed upon with your
122
+ # auditor, legal representative, and accounting team.
123
+ #
124
+ # ### Security Policies
125
+ #
126
+ # * This API requires one of the following user roles: AccountAdmin, AvaTaxOnlyAccountAdmin, AvaTaxOnlyCompanyAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, SSTAdmin, TechnicalSupportAdmin.
127
+ # Swagger Name: AvaTaxClient
128
+ # @param companyId [Integer] The ID of the company that owns the rule.
129
+ # @param id [Integer] The ID of the rule to delete.
130
+ # @return [ErrorDetail[]]
131
+ def delete_custom_rule(companyId, id) path = "/api/v2/companies/#{companyId}/customrules/#{id}"
132
+ delete(path, {}, AvaTax::VERSION) end
133
+
134
+ # Export custom rules for a company
135
+ #
136
+ # Export all rule objects defined for this company as a portable JSON envelope.
137
+ #
138
+ # The export set can be filtered and paginated using the same query parameters
139
+ # as the `ListCustomRules` endpoint.
140
+ #
141
+ # This endpoint uses OData filter syntax in order to support querying nested properties;
142
+ # note the following differences from standard AvaTax filtering:
143
+ # - Instead of the infix form, use the contains() function, e.g. `contains(description, 'Amount')`
144
+ # - Query collection fields with the any()/all() lambda operators, e.g. `subtype/any(r: r eq 'UpdateLocationCode')`.
145
+ #
146
+ # The exported envelope can be re-imported into another company or account using the
147
+ # `CreateCustomRulesBatch` endpoint.
148
+ #
149
+ # By default, the export includes all rule types:
150
+ # - Custom Rules, the latest system which provides a new, unified, graph-based interface for engine customization
151
+ # - Advanced Rules, also known as transaction rules, the legacy system for modifying incoming or outgoing transaction fields
152
+ # - Legacy Tax Rules, traditional taxability customization
153
+ #
154
+ # Filtering is applied in two stages: `taxRuleFilter`, `advancedRuleFilter`, and `customRuleFilter` are each
155
+ # applied first, against their respective inner entity type, to select which rules are included. The
156
+ # resulting records are then converted into summary rows, and `filter` is applied afterward against
157
+ # those generated summary records.
158
+ #
159
+ # ### Security Policies
160
+ #
161
+ # * This API requires one of the following user roles: AccountAdmin, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser.
162
+ # Swagger Name: AvaTaxClient
163
+ # @param companyId [Integer] The ID of the company to produce a rule export for.
164
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
165
+ # @param taxRuleFilter [String] A simple filter statement to select specific TaxRuleModel records. Applied to the underlying Legacy Tax Rule entities before they are converted into summary records; evaluated before `filter`.
166
+ # @param advancedRuleFilter [String] A simple filter statement to select specific AdvancedRuleExecutionModel records. Applied to the underlying Advanced Rule entities before they are converted into summary records; evaluated before `filter`.
167
+ # @param customRuleFilter [String] A simple filter statement to select specific CustomRuleOutputModel records. Applied to the underlying Custom Rule entities before they are converted into summary records; evaluated before `filter`.
168
+ # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
169
+ # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
170
+ # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
171
+ # @return [Object]
172
+ def export_custom_rules(companyId, options={}) path = "/api/v2/companies/#{companyId}/customrules/export"
173
+ get(path, options, AvaTax::VERSION) end
174
+
175
+ # Retrieve a single custom rule
176
+ #
177
+ # Retrieves a single custom rule object attached to this company.
178
+ #
179
+ # Use this endpoint to verify the persisted state of a specific rule given its ID,
180
+ # or to fetch the latest, most detailed definition for editing and auditing.
181
+ #
182
+ # Custom rules modify the default AvaTax behavior during tax calculation, customizing it to
183
+ # match requirements specific to your business. Rules can be used to change the taxability of
184
+ # an item, change the tax base of an item, alter the tax rate, modify transaction fields
185
+ # and addresses, allocate and split line items, update the location code, and more.
186
+ #
187
+ # Please use custom rules carefully and ensure they match the behavior agreed upon with your
188
+ # auditor, legal representative, and accounting team.
189
+ #
190
+ # ### Security Policies
191
+ #
192
+ # * This API requires one of the following user roles: AccountAdmin, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser.
193
+ # Swagger Name: AvaTaxClient
194
+ # @param companyId [Integer] The ID of the company that owns the rule.
195
+ # @param id [Integer] The ID of the rule.
196
+ # @return [Object]
197
+ def get_custom_rule(companyId, id) path = "/api/v2/companies/#{companyId}/customrules/#{id}"
198
+ get(path, {}, AvaTax::VERSION) end
199
+
200
+ # Fetch a filtered list of components used in custom rule definitions
201
+ #
202
+ # Retrieve a list of supported custom rule components. Start here to enumerate
203
+ # supported Conditions, Actions, and Variables to design rule graphs.
204
+ #
205
+ # A component may be of the following types:
206
+ # - *Conditions*, which are nodes which evaluate transaction-based criteria
207
+ # - *Actions*, which are nodes that change or update a transaction when preceding conditions pass
208
+ # - *Variables*, which are predefined values or expressions with rule-wide scope
209
+ #
210
+ # A component's subtype is the specific kind of condition, action, or variable it is. Examples include:
211
+ # - *Conditions*: MatchField, MatchAddress, MatchCustomerCode, MatchDocumentType, MatchTariffCode, MatchTaxCode, MatchEntityUseCode, MatchTax
212
+ # - *Actions*: UpdateField, UpdateAddress, UpdateLocationCode, TaxRuleRateOverride, TaxRuleBaseOverride, TaxRuleExemptEntity, TaxRuleProductTaxability, AddMessage
213
+ # - *Variables*: Expression, Aggregation
214
+ #
215
+ # The definition of a custom rule is a directed acyclic graph consisting of condition and action nodes.
216
+ # Variable components have rule-wide scope and are not part of the execution graph, but all three
217
+ # component types conform to the same model.
218
+ #
219
+ # The `dataSchema` member is an escaped JSON string which defines, in JSON schema format,
220
+ # the expected structure of the `data` property of any rule component with the corresponding `subtype`.
221
+ # Swagger Name: AvaTaxClient
222
+ # @param companyId [Integer] The ID of the company to retrieve supported definitions for.
223
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
224
+ # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
225
+ # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
226
+ # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
227
+ # @return [FetchResult]
228
+ def get_custom_rule_components(companyId, options={}) path = "/api/v2/companies/#{companyId}/customrules/definitions/components"
229
+ get(path, options, AvaTax::VERSION) end
230
+
231
+ # Fetch a filtered list of transaction fields supported by custom rules
232
+ #
233
+ # Query the transaction properties which may be used in custom rules.
234
+ #
235
+ # The following metadata is also included for each property:
236
+ # - A display name and description
237
+ # - The data type
238
+ # - Whether it exists at document and/or line level
239
+ # - Whether it can be read from and/or written to
240
+ # - Whether it is only available in certain steps; examples of such restrictions include: only after address validation, only after tax calculation
241
+ #
242
+ # Note that the name of a field may differ between the rule system and the raw transaction models
243
+ # due to the abstractions the rules system provides. The values returned by this endpoint should
244
+ # be considered authoritative in all custom rules contexts, including:
245
+ # - Components which accept field names, such as `MatchField` and `UpdateField`
246
+ # - In variable expressions; see also `GetCustomRuleTokens`
247
+ # Swagger Name: AvaTaxClient
248
+ # @param companyId [Integer] The ID of the company to retrieve supported fields for.
249
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
250
+ # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
251
+ # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
252
+ # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
253
+ # @return [FetchResult]
254
+ def get_custom_rule_fields(companyId, options={}) path = "/api/v2/companies/#{companyId}/customrules/definitions/fields"
255
+ get(path, options, AvaTax::VERSION) end
256
+
257
+ # Construct an empty template for a rule definition
258
+ #
259
+ # Generate a starter graph with empty nodes based on parameters specified in the request body.
260
+ #
261
+ # Typically, this is used to initialize an editor interface after selecting basic parameters for rule creation
262
+ # such as the types of conditions and actions to include.
263
+ #
264
+ # Note that this endpoint does not return a complete rule entity, only its behavior definition.
265
+ # The rule definition returned is not guaranteed to pass validation, as most fields for component content are left empty.
266
+ # Fill in any empty fields, then call `ValidateCustomRule` to validate and `CreateCustomRule` to persist.
267
+ # Swagger Name: AvaTaxClient
268
+ # @param companyId [Integer] The ID of the company
269
+ # @param model [Object] The template request
270
+ # @return [Object]
271
+ def get_custom_rule_template(companyId, model) path = "/api/v2/companies/#{companyId}/customrules/definitions/template"
272
+ post(path, model, {}, AvaTax::VERSION) end
273
+
274
+ # Fetch a filtered list of supported custom rule expression tokens
275
+ #
276
+ # Query the list of supported tokens for use in custom rule expressions.
277
+ #
278
+ # Some rule components support _expressions_, which may have variable values evaluated
279
+ # each time the rule runs on a transaction. An _expression token_ is a sequence delimited
280
+ # by double braces, such as `{{Document.Description}}`, which refers to a variable value
281
+ # and evaluates to that value at transaction time when used within a supporting rule.
282
+ #
283
+ # Expressions can contain formulas using many of these tokens. For example, the expression
284
+ # `{{Document.TotalAmount}} * 0.1` evaluates to 10% of the total document amount for
285
+ # the current transaction.
286
+ #
287
+ # Supported tokens include all readable transaction fields, including parameters and user-defined fields,
288
+ # as well as company-specific reference lists. Examples of the different token types include:
289
+ # - Document-level fields: `{{Document.CustomerCode}}`
290
+ # - Line-level fields: `{{Line.TaxCode}}`
291
+ # - Rule-wide variables: `{{MyVar}}`
292
+ # - Company lookup files: `{{FileName.ColumnName}}`
293
+ #
294
+ # String-type tokens support _functions_, which can be used for transforming the evaluated value:
295
+ # - `Substring(start, length)`: Extract up to `length` characters starting at 0-based index `start`; omit `length` to read to end
296
+ # - `Trim(str)`: Trim complete occurrences of `str` from the beginning and end of the string; omit `str` to trim whitespace
297
+ #
298
+ # Place functions inside the braces, e.g. `{{Line.Ref1.Substring(1,2)}}`.
299
+ #
300
+ # When using expressions in escaped JSON component `data`, include them verbatim inside the
301
+ # JSON string value. Only escape the surrounding double quotes required by JSON.
302
+ # Do not double-escape the braces in `{{...}}`.
303
+ # Swagger Name: AvaTaxClient
304
+ # @param companyId [Integer] The ID of the company to retrieve supported tokens for.
305
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
306
+ # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
307
+ # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
308
+ # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
309
+ # @return [FetchResult]
310
+ def get_custom_rule_tokens(companyId, options={}) path = "/api/v2/companies/#{companyId}/customrules/definitions/tokens"
311
+ get(path, options, AvaTax::VERSION) end
312
+
313
+ # Retrieve all custom rules for a company
314
+ #
315
+ # Query the custom rule objects defined for this company.
316
+ #
317
+ # This endpoint uses OData filter syntax in order to support querying nested properties;
318
+ # note the following differences from standard AvaTax filtering:
319
+ # - Instead of the infix form, use the contains() function, e.g. `contains(description, 'Amount')`
320
+ # - Query collection fields with the any()/all() lambda operators, e.g. `subtype/any(r: r eq 'UpdateLocationCode')`.
321
+ #
322
+ # By default, all rule types are included:
323
+ # - Custom Rules, the latest system which provides a new, unified, graph-based interface for engine customization
324
+ # - Advanced Rules, also known as transaction rules, the legacy system for modifying incoming or outgoing transaction fields
325
+ # - Legacy Tax Rules, traditional taxability customization
326
+ #
327
+ # Note that not every rule type supports every field in `CustomRuleSummaryModel`, so information
328
+ # unavailable for that rule type may be omitted.
329
+ #
330
+ # Filtering is applied in two stages: `taxRuleFilter`, `advancedRuleFilter`, and `customRuleFilter` are each
331
+ # applied first, against their respective inner entity type, to select which rules are included. The
332
+ # resulting records are then converted into summary rows, and `filter` is applied afterward against
333
+ # those generated `CustomRuleSummaryModel` summary records.
334
+ #
335
+ # ### Security Policies
336
+ #
337
+ # * This API requires one of the following user roles: AccountAdmin, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser.
338
+ # Swagger Name: AvaTaxClient
339
+ # @param companyId [Integer] The ID of the company to query the custom rules for.
340
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).<br />*Not filterable:* subtypeDescription, ruleEntity
341
+ # @param taxRuleFilter [String] A simple filter statement to select specific TaxRuleModel records. Applied to the underlying Legacy Tax Rule entities before they are converted into summary records; evaluated before `filter`.
342
+ # @param advancedRuleFilter [String] A simple filter statement to select specific AdvancedRuleExecutionModel records. Applied to the underlying Advanced Rule entities before they are converted into summary records; evaluated before `filter`.
343
+ # @param customRuleFilter [String] A simple filter statement to select specific CustomRuleOutputModel records. Applied to the underlying Custom Rule entities before they are converted into summary records; evaluated before `filter`.
344
+ # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
345
+ # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
346
+ # @param orderBy [String] A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
347
+ # @param includeEntities [Boolean] Whether or not to include the full entity definitions in the response; otherwise, only summary information is returned.
348
+ # @return [FetchResult]
349
+ def list_custom_rules(companyId, options={}) path = "/api/v2/companies/#{companyId}/customrules/summary"
350
+ get(path, options, AvaTax::VERSION) end
351
+
352
+ # Update a custom rule
353
+ #
354
+ # Updates an existing custom rule object attached to this company.
355
+ # The rule's ID must be supplied in the request body and must match the request URL path.
356
+ #
357
+ # Prefer updating an existing rule over deletion and re-creation when the overall purpose of the rule is not changing.
358
+ # If required to keep different versions of a rule active (e.g. so historical transactions recalculate consistently),
359
+ # use this endpoint to set an explicit expiry date (end date) for a rule to limit its effective range.
360
+ #
361
+ # Custom rules modify the default AvaTax behavior during tax calculation, customizing it to
362
+ # match requirements specific to your business. Rules can be used to change the taxability of
363
+ # an item, change the tax base of an item, alter the tax rate, modify transaction fields
364
+ # and addresses, allocate and split line items, update the location code, and more.
365
+ #
366
+ # Please use custom rules carefully and ensure they match the behavior agreed upon with your
367
+ # auditor, legal representative, and accounting team.
368
+ #
369
+ # ---
370
+ #
371
+ # Rules are built from modular _components_. A component can be a rule-wide variable or a
372
+ # _node_ in the directed acyclic graph defining the rule's behavior. To build a rule from scratch,
373
+ # start with `GetCustomRuleComponents` to retrieve supported components and the JSON `dataSchema` for each.
374
+ #
375
+ # Ensure each component has a unique `id` (for _Variable_ components, this is its name) and that its `data` field conforms to the node subtype's `dataSchema`.
376
+ # The `data` must be a single-escaped JSON string, not a nested object. Do not quote numbers or booleans, use only valid enumeration values, and keep
377
+ # arrays arrays even if they only contain a single element.
378
+ #
379
+ # _Nodes_ may be _Conditions_ or _Actions_. When deciding which node to use, prefer nodes for specific use cases,
380
+ # such as `MatchAddress` and `UpdateAddress`, over generic ones `MatchField` and `UpdateField` when possible.
381
+ #
382
+ # Use the `GetCustomRuleFields` endpoint to query the fields that can be used in nodes which accept arbitrary fields, such as `MatchField` and `UpdateField`.
383
+ #
384
+ # Each node defines its outgoing edges by specifying its child node IDs in the `next` array. The result of a node execution is a set of matches
385
+ # (e.g. which lines on the document met the criteria). Node results behave as follows:
386
+ # - Sequences *intersect* their results ("AND")
387
+ # - Branches *propagate* their results as the input to each child
388
+ # - Merges *union* their results ("OR")
389
+ #
390
+ # The `scope` of a condition is what part of the transaction it operates on: `Document`, `SomeLines`, `OneLine`, `AllLines`, or `NoLines`.
391
+ # The `scope` of an action determines what part of the transaction to apply changes to: `Document`, `MatchedLines`, `NotMatchedLines`, or `AllLines`.
392
+ #
393
+ # When using a rule to adjust taxability,
394
+ # - To exempt a line from tax entirely, use an `UpdateField` node to set its tax code to `NT` (Avalara's standard non-taxable code).
395
+ # - Place the UpdateField early in the rule so it takes effect pre-calculation.
396
+ # - To impact tax details, the MatchTax condition node is required to match on jurisdiction + tax type combinations.
397
+ # - There can only be one MatchTax node per rule, but it can have more than one criteria set.
398
+ # - Each criteria set has `matchTaxId` (unique identifier), `country`, `region`, `jurisdictionTypeId`, `jurisCode`, `taxTypeCode`, `taxSubType`, and `rateTypeCode`.
399
+ # - Tax subtypes and rate types may be wildcard (`*` or `ALL`) for most rule types.
400
+ # - Always use full names for `jurisdictionTypeId` (`Country`, `State`, `City`, `County`, `Special`) instead of their abbreviations.
401
+ # - A wildcard jurisdiction code (`*` or `ALL`) applies the treatment to all jurisdictions of the given `jurisdictionTypeId`.
402
+ # - `TaxRule*` action nodes define how the tax is to be adjusted.
403
+ # - `TaxRuleProductTaxability`: sets an item's taxability and assigns its rate type, so it requires a specific (non-wildcard) `rateTypeCode`.
404
+ # - `TaxRuleRateOverride`: overrides Avalara's tax rate.
405
+ # - `TaxRuleBaseOverride`: changes the tax base as a proportion of the original amount (e.g. `0.5` = 50% taxable).
406
+ # - `TaxRuleExemptEntity`: exempts the matched line for the jurisdiction and tax type; typically paired with a MatchEntityUseCode condition.
407
+ # - Caps and thresholds can be applied with the `TaxRuleProductTaxability` or `TaxRuleRateOverride` actions.
408
+ # - A threshold buckets amounts up to and including the threshold as non-taxable.
409
+ # - A cap limits the taxable amount (per unit by default, multiplied by quantity); amounts above the cap become non-taxable.
410
+ # - Add the `Document` option to apply the cap across all matching lines of the document.
411
+ # - A `default` value must be provided in `TaxRule*` nodes. Overrides for specific jurisdictions are optional and provided in an `overrides` array (NOT a dictionary).
412
+ # - If the tax treatment (rate, taxability, etc.) is the same for all configured jurisdictions, set only the `default` value and omit `overrides`.
413
+ # - You only need to set overrides for values that differ from the default.
414
+ # - If a `matchTaxId` member is present in an override, it will apply to the corresponding criteria in the MatchTax node.
415
+ # - If a `matchTaxId` member is NOT present in an override, pattern matching is performed on the override criteria fields with omitted fields treated as wildcards.
416
+ # - When multiple tax rules apply, a more specific tax type/subtype beats a wildcard, and the latest effective date wins.
417
+ # - A Tax Code and Tariff Code condition are mutually exclusive.
418
+ # - Expressions cannot be used in nodes which directly affect tax treatment.
419
+ #
420
+ # Some nodes support _expressions_, which may have variable values evaluated at transaction time.
421
+ # Expression-supporting fields should be indicated on the node's data schema. Expressions allow
422
+ # formulas using arithmetic, substitutions, and references to transaction fields; for example:
423
+ # - `{{Document.TotalAmount}} * 0.1` (10% of the total document amount)
424
+ # - `{{Line.UserDefinedFields.Udf8}}` (Line-level user-defined field 8)
425
+ # - `{{Line.Ref1}}{{Line.Ref2}}` (A line's Ref1 and Ref2 values concatenated)
426
+ # - `2 + {{MyVar}}` (The value of the "MyVar" variable defined elsewhere in the rule, plus 2)
427
+ #
428
+ # Use the `GetCustomRuleTokens` endpoint to enumerate or search for valid tokens that can be used in expressions.
429
+ #
430
+ # Lookup files / reference lists may be used where expressions are supported. Use the syntax `{{FileName.ColumnName}}` to match against
431
+ # a column in a Condition and use the value from another column in the matched row in an Action. Matching scopes must be compatible -
432
+ # line-level matches cannot be used to update a document-level field.
433
+ #
434
+ # Rule nodes are assigned execution steps based on their contents and surrounding nodes. For instance, nodes that follow tax
435
+ # rule actions (`TaxRule*`) or require a calculated field (such as taxable amount) are executed after tax calculation instead
436
+ # of before calculation. Not every node type may execute in every step. Place them accordingly to their `validSteps`.
437
+ # A rule will be rejected if an ordering cannot be resolved. Rules execute in the following stages:
438
+ # - `OnRequest`: On the API request values, before document validation.
439
+ # - `AfterAddressValidation`: After addresses have been geo-coded / validated once.
440
+ # - `AfterSourcing`: After jurisdictions and tax types have been evaluated, but before tax calculation.
441
+ # - `AfterDetails`: After tax calculation details have been generated.
442
+ # - `OnResponse`: After the document has been saved, if applicable; on the API response only.
443
+ #
444
+ # ---
445
+ #
446
+ # It is recommended to validate the rule with the `ValidateCustomRule` endpoint before updating it.
447
+ # This will let you review the rule's execution plan and any associated diagnostic information before saving it.
448
+ #
449
+ # ### Security Policies
450
+ #
451
+ # * This API requires one of the following user roles: AccountAdmin, AvaTaxOnlyAccountAdmin, AvaTaxOnlyCompanyAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, SSTAdmin, TechnicalSupportAdmin.
452
+ # Swagger Name: AvaTaxClient
453
+ # @param companyId [Integer] The ID of the company that owns the rule to update.
454
+ # @param id [Integer] The ID of the rule to update. Must match the rule ID passed in the request body.
455
+ # @param model [Object] The new contents of the rule.
456
+ # @return [Object]
457
+ def update_custom_rule(companyId, id, model) path = "/api/v2/companies/#{companyId}/customrules/#{id}"
458
+ put(path, model, {}, AvaTax::VERSION) end
459
+
460
+ # Validate a custom rule
461
+ #
462
+ # Validates a custom rule and returns a detailed validation result.
463
+ #
464
+ # This endpoint allows running rule validation independently of a create or update operation,
465
+ # enabling checking the validity of a proposed rule without persisting changes.
466
+ # It also returns additional diagnostic information about how a rule will be interpreted by the
467
+ # engine, such as how expressions were parsed and what order the graph nodes will be executed in.
468
+ # Therefore, it can also be used to inspect rule behavior when troubleshooting.
469
+ #
470
+ # Validation messages are categorized into "info," "warning," and "error" severity levels:
471
+ # - Info-level messages provide diagnostic details about how the rule was parsed
472
+ # - Warning-level messages flag potential misconfigurations or scenarios which may cause unexpected behavior
473
+ # and should be reviewed for intent, but do not block saving the rule
474
+ # - Error-level messages indicate that the rule has an issue that will prevent it from being saved or executed
475
+ #
476
+ # Examples of validation checks which are run include:
477
+ # - Directed acyclic graph structure compliance
478
+ # - Schema conformance for each `data` string
479
+ # - Enumeration value validity, including scope and condition operators
480
+ # - Field existence and step (set/get) constraints
481
+ # - Requirements verification for nodes with prerequisites
482
+ #
483
+ # Validation messages may reference a specific node in their `refersTo` field.
484
+ # If this field is empty, the message is rule-wide.
485
+ # Swagger Name: AvaTaxClient
486
+ # @param companyId [Integer] The ID of the company to validate the rule for.
487
+ # @param model [Object] Rule content to be validated.
488
+ # @return [Object]
489
+ def validate_custom_rule(companyId, model) path = "/api/v2/companies/#{companyId}/customrules/validate"
490
+ post(path, model, {}, AvaTax::VERSION) end
491
+ end
492
+ end
493
+ end
@@ -98,7 +98,7 @@ module AvaTax
98
98
  # * This API requires one of the following user roles: AccountAdmin, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, Compliance Root User, ComplianceAdmin, ComplianceUser, CSPAdmin, CSPTester, ECMAccountUser, ECMCompanyUser, FirmAdmin, FirmUser, ProStoresOperator, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser.
99
99
  # Swagger Name: AvaTaxClient
100
100
  # @param companyId [Integer] The ID of the company that owns these settings
101
- # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).<br />*Not filterable:* modifiedDate, ModifiedUserId
101
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
102
102
  # @param include [String] A comma separated list of additional data to retrieve.
103
103
  # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
104
104
  # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
@@ -127,7 +127,7 @@ module AvaTax
127
127
  #
128
128
  # * This API requires one of the following user roles: AccountAdmin, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, Compliance Root User, ComplianceAdmin, ComplianceUser, CSPAdmin, CSPTester, ECMAccountUser, ECMCompanyUser, FirmAdmin, FirmUser, ProStoresOperator, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser.
129
129
  # Swagger Name: AvaTaxClient
130
- # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).<br />*Not filterable:* modifiedDate, ModifiedUserId
130
+ # @param filter [String] A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/).
131
131
  # @param include [String] A comma separated list of additional data to retrieve.
132
132
  # @param top [Integer] If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records.
133
133
  # @param skip [Integer] If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets.
@@ -26,7 +26,7 @@ module AvaTax
26
26
  # * This API depends on the following active services:*Required* (all): AvaTaxPro, BasicReturns.
27
27
  # Swagger Name: AvaTaxClient
28
28
  # @param companyId [Integer]
29
- # @param udfType [String] Document or Line level UDF (See UserDefinedFieldType::* for a list of allowable values)
29
+ # @param udfType [String] Document, Line, or Detail level UDF (See UserDefinedFieldType::* for a list of allowable values)
30
30
  # @param allowDefaults [Boolean] If true this will add defaulted UDFs to the list that are not named yet
31
31
  # @return [FetchResult]
32
32
  def list_user_defined_fields_by_company_id(companyId, options={}) path = "/api/v2/companies/#{companyId}/userdefinedfields"
@@ -1,3 +1,3 @@
1
1
  module AvaTax
2
- VERSION = '26.8.3'.freeze unless defined?(::AvaTax::VERSION)
2
+ VERSION = '26.9.0'.freeze unless defined?(::AvaTax::VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatax
3
3
  version: !ruby/object:Gem::Version
4
- version: 26.8.3
4
+ version: 26.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Vorwaller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-24 00:00:00.000000000 Z
11
+ date: 2026-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,6 +136,7 @@ files:
136
136
  - lib/avatax/client/costcenter.rb
137
137
  - lib/avatax/client/currencyroundingrules.rb
138
138
  - lib/avatax/client/customers.rb
139
+ - lib/avatax/client/customrules.rb
139
140
  - lib/avatax/client/datasources.rb
140
141
  - lib/avatax/client/definitions.rb
141
142
  - lib/avatax/client/distancethresholds.rb