vertex_client 0.6.1
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 +7 -0
- data/.env +2 -0
- data/.gitignore +12 -0
- data/.travis.yml +24 -0
- data/Brewfile +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +195 -0
- data/Rakefile +11 -0
- data/bin/bootstrap +23 -0
- data/bin/console +15 -0
- data/bin/setup +11 -0
- data/bin/test +12 -0
- data/bin/update +4 -0
- data/lib/generators/install/install_generator.rb +12 -0
- data/lib/generators/install/templates/initializer.rb.erb +27 -0
- data/lib/vertex_client.rb +89 -0
- data/lib/vertex_client/configuration.rb +35 -0
- data/lib/vertex_client/connection.rb +58 -0
- data/lib/vertex_client/payloads/base.rb +44 -0
- data/lib/vertex_client/payloads/distribute_tax.rb +20 -0
- data/lib/vertex_client/payloads/invoice.rb +29 -0
- data/lib/vertex_client/payloads/quotation.rb +69 -0
- data/lib/vertex_client/payloads/quotation_fallback.rb +14 -0
- data/lib/vertex_client/payloads/tax_area.rb +22 -0
- data/lib/vertex_client/railtie.rb +7 -0
- data/lib/vertex_client/rates.rb +55 -0
- data/lib/vertex_client/resources/base.rb +41 -0
- data/lib/vertex_client/resources/distribute_tax.rb +6 -0
- data/lib/vertex_client/resources/invoice.rb +12 -0
- data/lib/vertex_client/resources/quotation.rb +12 -0
- data/lib/vertex_client/resources/tax_area.rb +10 -0
- data/lib/vertex_client/responses/base.rb +17 -0
- data/lib/vertex_client/responses/distribute_tax.rb +17 -0
- data/lib/vertex_client/responses/invoice.rb +6 -0
- data/lib/vertex_client/responses/line_item.rb +15 -0
- data/lib/vertex_client/responses/quotation.rb +39 -0
- data/lib/vertex_client/responses/quotation_fallback.rb +42 -0
- data/lib/vertex_client/responses/tax_area.rb +9 -0
- data/lib/vertex_client/responses/tax_area_fallback.rb +9 -0
- data/lib/vertex_client/utils/adjustment_allocator.rb +61 -0
- data/lib/vertex_client/version.rb +3 -0
- data/vertex_client.gemspec +54 -0
- metadata +288 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11ed8d014744d39407ca7e188da269f509f4f24daa20860fe18811f589909f64
|
4
|
+
data.tar.gz: 20daf898b1aadeb787068d7d313145df258720b8168dde5772f5c9be63b2f86b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6732453d5d31302dfad3e8a67c2911d55e28f44a8f5b675eccb8634576f2fa649dcf54fccf5c41113618e0e8832016d53cc9c03ee491a7c8d0cc639ed2f38bc
|
7
|
+
data.tar.gz: 75eb538e6aa4d3587ce7d19976fd0fbc7d8f1652e46aff650fe529aec196a62ccf2296b575e0d927efc8af97a239cb63ac849aec1796504139405314b2f3d49f
|
data/.env
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- 2.1.10
|
7
|
+
- 2.2.4
|
8
|
+
- 2.4.1
|
9
|
+
- 2.5.3
|
10
|
+
if: branch = master OR type = pull_request
|
11
|
+
env:
|
12
|
+
global:
|
13
|
+
- CC_TEST_REPORTER_ID=88a7fd75659a6698f28c8c4c6b60c20f902e26733691b2fe449a65474f22b618
|
14
|
+
- CI=true
|
15
|
+
before_install:
|
16
|
+
- bin/setup
|
17
|
+
before_script:
|
18
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
19
|
+
- chmod +x ./cc-test-reporter
|
20
|
+
- ./cc-test-reporter before-build
|
21
|
+
script:
|
22
|
+
- bin/test
|
23
|
+
after_success:
|
24
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Brewfile
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at amaas@customink.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Custom Ink
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
# VertexClient
|
2
|
+
|
3
|
+
[](https://travis-ci.org/customink/vertex_client) [](https://codeclimate.com/github/customink/vertex_client/maintainability) [](https://codeclimate.com/github/customink/vertex_client/test_coverage)
|
4
|
+
|
5
|
+
The Vertex Client Ruby Gem provides an interface to integrate with _Vertex SMB_ which is also known as [Vertex Cloud Indirect Tax](https://www.vertexinc.com/solutions/products/vertex-cloud-indirect-tax).
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Quotation
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
response = VertexClient.quotation(
|
13
|
+
# The top level transaction date for all line items.
|
14
|
+
date: '2018-11-15',
|
15
|
+
# The top level customer for all line items.
|
16
|
+
customer: {
|
17
|
+
code: "inky@customink.com",
|
18
|
+
address_1: "11 Wall Street",
|
19
|
+
address_2: "#300",
|
20
|
+
city: "New York",
|
21
|
+
state: "NY",
|
22
|
+
postal_code: '10005',
|
23
|
+
# Optional tax_exempt status for customer
|
24
|
+
is_tax_exempt: true
|
25
|
+
|
26
|
+
# Optional tax_area_id for customer location
|
27
|
+
tax_area_id: '330612010'
|
28
|
+
},
|
29
|
+
# The top level seller for all line items.
|
30
|
+
seller: {
|
31
|
+
company: "CustomInk"
|
32
|
+
},
|
33
|
+
line_items: [
|
34
|
+
{
|
35
|
+
# Internal product ID or code
|
36
|
+
product_code: "4600",
|
37
|
+
# Mapped product class, or "commodity code", in Vertex Cloud
|
38
|
+
product_class: "123456"
|
39
|
+
quantity: 7,
|
40
|
+
# Total price of this line item
|
41
|
+
price: "35.50",
|
42
|
+
},
|
43
|
+
{
|
44
|
+
product_code: "5200",
|
45
|
+
product_class: "123456"
|
46
|
+
quantity: 4,
|
47
|
+
price: "25.40",
|
48
|
+
# Optional transaction date override for a line item.
|
49
|
+
date: '2018-11-14',
|
50
|
+
# Optional seller override for a line item.
|
51
|
+
seller: {
|
52
|
+
company: "CustomInkStores"
|
53
|
+
},
|
54
|
+
# Optional customer override for a line item.
|
55
|
+
customer: {
|
56
|
+
code: "prez@customink.com",
|
57
|
+
address_1: "1600 Pennsylvania Ave NW",
|
58
|
+
city: "Washington",
|
59
|
+
state: "DC",
|
60
|
+
postal_code: '20500'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
]
|
64
|
+
)
|
65
|
+
|
66
|
+
response.total_tax #=> Total tax amount
|
67
|
+
response.total #=> Total price plus total tax
|
68
|
+
response.subtotal #=> Total price before tax
|
69
|
+
```
|
70
|
+
|
71
|
+
### Invoice
|
72
|
+
|
73
|
+
Invoice is the same payload as quotation, but with one added identifier.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
VertexClient.invoice(
|
77
|
+
# Vertex's Document Number is a unique referencial identifier for this invoice.
|
78
|
+
document_number: "unique-identifier-1a43b",
|
79
|
+
|
80
|
+
# ... All of the of the payload from quotation here ...
|
81
|
+
)
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
### Distribute Tax
|
86
|
+
|
87
|
+
Distribute Tax is the same payload as Invoice, but you pass `total_tax` on each line item. The `product_code` and `quantity` are optional.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
VertexClient.distribute_tax(
|
91
|
+
|
92
|
+
# ...
|
93
|
+
|
94
|
+
line_items: [
|
95
|
+
{
|
96
|
+
price: "100.00",
|
97
|
+
total_tax: "6.00",
|
98
|
+
}
|
99
|
+
]
|
100
|
+
|
101
|
+
)
|
102
|
+
```
|
103
|
+
|
104
|
+
### Tax Area
|
105
|
+
Look up the internal Vertex location identifier for a given address. Including `tax_area_id` as part of the customer information in calls to `invoice` and `quotation` should improve performance, especially in situations where there are many destination addresses.
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
response = VertexClient.tax_area(
|
109
|
+
address_1: "11 Wall Street",
|
110
|
+
address_2: "#300",
|
111
|
+
city: "New York",
|
112
|
+
state: "NY",
|
113
|
+
postal_code: '10005'
|
114
|
+
)
|
115
|
+
response.tax_area_id # => '330612010'
|
116
|
+
```
|
117
|
+
|
118
|
+
### Adjustment Allocator
|
119
|
+
|
120
|
+
Allocates a given monetary adjustment, such as a service charge or a discount, across a given array of weights, such as line items. The `adjustment` parameter must be passed in as a positive or negative numeric dollar amount, such as `-0.56`, `7.00` or `12.34`, and the `weights` parameter must be passed in as an array of non-negative numeric values, such as `[1.23, 4.56, 7.89]` or `[1, 2, 3, 4]`, which can represent prices or ratios.
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
VertexClient::Utils::AdjustmentAllocator.new(1234.56, [310.00, 350.00, 200.00, 140.00]).allocate
|
124
|
+
#=> [#<BigDecimal:7fa6bba053c0,'0.38271E3',18(36)>,
|
125
|
+
#<BigDecimal:7fa6bba0fcd0,'0.4321E3',18(36)>,
|
126
|
+
#<BigDecimal:7fa6bba0dfc0,'0.24691E3',18(36)>,
|
127
|
+
#<BigDecimal:7fa6bba17b88,'0.17284E3',18(36)>]
|
128
|
+
```
|
129
|
+
|
130
|
+
## Installation
|
131
|
+
|
132
|
+
Add this line to your application's Gemfile:
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
gem 'vertex_client'
|
136
|
+
```
|
137
|
+
|
138
|
+
And then execute:
|
139
|
+
|
140
|
+
$ bundle
|
141
|
+
|
142
|
+
Or install it yourself as:
|
143
|
+
|
144
|
+
$ gem install vertex_client
|
145
|
+
|
146
|
+
## Configuration
|
147
|
+
|
148
|
+
Configure the client's connection to Vertex using environment variables or an initializer.
|
149
|
+
|
150
|
+
### Environment Variables
|
151
|
+
The following environment variables are used to configure the client.
|
152
|
+
|
153
|
+
```
|
154
|
+
VERTEX_TRUSTED_ID=your-trusted-id
|
155
|
+
VERTEX_SOAP_API=https://connect.vertexsmb.com/vertex-ws/services/
|
156
|
+
```
|
157
|
+
### Initializer
|
158
|
+
|
159
|
+
If you are using Rails, take advantage of the included generator:
|
160
|
+
|
161
|
+
$ bundle exec rails g vertex_client:install
|
162
|
+
|
163
|
+
Otherwise reference our [initializer template](https://github.com/customink/vertex_client/blob/master/lib/generators/install/templates/initializer.rb.erb)
|
164
|
+
|
165
|
+
|
166
|
+
## Development
|
167
|
+
|
168
|
+
This project follows Github's [Scripts to rule them all conventions][scripts-to-rule-them-all]. After cloning the app,
|
169
|
+
run the following:
|
170
|
+
|
171
|
+
bin/bootstrap
|
172
|
+
bin/setup
|
173
|
+
bin/test
|
174
|
+
|
175
|
+
After pulling down changes, run the following:
|
176
|
+
|
177
|
+
bin/update
|
178
|
+
|
179
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
180
|
+
|
181
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
182
|
+
|
183
|
+
## Contributing
|
184
|
+
|
185
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/customink/vertex_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
186
|
+
|
187
|
+
## License
|
188
|
+
|
189
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
190
|
+
|
191
|
+
## Code of Conduct
|
192
|
+
|
193
|
+
Everyone interacting in the VertexClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/customink/vertex_client/blob/master/CODE_OF_CONDUCT.md).
|
194
|
+
|
195
|
+
[scripts-to-rule-them-all]: https://github.com/github/scripts-to-rule-them-all
|
data/Rakefile
ADDED
data/bin/bootstrap
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# script/bootstrap: Resolve all dependencies that the application requires to
|
4
|
+
# run.
|
5
|
+
|
6
|
+
set -e
|
7
|
+
|
8
|
+
cd "$(dirname "$0")/.."
|
9
|
+
|
10
|
+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
|
11
|
+
brew bundle check || {
|
12
|
+
echo "==> Installing Homebrew dependencies..."
|
13
|
+
brew bundle
|
14
|
+
}
|
15
|
+
fi
|
16
|
+
|
17
|
+
RUBIES=(2.1.10 2.2.4 2.4.1 2.5.3)
|
18
|
+
for VERSION in "${RUBIES[@]}"
|
19
|
+
do
|
20
|
+
echo "Setting up ruby version $VERSION..."
|
21
|
+
echo $VERSION > .ruby-version
|
22
|
+
brew bootstrap-rbenv-ruby
|
23
|
+
done
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dotenv/load"
|
5
|
+
require "vertex_client"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/test
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This script is a starting point to run the entire test suite.
|
4
|
+
# Add necessary setup steps to this file.
|
5
|
+
|
6
|
+
# Uncomment when `rake db:setup` doesn't setup the test database in bin/setup
|
7
|
+
# puts '==> Prepping test db'
|
8
|
+
# system('RAILS_ENV=test bin/rails db:setup')
|
9
|
+
|
10
|
+
puts '== Running tests =='
|
11
|
+
command = ENV['CI'] ? 'bundle exec rake' : 'wwtd'
|
12
|
+
system("#{command}") || abort
|
data/bin/update
ADDED