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

#bad_standing_reasonObject

Bad Standing



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

def bad_standing_reason
  @bad_standing_reason
end

#category_idObject

Reclassify & Register



19
20
21
# File 'app/models/effective/registrar_action.rb', line 19

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.



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

def membership_number
  @membership_number
end

#note_internalObject

Returns the value of attribute note_internal.



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

def note_internal
  @note_internal
end

#note_to_buyerObject

Returns the value of attribute note_to_buyer.



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

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

#skip_feesObject

Returns the value of attribute skip_fees.



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

def skip_fees
  @skip_fees
end

#status_idObject

Register



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

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



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

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

#assign_attributes(atts) ⇒ Object



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

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

#bad_standing!Object



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

def bad_standing!
  update!(current_action: :bad_standing)
  EffectiveMemberships.Registrar.bad_standing!(owner, reason: bad_standing_reason)
end

#categoriesObject



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

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

#categoryObject



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

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

#fees_paid!Object



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

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

#good_standing!Object



87
88
89
90
# File 'app/models/effective/registrar_action.rb', line 87

def good_standing!
  update!(current_action: :good_standing)
  EffectiveMemberships.Registrar.good_standing!(owner)
end

#numberObject



147
148
149
# File 'app/models/effective/registrar_action.rb', line 147

def number
  membership_number.presence
end

#order_attributesObject



151
152
153
154
155
156
157
158
# File 'app/models/effective/registrar_action.rb', line 151

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

#reclassify!Object



67
68
69
70
# File 'app/models/effective/registrar_action.rb', line 67

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

#register!Object



62
63
64
65
# File 'app/models/effective/registrar_action.rb', line 62

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

#remove!Object



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

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

#save!Object



115
116
117
# File 'app/models/effective/registrar_action.rb', line 115

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

#skip_fees?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'app/models/effective/registrar_action.rb', line 160

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

#statusObject



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

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

#status_assign!Object



72
73
74
75
# File 'app/models/effective/registrar_action.rb', line 72

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

#status_remove!Object



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

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

#statusesObject



143
144
145
# File 'app/models/effective/registrar_action.rb', line 143

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

#to_sObject



58
59
60
# File 'app/models/effective/registrar_action.rb', line 58

def to_s
  'action'
end

#update!(atts) ⇒ Object



111
112
113
# File 'app/models/effective/registrar_action.rb', line 111

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