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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad3786bac36f09eb868b05288e7cf8303f296f717d0c6e0cfdc4679d5340f687
4
- data.tar.gz: e39c8296c61fec69eb1bf102743767e4171ce36a8f3dac140cbb95b58121f2f0
3
+ metadata.gz: c5a596216f6d84e6178eed61ca60146695d1442651cd4d1193b8d430a061d01e
4
+ data.tar.gz: 511e5e30a8e24910c05abd028a977fcebb039353073476ca3afaa05a4975a4f5
5
5
  SHA512:
6
- metadata.gz: 976a67a9a004a2e6c2c3613826cd5ba8670b08064985426f6aa47b00838e1037e0088890e9a0a626cdf6a91ddbbc8318eb35c4454cce362f49bd6c777b084ccb
7
- data.tar.gz: e4d6e7b8976351ad93433c843d41176358ca43f60950b546e89600a992d75e00c091ed9d602c3490fecd3057a403bd0cdc3dc077f0da7fdf91fcae6bf7f7a7ec
6
+ metadata.gz: b9c353f6e72d5586820db41c452ecf1b3d6f9c2db7ff1713ffc4ffe5fe03a5e0a0bfb3872c5d4959bec6aad36b0e64fe75836d152eec0923c32e45bc410acc81
7
+ data.tar.gz: d3f0b382e87bcf84e3473811d1ff54da883cebe614b81d6ce46aad7ad63822bb9c6adcc5e449da0d7ef14d80bde0e1e7ea552c20f7d641c395bf91ecec78f0ec
data/.rubocop.yml CHANGED
@@ -15,4 +15,4 @@ Metrics/BlockLength:
15
15
  - 'spec/**/*'
16
16
 
17
17
  RSpec/NestedGroups:
18
- Max: 4
18
+ Max: 5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moss_generator (0.4.1)
4
+ moss_generator (0.4.1.1)
5
5
  countries (~> 3.1)
6
6
  money (~> 6.14)
7
7
  valvat (~> 1.1)
@@ -51,22 +51,24 @@ module MossGenerator
51
51
 
52
52
  charge_row
53
53
  end.compact
54
- charges_rows.group_by(&:country_code)
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 charges.first.vat_rate.nil?
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(charges.first.vat_rate),
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 = MossGenerator::VatRate.for(country_code)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MossGenerator
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moss_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - frdrkolsson