Class: SKVReport::StripeChargeRow
- Inherits:
-
Object
- Object
- SKVReport::StripeChargeRow
- 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
-
#buyer_vat_number ⇒ Object
readonly
Returns the value of attribute buyer_vat_number.
-
#charge ⇒ Object
readonly
Returns the value of attribute charge.
-
#exchange_rates ⇒ Object
readonly
Returns the value of attribute exchange_rates.
Instance Method Summary collapse
-
#initialize(charge, exchange_rates) ⇒ StripeChargeRow
constructor
charge: a stripe charge exchange_rates: a SKVReport::ExchangeRates object.
- #sales_amount ⇒ Object
- #skippable? ⇒ Boolean
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_number ⇒ Object (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 |
#charge ⇒ Object (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_rates ⇒ Object (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_amount ⇒ Object
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
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 |