Class: Effective::RegistrarAction

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/effective/registrar_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#category_idObject

Reclassify & Register



16
17
18
# File 'app/models/effective/registrar_action.rb', line 16

def category_id
  @category_id
end

#category_idsObject

Assign



28
29
30
# File 'app/models/effective/registrar_action.rb', line 28

def category_ids
  @category_ids
end

#current_actionObject

Returns the value of attribute current_action.



9
10
11
# File 'app/models/effective/registrar_action.rb', line 9

def current_action
  @current_action
end

#current_userObject

All Actions



8
9
10
# File 'app/models/effective/registrar_action.rb', line 8

def current_user
  @current_user
end

#membership_numberObject

Returns the value of attribute membership_number.



17
18
19
# File 'app/models/effective/registrar_action.rb', line 17

def membership_number
  @membership_number
end

#note_internalObject

Returns the value of attribute note_internal.



36
37
38
# File 'app/models/effective/registrar_action.rb', line 36

def note_internal
  @note_internal
end

#note_to_buyerObject

Returns the value of attribute note_to_buyer.



35
36
37
# File 'app/models/effective/registrar_action.rb', line 35

def note_to_buyer
  @note_to_buyer
end

#ownerObject

Returns the value of attribute owner.



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

def owner
  @owner
end

#owner_idObject

Returns the value of attribute owner_id.



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

def owner_id
  @owner_id
end

#owner_typeObject

Returns the value of attribute owner_type.



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

def owner_type
  @owner_type
end

#payment_cardObject

Returns the value of attribute payment_card.



33
34
35
# File 'app/models/effective/registrar_action.rb', line 33

def payment_card
  @payment_card
end

#payment_providerObject

Mark Fees Paid - Order Attributes



32
33
34
# File 'app/models/effective/registrar_action.rb', line 32

def payment_provider
  @payment_provider
end

#purchased_atObject

Returns the value of attribute purchased_at.



34
35
36
# File 'app/models/effective/registrar_action.rb', line 34

def purchased_at
  @purchased_at
end

#skip_feesObject

Reinstate



21
22
23
# File 'app/models/effective/registrar_action.rb', line 21

def skip_fees
  @skip_fees
end

#status_idObject

Register



13
14
15
# File 'app/models/effective/registrar_action.rb', line 13

def status_id
  @status_id
end

#status_idsObject

Status Change



24
25
26
# File 'app/models/effective/registrar_action.rb', line 24

def status_ids
  @status_ids
end

Instance Method Details

#assign!Object



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

def assign!
  update!(current_action: :assign)
  EffectiveMemberships.Registrar.assign!(owner, categories: categories, statuses: statuses, number: number)
end

#assign_attributes(atts) ⇒ Object



100
101
102
# File 'app/models/effective/registrar_action.rb', line 100

def assign_attributes(atts)
  super(atts.reject { |k, _| k.to_s.start_with?('status_remove_action_') })
end

#categoriesObject



128
129
130
# File 'app/models/effective/registrar_action.rb', line 128

def categories
  EffectiveMemberships.Category.where(id: @category_ids) if @category_ids.present?
end

#categoryObject



124
125
126
# File 'app/models/effective/registrar_action.rb', line 124

def category
  EffectiveMemberships.Category.find(@category_id) if @category_id.present?
end

#fees_paid!Object



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

def fees_paid!
  update!(current_action: :fees_paid)
  EffectiveMemberships.Registrar.fees_paid!(owner, order_attributes: order_attributes)
end

#numberObject



140
141
142
# File 'app/models/effective/registrar_action.rb', line 140

def number
  membership_number.presence
end

#order_attributesObject



144
145
146
147
148
149
150
151
152
# File 'app/models/effective/registrar_action.rb', line 144

def order_attributes
  {
    payment_provider: @payment_provider.presence,
    payment_card: @payment_card.presence,
    purchased_at: @purchased_at.presence,
    note_to_buyer: @note_to_buyer.presence,
    note_internal: @note_internal.presence
  }.compact
end

#reclassify!Object



65
66
67
68
# File 'app/models/effective/registrar_action.rb', line 65

def reclassify!
  update!(current_action: :reclassify)
  EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?)
end

#register!Object



60
61
62
63
# File 'app/models/effective/registrar_action.rb', line 60

def register!
  update!(current_action: :register)
  EffectiveMemberships.Registrar.register!(owner, to: category, status: status, number: number, skip_fees: skip_fees?)
end

#reinstate!Object



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

def reinstate!
  update!(current_action: :reinstate)
  EffectiveMemberships.Registrar.reinstate!(owner, skip_fees: skip_fees?)
end

#remove!Object



95
96
97
98
# File 'app/models/effective/registrar_action.rb', line 95

def remove!
  update!(current_action: :remove)
  EffectiveMemberships.Registrar.remove!(owner, statuses: statuses)
end

#save!Object



108
109
110
# File 'app/models/effective/registrar_action.rb', line 108

def save!
  valid? ? true : raise('invalid')
end

#skip_fees?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'app/models/effective/registrar_action.rb', line 154

def skip_fees?
  EffectiveResources.truthy?(@skip_fees)
end

#statusObject



132
133
134
# File 'app/models/effective/registrar_action.rb', line 132

def status
  EffectiveMemberships.Status.find(@status_id) if @status_id.present?
end

#status_assign!Object



75
76
77
78
# File 'app/models/effective/registrar_action.rb', line 75

def status_assign!
  update!(current_action: :status_assign)
  EffectiveMemberships.Registrar.status_assign!(owner, status: statuses)
end

#status_remove!Object



80
81
82
83
# File 'app/models/effective/registrar_action.rb', line 80

def status_remove!
  update!(current_action: :status_remove)
  EffectiveMemberships.Registrar.status_remove!(owner, status: status)
end

#statusesObject



136
137
138
# File 'app/models/effective/registrar_action.rb', line 136

def statuses
  EffectiveMemberships.Status.where(id: @status_ids) if @status_ids.present?
end

#to_sObject



56
57
58
# File 'app/models/effective/registrar_action.rb', line 56

def to_s
  'action'
end

#update!(atts) ⇒ Object



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

def update!(atts)
  assign_attributes(atts); save!
end