effective_products 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/admin/stamps_controller.rb +2 -0
- data/app/datatables/admin/effective_stamps_datatable.rb +13 -4
- data/app/models/concerns/effective_products_stamp_wizard.rb +1 -1
- data/app/models/effective/stamp.rb +53 -8
- data/app/views/admin/stamps/_form.html.haml +12 -0
- data/app/views/effective/stamps/_fields.html.haml +11 -0
- data/config/routes.rb +1 -1
- data/db/migrate/01_create_effective_products.rb.erb +6 -0
- data/lib/effective_products/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36f1b24a9da60c9e39f6d27fd085283bd0f5b061f80c14a53f7a4a59edb1d31a
|
4
|
+
data.tar.gz: 713caaaaa536356ede62d6d207166a8861190bb3d8ea41c16296637f49033c84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bc5e5606f1fe01fde2bc06429ba9f4813a0f6115cfafaa7fa657aaee71c4440f61a00bf523446a4b82af4e2513bf5593c19801030f50e1d7f82aafd87bddead
|
7
|
+
data.tar.gz: aa6f08d926456c04c97f34b7ad4d53b26e021339a98c3e54781ce3475056771b22ec46063d6daf0a47af990362c7e1d84213bc5392c07725673e71f3cf44db7c
|
@@ -16,8 +16,9 @@ module Admin
|
|
16
16
|
col :created_at, as: :date
|
17
17
|
col :owner, search: :string
|
18
18
|
|
19
|
-
col
|
20
|
-
col
|
19
|
+
col :applicant, visible: false
|
20
|
+
col :stamp_wizard, visible: false
|
21
|
+
|
21
22
|
col(:email) { |stamp| stamp.owner.email }
|
22
23
|
col(:phone) { |stamp| stamp.owner.phone }
|
23
24
|
|
@@ -25,12 +26,20 @@ module Admin
|
|
25
26
|
stamp.owner.try(:membership).try(:number)
|
26
27
|
end
|
27
28
|
|
28
|
-
col :category
|
29
29
|
col :name
|
30
|
-
col :name_confirmation
|
30
|
+
col :name_confirmation, visible: false
|
31
|
+
|
32
|
+
col :category, visible: false
|
31
33
|
|
32
34
|
col :shipping_address, label: 'Address'
|
33
35
|
|
36
|
+
col :purchased_order, visible: false
|
37
|
+
col :price, visible: false
|
38
|
+
col :tax_exempt, visible: false
|
39
|
+
col :qb_item_name, visible: false
|
40
|
+
|
41
|
+
col :status, visible: false
|
42
|
+
|
34
43
|
col :issued_at
|
35
44
|
|
36
45
|
actions_col
|
@@ -5,15 +5,24 @@ module Effective
|
|
5
5
|
acts_as_purchasable
|
6
6
|
acts_as_addressable :shipping
|
7
7
|
|
8
|
+
acts_as_statused(
|
9
|
+
:draft, # Built in an application
|
10
|
+
:submitted, # Submitted by an applicant or stamp wizard
|
11
|
+
:issued # Issued by an admin
|
12
|
+
)
|
13
|
+
|
8
14
|
#CATEGORIES = ['Physical', 'Digital-only']
|
9
15
|
CATEGORIES = ['Physical']
|
10
16
|
|
11
17
|
log_changes if respond_to?(:log_changes)
|
12
18
|
|
13
|
-
# This
|
19
|
+
# This stamp is charged to an owner
|
14
20
|
belongs_to :owner, polymorphic: true
|
15
21
|
|
16
|
-
#
|
22
|
+
# Sometimes a stamp is built through an applicant
|
23
|
+
belongs_to :applicant, polymorphic: true, optional: true
|
24
|
+
|
25
|
+
# Other times through the stamp_wizard
|
17
26
|
belongs_to :stamp_wizard, polymorphic: true, optional: true
|
18
27
|
|
19
28
|
effective_resource do
|
@@ -25,6 +34,10 @@ module Effective
|
|
25
34
|
# Admin issues stamps
|
26
35
|
issued_at :datetime # Present when issued by an admin
|
27
36
|
|
37
|
+
# Acts as Statused
|
38
|
+
status :string
|
39
|
+
status_steps :text
|
40
|
+
|
28
41
|
# Acts as Purchasable
|
29
42
|
price :integer
|
30
43
|
qb_item_name :string
|
@@ -34,8 +47,13 @@ module Effective
|
|
34
47
|
end
|
35
48
|
|
36
49
|
scope :deep, -> { includes(:owner) }
|
37
|
-
|
38
|
-
scope :
|
50
|
+
|
51
|
+
scope :with_approved_applicants, -> { where(applicant_id: EffectiveMemberships.Applicant.approved) }
|
52
|
+
scope :with_stamp_wizards, -> { where(applicant_id: nil).where.not(stamp_wizard_id: nil) }
|
53
|
+
|
54
|
+
scope :ready_to_issue, -> {
|
55
|
+
with_approved_applicants.or(with_stamp_wizards).purchased.where.not(issued_at: nil)
|
56
|
+
}
|
39
57
|
|
40
58
|
validates :category, presence: true, inclusion: { in: CATEGORIES }
|
41
59
|
validates :name, presence: true
|
@@ -53,17 +71,44 @@ module Effective
|
|
53
71
|
['Professional Stamp', *name.presence].join(' ')
|
54
72
|
end
|
55
73
|
|
56
|
-
def mark_as_issued!
|
57
|
-
update!(issued_at: Time.zone.now)
|
58
|
-
end
|
59
|
-
|
60
74
|
def issued?
|
61
75
|
issued_at.present?
|
62
76
|
end
|
63
77
|
|
78
|
+
def mark_as_issued!
|
79
|
+
issued!
|
80
|
+
end
|
81
|
+
|
64
82
|
def physical?
|
65
83
|
category == 'Physical'
|
66
84
|
end
|
67
85
|
|
86
|
+
def created_by_admin?
|
87
|
+
stamp_wizard_id.blank? && applicant_id.blank?
|
88
|
+
end
|
89
|
+
|
90
|
+
# Called by an application when submitted
|
91
|
+
# Called by a stamp wizard when submitted
|
92
|
+
def submit!
|
93
|
+
raise('expected a purchased order') unless purchased?
|
94
|
+
submitted!
|
95
|
+
end
|
96
|
+
|
97
|
+
# This is the Admin Save and Mark Paid action
|
98
|
+
def mark_paid!
|
99
|
+
raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
|
100
|
+
|
101
|
+
category = owner.membership.categories.first
|
102
|
+
|
103
|
+
assign_attributes(
|
104
|
+
price: category.stamp_fee,
|
105
|
+
tax_exempt: category.stamp_fee_tax_exempt,
|
106
|
+
qb_item_name: category.stamp_fee_qb_item_name
|
107
|
+
)
|
108
|
+
|
109
|
+
save!
|
110
|
+
Effective::Order.new(items: self, user: owner).mark_as_purchased!
|
111
|
+
end
|
112
|
+
|
68
113
|
end
|
69
114
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= effective_form_with(model: [:admin, stamp], engine: true) do |f|
|
2
|
+
- if f.object.new_record?
|
3
|
+
= f.select :owner, { 'Users' => current_user.class.members.sorted }, polymorphic: true
|
4
|
+
- else
|
5
|
+
= f.static_field :owner
|
6
|
+
|
7
|
+
= render 'effective/stamps/fields', f: f, stamp: f.object
|
8
|
+
|
9
|
+
- if f.object.new_record?
|
10
|
+
= f.submit 'Save and Mark Paid'
|
11
|
+
- else
|
12
|
+
= f.submit 'Save'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
= f.text_field :name
|
2
|
+
= f.text_field :name_confirmation, hint: 'must match name'
|
3
|
+
|
4
|
+
%h2 Stamp Information
|
5
|
+
|
6
|
+
%p Please select a stamp and enter a shipping address.
|
7
|
+
|
8
|
+
= f.select :category, Effective::Stamp::CATEGORIES
|
9
|
+
|
10
|
+
= f.show_if :category, 'Physical' do
|
11
|
+
= effective_address_fields(f, :shipping)
|
data/config/routes.rb
CHANGED
@@ -55,6 +55,12 @@ class CreateEffectiveProducts < ActiveRecord::Migration[6.1]
|
|
55
55
|
t.integer :stamp_wizard_id
|
56
56
|
t.string :stamp_wizard_type
|
57
57
|
|
58
|
+
t.integer :applicant_id
|
59
|
+
t.string :applicant_type
|
60
|
+
|
61
|
+
t.string :status
|
62
|
+
t.text :status_steps
|
63
|
+
|
58
64
|
t.string :category
|
59
65
|
t.string :name
|
60
66
|
t.string :name_confirmation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- app/models/effective/stamp.rb
|
238
238
|
- app/models/effective/stamp_wizard.rb
|
239
239
|
- app/views/admin/rings/_ring.html.haml
|
240
|
+
- app/views/admin/stamps/_form.html.haml
|
240
241
|
- app/views/admin/stamps/_stamp.html.haml
|
241
242
|
- app/views/effective/ring_wizards/_content.html.haml
|
242
243
|
- app/views/effective/ring_wizards/_dashboard.html.haml
|
@@ -266,6 +267,7 @@ files:
|
|
266
267
|
- app/views/effective/stamp_wizards/start.html.haml
|
267
268
|
- app/views/effective/stamp_wizards/submitted.html.haml
|
268
269
|
- app/views/effective/stamp_wizards/summary.html.haml
|
270
|
+
- app/views/effective/stamps/_fields.html.haml
|
269
271
|
- config/effective_products.rb
|
270
272
|
- config/routes.rb
|
271
273
|
- db/migrate/01_create_effective_products.rb.erb
|