avatax 14.4.4 → 17.5.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +54 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +5 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +201 -191
  8. data/README.md +63 -61
  9. data/Rakefile +9 -0
  10. data/avatax.gemspec +39 -0
  11. data/example/avatax.rb +14 -0
  12. data/example/credentials.example.yaml +5 -0
  13. data/lib/avatax.rb +19 -13
  14. data/lib/avatax/api.rb +27 -0
  15. data/lib/avatax/client.rb +32 -0
  16. data/lib/avatax/client/accounts.rb +110 -0
  17. data/lib/avatax/client/addresses.rb +52 -0
  18. data/lib/avatax/client/batches.rb +117 -0
  19. data/lib/avatax/client/companies.rb +218 -0
  20. data/lib/avatax/client/contacts.rb +115 -0
  21. data/lib/avatax/client/definitions.rb +569 -0
  22. data/lib/avatax/client/filingcalendars.rb +313 -0
  23. data/lib/avatax/client/filings.rb +417 -0
  24. data/lib/avatax/client/free.rb +104 -0
  25. data/lib/avatax/client/fundingrequests.rb +53 -0
  26. data/lib/avatax/client/items.rb +111 -0
  27. data/lib/avatax/client/jurisdictionoverrides.rb +125 -0
  28. data/lib/avatax/client/locations.rb +158 -0
  29. data/lib/avatax/client/nexus.rb +157 -0
  30. data/lib/avatax/client/notices.rb +297 -0
  31. data/lib/avatax/client/onboarding.rb +23 -0
  32. data/lib/avatax/client/pointofsale.rb +24 -0
  33. data/lib/avatax/client/registrar.rb +216 -0
  34. data/lib/avatax/client/settings.rb +137 -0
  35. data/lib/avatax/client/subscriptions.rb +66 -0
  36. data/lib/avatax/client/taxcodes.rb +127 -0
  37. data/lib/avatax/client/taxrules.rb +127 -0
  38. data/lib/avatax/client/transactions.rb +473 -0
  39. data/lib/avatax/client/upcs.rb +112 -0
  40. data/lib/avatax/client/users.rb +112 -0
  41. data/lib/avatax/client/utilities.rb +52 -0
  42. data/lib/avatax/configuration.rb +53 -18
  43. data/lib/avatax/connection.rb +28 -0
  44. data/lib/avatax/request.rb +38 -0
  45. data/lib/avatax/version.rb +3 -0
  46. data/spec/avatax/client/accounts_spec.rb +26 -0
  47. data/spec/avatax_spec.rb +59 -0
  48. data/spec/fixtures/accounts.json +16 -0
  49. data/spec/spec_helper.rb +47 -0
  50. metadata +143 -30
  51. data/lib/avatax/address_service.rb +0 -31
  52. data/lib/avatax/tax_service.rb +0 -61
@@ -0,0 +1,127 @@
1
+ module AvaTax
2
+ class Client
3
+ module TaxCodes
4
+
5
+
6
+ # Create a new tax code
7
+ #
8
+ # Create one or more new taxcode objects attached to this company.
9
+ # A 'TaxCode' represents a uniquely identified type of product, good, or service.
10
+ # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
11
+ # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
12
+ # taxability rules for this product in all supported jurisdictions.
13
+ #
14
+ # @param int companyId The ID of the company that owns this tax code.
15
+ # @param TaxCodeModel[] model The tax code you wish to create.
16
+ # @return TaxCodeModel[]
17
+ def create_tax_codes(companyId, model)
18
+ path = "/api/v2/companies/#{companyId}/taxcodes"
19
+
20
+ post(path, model)
21
+ end
22
+
23
+
24
+ # Delete a single tax code
25
+ #
26
+ # Marks the existing TaxCode object at this URL as deleted.
27
+ #
28
+ # @param int companyId The ID of the company that owns this tax code.
29
+ # @param int id The ID of the tax code you wish to delete.
30
+ # @return ErrorDetail[]
31
+ def delete_tax_code(companyId, id)
32
+ path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
33
+
34
+ delete(path)
35
+ end
36
+
37
+
38
+ # Retrieve a single tax code
39
+ #
40
+ # Get the taxcode object identified by this URL.
41
+ # A 'TaxCode' represents a uniquely identified type of product, good, or service.
42
+ # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
43
+ # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
44
+ # taxability rules for this product in all supported jurisdictions.
45
+ #
46
+ # @param int companyId The ID of the company that owns this tax code
47
+ # @param int id The primary key of this tax code
48
+ # @return TaxCodeModel
49
+ def get_tax_code(companyId, id)
50
+ path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
51
+
52
+ get(path)
53
+ end
54
+
55
+
56
+ # Retrieve tax codes for this company
57
+ #
58
+ # List all taxcode objects attached to this company.
59
+ # A 'TaxCode' represents a uniquely identified type of product, good, or service.
60
+ # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
61
+ # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
62
+ # taxability rules for this product in all supported jurisdictions.
63
+ #
64
+ # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
65
+ # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
66
+ #
67
+ # @param int companyId The ID of the company that owns these tax codes
68
+ # @param string filter 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/) .
69
+ # @param string include A comma separated list of child objects to return underneath the primary object.
70
+ # @param int top If nonzero, return no more than this number of results. Used with $skip to provide pagination for large datasets.
71
+ # @param int skip If nonzero, skip this number of results before returning data. Used with $top to provide pagination for large datasets.
72
+ # @param string orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
73
+ # @return FetchResult
74
+ def list_tax_codes_by_company(companyId, options={})
75
+ path = "/api/v2/companies/#{companyId}/taxcodes"
76
+
77
+ get(path, options)
78
+ end
79
+
80
+
81
+ # Retrieve all tax codes
82
+ #
83
+ # Get multiple taxcode objects across all companies.
84
+ # A 'TaxCode' represents a uniquely identified type of product, good, or service.
85
+ # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
86
+ # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
87
+ # taxability rules for this product in all supported jurisdictions.
88
+ #
89
+ # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
90
+ # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
91
+ #
92
+ # @param string filter 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/) .
93
+ # @param string include A comma separated list of child objects to return underneath the primary object.
94
+ # @param int top If nonzero, return no more than this number of results. Used with $skip to provide pagination for large datasets.
95
+ # @param int skip If nonzero, skip this number of results before returning data. Used with $top to provide pagination for large datasets.
96
+ # @param string orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
97
+ # @return FetchResult
98
+ def query_tax_codes(options={})
99
+ path = "/api/v2/taxcodes"
100
+
101
+ get(path, options)
102
+ end
103
+
104
+
105
+ # Update a single tax code
106
+ #
107
+ # Replace the existing taxcode object at this URL with an updated object.
108
+ # A 'TaxCode' represents a uniquely identified type of product, good, or service.
109
+ # Avalara supports correct tax rates and taxability rules for all TaxCodes in all supported jurisdictions.
110
+ # If you identify your products by tax code in your 'Create Transacion' API calls, Avalara will correctly calculate tax rates and
111
+ # taxability rules for this product in all supported jurisdictions.
112
+ # All data from the existing object will be replaced with data in the object you PUT.
113
+ # To set a field's value to null, you may either set its value to null or omit that field from the object you post.
114
+ #
115
+ # @param int companyId The ID of the company that this tax code belongs to.
116
+ # @param int id The ID of the tax code you wish to update
117
+ # @param TaxCodeModel model The tax code you wish to update.
118
+ # @return TaxCodeModel
119
+ def update_tax_code(companyId, id, model)
120
+ path = "/api/v2/companies/#{companyId}/taxcodes/#{id}"
121
+
122
+ put(path, model)
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,127 @@
1
+ module AvaTax
2
+ class Client
3
+ module TaxRules
4
+
5
+
6
+ # Create a new tax rule
7
+ #
8
+ # Create one or more new taxrule objects attached to this company.
9
+ # A tax rule represents a custom taxability rule for a product or service sold by your company.
10
+ # If you have obtained a custom tax ruling from an auditor that changes the behavior of certain goods or services
11
+ # within certain taxing jurisdictions, or you have obtained special tax concessions for certain dates or locations,
12
+ # you may wish to create a TaxRule object to override the AvaTax engine's default behavior in those circumstances.
13
+ #
14
+ # @param int companyId The ID of the company that owns this tax rule.
15
+ # @param TaxRuleModel[] model The tax rule you wish to create.
16
+ # @return TaxRuleModel[]
17
+ def create_tax_rules(companyId, model)
18
+ path = "/api/v2/companies/#{companyId}/taxrules"
19
+
20
+ post(path, model)
21
+ end
22
+
23
+
24
+ # Delete a single tax rule
25
+ #
26
+ # Mark the TaxRule identified by this URL as deleted.
27
+ #
28
+ # @param int companyId The ID of the company that owns this tax rule.
29
+ # @param int id The ID of the tax rule you wish to delete.
30
+ # @return ErrorDetail[]
31
+ def delete_tax_rule(companyId, id)
32
+ path = "/api/v2/companies/#{companyId}/taxrules/#{id}"
33
+
34
+ delete(path)
35
+ end
36
+
37
+
38
+ # Retrieve a single tax rule
39
+ #
40
+ # Get the taxrule object identified by this URL.
41
+ # A tax rule represents a custom taxability rule for a product or service sold by your company.
42
+ # If you have obtained a custom tax ruling from an auditor that changes the behavior of certain goods or services
43
+ # within certain taxing jurisdictions, or you have obtained special tax concessions for certain dates or locations,
44
+ # you may wish to create a TaxRule object to override the AvaTax engine's default behavior in those circumstances.
45
+ #
46
+ # @param int companyId The ID of the company that owns this tax rule
47
+ # @param int id The primary key of this tax rule
48
+ # @return TaxRuleModel
49
+ def get_tax_rule(companyId, id)
50
+ path = "/api/v2/companies/#{companyId}/taxrules/#{id}"
51
+
52
+ get(path)
53
+ end
54
+
55
+
56
+ # Retrieve tax rules for this company
57
+ #
58
+ # List all taxrule objects attached to this company.
59
+ # A tax rule represents a custom taxability rule for a product or service sold by your company.
60
+ # If you have obtained a custom tax ruling from an auditor that changes the behavior of certain goods or services
61
+ # within certain taxing jurisdictions, or you have obtained special tax concessions for certain dates or locations,
62
+ # you may wish to create a TaxRule object to override the AvaTax engine's default behavior in those circumstances.
63
+ #
64
+ # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
65
+ # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
66
+ #
67
+ # @param int companyId The ID of the company that owns these tax rules
68
+ # @param string filter 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/) .
69
+ # @param string include A comma separated list of child objects to return underneath the primary object.
70
+ # @param int top If nonzero, return no more than this number of results. Used with $skip to provide pagination for large datasets.
71
+ # @param int skip If nonzero, skip this number of results before returning data. Used with $top to provide pagination for large datasets.
72
+ # @param string orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
73
+ # @return FetchResult
74
+ def list_tax_rules(companyId, options={})
75
+ path = "/api/v2/companies/#{companyId}/taxrules"
76
+
77
+ get(path, options)
78
+ end
79
+
80
+
81
+ # Retrieve all tax rules
82
+ #
83
+ # Get multiple taxrule objects across all companies.
84
+ # A tax rule represents a custom taxability rule for a product or service sold by your company.
85
+ # If you have obtained a custom tax ruling from an auditor that changes the behavior of certain goods or services
86
+ # within certain taxing jurisdictions, or you have obtained special tax concessions for certain dates or locations,
87
+ # you may wish to create a TaxRule object to override the AvaTax engine's default behavior in those circumstances.
88
+ #
89
+ # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
90
+ # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
91
+ #
92
+ # @param string filter 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/) .
93
+ # @param string include A comma separated list of child objects to return underneath the primary object.
94
+ # @param int top If nonzero, return no more than this number of results. Used with $skip to provide pagination for large datasets.
95
+ # @param int skip If nonzero, skip this number of results before returning data. Used with $top to provide pagination for large datasets.
96
+ # @param string orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
97
+ # @return FetchResult
98
+ def query_tax_rules(options={})
99
+ path = "/api/v2/taxrules"
100
+
101
+ get(path, options)
102
+ end
103
+
104
+
105
+ # Update a single tax rule
106
+ #
107
+ # Replace the existing taxrule object at this URL with an updated object.
108
+ # A tax rule represents a custom taxability rule for a product or service sold by your company.
109
+ # If you have obtained a custom tax ruling from an auditor that changes the behavior of certain goods or services
110
+ # within certain taxing jurisdictions, or you have obtained special tax concessions for certain dates or locations,
111
+ # you may wish to create a TaxRule object to override the AvaTax engine's default behavior in those circumstances.
112
+ # All data from the existing object will be replaced with data in the object you PUT.
113
+ # To set a field's value to null, you may either set its value to null or omit that field from the object you post.
114
+ #
115
+ # @param int companyId The ID of the company that this tax rule belongs to.
116
+ # @param int id The ID of the tax rule you wish to update
117
+ # @param TaxRuleModel model The tax rule you wish to update.
118
+ # @return TaxRuleModel
119
+ def update_tax_rule(companyId, id, model)
120
+ path = "/api/v2/companies/#{companyId}/taxrules/#{id}"
121
+
122
+ put(path, model)
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,473 @@
1
+ module AvaTax
2
+ class Client
3
+ module Transactions
4
+
5
+
6
+ # Add lines to an existing unlocked transaction
7
+ #
8
+ # Add lines to an existing unlocked transaction.
9
+ #
10
+ # The `AddLines` API allows you to add additional transaction lines to existing transaction, so that customer will
11
+ # be able to append multiple calls together and form an extremely large transaction. If customer does not specify line number
12
+ # in the lines to be added, a new random Guid string will be generated for line number. If customer are not satisfied with
13
+ # the line number for the transaction lines, they can turn on the renumber switch to have REST v2 automatically renumber all
14
+ # transaction lines for them, in this case, the line number becomes: "1", "2", "3", ...
15
+ #
16
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
17
+ # sales, purchases, inventory transfer, and returns (also called refunds).
18
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
19
+ #
20
+ # * Lines
21
+ # * Details (implies lines)
22
+ # * Summary (implies details)
23
+ # * Addresses
24
+ #
25
+ # If you don't specify '$include' parameter, it will include both details and addresses.
26
+ #
27
+ # @param string include A comma separated list of child objects to return underneath the primary object.
28
+ # @param AddTransactionLineModel model information about the transaction and lines to be added
29
+ # @return TransactionModel
30
+ def add_lines(model, options={})
31
+ path = "/api/v2/companies/transactions/lines/add"
32
+
33
+ post(path, model, options)
34
+ end
35
+
36
+
37
+ # Correct a previously created transaction
38
+ #
39
+ # Replaces the current transaction uniquely identified by this URL with a new transaction.
40
+ #
41
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
42
+ # sales, purchases, inventory transfer, and returns (also called refunds).
43
+ #
44
+ # When you adjust a committed transaction, the original transaction will be updated with the status code `Adjusted`, and
45
+ # both revisions will be available for retrieval based on their code and ID numbers.
46
+ # Only transactions in `Committed` status are reported by Avalara Managed Returns.
47
+ #
48
+ # Transactions that have been previously reported to a tax authority by Avalara Managed Returns are considered `locked` and are
49
+ # no longer available for adjustments.
50
+ #
51
+ # @param string companyCode The company code of the company that recorded this transaction
52
+ # @param string transactionCode The transaction code to adjust
53
+ # @param AdjustTransactionModel model The adjustment you wish to make
54
+ # @return TransactionModel
55
+ def adjust_transaction(companyCode, transactionCode, model)
56
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/adjust"
57
+
58
+ post(path, model)
59
+ end
60
+
61
+
62
+ # Get audit information about a transaction
63
+ #
64
+ # Retrieve audit information about a transaction stored in AvaTax.
65
+ #
66
+ # The 'AuditTransaction' endpoint retrieves audit information related to a specific transaction. This audit
67
+ # information includes the following:
68
+ #
69
+ # * The `CompanyId` of the company that created the transaction
70
+ # * The server timestamp representing the exact server time when the transaction was created
71
+ # * The server duration - how long it took to process this transaction
72
+ # * Whether exact API call details were logged
73
+ # * A reconstructed API call showing what the original CreateTransaction call looked like
74
+ #
75
+ # This API can be used to examine information about a previously created transaction.
76
+ #
77
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
78
+ # sales, purchases, inventory transfer, and returns (also called refunds).
79
+ #
80
+ # @param string companyCode The code identifying the company that owns this transaction
81
+ # @param string transactionCode The code identifying the transaction
82
+ # @return AuditTransactionModel
83
+ def audit_transaction(companyCode, transactionCode)
84
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/audit"
85
+
86
+ get(path)
87
+ end
88
+
89
+
90
+ # Get audit information about a transaction
91
+ #
92
+ # Retrieve audit information about a transaction stored in AvaTax.
93
+ #
94
+ # The 'AuditTransaction' endpoint retrieves audit information related to a specific transaction. This audit
95
+ # information includes the following:
96
+ #
97
+ # * The `CompanyId` of the company that created the transaction
98
+ # * The server timestamp representing the exact server time when the transaction was created
99
+ # * The server duration - how long it took to process this transaction
100
+ # * Whether exact API call details were logged
101
+ # * A reconstructed API call showing what the original CreateTransaction call looked like
102
+ #
103
+ # This API can be used to examine information about a previously created transaction.
104
+ #
105
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
106
+ # sales, purchases, inventory transfer, and returns (also called refunds).
107
+ #
108
+ # @param string companyCode The code identifying the company that owns this transaction
109
+ # @param string transactionCode The code identifying the transaction
110
+ # @param string documentType The document type of the original transaction (See DocumentType::* for a list of allowable values)
111
+ # @return AuditTransactionModel
112
+ def audit_transaction_with_type(companyCode, transactionCode, documentType)
113
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/types/#{documentType}/audit"
114
+
115
+ get(path)
116
+ end
117
+
118
+
119
+ # Lock a set of documents
120
+ #
121
+ # This API is available by invitation only.
122
+ #
123
+ # Lock a set of transactions uniquely identified by DocumentIds provided. This API allows locking multiple documents at once.
124
+ # After this API call succeeds, documents will be locked and can't be voided.
125
+ #
126
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
127
+ # sales, purchases, inventory transfer, and returns (also called refunds).
128
+ #
129
+ # @param BulkLockTransactionModel model bulk lock request
130
+ # @return BulkLockTransactionResult
131
+ def bulk_lock_transaction(model)
132
+ path = "/api/v2/transactions/lock"
133
+
134
+ post(path, model)
135
+ end
136
+
137
+
138
+ # Change a transaction's code
139
+ #
140
+ # Renames a transaction uniquely identified by this URL by changing its code to a new code.
141
+ # After this API call succeeds, the transaction will have a new URL matching its new code.
142
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
143
+ # sales, purchases, inventory transfer, and returns (also called refunds).
144
+ #
145
+ # @param string companyCode The company code of the company that recorded this transaction
146
+ # @param string transactionCode The transaction code to change
147
+ # @param ChangeTransactionCodeModel model The code change request you wish to execute
148
+ # @return TransactionModel
149
+ def change_transaction_code(companyCode, transactionCode, model)
150
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/changecode"
151
+
152
+ post(path, model)
153
+ end
154
+
155
+
156
+ # Commit a transaction for reporting
157
+ #
158
+ # Marks a transaction by changing its status to 'Committed'.
159
+ # Transactions that are committed are available to be reported to a tax authority by Avalara Managed Returns.
160
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
161
+ # sales, purchases, inventory transfer, and returns (also called refunds).
162
+ # Any changes made to a committed transaction will generate a transaction history.
163
+ #
164
+ # @param string companyCode The company code of the company that recorded this transaction
165
+ # @param string transactionCode The transaction code to commit
166
+ # @param CommitTransactionModel model The commit request you wish to execute
167
+ # @return TransactionModel
168
+ def commit_transaction(companyCode, transactionCode, model)
169
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/commit"
170
+
171
+ post(path, model)
172
+ end
173
+
174
+
175
+ # Create a new transaction
176
+ #
177
+ # Records a new transaction or adjust an existing in AvaTax.
178
+ #
179
+ # The `CreateOrAdjustTransaction` endpoint is used to create a new transaction if the input transaction does not exist
180
+ # or if there exists a transaction identified by code, the original transaction will be adjusted by using the meta data
181
+ # in the input transaction
182
+ #
183
+ # If you don't specify type in the provided data, a new transaction with type of SalesOrder will be recorded by default.
184
+ #
185
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
186
+ # sales, purchases, inventory transfer, and returns (also called refunds).
187
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
188
+ #
189
+ # * Lines
190
+ # * Details (implies lines)
191
+ # * Summary (implies details)
192
+ # * Addresses
193
+ #
194
+ # If you don't specify '$include' parameter, it will include both details and addresses.
195
+ #
196
+ # @param string include A comma separated list of child objects to return underneath the primary object.
197
+ # @param CreateOrAdjustTransactionModel model The transaction you wish to create
198
+ # @return TransactionModel
199
+ def create_or_adjust_transaction(model, options={})
200
+ path = "/api/v2/transactions/createoradjust"
201
+
202
+ post(path, model, options)
203
+ end
204
+
205
+
206
+ # Create a new transaction
207
+ #
208
+ # Records a new transaction in AvaTax.
209
+ #
210
+ # The `CreateTransaction` endpoint uses the configuration values specified by your company to identify the correct tax rules
211
+ # and rates to apply to all line items in this transaction, and reports the total tax calculated by AvaTax based on your
212
+ # company's configuration and the data provided in this API call.
213
+ #
214
+ # If you don't specify type in the provided data, a new transaction with type of SalesOrder will be recorded by default.
215
+ #
216
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
217
+ # sales, purchases, inventory transfer, and returns (also called refunds).
218
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
219
+ #
220
+ # * Lines
221
+ # * Details (implies lines)
222
+ # * Summary (implies details)
223
+ # * Addresses
224
+ #
225
+ # If you don't specify '$include' parameter, it will include both details and addresses.
226
+ #
227
+ # @param string include A comma separated list of child objects to return underneath the primary object.
228
+ # @param CreateTransactionModel model The transaction you wish to create
229
+ # @return TransactionModel
230
+ def create_transaction(model, options={})
231
+ path = "/api/v2/transactions/create"
232
+
233
+ post(path, model, options)
234
+ end
235
+
236
+
237
+ # Remove lines from an existing unlocked transaction
238
+ #
239
+ # Remove lines to an existing unlocked transaction.
240
+ #
241
+ # The `DeleteLines` API allows you to remove transaction lines from existing unlocked transaction, so that customer will
242
+ # be able to delete transaction lines and adjust original transaction the way they like
243
+ #
244
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
245
+ # sales, purchases, inventory transfer, and returns (also called refunds).
246
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
247
+ #
248
+ # * Lines
249
+ # * Details (implies lines)
250
+ # * Summary (implies details)
251
+ # * Addresses
252
+ #
253
+ # If you don't specify '$include' parameter, it will include both details and addresses.
254
+ #
255
+ # @param string include A comma separated list of child objects to return underneath the primary object.
256
+ # @param RemoveTransactionLineModel model information about the transaction and lines to be removed
257
+ # @return TransactionModel
258
+ def delete_lines(model, options={})
259
+ path = "/api/v2/companies/transactions/lines/delete"
260
+
261
+ post(path, model, options)
262
+ end
263
+
264
+
265
+ # Retrieve a single transaction by code
266
+ #
267
+ # Get the current transaction identified by this URL.
268
+ # If this transaction was adjusted, the return value of this API will be the current transaction with this code, and previous revisions of
269
+ # the transaction will be attached to the 'history' data field.
270
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
271
+ #
272
+ # * Lines
273
+ # * Details (implies lines)
274
+ # * Summary (implies details)
275
+ # * Addresses
276
+ #
277
+ # @param string companyCode The company code of the company that recorded this transaction
278
+ # @param string transactionCode The transaction code to retrieve
279
+ # @param string include A comma separated list of child objects to return underneath the primary object.
280
+ # @return TransactionModel
281
+ def get_transaction_by_code(companyCode, transactionCode, options={})
282
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}"
283
+
284
+ get(path, options)
285
+ end
286
+
287
+
288
+ # Retrieve a single transaction by code
289
+ #
290
+ # Get the current transaction identified by this URL.
291
+ # If this transaction was adjusted, the return value of this API will be the current transaction with this code, and previous revisions of
292
+ # the transaction will be attached to the 'history' data field.
293
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
294
+ #
295
+ # * Lines
296
+ # * Details (implies lines)
297
+ # * Summary (implies details)
298
+ # * Addresses
299
+ #
300
+ # @param string companyCode The company code of the company that recorded this transaction
301
+ # @param string transactionCode The transaction code to retrieve
302
+ # @param string documentType The transaction type to retrieve (See DocumentType::* for a list of allowable values)
303
+ # @param string include A comma separated list of child objects to return underneath the primary object.
304
+ # @return TransactionModel
305
+ def get_transaction_by_code_and_type(companyCode, transactionCode, documentType, options={})
306
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/types/#{documentType}"
307
+
308
+ get(path, options)
309
+ end
310
+
311
+
312
+ # Retrieve a single transaction by ID
313
+ #
314
+ # Get the unique transaction identified by this URL.
315
+ # This endpoint retrieves the exact transaction identified by this ID number even if that transaction was later adjusted
316
+ # by using the 'Adjust Transaction' endpoint.
317
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
318
+ # sales, purchases, inventory transfer, and returns (also called refunds).
319
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
320
+ #
321
+ # * Lines
322
+ # * Details (implies lines)
323
+ # * Summary (implies details)
324
+ # * Addresses
325
+ #
326
+ # @param int id The unique ID number of the transaction to retrieve
327
+ # @param string include A comma separated list of child objects to return underneath the primary object.
328
+ # @return TransactionModel
329
+ def get_transaction_by_id(id, options={})
330
+ path = "/api/v2/transactions/#{id}"
331
+
332
+ get(path, options)
333
+ end
334
+
335
+
336
+ # Retrieve all transactions
337
+ #
338
+ # List all transactions attached to this company.
339
+ # This endpoint is limited to returning 1,000 transactions at a time maximum.
340
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
341
+ # sales, purchases, inventory transfer, and returns (also called refunds).
342
+ #
343
+ # Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) .
344
+ # Paginate your results using the `$top`, `$skip`, and `$orderby` parameters.
345
+ # You may specify one or more of the following values in the `$include` parameter to fetch additional nested data, using commas to separate multiple values:
346
+ #
347
+ # * Lines
348
+ # * Details (implies lines)
349
+ # * Summary (implies details)
350
+ # * Addresses
351
+ #
352
+ # @param string companyCode The company code of the company that recorded this transaction
353
+ # @param string include A comma separated list of child objects to return underneath the primary object.
354
+ # @param string filter 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/) .
355
+ # @param int top If nonzero, return no more than this number of results. Used with $skip to provide pagination for large datasets.
356
+ # @param int skip If nonzero, skip this number of results before returning data. Used with $top to provide pagination for large datasets.
357
+ # @param string orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`.
358
+ # @return FetchResult
359
+ def list_transactions_by_company(companyCode, options={})
360
+ path = "/api/v2/companies/#{companyCode}/transactions"
361
+
362
+ get(path, options)
363
+ end
364
+
365
+
366
+ # Lock a single transaction
367
+ #
368
+ # Lock a transaction uniquely identified by this URL.
369
+ #
370
+ # This API is mainly used for connector developer to simulate what happens when Returns product locks a document.
371
+ # After this API call succeeds, the document will be locked and can't be voided or adjusted.
372
+ #
373
+ # This API is only available to customers in Sandbox with AvaTaxPro subscription. On production servers, this API is available by invitation only.
374
+ #
375
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
376
+ # sales, purchases, inventory transfer, and returns (also called refunds).
377
+ #
378
+ # @param string companyCode The company code of the company that recorded this transaction
379
+ # @param string transactionCode The transaction code to lock
380
+ # @param LockTransactionModel model The lock request you wish to execute
381
+ # @return TransactionModel
382
+ def lock_transaction(companyCode, transactionCode, model)
383
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/lock"
384
+
385
+ post(path, model)
386
+ end
387
+
388
+
389
+ # Create a refund for a transaction
390
+ #
391
+ # Create a refund for a transaction.
392
+ #
393
+ # The `RefundTransaction` API allows you to quickly and easily create a `ReturnInvoice` representing a refund
394
+ # for a previously created `SalesInvoice` transaction. You can choose to create a full or partial refund, and
395
+ # specify individual line items from the original sale for refund.
396
+ #
397
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
398
+ # sales, purchases, inventory transfer, and returns (also called refunds).
399
+ # You may specify one or more of the following values in the '$include' parameter to fetch additional nested data, using commas to separate multiple values:
400
+ #
401
+ # * Lines
402
+ # * Details (implies lines)
403
+ # * Summary (implies details)
404
+ # * Addresses
405
+ #
406
+ # If you don't specify '$include' parameter, it will include both details and addresses.
407
+ #
408
+ # @param string companyCode The code of the company that made the original sale
409
+ # @param string transactionCode The transaction code of the original sale
410
+ # @param string include A comma separated list of child objects to return underneath the primary object.
411
+ # @param RefundTransactionModel model Information about the refund to create
412
+ # @return TransactionModel
413
+ def refund_transaction(companyCode, transactionCode, model, options={})
414
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/refund"
415
+
416
+ post(path, model, options)
417
+ end
418
+
419
+
420
+ # Perform multiple actions on a transaction
421
+ #
422
+ # Performs the same functions as /verify, /changecode, and /commit. You may specify one or many actions in each call to this endpoint.
423
+ #
424
+ # @param string companyCode The company code of the company that recorded this transaction
425
+ # @param string transactionCode The transaction code to settle
426
+ # @param SettleTransactionModel model The settle request containing the actions you wish to execute
427
+ # @return TransactionModel
428
+ def settle_transaction(companyCode, transactionCode, model)
429
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/settle"
430
+
431
+ post(path, model)
432
+ end
433
+
434
+
435
+ # Verify a transaction
436
+ #
437
+ # Verifies that the transaction uniquely identified by this URL matches certain expected values.
438
+ # If the transaction does not match these expected values, this API will return an error code indicating which value did not match.
439
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
440
+ # sales, purchases, inventory transfer, and returns (also called refunds).
441
+ #
442
+ # @param string companyCode The company code of the company that recorded this transaction
443
+ # @param string transactionCode The transaction code to settle
444
+ # @param VerifyTransactionModel model The settle request you wish to execute
445
+ # @return TransactionModel
446
+ def verify_transaction(companyCode, transactionCode, model)
447
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/verify"
448
+
449
+ post(path, model)
450
+ end
451
+
452
+
453
+ # Void a transaction
454
+ #
455
+ # Voids the current transaction uniquely identified by this URL.
456
+ # A transaction represents a unique potentially taxable action that your company has recorded, and transactions include actions like
457
+ # sales, purchases, inventory transfer, and returns (also called refunds).
458
+ # When you void a transaction, that transaction's status is recorded as 'DocVoided'.
459
+ # Transactions that have been previously reported to a tax authority by Avalara Managed Returns are no longer available to be voided.
460
+ #
461
+ # @param string companyCode The company code of the company that recorded this transaction
462
+ # @param string transactionCode The transaction code to void
463
+ # @param VoidTransactionModel model The void request you wish to execute
464
+ # @return TransactionModel
465
+ def void_transaction(companyCode, transactionCode, model)
466
+ path = "/api/v2/companies/#{companyCode}/transactions/#{transactionCode}/void"
467
+
468
+ post(path, model)
469
+ end
470
+
471
+ end
472
+ end
473
+ end