Class: SKVReport::Stripe

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

Overview

Generate SKV CSV string from Stripe charge

Defined Under Namespace

Classes: UndefinedTypeOfSalesError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(charges, period, year, company_information = {}, rates = {}) ⇒ Stripe

company_information needs to contain the following information

vat_number: String, # vat number of the selling company
name: String, # contact name on selling company
phone: String, # phone to contact on selling company
email: String, # optional email to contact on selling company
period_type: String, # defaults to 'quarter', can be set to month
type_of_sales: String, # one of the following three
                         ['wares', 'third_party', 'services']

Send rates to ImportExchangeRates, and send the object to stripe charge row, and then call rate for in there? Nah…



27
28
29
30
31
32
33
# File 'lib/skv_report/stripe.rb', line 27

def initialize(charges, period, year, company_information = {}, rates = {})
  @charges = charges
  @company_information = company_information
  @period = period
  @year = year
  @rates = rates
end

Instance Attribute Details

#chargesObject (readonly)

Returns the value of attribute charges.



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

def charges
  @charges
end

#company_informationObject (readonly)

Returns the value of attribute company_information.



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

def company_information
  @company_information
end

#periodObject (readonly)

Returns the value of attribute period.



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

def period
  @period
end

#ratesObject (readonly)

Returns the value of attribute rates.



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

def rates
  @rates
end

#yearObject (readonly)

Returns the value of attribute year.



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

def year
  @year
end

Class Method Details

.call(charges, period, year, company_information = {}, rates = {}) ⇒ Object



35
36
37
# File 'lib/skv_report/stripe.rb', line 35

def self.call(charges, period, year, company_information = {}, rates = {})
  new(charges, period, year, company_information, rates).call
end

Instance Method Details

#callObject



39
40
41
42
43
44
45
# File 'lib/skv_report/stripe.rb', line 39

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