Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSS to OSS corrections #14

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ AllCops:
Layout/LineLength:
Max: 80

Metrics/ParameterLists:
Max: 6

Metrics/BlockLength:
Exclude:
- 'spec/**/*'
Expand Down
14 changes: 8 additions & 6 deletions lib/moss_generator/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ module MossGenerator
class Stripe
class NoTurnoverCountryError < StandardError; end

attr_reader :charges, :vat_number, :period, :year, :rates
attr_reader :charges, :vat_number, :period, :year, :rates, :sale_type

def initialize(charges, vat_number, period, year, rates)
def initialize(charges, vat_number, period, year, rates, sale_type)
@charges = charges
@vat_number = vat_number
@period = period
@year = year
@rates = rates
@sale_type = sale_type
end

def self.call(charges, vat_number, period, year, rates)
new(charges, vat_number, period, year, rates).call
def self.call(charges, vat_number, period, year, rates, sale_type)
new(charges, vat_number, period, year, rates, sale_type).call
end

def call
Expand All @@ -33,7 +34,7 @@ def call
private

def first_row
['MOSS_001']
['OSS_001']
end

def second_row
Expand Down Expand Up @@ -70,7 +71,8 @@ def country_row(country, charges, vat)
country,
format_to_two_decimals(vat),
format_to_two_decimals(charges.sum(&:amount_without_vat)),
format_to_two_decimals(charges.sum(&:vat_amount))]
format_to_two_decimals(charges.sum(&:vat_amount)),
sale_type]
end

def csv_options
Expand Down
15 changes: 8 additions & 7 deletions spec/moss_generator/stripe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
'SE556000016701',
3,
2020,
read_exchange_rates)
read_exchange_rates,
'GOODS')
end

before { stub_vat_rates_file }

it 'returns a csv format string' do
result = "MOSS_001;\r\n"\
result = "OSS_001;\r\n"\
"SE556000016701;3;2020;\r\n"\
"SE;IT;22,00;205,90;45,30;\r\n"\
"SE;FR;20,00;415,00;83,00;\r\n"\
"SE;IT;22,00;205,90;45,30;GOODS;\r\n"\
"SE;FR;20,00;415,00;83,00;GOODS;\r\n"\

expect(call).to eq(result)
end
Expand All @@ -35,10 +36,10 @@
end

it 'returns a csv with same country with different vat on two rows' do
result = "MOSS_001;\r\n"\
result = "OSS_001;\r\n"\
"SE556000016701;3;2020;\r\n"\
"SE;IE;23,00;204,23;46,97;\r\n"\
"SE;IE;21,00;205,79;43,22;\r\n"\
"SE;IE;23,00;204,23;46,97;GOODS;\r\n"\
"SE;IE;21,00;205,79;43,22;GOODS;\r\n"\

expect(call).to eq(result)
end
Expand Down