moss_generator 0.6.0 → 0.7.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 +4 -4
- data/Gemfile.lock +19 -16
- data/README.md +17 -0
- data/lib/moss_generator/stripe.rb +18 -7
- data/lib/moss_generator/stripe_charge_row.rb +4 -3
- data/lib/moss_generator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d76e193b26e8d61b718f567d7416a7a06b63d1869a8b4f8734093aee72120ca5
|
4
|
+
data.tar.gz: 47ce0bc69d2cdf03c0c783c6fc2ca464b7da346597df81d074fcfda209bb2be5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6bb77da4514d7cfb3560f826160e5fa51bce80ec9f413b9d1334c70070e69e4c6da7eba70e5e5bf73a8a4db0ee558072d6041c5d323677db14678b248b7423b
|
7
|
+
data.tar.gz: 0ff1ae9664e557fd06897730c1cfae4dce0ffbb99dece76e4464678b11428fc492709ff5b3333ee20875eca31aff68c778843d4bcc3032d58f6c753a8d68247a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
moss_generator (0.
|
4
|
+
moss_generator (0.7.0)
|
5
5
|
countries (~> 4.0)
|
6
6
|
money (~> 6.14)
|
7
7
|
valvat (~> 1.1)
|
@@ -18,27 +18,29 @@ GEM
|
|
18
18
|
builder (3.2.4)
|
19
19
|
byebug (11.1.3)
|
20
20
|
coderay (1.1.3)
|
21
|
-
concurrent-ruby (1.1.
|
22
|
-
countries (4.
|
23
|
-
i18n_data (~> 0.
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
countries (4.2.3)
|
23
|
+
i18n_data (~> 0.16.0)
|
24
24
|
sixarm_ruby_unaccent (~> 1.1)
|
25
25
|
diff-lcs (1.4.4)
|
26
|
-
gyoku (1.
|
26
|
+
gyoku (1.4.0)
|
27
27
|
builder (>= 2.1.2)
|
28
|
+
rexml (~> 3.0)
|
28
29
|
httpi (2.5.0)
|
29
30
|
rack
|
30
31
|
socksify
|
31
|
-
i18n (1.
|
32
|
+
i18n (1.10.0)
|
32
33
|
concurrent-ruby (~> 1.0)
|
33
|
-
i18n_data (0.
|
34
|
+
i18n_data (0.16.0)
|
35
|
+
simple_po_parser (~> 1.1)
|
34
36
|
method_source (1.0.0)
|
35
|
-
mini_portile2 (2.
|
37
|
+
mini_portile2 (2.8.0)
|
36
38
|
money (6.16.0)
|
37
39
|
i18n (>= 0.6.4, <= 2)
|
38
|
-
nokogiri (1.
|
39
|
-
mini_portile2 (~> 2.
|
40
|
+
nokogiri (1.13.6)
|
41
|
+
mini_portile2 (~> 2.8.0)
|
40
42
|
racc (~> 1.4)
|
41
|
-
nokogiri (1.
|
43
|
+
nokogiri (1.13.6-x86_64-darwin)
|
42
44
|
racc (~> 1.4)
|
43
45
|
nori (2.6.0)
|
44
46
|
parallel (1.20.1)
|
@@ -50,9 +52,9 @@ GEM
|
|
50
52
|
pry-byebug (3.9.0)
|
51
53
|
byebug (~> 11.0)
|
52
54
|
pry (~> 0.13.0)
|
53
|
-
public_suffix (4.0.
|
55
|
+
public_suffix (4.0.7)
|
54
56
|
racc (1.6.0)
|
55
|
-
rack (2.2.3)
|
57
|
+
rack (2.2.3.1)
|
56
58
|
rainbow (3.0.0)
|
57
59
|
rake (13.0.3)
|
58
60
|
regexp_parser (2.0.3)
|
@@ -98,12 +100,13 @@ GEM
|
|
98
100
|
nokogiri (>= 1.8.1)
|
99
101
|
nori (~> 2.4)
|
100
102
|
wasabi (~> 3.4)
|
103
|
+
simple_po_parser (1.1.6)
|
101
104
|
sixarm_ruby_unaccent (1.2.0)
|
102
105
|
socksify (1.7.1)
|
103
106
|
unicode-display_width (1.7.0)
|
104
|
-
valvat (1.1.
|
107
|
+
valvat (1.1.4)
|
105
108
|
savon (>= 2.3.0)
|
106
|
-
wasabi (3.
|
109
|
+
wasabi (3.7.0)
|
107
110
|
addressable
|
108
111
|
httpi (~> 2.0)
|
109
112
|
nokogiri (>= 1.4.2)
|
@@ -123,4 +126,4 @@ DEPENDENCIES
|
|
123
126
|
rubocop-rspec (~> 2.1)
|
124
127
|
|
125
128
|
BUNDLED WITH
|
126
|
-
2.2.
|
129
|
+
2.2.32
|
data/README.md
CHANGED
@@ -48,6 +48,23 @@ Vat rates currently needs to be updated manually in `config/vat_rates.json`.
|
|
48
48
|
|
49
49
|
Rates can also be found on the official website of the European Union [https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm#shortcut-8](https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm#shortcut-8), updates two times a year.
|
50
50
|
|
51
|
+
### Custom VAT rates
|
52
|
+
|
53
|
+
If standard VAT rates is not enough a custom VAT service can be written and used instead. To create a VAT service that change VAT for a country with a standard VAT rates fallback this one could be used.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class CustomVat
|
57
|
+
# Insane 50.5% VAT for France
|
58
|
+
def for(country_code)
|
59
|
+
return 50.5 if country_code == 'FR'
|
60
|
+
|
61
|
+
MossGenerator::VatRate.for(country_code)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
csv_string = MossGenerator::Stripe.call(charges, vat_number, period, year, rates, 'SERVICES', CustomVat.new)
|
66
|
+
```
|
67
|
+
|
51
68
|
## Contributing
|
52
69
|
|
53
70
|
Bug reports and pull requests are welcome on GitHub at https://github.com/standout/moss_generator.
|
@@ -8,23 +8,33 @@ module MossGenerator
|
|
8
8
|
class Stripe
|
9
9
|
class NoTurnoverCountryError < StandardError; end
|
10
10
|
|
11
|
-
attr_reader :charges, :vat_number, :period, :year, :rates, :sale_type
|
12
|
-
|
13
|
-
|
11
|
+
attr_reader :charges, :vat_number, :period, :year, :rates, :sale_type,
|
12
|
+
:vat_rate_service
|
13
|
+
|
14
|
+
# rubocop:disable Metrics/ParameterLists
|
15
|
+
def initialize(charges,
|
16
|
+
vat_number,
|
17
|
+
period,
|
18
|
+
year,
|
19
|
+
rates,
|
20
|
+
sale_type,
|
21
|
+
vat_rate_service = MossGenerator::VatRate)
|
14
22
|
@charges = charges
|
15
23
|
@vat_number = vat_number
|
16
24
|
@period = period
|
17
25
|
@year = year
|
18
26
|
@rates = rates
|
19
27
|
@sale_type = sale_type
|
28
|
+
@vat_rate_service = vat_rate_service
|
20
29
|
end
|
30
|
+
# rubocop:enable Metrics/ParameterLists
|
21
31
|
|
22
|
-
def self.call(
|
23
|
-
new(
|
32
|
+
def self.call(*args)
|
33
|
+
new(*args).call
|
24
34
|
end
|
25
35
|
|
26
36
|
def call
|
27
|
-
CSV.generate(csv_options) do |csv|
|
37
|
+
CSV.generate(**csv_options) do |csv|
|
28
38
|
csv << first_row
|
29
39
|
csv << second_row
|
30
40
|
generate_charges_rows(csv)
|
@@ -47,7 +57,8 @@ module MossGenerator
|
|
47
57
|
|
48
58
|
def group_charges_rows
|
49
59
|
charges_rows = charges.map do |charge|
|
50
|
-
charge_row = MossGenerator::StripeChargeRow.new(charge, rates
|
60
|
+
charge_row = MossGenerator::StripeChargeRow.new(charge, rates,
|
61
|
+
vat_rate_service)
|
51
62
|
next if charge_row.skippable?
|
52
63
|
|
53
64
|
charge_row
|
@@ -14,11 +14,12 @@ module MossGenerator
|
|
14
14
|
|
15
15
|
class NoExchangeRateForCurrencyOrDateError < StandardError; end
|
16
16
|
|
17
|
-
attr_reader :charge, :rates
|
17
|
+
attr_reader :charge, :rates, :vat_rate_service
|
18
18
|
|
19
|
-
def initialize(charge, rates)
|
19
|
+
def initialize(charge, rates, vat_rate_service = MossGenerator::VatRate)
|
20
20
|
@charge = charge
|
21
21
|
@rates = rates
|
22
|
+
@vat_rate_service = vat_rate_service
|
22
23
|
end
|
23
24
|
|
24
25
|
def country_code
|
@@ -63,7 +64,7 @@ module MossGenerator
|
|
63
64
|
|
64
65
|
21
|
65
66
|
else
|
66
|
-
|
67
|
+
vat_rate_service.for(country_code)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moss_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- frdrkolsson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.3.7
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Skatteverket One Stop Shop (OSS) generator.
|