moss_generator 0.4.1 → 0.4.1.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 +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/moss_generator/stripe.rb +8 -6
- data/lib/moss_generator/stripe_charge_row.rb +12 -1
- data/lib/moss_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a596216f6d84e6178eed61ca60146695d1442651cd4d1193b8d430a061d01e
|
4
|
+
data.tar.gz: 511e5e30a8e24910c05abd028a977fcebb039353073476ca3afaa05a4975a4f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9c353f6e72d5586820db41c452ecf1b3d6f9c2db7ff1713ffc4ffe5fe03a5e0a0bfb3872c5d4959bec6aad36b0e64fe75836d152eec0923c32e45bc410acc81
|
7
|
+
data.tar.gz: d3f0b382e87bcf84e3473811d1ff54da883cebe614b81d6ce46aad7ad63822bb9c6adcc5e449da0d7ef14d80bde0e1e7ea552c20f7d641c395bf91ecec78f0ec
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -51,22 +51,24 @@ module MossGenerator
|
|
51
51
|
|
52
52
|
charge_row
|
53
53
|
end.compact
|
54
|
-
charges_rows.group_by
|
54
|
+
charges_rows.group_by do |row|
|
55
|
+
[row.country_code, row.vat_rate]
|
56
|
+
end
|
55
57
|
end
|
56
58
|
|
57
59
|
def build_charges_rows
|
58
|
-
group_charges_rows.map do |country, charges|
|
60
|
+
group_charges_rows.map do |(country, vat), charges|
|
59
61
|
next if country == 'SE' && turnover_country == 'SE'
|
60
|
-
next if
|
62
|
+
next if vat.nil?
|
61
63
|
|
62
|
-
country_row(country, charges)
|
64
|
+
country_row(country, charges, vat)
|
63
65
|
end.compact
|
64
66
|
end
|
65
67
|
|
66
|
-
def country_row(country, charges)
|
68
|
+
def country_row(country, charges, vat)
|
67
69
|
[turnover_country,
|
68
70
|
country,
|
69
|
-
format_to_two_decimals(
|
71
|
+
format_to_two_decimals(vat),
|
70
72
|
format_to_two_decimals(charges.sum(&:amount_without_vat)),
|
71
73
|
format_to_two_decimals(charges.sum(&:vat_amount))]
|
72
74
|
end
|
@@ -36,7 +36,7 @@ module MossGenerator
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def vat_rate
|
39
|
-
@vat_rate =
|
39
|
+
@vat_rate = special_vat_rate_for_2021_quarter_one
|
40
40
|
end
|
41
41
|
|
42
42
|
def vat_amount
|
@@ -56,6 +56,17 @@ module MossGenerator
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
+
def special_vat_rate_for_2021_quarter_one
|
60
|
+
if fetch_country_code.casecmp?('IE')
|
61
|
+
changeover_day = Date.parse('2021-03-01').to_time
|
62
|
+
return 23 if Time.at(charge['created']) >= changeover_day
|
63
|
+
|
64
|
+
21
|
65
|
+
else
|
66
|
+
MossGenerator::VatRate.for(country_code)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
59
70
|
def company?
|
60
71
|
return false if charge.dig('metadata', 'vat_number').nil?
|
61
72
|
|