Class: Effective::Stamp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#admin_actionObject

Returns the value of attribute admin_action.



10
11
12
# File 'app/models/effective/stamp.rb', line 10

def admin_action
  @admin_action
end

Instance Method Details

#created_by_admin?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'app/models/effective/stamp.rb', line 98

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

#mark_as_issued!Object



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

def mark_as_issued!
  issued!
end

#mark_as_submitted!Object



90
91
92
# File 'app/models/effective/stamp.rb', line 90

def 
  
end

#mark_paid!Object

This is the Admin Save and Mark Paid action



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'app/models/effective/stamp.rb', line 110

def mark_paid!
  update!(admin_action: true) # Make sure we have an owner with a membership
  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
  )

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

#submit!Object

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



104
105
106
107
# File 'app/models/effective/stamp.rb', line 104

def submit!
  raise('expected a purchased order') unless (purchased? || applicant&.submit_order&.purchased?)
  
end

#to_sObject



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

def to_s
  [model_name.human, *name.presence, ("- #{category}" if category.present?)].join(' ')
end