Sha256: e83b6f355ccedd92f7066454d1afe3b2b5f6a5e6b49317db4bc08314e89b3057

Contents?: true

Size: 1.66 KB

Versions: 24

Compression:

Stored size: 1.66 KB

Contents

class MembershipsImport < Import
  include Imports::Rollback
  include Imports::Validations
  
  def kind
    "memberships"
  end
  
  def row_valid?(parsed_row)
    raise Import::RowError, "No Amount included in this row: #{parsed_row.row}" if parsed_row.unparsed_amount.blank?
    raise Import::RowError, "Please include a first name, last name, email, or company name in this row: #{parsed_row.row}" unless attach_person(parsed_row).naming_details_available?
    raise Import::RowError, "Please include a payment method in this row: #{parsed_row.row}" if parsed_row.payment_method.blank?
    valid_amount? parsed_row.unparsed_amount      unless parsed_row.unparsed_amount.blank?
    valid_date?   parsed_row.order_date           unless parsed_row.order_date.blank?
    true
  end
  
  def process(parsed_row)
    row_valid?(parsed_row)
    membership_type        = create_membership_type(parsed_row)
    person                 = create_person(parsed_row)
    order                  = create_order(parsed_row, person, membership_type)
    actions                = create_actions(parsed_row, person, memberships_type)
  end

  def create_membership_type(parsed_row)
    membership_type = self.organization.membership_types.build({
      :name => parsed_row.membership_name
    })
    membership_type.plan = parsed_row.membership_plan
    membership_type
  end

  def create_order(parsed_row, person, membership_type)
    #get order from hash
    # for 0 to parsed_row.number_of_memberships
         # create an item for this membership_type
    #add the item to the order
    #save the order
    #update get_action
    #hash order by order key (person, membership_type, payment_method)
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.beta.1 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.alpha.2 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.alpha.1 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.27 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.26 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.24 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.23 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.21 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.20 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.19 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.18 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.17 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.16 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.15 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.12 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.11 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.10 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.9 app/models/imports/memberships_import.rb
artfully_ose-1.2.0.pre.8 app/models/imports/memberships_import.rb