skv_report 0.3.0 → 0.3.4
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 +4 -4
- data/Gemfile.lock +17 -6
- data/README.md +5 -1
- data/lib/skv_report/stripe.rb +0 -2
- data/lib/skv_report/stripe_charge_row.rb +20 -2
- data/lib/skv_report/version.rb +1 -1
- data/skv_report.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b2b470ab5c999c069d598bb3f4cd544e9bd9a731a1ab45ad4837f131db6375
|
4
|
+
data.tar.gz: 5d131ea902c9e17041d5a9eeac5fdb0222ed3325c26267257f3804717067c554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efce1d73aa969417b74a0ebd0c401f6956fc1ca379818692382d1d76111a2d12d1225fe2316f1d0d2f05e70a652cf7007a2478f8f58e9c3d777c07bad3e53e05
|
7
|
+
data.tar.gz: fb547c8abef76120d513df937a34bb5f0a3bc75491774aaff7cf6729e3842a7c289f42ea6d066acc0ab70d1ac02b51d662fb98d8d00b6fe00391cd9001f39a46
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
skv_report (0.3.
|
4
|
+
skv_report (0.3.4)
|
5
|
+
countries (~> 3.1.0)
|
5
6
|
money (~> 6.14)
|
6
7
|
valvat (~> 1.1)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
addressable (2.
|
12
|
+
addressable (2.8.0)
|
12
13
|
public_suffix (>= 2.0.2, < 5.0)
|
13
14
|
akami (1.3.1)
|
14
15
|
gyoku (>= 0.4.0)
|
@@ -18,18 +19,25 @@ GEM
|
|
18
19
|
byebug (11.1.3)
|
19
20
|
coderay (1.1.3)
|
20
21
|
concurrent-ruby (1.1.8)
|
22
|
+
countries (3.1.0)
|
23
|
+
i18n_data (~> 0.11.0)
|
24
|
+
sixarm_ruby_unaccent (~> 1.1)
|
25
|
+
unicode_utils (~> 1.4)
|
21
26
|
diff-lcs (1.4.4)
|
22
27
|
gyoku (1.3.1)
|
23
28
|
builder (>= 2.1.2)
|
24
|
-
httpi (2.
|
29
|
+
httpi (2.5.0)
|
25
30
|
rack
|
26
31
|
socksify
|
27
32
|
i18n (1.8.10)
|
28
33
|
concurrent-ruby (~> 1.0)
|
34
|
+
i18n_data (0.11.0)
|
29
35
|
method_source (1.0.0)
|
36
|
+
mini_portile2 (2.6.1)
|
30
37
|
money (6.14.1)
|
31
38
|
i18n (>= 0.6.4, <= 2)
|
32
|
-
nokogiri (1.
|
39
|
+
nokogiri (1.12.5)
|
40
|
+
mini_portile2 (~> 2.6.1)
|
33
41
|
racc (~> 1.4)
|
34
42
|
nori (2.6.0)
|
35
43
|
parallel (1.20.1)
|
@@ -42,7 +50,7 @@ GEM
|
|
42
50
|
byebug (~> 11.0)
|
43
51
|
pry (~> 0.13.0)
|
44
52
|
public_suffix (4.0.6)
|
45
|
-
racc (1.
|
53
|
+
racc (1.6.0)
|
46
54
|
rack (2.2.3)
|
47
55
|
rainbow (3.0.0)
|
48
56
|
rake (13.0.3)
|
@@ -89,9 +97,11 @@ GEM
|
|
89
97
|
nokogiri (>= 1.8.1)
|
90
98
|
nori (~> 2.4)
|
91
99
|
wasabi (~> 3.4)
|
100
|
+
sixarm_ruby_unaccent (1.2.0)
|
92
101
|
socksify (1.7.1)
|
93
102
|
unicode-display_width (1.7.0)
|
94
|
-
|
103
|
+
unicode_utils (1.4.0)
|
104
|
+
valvat (1.1.2)
|
95
105
|
savon (>= 2.3.0)
|
96
106
|
wasabi (3.6.1)
|
97
107
|
addressable
|
@@ -99,6 +109,7 @@ GEM
|
|
99
109
|
nokogiri (>= 1.4.2)
|
100
110
|
|
101
111
|
PLATFORMS
|
112
|
+
ruby
|
102
113
|
x86_64-darwin-19
|
103
114
|
|
104
115
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -42,9 +42,13 @@ SKVReport::Stripe.call(charges, period, year, company_information, rates)
|
|
42
42
|
|
43
43
|
## Development
|
44
44
|
|
45
|
+
The main branch in this repository is called `main`.
|
46
|
+
|
45
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
48
|
|
47
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
50
|
+
|
51
|
+
To release a new version, update the version number in `version.rb`, and then make a release on GitHub which will automatically build the gem and upload to rubygems.
|
48
52
|
|
49
53
|
## Exchange rates
|
50
54
|
|
data/lib/skv_report/stripe.rb
CHANGED
@@ -6,8 +6,6 @@ require 'skv_report/stripe_charge_row'
|
|
6
6
|
module SKVReport
|
7
7
|
# Generate SKV CSV string from Stripe charge
|
8
8
|
class Stripe
|
9
|
-
class NoTurnoverCountryError < StandardError; end
|
10
|
-
|
11
9
|
class UndefinedTypeOfSalesError < StandardError; end
|
12
10
|
|
13
11
|
attr_reader :charges, :period, :year, :company_information, :rates
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'money'
|
4
4
|
require 'valvat/local'
|
5
5
|
require 'date'
|
6
|
+
require 'countries/global'
|
6
7
|
|
7
8
|
module SKVReport
|
8
9
|
# Parse charge data from single Stripe charge
|
@@ -19,7 +20,7 @@ module SKVReport
|
|
19
20
|
#
|
20
21
|
def initialize(charge, exchange_rates)
|
21
22
|
@charge = charge
|
22
|
-
@buyer_vat_number =
|
23
|
+
@buyer_vat_number = vat_number
|
23
24
|
@exchange_rates = exchange_rates
|
24
25
|
end
|
25
26
|
|
@@ -28,15 +29,32 @@ module SKVReport
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def skippable?
|
31
|
-
|
32
|
+
buyer_vat_number.nil? ||
|
33
|
+
swedish_buyer? ||
|
34
|
+
!valid_vat_number? ||
|
35
|
+
!eu_member? ||
|
36
|
+
not_completed? ||
|
37
|
+
refunded?
|
32
38
|
end
|
33
39
|
|
34
40
|
private
|
35
41
|
|
42
|
+
def vat_number
|
43
|
+
tax_object = charge.dig('customer', 'tax_ids', 'data').find do |tax_data|
|
44
|
+
tax_data['type'].casecmp?('eu_vat')
|
45
|
+
end
|
46
|
+
|
47
|
+
tax_object&.fetch('value', '')
|
48
|
+
end
|
49
|
+
|
36
50
|
def swedish_buyer?
|
37
51
|
buyer_vat_number[0...2].casecmp?('SE')
|
38
52
|
end
|
39
53
|
|
54
|
+
def eu_member?
|
55
|
+
ISO3166::Country.new(buyer_vat_number[0...2])&.in_eu?
|
56
|
+
end
|
57
|
+
|
40
58
|
def valid_vat_number?
|
41
59
|
Valvat::Syntax.validate(buyer_vat_number)
|
42
60
|
end
|
data/lib/skv_report/version.rb
CHANGED
data/skv_report.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
34
|
# spec.add_dependency to register a new dependency of your gem
|
35
|
+
spec.add_dependency 'countries', '~> 3.1.0'
|
35
36
|
spec.add_dependency 'money', '~> 6.14'
|
36
37
|
spec.add_dependency 'valvat', '~> 1.1'
|
37
38
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skv_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- frdrkolsson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: countries
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: money
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: '0'
|
87
101
|
requirements: []
|
88
|
-
rubygems_version: 3.2.
|
102
|
+
rubygems_version: 3.2.22
|
89
103
|
signing_key:
|
90
104
|
specification_version: 4
|
91
105
|
summary: Generates CSV complete string for Skatteverkets Periodisk Sammanfattning
|