ish_manager 0.1.8.461 → 0.1.8.462

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/ish_manager/application.scss +2 -0
  3. data/app/assets/stylesheets/ish_manager/products.scss +9 -0
  4. data/app/assets/stylesheets/ish_manager/subscriptions.scss +6 -0
  5. data/app/controllers/ish_manager/application_controller.rb +20 -0
  6. data/app/controllers/ish_manager/invoices_controller.rb +53 -1
  7. data/app/controllers/ish_manager/leadsets_controller.rb +3 -1
  8. data/app/controllers/ish_manager/prices_controller.rb +15 -0
  9. data/app/controllers/ish_manager/products_controller.rb +54 -26
  10. data/app/controllers/ish_manager/subscriptions_controller.rb +51 -22
  11. data/app/views/ish_manager/appliances/_index.haml +2 -1
  12. data/app/views/ish_manager/application/_alerts_notices.haml +12 -2
  13. data/app/views/ish_manager/application/_main_header_admin.haml +2 -1
  14. data/app/views/ish_manager/galleries/index_titles.haml +1 -1
  15. data/app/views/ish_manager/invoices/_index_list.haml +6 -0
  16. data/app/views/ish_manager/invoices/_index_table.haml +20 -0
  17. data/app/views/ish_manager/invoices/index.haml +1 -29
  18. data/app/views/ish_manager/invoices/new_pdf.haml +4 -1
  19. data/app/views/ish_manager/leadsets/show.haml +28 -6
  20. data/app/views/ish_manager/meetings/index.haml +1 -1
  21. data/app/views/ish_manager/payments/index.haml +1 -1
  22. data/app/views/ish_manager/products/_form.haml +4 -4
  23. data/app/views/ish_manager/products/_index_list.haml +10 -0
  24. data/app/views/ish_manager/products/_index_table.haml +20 -0
  25. data/app/views/ish_manager/products/index.haml +19 -15
  26. data/app/views/ish_manager/serverhosts/_index.haml +1 -2
  27. data/app/views/ish_manager/subscriptions/_form.haml +10 -2
  28. data/app/views/ish_manager/subscriptions/index.haml +15 -3
  29. data/app/views/ish_manager/subscriptions/new.haml +1 -1
  30. data/app/views/ish_manager/subscriptions/new_stripe.haml +4 -0
  31. data/app/views/ish_manager/subscriptions/new_wco.haml +4 -0
  32. data/app/views/ish_manager/subscriptions/show.haml +4 -0
  33. data/config/routes.rb +4 -0
  34. metadata +25 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a936861bb4879bb1d16f7e04dadf42d0932dd47bb73dfaa89b63c72267655dae
4
- data.tar.gz: 5ebcfead1814dfe078ef49a41e1c0b21af6f87c952e493838e89ef4450e8fd58
3
+ metadata.gz: d544fb840059764a4d3c9c557416c0ec338ca5ce9f2e109aff72bc3743e844a6
4
+ data.tar.gz: 82efc85b76bde5801fb399907e341d0f944f7813d4800a569f5e6109d3572878
5
5
  SHA512:
6
- metadata.gz: 13c83e9dd12495f4fa9d3e71464a693c9949fe4b7e5b2f34b580f4b24c55d9093741a63221b6b45af96427e7b3e1a9c755596b6b812e7244d7f4feabb1d1994d
7
- data.tar.gz: 7d7ac4f8fbe39793720d1bed308dd138731533b23601a2745935883e22e4e63be65baa58ecbf3b4463a8cdb56a5117a44cbb51eb565d4e2c20cb53fae5164fb4
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
@@ -0,0 +1,9 @@
1
+
2
+ .products--index-table {
3
+ td {
4
+ // padding: 10px;
5
+ }
6
+ th.name {
7
+ min-width: 250px;
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+
2
+ .subscriptions-new {
3
+ .select2-container {
4
+ width: 500px !important;
5
+ }
6
+ }
@@ -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
- pdf.text "Job Summary."
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
@@ -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 = @leadset.employees.page( params[:leads_page] ).per( current_profile.per_page )
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
@@ -0,0 +1,15 @@
1
+
2
+
3
+
4
+
5
+ class IshManager::PricesController < IshManager::ApplicationController
6
+
7
+ def update
8
+
9
+ # if !params[:price][:interval].present?
10
+ # @price.interval = nil
11
+ # end
12
+ end
13
+
14
+ end
15
+
@@ -3,37 +3,48 @@ class IshManager::ProductsController < IshManager::ApplicationController
3
3
 
4
4
  before_action :set_lists
5
5
 
6
- # alphabetized : )
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
- stripe_product = Stripe::Product.create({ name: params[:product][:name] })
13
- puts! stripe_product, 'stripe_product'
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: stripe_product.id,
17
- unit_amount: params[:product][:price_cents],
18
- currency: 'usd',
29
+ product: stripe_product.id,
30
+ unit_amount: @price.amount_cents,
31
+ currency: 'usd',
19
32
  }
20
- if params[:product][:interval].present?
21
- price_hash[:recurring] = { interval: params[:product][: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.product_id = stripe_product[:id]
27
- @product.price_id = stripe_price[:id]
28
-
29
- flag = @product.save
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
- flash[:alert] = "No luck: #{@product.errors.full_messages.join(', ')}."
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
- Stripe.api_key = ::STRIPE_SK
66
- Stripe.api_version = '2020-08-27'
75
+ @stripe_products = {}
67
76
  @_stripe_products = Stripe::Product.list().data
68
- @_stripe_prices = Stripe::Price.list().data
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
- @stripe_products[price[:product]][:prices][price[:id]] = price
84
+ begin
85
+ @stripe_products[price[:product]][:prices][price[:id]] = price
86
+ rescue Exception
87
+ nil
88
+ end
76
89
  end
77
90
 
78
- @products = Wco::Product.all
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
- payment_methods = Stripe::Customer.list_payment_methods( params[:subscription][:customer_id] ).data
13
- # puts! payment_methods, 'payment_methods'
14
-
15
- params = {
16
- customer: params[:subscription][:customer_id],
17
- default_payment_method: payment_methods[0][:id],
18
- items: [
19
- { price: params[:subscription][:price_id] },
20
- ],
21
- }
22
- puts! params, 'params'
23
- @stripe_subscription = Stripe::Subscription.create( params )
24
- # puts! @stripe_subscription, '@stripe_subscription'
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
- flash[:notice] = 'Created the subscription.'
37
+ flash_notice @subscription
30
38
  redirect_to action: :show, id: @subscription.id
31
39
  else
32
- flash[:alert] = "Cannot create the subscription: #{@subscription.errors.full_messages.join(', ')}."
33
- render action: :new
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 = Wco::Product.list
79
- leadsets = Leadset.where( "customer_id IS NOT NULL" ).map { |i| [ "leadset // #{i.company_url}", i.customer_id ] }
80
- profiles = ::Ish::UserProfile.where( :customer_id.ne => nil ).map { |i| [ "profile ++ #{i.email}", i.customer_id ] }
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 = Wco::Product.all.map { |i| [ i.name, i.price_id ] }
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
@@ -18,4 +18,5 @@
18
18
  - else
19
19
  <no-serverhost>
20
20
  %li.host <b>host:</b> #{i.host}
21
- -# %li.inspect= i.inspect
21
+ %hr
22
+
@@ -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 alert
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
 
@@ -104,7 +104,8 @@
104
104
  %li
105
105
  = link_to 'Products & Prices', products_path
106
106
  %li
107
- = link_to 'Customers & Subscriptions', subscriptions_path
107
+ = link_to 'Subscriptions', subscriptions_path
108
+ = link_to '[+]', new_wco_subscription_path
108
109
 
109
110
  .c
110
111
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  = render 'ish_manager/galleries/menu', count: @galleries.count
3
3
 
4
- %table#dataTable
4
+ %table.bordered.data-table
5
5
  %thead
6
6
  %tr
7
7
  %th Public?
@@ -0,0 +1,6 @@
1
+
2
+ .invoices--list
3
+ %ul
4
+ - invoices.each do |i|
5
+ %li
6
+ = i.inspect
@@ -0,0 +1,20 @@
1
+
2
+ .invoices--index-table
3
+ %table.bordered.data-table
4
+ %thead
5
+ %tr
6
+ %th
7
+ %th Email
8
+ %th Number
9
+ %th Amount
10
+ %th Amount Paid
11
+ %th Created At
12
+ %tbody
13
+ - invoices.each do |i|
14
+ %tr
15
+ %td= link_to "View", invoice_path( i )
16
+ %td= i.email
17
+ %td= i.number
18
+ %td= i.amount_cents
19
+ %td= i.paid_amount_cents
20
+ %td= i.created_at.to_s[0..10]
@@ -1,31 +1,3 @@
1
1
 
2
2
  .invoices-index.max-width
3
-
4
-
5
- %h5
6
- Invoices
7
- -# = link_to '[+]', new_invoice_path
8
-
9
- -# .row
10
- -# .col.s12.col.m6.col-md-offset-3
11
- -# = render 'form', :invoice => @new_invoice
12
- %hr
13
-
14
- %table#dataTable
15
- %thead
16
- %tr
17
- %th
18
- %th Email
19
- %th Number
20
- %th Amount
21
- %th Amount Paid
22
- %th Created At
23
- %tbody
24
- - @invoices.each do |i|
25
- %tr
26
- %td= link_to "View", invoice_path( i )
27
- %td= i.email
28
- %td= i.number
29
- %td= i.amount_cents
30
- %td= i.paid_amount_cents
31
- %td= i.created_at.to_s[0..10]
3
+ = render 'index_table', invoices: @invoices
@@ -3,9 +3,12 @@
3
3
 
4
4
  .row
5
5
  .col.s12.col.m6.col-md-offset-3
6
+
6
7
  %h5 New PDF Invoice for `#{link_to @leadset&.name, leadset_path(@leadset)}`:
7
8
  = form_for @new_invoice, as: :invoice, url: create_invoice_pdf_path do |f|
8
- = f.text_field :email
9
+ .input-field
10
+ %label Email
11
+ = f.text_field :email
9
12
  .input-field
10
13
  invoice month, description
11
14
  .input-field
@@ -9,14 +9,11 @@
9
9
  %li <b>Email:</b> #{@leadset.email}
10
10
  %li <b>company_url</b>: #{@leadset.company_url}
11
11
  %li <b>customer_id</b>: #{@leadset.customer_id}
12
- %li
13
- = link_to invoices_path({ leadset_id: @leadset.id }) do
14
- Invoices
15
- (#{@leadset.invoices.length})
16
- = link_to '[+stripe]', new_invoice_stripe_path({ leadset_id: @leadset.id })
17
- = link_to '[+pdf]', new_invoice_pdf_path({ leadset_id: @leadset.id })
18
12
 
13
+
14
+ %h5.collapse-expand#leads Leads
19
15
  = render 'ish_manager/leads/index', leads: @employees
16
+ %hr
20
17
 
21
18
  .row
22
19
  .col-md-6
@@ -24,3 +21,28 @@
24
21
 
25
22
  .col-md-6
26
23
  = render 'ish_manager/appliances/index', appliances: @leadset.appliances
24
+
25
+ .row
26
+ .col-md-6
27
+ %h5.collapse-expand#invoicesList
28
+ Invoices (#{@leadset.invoices.length})
29
+ = link_to '[+stripe]', new_invoice_stripe_path({ leadset_id: @leadset.id })
30
+ = link_to '[+pdf]', new_invoice_pdf_path({ leadset_id: @leadset.id })
31
+ = render 'ish_manager/invoices/index_list', invoices: @invoices
32
+ %hr
33
+
34
+ .col-md-6
35
+ %h5.collapse-expand#subscriptionsList
36
+ Subscriptions (#{@subscriptions.length})
37
+ = link_to '[+wco]', new_wco_subscription_path({ customer_id: @leadset.customer_id })
38
+ %table.bordered
39
+ %thead
40
+ %tr
41
+ %th Name
42
+ %th Price
43
+ - @subscriptions.each do |i|
44
+ %tr
45
+ %td= i.product.name
46
+ %td= i.price
47
+ %hr
48
+
@@ -1,7 +1,7 @@
1
1
 
2
2
  .manager-meeetings-index
3
3
 
4
- %table#dataTable.display.compact
4
+ %table.data-table.display.compact
5
5
  %thead
6
6
  %tr
7
7
  %th Invitee
@@ -5,7 +5,7 @@
5
5
 
6
6
  %h1 Payments
7
7
 
8
- %table#dataTable
8
+ %table.bordered.data-table
9
9
  %thead
10
10
  %tr
11
11
  %th Amount
@@ -2,19 +2,19 @@
2
2
  - url = product.new_record? ? products_path : product_path( product )
3
3
 
4
4
  .products--form
5
- = form_for product, as: :product, url: url do |f|
5
+ = form_for product, url: url do |f|
6
6
 
7
7
  .form-field
8
8
  %label Name
9
- = f.text_field :name
9
+ = text_field_tag 'product[name]'
10
10
 
11
11
  .form-field
12
12
  %label Price in cents
13
- = f.text_field :price_cents
13
+ = text_field_tag 'price[amount_cents]'
14
14
 
15
15
  .form-field
16
16
  %label Recurring?
17
- = f.select :interval, options_for_select(Wco::Product::INTERVALS)
17
+ = select_tag 'price[interval]', options_for_select(Wco::Price::INTERVALS)
18
18
 
19
19
  -# .form-field
20
20
  -# %label Stripe product_id
@@ -0,0 +1,10 @@
1
+
2
+ %ol
3
+ - products.each do |product|
4
+ %li
5
+ = link_to '[~]', edit_product_path( product )
6
+ #{product.name} // $#{product.price_cents.to_f/100}/#{product.interval.presence || 'onetime'}
7
+ - if product.product_id
8
+ .ml-5 <b>product_id:</b> #{product.product_id}
9
+ - if product.price_id
10
+ .ml-5 <b>price_id:</b> #{product.price_id}
@@ -0,0 +1,20 @@
1
+
2
+ .products--index-table
3
+ %table.bordered.data-table
4
+ %thead
5
+ %tr
6
+ %th.name Name
7
+ %th.prices Prices
8
+
9
+ - products.each do |product|
10
+ %tr
11
+ %td.p-2
12
+ = link_to '[~]', edit_product_path( product )
13
+ = product.name
14
+ .gray= product.product_id
15
+ %td.p-2
16
+ %ul
17
+ - product.prices.each do |price|
18
+ %li
19
+ $#{ price.amount_cents.to_f/100 } / #{price.interval}
20
+ .gray= price.price_id
@@ -1,7 +1,12 @@
1
1
 
2
2
  .products-index.max-width
3
3
 
4
- %h5
4
+ .a
5
+ %h5 New Product:
6
+ = render 'ish_manager/products/form', product: Wco::Product.new
7
+ %hr
8
+
9
+ %h5.collapse-expand#stripeProducts
5
10
  Stripe Products (#{@stripe_products.length}):
6
11
  -# = link_to '[+]', new_product_path
7
12
  %ol
@@ -10,24 +15,23 @@
10
15
  = link_to '[~]', edit_product_path( product.id )
11
16
  .inline-block= button_to '[x]', product_path( product.id ), :method => :delete, :data => { :confirm => 'Are you sure?' }
12
17
  %span.gray= product.id
13
- = product.name
18
+ - if product[:wco_product]
19
+ = link_to product.name, product_path( product )
20
+ - else
21
+ = product.name
14
22
  %ul
15
23
  - product[:prices].each do |price_id, price|
16
24
  %li
17
25
  %span.gray= price.id
18
- $#{price[:unit_amount].to_f/100}/#{(price[:recurring]||{})[:interval]||'onetime'}
19
- -# = price.inspect
20
-
26
+ - price_str = "$#{ price[:unit_amount].to_f/100 }/#{ (price[:recurring]||{})[:interval]||'onetime' }"
27
+ - if @wco_prices_hash[price.id]
28
+ = link_to price_str, price_path( @wco_prices_hash[price.id] )
29
+ - else
30
+ = price_str
21
31
  %hr
22
32
 
23
- %h5 New Product:
24
- = render 'ish_manager/products/form', product: Wco::Product.new
33
+ %h5.collapse-expand#wcoProducts
34
+ Wco::Products (#{@wco_products.length}):
35
+ = render 'index_table', products: @wco_products
36
+ -# = render 'index_list', products: @wco_products
25
37
 
26
- %hr
27
- %h5 Wco::Product's (#{@products.length})
28
- %ul
29
- - @products.each do |product|
30
- %li
31
- = link_to '[~]', edit_product_path( product )
32
- #{product.name} // $#{product.price_cents.to_f/100}/#{product.interval.presence || 'onetime'}
33
- [ #{product.product_id}, #{product.price_id} ]
@@ -1,7 +1,6 @@
1
1
 
2
2
  .serverhosts--index
3
3
  %h5 Serverhosts (#{serverhosts.length})
4
- %hr
5
4
 
6
5
  %ul.items
7
6
  - serverhosts.each do |i|
@@ -18,4 +17,4 @@
18
17
  %li.nginx_root <b>nginx_root:</b> #{i.nginx_root}
19
18
  %li.appliances
20
19
  = render 'ish_manager/appliances/index', appliances: i.appliances
21
-
20
+ %hr
@@ -8,9 +8,17 @@
8
8
  %label Product (price):
9
9
  = f.select :price_id, options_for_select(@price_ids_list, selected: subscription.price_id), {}, class: :select2
10
10
 
11
+ .input-group
12
+ %label Quantity:
13
+ = f.number_field :quantity
14
+
11
15
  .input-group
12
16
  %label Customer/Leadset
13
- = f.select :customer_id, options_for_select(@customer_ids_list, selected: subscription.customer_id), {}, class: :select2
17
+ = f.select :customer_id, options_for_select(@customer_ids_list, selected: params[:customer_id] || subscription.customer_id), {}, class: :select2
18
+
19
+ .input-group
20
+ %label Create a stripe subscription?
21
+ = check_box_tag :is_stripe
14
22
 
15
23
  .actions
16
- = f.submit 'Submit'
24
+ = f.submit 'Submit', data: { confirm: 'Are you sure?' }
@@ -1,7 +1,7 @@
1
1
 
2
2
  .container.subscriptions-index.padded
3
+ %p.collapse-expand#rowStripe Stripe
3
4
  .row
4
-
5
5
  .col-md-6
6
6
  %h5 Stripe Customers
7
7
  %ul
@@ -16,11 +16,10 @@
16
16
  - @stripe_subscriptions.each do |sub|
17
17
  - if sub.customer == customer.id
18
18
  %li= sub.items.data[0].plan.product
19
-
20
19
  .col-md-6
21
20
  %h5
22
21
  Stripe Subscriptions
23
- = link_to '[+]', new_subscription_path
22
+ = link_to '[+]', new_stripe_subscription_path
24
23
  %ul
25
24
  - @stripe_subscriptions.each do |sub|
26
25
  %li
@@ -33,4 +32,17 @@
33
32
  %li leadsets: #{ @customers[sub[:customer]][:leadsets]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
34
33
  - if @customers[sub[:customer]] && @customers[sub[:customer]][:profiles]
35
34
  %li profiles: #{ @customers[sub[:customer]][:profiles]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
35
+ %hr
36
+
37
+ %p.collapse-expand#rowWco WasyaCo
38
+ .row
39
+ .col-md-6
40
+ Customers (leadsets)
41
+ .col-md-6
42
+ %h5
43
+ Subscriptions
44
+ = link_to '[+]', new_wco_subscription_path
45
+ %ul
46
+ - @wco_subscriptions.each do |item|
47
+ %li= item.inspect
36
48
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  .subscriptions-new.max-width
3
- %h5 New Subscription
3
+ %h5 New ^^ generic ^^ Subscription
4
4
  = render 'form', subscription: @subscription
@@ -0,0 +1,4 @@
1
+
2
+ .subscriptions-new.max-width
3
+ %h5 New Stripe Subscription
4
+ = render 'form', subscription: @subscription
@@ -0,0 +1,4 @@
1
+
2
+ .subscriptions-new.max-width
3
+ %h5 New Wco Subscription
4
+ = render 'form', subscription: @subscription
@@ -1,4 +1,8 @@
1
1
 
2
2
  .subscriptions-show.max-width
3
3
  %h5 Subscription
4
+ %ul
5
+ %li
6
+ <b>Leadset:</b>
7
+ = link_to @subscription.leadset.company_url, leadset_path( @subscription.leadset )
4
8
  = @subscription.inspect
data/config/routes.rb CHANGED
@@ -122,12 +122,16 @@ IshManager::Engine.routes.draw do
122
122
 
123
123
  resources :photos
124
124
  resources :payments
125
+ resources :prices
125
126
  resources :products
126
127
 
127
128
  resources :reports
128
129
 
129
130
  resources :serverhosts
130
131
  resources :scheduled_email_actions
132
+
133
+ get 'subscriptions/new_stripe', to: 'subscriptions#new_stripe', as: :new_stripe_subscription
134
+ get 'subscriptions/new_wco', to: 'subscriptions#new_wco', as: :new_wco_subscription
131
135
  resources :subscriptions
132
136
 
133
137
  resources :user_profiles do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.461
4
+ version: 0.1.8.462
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: 2.4.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: prawn-table
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.2.1
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.2.1
237
251
  description: Description of IshManager.
238
252
  email:
239
253
  - piousbox@gmail.com
@@ -456,7 +470,9 @@ files:
456
470
  - app/assets/stylesheets/ish_manager/office.scss
457
471
  - app/assets/stylesheets/ish_manager/pagination.scss
458
472
  - app/assets/stylesheets/ish_manager/photos.scss
473
+ - app/assets/stylesheets/ish_manager/products.scss
459
474
  - app/assets/stylesheets/ish_manager/scheduled_email_actions.scss
475
+ - app/assets/stylesheets/ish_manager/subscriptions.scss
460
476
  - app/assets/stylesheets/ish_manager/tags.scss
461
477
  - app/assets/stylesheets/ish_manager/trash/pagination.scss
462
478
  - app/assets/stylesheets/ish_manager/user_profiles.scss
@@ -495,6 +511,7 @@ files:
495
511
  - app/controllers/ish_manager/office_actions_controller.rb
496
512
  - app/controllers/ish_manager/payments_controller.rb
497
513
  - app/controllers/ish_manager/photos_controller.rb
514
+ - app/controllers/ish_manager/prices_controller.rb
498
515
  - app/controllers/ish_manager/products_controller.rb
499
516
  - app/controllers/ish_manager/reports_controller.rb
500
517
  - app/controllers/ish_manager/scheduled_email_actions_controller.rb
@@ -665,6 +682,8 @@ files:
665
682
  - app/views/ish_manager/galleries/show.haml
666
683
  - app/views/ish_manager/image_assets/index.haml
667
684
  - app/views/ish_manager/invoices/_form.haml-trash
685
+ - app/views/ish_manager/invoices/_index_list.haml
686
+ - app/views/ish_manager/invoices/_index_table.haml
668
687
  - app/views/ish_manager/invoices/index.haml
669
688
  - app/views/ish_manager/invoices/new_pdf.haml
670
689
  - app/views/ish_manager/invoices/new_stripe.haml
@@ -758,6 +777,8 @@ files:
758
777
  - app/views/ish_manager/photos/show.haml
759
778
  - app/views/ish_manager/photos/without_gallery.haml
760
779
  - app/views/ish_manager/products/_form.haml
780
+ - app/views/ish_manager/products/_index_list.haml
781
+ - app/views/ish_manager/products/_index_table.haml
761
782
  - app/views/ish_manager/products/edit.haml
762
783
  - app/views/ish_manager/products/index.haml
763
784
  - app/views/ish_manager/products/show.haml
@@ -782,6 +803,8 @@ files:
782
803
  - app/views/ish_manager/subscriptions/_form.haml
783
804
  - app/views/ish_manager/subscriptions/index.haml
784
805
  - app/views/ish_manager/subscriptions/new.haml
806
+ - app/views/ish_manager/subscriptions/new_stripe.haml
807
+ - app/views/ish_manager/subscriptions/new_wco.haml
785
808
  - app/views/ish_manager/subscriptions/show.haml
786
809
  - app/views/ish_manager/trash/email_campaigns-trash/_form.haml
787
810
  - app/views/ish_manager/trash/email_campaigns-trash/edit.haml