ish_manager 0.1.8.460 → 0.1.8.462
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/assets/stylesheets/ish_manager/application.scss +2 -0
- data/app/assets/stylesheets/ish_manager/products.scss +9 -0
- data/app/assets/stylesheets/ish_manager/subscriptions.scss +6 -0
- data/app/controllers/ish_manager/application_controller.rb +20 -0
- data/app/controllers/ish_manager/invoices_controller.rb +57 -5
- data/app/controllers/ish_manager/iro_option_gets_controller.rb +100 -57
- data/app/controllers/ish_manager/leadsets_controller.rb +3 -1
- data/app/controllers/ish_manager/prices_controller.rb +15 -0
- data/app/controllers/ish_manager/products_controller.rb +54 -26
- data/app/controllers/ish_manager/subscriptions_controller.rb +51 -22
- data/app/views/ish_manager/appliances/_index.haml +2 -1
- data/app/views/ish_manager/application/_alerts_notices.haml +12 -2
- data/app/views/ish_manager/application/_main_header_admin.haml +2 -1
- data/app/views/ish_manager/application/home.haml +8 -0
- data/app/views/ish_manager/galleries/index_titles.haml +1 -1
- data/app/views/ish_manager/invoices/_index_list.haml +6 -0
- data/app/views/ish_manager/invoices/_index_table.haml +20 -0
- data/app/views/ish_manager/invoices/index.haml +1 -29
- data/app/views/ish_manager/invoices/new_pdf.haml +4 -1
- data/app/views/ish_manager/invoices/new_stripe.haml +31 -28
- data/app/views/ish_manager/iro_watches/max_pain.haml +11 -15
- data/app/views/ish_manager/leads/show.haml +2 -1
- data/app/views/ish_manager/leadsets/show.haml +28 -6
- data/app/views/ish_manager/meetings/index.haml +1 -1
- data/app/views/ish_manager/payments/index.haml +1 -1
- data/app/views/ish_manager/products/_form.haml +4 -4
- data/app/views/ish_manager/products/_index_list.haml +10 -0
- data/app/views/ish_manager/products/_index_table.haml +20 -0
- data/app/views/ish_manager/products/index.haml +19 -15
- data/app/views/ish_manager/serverhosts/_index.haml +1 -2
- data/app/views/ish_manager/subscriptions/_form.haml +10 -2
- data/app/views/ish_manager/subscriptions/index.haml +15 -3
- data/app/views/ish_manager/subscriptions/new.haml +1 -1
- data/app/views/ish_manager/subscriptions/new_stripe.haml +4 -0
- data/app/views/ish_manager/subscriptions/new_wco.haml +4 -0
- data/app/views/ish_manager/subscriptions/show.haml +4 -0
- data/config/routes.rb +10 -5
- metadata +25 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d544fb840059764a4d3c9c557416c0ec338ca5ce9f2e109aff72bc3743e844a6
|
|
4
|
+
data.tar.gz: 82efc85b76bde5801fb399907e341d0f944f7813d4800a569f5e6109d3572878
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a308e33cb23380dcc77f7b7518cfde43587d3f2260745dd9c808990c9acbefa9412a52e13e8341da39cc3b17f467957426590366927c5f1431740d54f3ffc80
|
|
7
|
+
data.tar.gz: 49c3077ff88f4139b3bc2a25f57202b21ae0f26784dca13eb486f24c1a0e7a02bbb12f1c593a04ff4da571d24523f7c348f942e7cfdfa437d00e830f8bb0223f
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
*= require ish_manager/markers
|
|
21
21
|
*= require ish_manager/office
|
|
22
22
|
*= require ish_manager/pagination
|
|
23
|
+
*= require ish_manager/products
|
|
23
24
|
*= require ish_manager/photos
|
|
24
25
|
*= require ish_manager/scheduled_email_actions
|
|
26
|
+
*= require ish_manager/subscriptions
|
|
25
27
|
*= require ish_manager/tags
|
|
26
28
|
*= require ish_manager/user_profiles
|
|
27
29
|
*= require ish_manager/videos
|
|
@@ -50,6 +50,26 @@ class IshManager::ApplicationController < ActionController::Base
|
|
|
50
50
|
JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def flash_alert what
|
|
54
|
+
flash[:alert] ||= []
|
|
55
|
+
if String == what.class
|
|
56
|
+
str = what
|
|
57
|
+
else
|
|
58
|
+
str = "Cannot create/update #{what.class.name}: #{what.errors.full_messages.join(', ')} ."
|
|
59
|
+
end
|
|
60
|
+
flash[:alert] << str
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def flash_notice what
|
|
64
|
+
flash[:notice] ||= []
|
|
65
|
+
if String == what.class
|
|
66
|
+
str = what
|
|
67
|
+
else
|
|
68
|
+
str = "Created/updated #{what.class.name} ."
|
|
69
|
+
end
|
|
70
|
+
flash[:notice] << str
|
|
71
|
+
end
|
|
72
|
+
|
|
53
73
|
def my_truthy? which
|
|
54
74
|
["1", "t", "T", "true"].include?( which )
|
|
55
75
|
end
|
|
@@ -1,14 +1,66 @@
|
|
|
1
|
+
require 'prawn'
|
|
1
2
|
|
|
2
3
|
class ::IshManager::InvoicesController < IshManager::ApplicationController
|
|
3
4
|
|
|
4
5
|
before_action :set_lists
|
|
5
6
|
|
|
7
|
+
##
|
|
8
|
+
## Prawn/pdf unit of measure is 1/72" .
|
|
9
|
+
##
|
|
6
10
|
def create_pdf
|
|
7
11
|
@invoice = Ish::Invoice.new
|
|
8
12
|
authorize! :new, @invoice
|
|
9
13
|
|
|
14
|
+
tree_img_url = "https://wasya.co/wp-content/uploads/2023/09/tree-1.jpg"
|
|
15
|
+
tree_img_url = "#{Rails.root.join('public')}/tree-1.jpg"
|
|
16
|
+
wasya_co_logo_url = "#{Rails.root.join('public')}/259x66-WasyaCo-logo.png"
|
|
17
|
+
|
|
18
|
+
## canvas width: 612, height: 792
|
|
10
19
|
pdf = Prawn::Document.new
|
|
11
|
-
|
|
20
|
+
|
|
21
|
+
pdf.canvas do
|
|
22
|
+
pdf.image tree_img_url, at: [ 0, 792 ], width: 612
|
|
23
|
+
|
|
24
|
+
pdf.fill_color 'ffffff'
|
|
25
|
+
# pdf.stroke_color '000000'
|
|
26
|
+
pdf.transparent( 0.75 ) do
|
|
27
|
+
pdf.fill_rectangle [0, 792], 612, 792
|
|
28
|
+
end
|
|
29
|
+
pdf.fill_color '000000'
|
|
30
|
+
|
|
31
|
+
pdf.image wasya_co_logo_url, at: [252, 720], width: 108 ## 1.5"
|
|
32
|
+
|
|
33
|
+
pdf.bounding_box( [0.75*72, 9.5*72], width: 3.25*72, height: 0.75*72 ) do
|
|
34
|
+
pdf.stroke_bounds
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
pdf.bounding_box( [4.5*72, 9.5*72], width: 3.25*72, height: 0.75*72 ) do
|
|
38
|
+
pdf.stroke_bounds
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
pdf.bounding_box( [0.75*72, 8.5*72], width: 3.25*72, height: 0.75*72 ) do
|
|
42
|
+
pdf.stroke_bounds
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
pdf.bounding_box( [4.5*72, 8.5*72], width: 3.25*72, height: 0.75*72 ) do
|
|
46
|
+
pdf.stroke_bounds
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
pdf.make_table([ ['one'],
|
|
50
|
+
['two'],
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
pdf.text_box "Thank you!", at: [ 3.25*72, 1.25*72 ], width: 2*72, height: 1*72, align: :center
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# pdf.text "hello, world?", align: :center
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
12
64
|
|
|
13
65
|
filename = "a-summary.pdf"
|
|
14
66
|
path = Rails.root.join 'tmp', filename
|
|
@@ -22,8 +74,7 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
|
|
|
22
74
|
})
|
|
23
75
|
end
|
|
24
76
|
|
|
25
|
-
|
|
26
|
-
def create
|
|
77
|
+
def create_stripe
|
|
27
78
|
@invoice = Ish::Invoice.new params[:invoice].permit!
|
|
28
79
|
authorize! :create, @invoice
|
|
29
80
|
|
|
@@ -35,11 +86,12 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
|
|
|
35
86
|
pending_invoice_items_behavior: 'exclude',
|
|
36
87
|
})
|
|
37
88
|
params[:invoice][:items].each do |item|
|
|
38
|
-
stripe_price = Wco::Product.find( item ).price_id
|
|
89
|
+
stripe_price = Wco::Product.find( item[:product_id] ).price_id
|
|
39
90
|
invoice_item = Stripe::InvoiceItem.create({
|
|
40
91
|
customer: @invoice.leadset.customer_id,
|
|
41
92
|
price: stripe_price,
|
|
42
93
|
invoice: stripe_invoice.id,
|
|
94
|
+
quantity: item[:quantity],
|
|
43
95
|
})
|
|
44
96
|
end
|
|
45
97
|
Stripe::Invoice.send_invoice(stripe_invoice[:id])
|
|
@@ -71,7 +123,7 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
|
|
|
71
123
|
|
|
72
124
|
def new_stripe
|
|
73
125
|
authorize! :new, @invoice
|
|
74
|
-
@leadset
|
|
126
|
+
@leadset = Leadset.find params[:leadset_id]
|
|
75
127
|
@products_list = Wco::Product.list
|
|
76
128
|
end
|
|
77
129
|
|
|
@@ -16,57 +16,49 @@ class ::IshManager::IroOptionGetsController < IshManager::ApplicationController
|
|
|
16
16
|
redirect_to action: 'index', controller: 'ish_manager/iro_watches'
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
|
|
20
|
+
=begin
|
|
21
|
+
|
|
22
|
+
select t1.putCall, t1.symbol, t1.strikePrice, t1.openInterest, t1.created_at
|
|
23
|
+
from iro_option_price_items t1
|
|
24
|
+
join (
|
|
25
|
+
select symbol, max(created_at) as c1
|
|
26
|
+
from iro_option_price_items
|
|
27
|
+
where expirationDate = 1694808000000 and ticker = 'GME'
|
|
28
|
+
group by symbol ) as t2
|
|
29
|
+
on t1.symbol = t2.symbol and t1.created_at = t2.c1
|
|
30
|
+
order by t1.strikePrice, t1.created_at desc;
|
|
31
|
+
|
|
32
|
+
=end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
## Tda::Option.get_chain({ ticker: 'GME' })
|
|
37
|
+
##
|
|
38
|
+
## SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
|
|
39
|
+
## SET sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));
|
|
40
|
+
##
|
|
19
41
|
def max_pain
|
|
20
42
|
authorize! :max_pain, Iro::Iro
|
|
21
|
-
@ticker
|
|
22
|
-
|
|
23
|
-
@expirationDate
|
|
24
|
-
|
|
25
|
-
# expirationDate = '1690574400000'
|
|
26
|
-
@all_items = {}
|
|
27
|
-
|
|
28
|
-
calls_sql = " select distinct putCall, symbol, strikePrice, openInterest, max(created_at)
|
|
29
|
-
from iro_option_price_items
|
|
30
|
-
where expirationDate = #{@expirationDate} and putCall = 'CALL' and ticker = '#{@ticker}'
|
|
31
|
-
group by putCall, symbol, strikePrice, openInterest
|
|
32
|
-
order by strikePrice, max(created_at) desc; "
|
|
33
|
-
@calls_items = []
|
|
34
|
-
@calls_array = ActiveRecord::Base.connection.execute(calls_sql)
|
|
35
|
-
calls_subtotal = 0
|
|
36
|
-
@calls_array.each do |_item|
|
|
37
|
-
# puts! _item, 'item'
|
|
38
|
-
item = {
|
|
39
|
-
putCall: _item[0],
|
|
40
|
-
symbol: _item[1],
|
|
41
|
-
strikePrice: _item[2],
|
|
42
|
-
oi: _item[3],
|
|
43
|
-
created_at: _item[4],
|
|
44
|
-
}
|
|
45
|
-
# puts! item, 'item'
|
|
46
|
-
item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
|
|
47
|
-
calls_subtotal = calls_subtotal + item[:subtotal]
|
|
48
|
-
item[:total] = calls_subtotal
|
|
49
|
-
puts! item, 'item'
|
|
50
|
-
@calls_items.push( item )
|
|
43
|
+
@ticker = params[:ticker]
|
|
44
|
+
@expirationDate = ( params[:date].to_date + 15.hours ).to_time.to_i * 1000
|
|
45
|
+
# puts! @expirationDate, '@expirationDate'
|
|
46
|
+
@all_items = {}
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
sql = " select t1.putCall, t1.symbol, t1.strikePrice, t1.openInterest, t1.created_at
|
|
49
|
+
from iro_option_price_items t1
|
|
50
|
+
join (
|
|
51
|
+
select symbol, max(created_at) as c1
|
|
52
|
+
from iro_option_price_items
|
|
53
|
+
where expirationDate = #{@expirationDate} and ticker = '#{@ticker}'
|
|
54
|
+
group by symbol ) as t2
|
|
55
|
+
on t1.symbol = t2.symbol and t1.created_at = t2.c1
|
|
56
|
+
order by t1.strikePrice, t1.created_at desc;
|
|
57
|
+
"
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
group by putCall, symbol, strikePrice, openInterest, created_at
|
|
65
|
-
order by putCall, strikePrice, created_at desc;"
|
|
66
|
-
@puts_items = []
|
|
67
|
-
@puts_array = ActiveRecord::Base.connection.execute(puts_sql)
|
|
68
|
-
puts_subtotal = 0
|
|
69
|
-
@puts_array.each do |_item|
|
|
59
|
+
results_array = ActiveRecord::Base.connection.execute(sql)
|
|
60
|
+
results_array.each do |_item|
|
|
61
|
+
# puts! _item, '_item'
|
|
70
62
|
item = {
|
|
71
63
|
putCall: _item[0],
|
|
72
64
|
symbol: _item[1],
|
|
@@ -74,20 +66,71 @@ class ::IshManager::IroOptionGetsController < IshManager::ApplicationController
|
|
|
74
66
|
oi: _item[3],
|
|
75
67
|
created_at: _item[4],
|
|
76
68
|
}
|
|
77
|
-
item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
|
|
78
|
-
puts_subtotal = puts_subtotal + item[:subtotal]
|
|
79
|
-
item[:total] = puts_subtotal
|
|
80
|
-
puts! item, 'item'
|
|
81
|
-
@puts_items.push( item )
|
|
82
69
|
@all_items[item[:strikePrice]] ||= {
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
strike_price: item[:strikePrice],
|
|
71
|
+
call_max_pain: 0,
|
|
72
|
+
put_max_pain: 0,
|
|
85
73
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
if 'CALL' == item[:putCall]
|
|
75
|
+
@all_items[item[:strikePrice]][:call_oi] = item[:oi]
|
|
76
|
+
else
|
|
77
|
+
@all_items[item[:strikePrice]][:put_oi] = item[:oi]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
@all_items.each_with_index do |_item, idx|
|
|
82
|
+
strike_price = _item[0]
|
|
83
|
+
item = _item[1]
|
|
84
|
+
# break if idx > 3
|
|
85
|
+
# puts! item, 'item'
|
|
86
|
+
|
|
87
|
+
@all_items.each do |next_strike_price, next_item|
|
|
88
|
+
if next_strike_price < strike_price
|
|
89
|
+
if next_item[:call_oi] > 0
|
|
90
|
+
@all_items[strike_price][:call_max_pain] += 100 * next_item[:call_oi] * (strike_price - next_strike_price)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if next_strike_price > strike_price
|
|
95
|
+
if next_item[:put_oi] > 0
|
|
96
|
+
@all_items[strike_price][:put_max_pain] += 100 * next_item[:put_oi] * (next_strike_price - strike_price)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
89
102
|
end
|
|
90
103
|
|
|
104
|
+
# puts_sql = "select putCall, symbol, strikePrice, openInterest, created_at
|
|
105
|
+
# from iro_option_price_items
|
|
106
|
+
# where expirationDate = #{@expirationDate} and putCall = 'PUT' and ticker = '#{@ticker}'
|
|
107
|
+
# group by putCall, symbol, strikePrice, openInterest, created_at
|
|
108
|
+
# order by putCall, strikePrice, created_at desc;"
|
|
109
|
+
# @puts_items = []
|
|
110
|
+
# @puts_array = ActiveRecord::Base.connection.execute(puts_sql)
|
|
111
|
+
# puts_subtotal = 0
|
|
112
|
+
# @puts_array.each do |_item|
|
|
113
|
+
# item = {
|
|
114
|
+
# putCall: _item[0],
|
|
115
|
+
# symbol: _item[1],
|
|
116
|
+
# strikePrice: _item[2],
|
|
117
|
+
# oi: _item[3],
|
|
118
|
+
# created_at: _item[4],
|
|
119
|
+
# }
|
|
120
|
+
# item[:subtotal] = item[:strikePrice] * 100 * item[:oi]
|
|
121
|
+
# puts_subtotal = puts_subtotal + item[:subtotal]
|
|
122
|
+
# item[:total] = puts_subtotal
|
|
123
|
+
# puts! item, 'item'
|
|
124
|
+
# @puts_items.push( item )
|
|
125
|
+
# @all_items[item[:strikePrice]] ||= {
|
|
126
|
+
# subtotal: 0,
|
|
127
|
+
# strikePrice: item[:strikePrice],
|
|
128
|
+
# }
|
|
129
|
+
# @all_items[item[:strikePrice]][:puts_subtotal] = puts_subtotal
|
|
130
|
+
# @all_items[item[:strikePrice]][:puts_oi] = item[:oi]
|
|
131
|
+
# @all_items[item[:strikePrice]][:subtotal] = @all_items[item[:strikePrice]][:subtotal] + puts_subtotal
|
|
132
|
+
# end
|
|
133
|
+
|
|
91
134
|
|
|
92
135
|
render 'ish_manager/iro_watches/max_pain'
|
|
93
136
|
end
|
|
@@ -57,7 +57,9 @@ class ::IshManager::LeadsetsController < IshManager::ApplicationController
|
|
|
57
57
|
@email_contexts[lead.email] = lead.email_contexts
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
@employees
|
|
60
|
+
@employees = @leadset.employees.page( params[:leads_page] ).per( current_profile.per_page )
|
|
61
|
+
@subscriptions = @leadset.subscriptions
|
|
62
|
+
@invoices = @leadset.invoices
|
|
61
63
|
end
|
|
62
64
|
|
|
63
65
|
def update
|
|
@@ -3,37 +3,48 @@ class IshManager::ProductsController < IshManager::ApplicationController
|
|
|
3
3
|
|
|
4
4
|
before_action :set_lists
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Alphabetized : )
|
|
7
7
|
|
|
8
8
|
def create
|
|
9
|
-
@product = Wco::Product.new params[:product].permit
|
|
9
|
+
@product = Wco::Product.new params[:product].permit( :name )
|
|
10
|
+
@price = Wco::Price.new params[:price].permit( :amount_cents, :interval )
|
|
10
11
|
authorize! :create, @product
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
if !params[:price][:interval].present?
|
|
14
|
+
@price.interval = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
stripe_product = Stripe::Product.create({ name: @product.name })
|
|
18
|
+
# puts! stripe_product, 'stripe_product'
|
|
19
|
+
flash_notice 'Created stripe product.'
|
|
20
|
+
@product.product_id = stripe_product[:id]
|
|
21
|
+
|
|
22
|
+
if @product.save
|
|
23
|
+
flash_notice 'Created wco product.'
|
|
24
|
+
else
|
|
25
|
+
flash_alert "Cannot create wco product: #{@product.errors.full_messages.join(', ')}."
|
|
26
|
+
end
|
|
14
27
|
|
|
15
28
|
price_hash = {
|
|
16
|
-
product:
|
|
17
|
-
unit_amount:
|
|
18
|
-
currency:
|
|
29
|
+
product: stripe_product.id,
|
|
30
|
+
unit_amount: @price.amount_cents,
|
|
31
|
+
currency: 'usd',
|
|
19
32
|
}
|
|
20
|
-
if
|
|
21
|
-
price_hash[:recurring] = { interval:
|
|
33
|
+
if @price.interval.present?
|
|
34
|
+
price_hash[:recurring] = { interval: @price.interval }
|
|
22
35
|
end
|
|
23
36
|
stripe_price = Stripe::Price.create( price_hash )
|
|
24
|
-
puts! stripe_price, 'stripe_price'
|
|
25
|
-
|
|
26
|
-
@product
|
|
27
|
-
@
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if flag
|
|
31
|
-
flash[:notice] = 'Created the product.'
|
|
32
|
-
redirect_to action: :index
|
|
37
|
+
# puts! stripe_price, 'stripe_price'
|
|
38
|
+
flash_notice 'Created stripe price.'
|
|
39
|
+
@price.product = @product
|
|
40
|
+
@price.price_id = stripe_price[:id]
|
|
41
|
+
if @price.save
|
|
42
|
+
flash_notice @price
|
|
33
43
|
else
|
|
34
|
-
|
|
35
|
-
render action: :index
|
|
44
|
+
flash_alert @price
|
|
36
45
|
end
|
|
46
|
+
|
|
47
|
+
redirect_to action: :index
|
|
37
48
|
end
|
|
38
49
|
|
|
39
50
|
def destroy
|
|
@@ -60,25 +71,42 @@ class IshManager::ProductsController < IshManager::ApplicationController
|
|
|
60
71
|
|
|
61
72
|
def index
|
|
62
73
|
authorize! :index, Wco::Product
|
|
63
|
-
@stripe_products = {}
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
Stripe.api_version = '2020-08-27'
|
|
75
|
+
@stripe_products = {}
|
|
67
76
|
@_stripe_products = Stripe::Product.list().data
|
|
68
|
-
@_stripe_prices
|
|
77
|
+
@_stripe_prices = Stripe::Price.list().data
|
|
69
78
|
|
|
70
79
|
@_stripe_products.each do |sp|
|
|
71
80
|
@stripe_products[sp[:id]] = sp
|
|
72
81
|
@stripe_products[sp[:id]][:prices] ||= {}
|
|
73
82
|
end
|
|
74
83
|
@_stripe_prices.each do |price|
|
|
75
|
-
|
|
84
|
+
begin
|
|
85
|
+
@stripe_products[price[:product]][:prices][price[:id]] = price
|
|
86
|
+
rescue Exception
|
|
87
|
+
nil
|
|
88
|
+
end
|
|
76
89
|
end
|
|
77
90
|
|
|
78
|
-
@
|
|
91
|
+
@wco_products = Wco::Product.all.includes( :prices )
|
|
92
|
+
@wco_products.each do |item|
|
|
93
|
+
if @stripe_products[item[:product_id]]
|
|
94
|
+
@stripe_products[item[:product_id]][:wco_product] = item
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
## 2023-09-07 @TODO: move to model:
|
|
99
|
+
## @wco_prices_hash = Wco::Price.all.hash_by( :price_id )
|
|
100
|
+
##
|
|
101
|
+
@wco_prices_hash = {}
|
|
102
|
+
@wco_prices = Wco::Price.all
|
|
103
|
+
@wco_prices.each do |item|
|
|
104
|
+
@wco_prices_hash[item[:price_id]] = item
|
|
105
|
+
end
|
|
79
106
|
|
|
80
107
|
end
|
|
81
108
|
|
|
109
|
+
|
|
82
110
|
def show
|
|
83
111
|
authorize! :show, @product
|
|
84
112
|
@product = Wco::Product.find params[:id]
|
|
@@ -5,42 +5,51 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
|
5
5
|
|
|
6
6
|
## Alphabetized : )
|
|
7
7
|
|
|
8
|
+
##
|
|
9
|
+
## A stripe subscription is currently single-item only.
|
|
10
|
+
##
|
|
8
11
|
def create
|
|
9
12
|
@subscription = Wco::Subscription.new params[:subscription].permit!
|
|
10
13
|
authorize! :create, @subscription
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
@subscription.leadset_id = Leadset.where({ customer_id: params[:subscription][:customer_id] }).first&.id
|
|
16
|
+
@subscription.price = Wco::Price.find_by price_id: params[:subscription][:price_id]
|
|
17
|
+
@subscription.product = @subscription.price.product
|
|
18
|
+
|
|
19
|
+
if params[:is_stripe]
|
|
20
|
+
payment_methods = Stripe::Customer.list_payment_methods( params[:subscription][:customer_id] ).data
|
|
21
|
+
params = {
|
|
22
|
+
customer: params[:subscription][:customer_id],
|
|
23
|
+
default_payment_method: payment_methods[0][:id],
|
|
24
|
+
items: [
|
|
25
|
+
{ price: params[:subscription][:price_id],
|
|
26
|
+
quantity: params[:subscription][:quantity],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}
|
|
30
|
+
@stripe_subscription = Stripe::Subscription.create( params )
|
|
31
|
+
flash_notice @stripe_subscription
|
|
32
|
+
end
|
|
25
33
|
|
|
26
34
|
|
|
27
35
|
flag = @subscription.save
|
|
28
36
|
if flag
|
|
29
|
-
|
|
37
|
+
flash_notice @subscription
|
|
30
38
|
redirect_to action: :show, id: @subscription.id
|
|
31
39
|
else
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
flash_alert @subscription
|
|
41
|
+
redirect_to action: :new
|
|
34
42
|
end
|
|
35
43
|
end
|
|
36
44
|
|
|
45
|
+
|
|
37
46
|
def index
|
|
38
47
|
authorize! :index, Wco::Subscription
|
|
39
48
|
|
|
40
49
|
@stripe_customers = Stripe::Customer.list().data
|
|
41
50
|
@stripe_subscriptions = Stripe::Subscription.list().data
|
|
42
51
|
|
|
43
|
-
@customers = {}
|
|
52
|
+
@customers = {} ## still stripe customers
|
|
44
53
|
customer_ids = @stripe_customers.map &:id
|
|
45
54
|
@leadsets = Leadset.where( :customer_id.in => customer_ids )
|
|
46
55
|
@leadsets.each do |i|
|
|
@@ -54,8 +63,10 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
|
54
63
|
@customers[i[:customer_id]][:profiles] ||= []
|
|
55
64
|
@customers[i[:customer_id]][:profiles].push( i )
|
|
56
65
|
end
|
|
57
|
-
|
|
58
66
|
# puts! @customers, '@customers'
|
|
67
|
+
|
|
68
|
+
@wco_subscriptions = Wco::Subscription.all
|
|
69
|
+
|
|
59
70
|
end
|
|
60
71
|
|
|
61
72
|
def new
|
|
@@ -63,6 +74,16 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
|
63
74
|
authorize! :new, @subscription
|
|
64
75
|
end
|
|
65
76
|
|
|
77
|
+
def new_stripe
|
|
78
|
+
@subscription = Wco::Subscription.new
|
|
79
|
+
authorize! :new, @subscription
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def new_wco
|
|
83
|
+
@subscription = Wco::Subscription.new
|
|
84
|
+
authorize! :new, @subscription
|
|
85
|
+
end
|
|
86
|
+
|
|
66
87
|
def show
|
|
67
88
|
@subscription = Wco::Subscription.find params[:id]
|
|
68
89
|
authorize! :show, @subscription
|
|
@@ -75,11 +96,19 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
|
75
96
|
|
|
76
97
|
def set_lists
|
|
77
98
|
super
|
|
78
|
-
@products_list
|
|
79
|
-
leadsets = Leadset.where( "customer_id IS NOT NULL"
|
|
80
|
-
profiles = ::Ish::UserProfile.where( :customer_id.ne => nil ).map { |i| [ "profile
|
|
99
|
+
@products_list = Wco::Product.list
|
|
100
|
+
leadsets = Leadset.where( "customer_id IS NOT NULL" ).map { |i| [ "leadset // #{i.company_url} (#{i.email})", i.customer_id ] }
|
|
101
|
+
profiles = ::Ish::UserProfile.where( :customer_id.ne => nil ).map { |i| [ "profile // #{i.email}", i.customer_id ] }
|
|
81
102
|
@customer_ids_list = leadsets + profiles
|
|
82
|
-
@price_ids_list
|
|
103
|
+
@price_ids_list = Wco::Product.all.includes( :prices ).map do |i|
|
|
104
|
+
price = i.prices[0]
|
|
105
|
+
if price&.price_id
|
|
106
|
+
puts! price.interval, 'price.interval'
|
|
107
|
+
[ "#{i.name} // $#{price.amount_cents.to_f/100}/#{price.interval||'onetime'}", price.price_id ]
|
|
108
|
+
else
|
|
109
|
+
[ "#{i.name} - no price!!!", nil ]
|
|
110
|
+
end
|
|
111
|
+
end
|
|
83
112
|
end
|
|
84
113
|
|
|
85
114
|
end
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
.row.max-width
|
|
3
3
|
.col-sm-12
|
|
4
|
-
- if notice
|
|
4
|
+
- if notice&.class == String
|
|
5
5
|
.notice
|
|
6
6
|
= notice
|
|
7
7
|
.close [x]
|
|
8
|
-
- if
|
|
8
|
+
- if notice&.class == Array
|
|
9
|
+
- notice.each do |i|
|
|
10
|
+
.notice
|
|
11
|
+
= i
|
|
12
|
+
.close [x]
|
|
13
|
+
- if alert&.class == String
|
|
9
14
|
.alert
|
|
10
15
|
= alert
|
|
11
16
|
.close [x]
|
|
17
|
+
- if alert&.class == Array
|
|
18
|
+
- alert.each do |i|
|
|
19
|
+
.alert
|
|
20
|
+
= i
|
|
21
|
+
.close [x]
|
|
12
22
|
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
= text_field_tag "search_query"
|
|
16
16
|
= submit_tag 'search'
|
|
17
17
|
|
|
18
|
+
.bordered-card
|
|
19
|
+
= form_tag "https://wiki.wasya.co/index.php", method: :get, target: :_blank do
|
|
20
|
+
%p Search wiki.wasya.co:
|
|
21
|
+
= text_field_tag "search"
|
|
22
|
+
= submit_tag 'search'
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
18
26
|
.bordered-card
|
|
19
27
|
%h5.center.text-center USD to COP
|
|
20
28
|
#root{ width: 500, height: 300 }
|