Class: MossGenerator::StripeChargeRow
- Inherits:
-
Object
- Object
- MossGenerator::StripeChargeRow
- Defined in:
- lib/moss_generator/stripe_charge_row.rb
Overview
Parse charge data from single Stripe charge
Defined Under Namespace
Classes: NoConsumptionCountryError, NoExchangeRateForCurrencyOrDateError, NoVatRateForCountryError
Instance Attribute Summary collapse
-
#charge ⇒ Object
readonly
Returns the value of attribute charge.
-
#rates ⇒ Object
readonly
Returns the value of attribute rates.
-
#vat_rate_service ⇒ Object
readonly
Returns the value of attribute vat_rate_service.
Instance Method Summary collapse
- #amount_without_vat ⇒ Object
- #amount_without_vat_cents ⇒ Object
- #country_code ⇒ Object
-
#initialize(charge, rates, vat_rate_service = MossGenerator::VatRate) ⇒ StripeChargeRow
constructor
A new instance of StripeChargeRow.
- #skippable? ⇒ Boolean
- #vat_amount ⇒ Object
- #vat_rate ⇒ Object
Constructor Details
#initialize(charge, rates, vat_rate_service = MossGenerator::VatRate) ⇒ StripeChargeRow
Returns a new instance of StripeChargeRow.
19 20 21 22 23 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 19 def initialize(charge, rates, vat_rate_service = MossGenerator::VatRate) @charge = charge @rates = rates @vat_rate_service = vat_rate_service end |
Instance Attribute Details
#charge ⇒ Object (readonly)
Returns the value of attribute charge.
17 18 19 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 17 def charge @charge end |
#rates ⇒ Object (readonly)
Returns the value of attribute rates.
17 18 19 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 17 def rates @rates end |
#vat_rate_service ⇒ Object (readonly)
Returns the value of attribute vat_rate_service.
17 18 19 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 17 def vat_rate_service @vat_rate_service end |
Instance Method Details
#amount_without_vat ⇒ Object
31 32 33 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 31 def amount_without_vat Money.new(amount_with_vat * percent_without_vat).dollars.to_f end |
#amount_without_vat_cents ⇒ Object
35 36 37 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 35 def amount_without_vat_cents Money.new(amount_with_vat * percent_without_vat).cents end |
#country_code ⇒ Object
25 26 27 28 29 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 25 def country_code return fetch_country_code unless fetch_country_code.nil? raise NoConsumptionCountryError, "charge: #{charge}" end |
#skippable? ⇒ Boolean
49 50 51 52 53 54 55 56 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 49 def skippable? not_completed? || company? || fetch_country_code.nil? || sold_outside_of_eu? || swedish_charge? || refunded? end |
#vat_amount ⇒ Object
43 44 45 46 47 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 43 def vat_amount Money.new(amount_without_vat_cents * vat_rate_calculatable_percent) .dollars .to_f end |
#vat_rate ⇒ Object
39 40 41 |
# File 'lib/moss_generator/stripe_charge_row.rb', line 39 def vat_rate @vat_rate = special_vat_rate_for_2021_quarter_one end |