Class: MossGenerator::Stripe

Inherits:
Object
  • Object
show all
Defined in:
lib/moss_generator/stripe.rb

Overview

Generate MOSS CSV string from Stripe charges

Defined Under Namespace

Classes: NoTurnoverCountryError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(charges, vat_number, period, year, rates, sale_type, vat_rate_service = MossGenerator::VatRate) ⇒ Stripe

rubocop:disable Metrics/ParameterLists



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/moss_generator/stripe.rb', line 15

def initialize(charges,
               vat_number,
               period,
               year,
               rates,
               sale_type,
               vat_rate_service = MossGenerator::VatRate)
  @charges = charges
  @vat_number = vat_number
  @period = period
  @year = year
  @rates = rates
  @sale_type = sale_type
  @vat_rate_service = vat_rate_service
end

Instance Attribute Details

#chargesObject (readonly)

Returns the value of attribute charges.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def charges
  @charges
end

#periodObject (readonly)

Returns the value of attribute period.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def period
  @period
end

#ratesObject (readonly)

Returns the value of attribute rates.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def rates
  @rates
end

#sale_typeObject (readonly)

Returns the value of attribute sale_type.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def sale_type
  @sale_type
end

#vat_numberObject (readonly)

Returns the value of attribute vat_number.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def vat_number
  @vat_number
end

#vat_rate_serviceObject (readonly)

Returns the value of attribute vat_rate_service.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def vat_rate_service
  @vat_rate_service
end

#yearObject (readonly)

Returns the value of attribute year.



11
12
13
# File 'lib/moss_generator/stripe.rb', line 11

def year
  @year
end

Class Method Details

.call(*args) ⇒ Object

rubocop:enable Metrics/ParameterLists



32
33
34
# File 'lib/moss_generator/stripe.rb', line 32

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



36
37
38
39
40
41
42
# File 'lib/moss_generator/stripe.rb', line 36

def call
  CSV.generate(**csv_options) do |csv|
    csv << first_row
    csv << second_row
    generate_charges_rows(csv)
  end
end