effective_products 0.0.6 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- 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_ring_wizard.rb +1 -2
- data/app/models/concerns/effective_products_stamp_wizard.rb +8 -3
- data/app/models/effective/stamp.rb +50 -9
- 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: 33912b031a749bc69286e6d5d04a85a67c930237b426389f0fbe890a05707e18
|
4
|
+
data.tar.gz: f2ab6eaf54d5c407ab891370ceaec1d1d25d659730e12c5dd2ad9b5fb3ac7ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a258133393608311a4044c421905b90e511af529ba465ba59173482722e01c63d06958434b7ee2d038a955c26205825fbb2b994e23460503ac61545a2e330c2
|
7
|
+
data.tar.gz: 1a6ba5a8f9de60dab801d4c5eb7ad871d3a00e0fe9cc58b25fa751d25c6b2a154ca2eb2880c8dc566556aabe183a15737fccd64905e34a1087bb0b066414d9d2
|
@@ -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
|
@@ -110,9 +110,8 @@ module EffectiveProductsRingWizard
|
|
110
110
|
|
111
111
|
def build_ring
|
112
112
|
ring = rings.build(owner: owner)
|
113
|
-
address = owner.try(:shipping_address) || owner.try(:billing_address)
|
114
113
|
|
115
|
-
if address.present?
|
114
|
+
if (address = owner.try(:shipping_address) || owner.try(:billing_address)).present?
|
116
115
|
ring.shipping_address = address
|
117
116
|
end
|
118
117
|
|
@@ -86,7 +86,7 @@ module EffectiveProductsStampWizard
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def after_submit_purchased!
|
89
|
-
|
89
|
+
stamps.each { |stamp| stamp.submit! }
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
@@ -109,8 +109,13 @@ module EffectiveProductsStampWizard
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def build_stamp
|
112
|
-
|
113
|
-
|
112
|
+
stamp = stamps.build(owner: owner)
|
113
|
+
|
114
|
+
if (address = owner.try(:shipping_address) || owner.try(:billing_address)).present?
|
115
|
+
stamp.shipping_address = address
|
116
|
+
end
|
117
|
+
|
118
|
+
stamp
|
114
119
|
end
|
115
120
|
|
116
121
|
def assign_pricing
|
@@ -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(status: :issued)
|
56
|
+
}
|
39
57
|
|
40
58
|
validates :category, presence: true, inclusion: { in: CATEGORIES }
|
41
59
|
validates :name, presence: true
|
@@ -54,16 +72,39 @@ module Effective
|
|
54
72
|
end
|
55
73
|
|
56
74
|
def mark_as_issued!
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def issued?
|
61
|
-
issued_at.present?
|
75
|
+
issued!
|
62
76
|
end
|
63
77
|
|
64
78
|
def physical?
|
65
79
|
category == 'Physical'
|
66
80
|
end
|
67
81
|
|
82
|
+
def created_by_admin?
|
83
|
+
stamp_wizard_id.blank? && applicant_id.blank?
|
84
|
+
end
|
85
|
+
|
86
|
+
# Called by an application when submitted
|
87
|
+
# Called by a stamp wizard when submitted
|
88
|
+
def submit!
|
89
|
+
raise('expected a purchased order') unless purchased?
|
90
|
+
submitted!
|
91
|
+
end
|
92
|
+
|
93
|
+
# This is the Admin Save and Mark Paid action
|
94
|
+
def mark_paid!
|
95
|
+
raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
|
96
|
+
|
97
|
+
category = owner.membership.categories.first
|
98
|
+
|
99
|
+
assign_attributes(
|
100
|
+
price: category.stamp_fee,
|
101
|
+
tax_exempt: category.stamp_fee_tax_exempt,
|
102
|
+
qb_item_name: category.stamp_fee_qb_item_name
|
103
|
+
)
|
104
|
+
|
105
|
+
save!
|
106
|
+
Effective::Order.new(items: self, user: owner).mark_as_purchased!
|
107
|
+
end
|
108
|
+
|
68
109
|
end
|
69
110
|
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.9
|
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-03-09 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
|