Module: EffectiveProductsRingPayment

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_products_ring_payment.rb

Overview

EffectiveProductsRingPayment

Mark your owner model with effective_products_ring_payment to get all the includes

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#assign_pricingObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'app/models/concerns/effective_products_ring_payment.rb', line 137

def assign_pricing
  price = case ring.metal
    when '14k Yellow Gold' then 450_00
    when 'Sterling Silver' then 175_00
    when 'Titanium' then 50_00
    else
      raise "unexpected ring metal: #{ring.metal || 'none'}"
    end

  qb_item_name = "Chemist's Ring"
  tax_exempt = false

  ring.assign_attributes(price: price, qb_item_name: qb_item_name, tax_exempt: tax_exempt)
end

#build_ringObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'app/models/concerns/effective_products_ring_payment.rb', line 119

def build_ring
  ring = rings.build(
    owner: owner,
    first_name: owner.try(:first_name),
    last_name: owner.try(:last_name),
    email: owner.try(:email),
    phone: owner.try(:phone)
  )

  address = owner.try(:shipping_address) || owner.try(:billing_address)

  if address.present?
    ring.shipping_address = address
  end

  ring
end

#done?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'app/models/concerns/effective_products_ring_payment.rb', line 111

def done?
  
end

#in_progress?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'app/models/concerns/effective_products_ring_payment.rb', line 107

def in_progress?
  draft?
end

#ringObject



115
116
117
# File 'app/models/concerns/effective_products_ring_payment.rb', line 115

def ring
  rings.first
end

#ring!Object

After the configure Ring step



153
154
155
156
# File 'app/models/concerns/effective_products_ring_payment.rb', line 153

def ring!
  assign_pricing() if ring.present?
  save!
end

#to_sObject

Instance Methods



103
104
105
# File 'app/models/concerns/effective_products_ring_payment.rb', line 103

def to_s
  'ring payment'
end