Class: SKVReport::StripeChargeRow

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

Overview

Parse charge data from single Stripe charge Sales amount will not contain any cents, so we round All amounts should be handled as without vat

Defined Under Namespace

Classes: AmountNotInSwedishKronorError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(charge, exchange_rates) ⇒ StripeChargeRow

charge: a stripe charge exchange_rates: a SKVReport::ExchangeRates object



21
22
23
24
25
# File 'lib/skv_report/stripe_charge_row.rb', line 21

def initialize(charge, exchange_rates)
  @charge = charge
  @buyer_vat_number = vat_number
  @exchange_rates = exchange_rates
end

Instance Attribute Details

#buyer_vat_numberObject (readonly)

Returns the value of attribute buyer_vat_number.



15
16
17
# File 'lib/skv_report/stripe_charge_row.rb', line 15

def buyer_vat_number
  @buyer_vat_number
end

#chargeObject (readonly)

Returns the value of attribute charge.



15
16
17
# File 'lib/skv_report/stripe_charge_row.rb', line 15

def charge
  @charge
end

#exchange_ratesObject (readonly)

Returns the value of attribute exchange_rates.



15
16
17
# File 'lib/skv_report/stripe_charge_row.rb', line 15

def exchange_rates
  @exchange_rates
end

Instance Method Details

#sales_amountObject



27
28
29
# File 'lib/skv_report/stripe_charge_row.rb', line 27

def sales_amount
  Money.new(amount).dollars.to_f.round
end

#skippable?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
# File 'lib/skv_report/stripe_charge_row.rb', line 31

def skippable?
  buyer_vat_number.nil? ||
    swedish_buyer? ||
    !valid_vat_number? ||
    !eu_member? ||
    not_completed? ||
    refunded?
end