Class: Effective::Stamp

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/stamp.rb

Constant Summary collapse

CATEGORIES =

CATEGORIES = ['Physical', 'Digital-only']

['Physical']

Instance Method Summary collapse

Instance Method Details

#created_by_admin?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'app/models/effective/stamp.rb', line 86

def created_by_admin?
  stamp_wizard_id.blank? && applicant_id.blank?
end

#issued?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/models/effective/stamp.rb', line 74

def issued?
  issued_at.present?
end

#mark_as_issued!Object



78
79
80
# File 'app/models/effective/stamp.rb', line 78

def mark_as_issued!
  issued!
end

#mark_paid!Object

This is the Admin Save and Mark Paid action



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'app/models/effective/stamp.rb', line 98

def mark_paid!
  raise('expected an user with a membership category') unless owner && owner.try(:membership).present?

  category = owner.membership.categories.first

  assign_attributes(
    price: category.stamp_fee,
    tax_exempt: category.stamp_fee_tax_exempt,
    qb_item_name: category.stamp_fee_qb_item_name
  )

  save!
  Effective::Order.new(items: self, user: owner).mark_as_purchased!
end

#physical?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/models/effective/stamp.rb', line 82

def physical?
  category == 'Physical'
end

#submit!Object

Called by an application when submitted Called by a stamp wizard when submitted



92
93
94
95
# File 'app/models/effective/stamp.rb', line 92

def submit!
  raise('expected a purchased order') unless purchased?
  
end

#to_sObject



70
71
72
# File 'app/models/effective/stamp.rb', line 70

def to_s
  ['Professional Stamp', *name.presence].join(' ')
end