ish_manager 0.1.8.465 → 0.1.8.466

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d91941f9fc2e9e5bb08b1ab6f12f69de1350b6760b6464afafadf2cb7dac91d
4
- data.tar.gz: '094c5bb30096222105f1324259c7a3998acc23f641feeb2bc85af16475543413'
3
+ metadata.gz: 8a683cfef772c003347453411d5e573a99e0e728dd991e8f8992fe6aa1f513cb
4
+ data.tar.gz: cc083c29d80e582b0419d54416a795ea526786361486a615e445fc3e052439c1
5
5
  SHA512:
6
- metadata.gz: e05720b0f2baae54d689bfda6fee1710fe5c118e6e0f22d285efc3429bb2951bdfef2af6a4da051b835fb883a4156b80b8f557f8818602215cc6e2bc4c0a4304
7
- data.tar.gz: f7c043b63480881d1ecafc98721bc7766aec1f4bb4d7bafc6ec93aa5c9d619367f46422b63537a987c14079489159a389b6db56ac7fb77e4a24fef6002df4563
6
+ metadata.gz: 05ca4a618c3395a1342c7a4707b81fa0e19d5718f3e97b113c93964bda85639936eed2a965ed392ea494bf52c8e215b30e80c969b552f5df0efdeed5efbfd352
7
+ data.tar.gz: 43657b8c0a70855ad030dfb4438a28b9558ad88aba7e3bd57f8fc75ffb737ae2db5347f6a6d8037b99fdf1bd0915de3560217cb6dec69f1215ac0c55d1b00fa8
@@ -13,6 +13,7 @@
13
13
  //= require ish_manager/email_conversations
14
14
  //= require ish_manager/email_templates
15
15
  //= require ish_manager/galleries
16
+ //= require ish_manager/invoices
16
17
  //= require ish_manager/iro
17
18
  //= require ish_manager/leads
18
19
  //
@@ -0,0 +1,29 @@
1
+
2
+
3
+ $(document).ready(function () {
4
+
5
+ const jwt_token = $("#Config").data('jwt-token')
6
+ logg(jwt_token, 'jwt_token')
7
+
8
+ if ($(".invoices-new").length) {
9
+
10
+ $("select[name='invoice[items][][product_id]']").on('change', function(ev) {
11
+ var productId = ev.target.value
12
+ logg(productId, 'productId')
13
+
14
+ $.get(`/api/products/${productId}.json?jwt_token=${jwt_token}`, function(_data) {
15
+ logg(_data, '_data')
16
+
17
+ $('select[name="invoice[items][][price_id]"]').empty();
18
+ // $('select[name="invoice[items][][price_id]"]').append($("<option disabled=true selected=true></option>").attr("value", '').text('Choose a price...')
19
+ $.each(_data.prices, function(_, item) {
20
+ $('select[name="invoice[items][][price_id]"]').append($("<option></option>").attr("value", item.id).text(item.name));
21
+ })
22
+ })
23
+ })
24
+
25
+ }
26
+
27
+
28
+ })
29
+
@@ -64,7 +64,8 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
64
64
  pending_invoice_items_behavior: 'exclude',
65
65
  })
66
66
  params[:invoice][:items].each do |item|
67
- stripe_price = Wco::Product.find( item[:product_id] ).price_id
67
+ stripe_price = Wco::Price.find( item[:price_id] ).price_id
68
+ puts! stripe_price, 'stripe_price'
68
69
  invoice_item = Stripe::InvoiceItem.create({
69
70
  customer: @invoice.leadset.customer_id,
70
71
  price: stripe_price,
@@ -72,14 +73,18 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
72
73
  quantity: item[:quantity],
73
74
  })
74
75
  end
75
- Stripe::Invoice.send_invoice(stripe_invoice[:id])
76
+ Stripe::Invoice.finalize_invoice( stripe_invoice[:id] )
77
+ if params[:do_send]
78
+ Stripe::Invoice.send_invoice(stripe_invoice[:id])
79
+ flash_notice "Scheduled to send the invoice via stripe."
80
+ end
76
81
  @invoice.update_attributes({ invoice_id: stripe_invoice[:id] })
77
82
 
78
83
  if @invoice.save
79
- flash[:notice] = "Created the invoice."
84
+ flash_notice "Created the invoice."
80
85
  redirect_to action: :show, id: @invoice.id
81
86
  else
82
- flash[:alert] = "Cannot create invoice: #{@invoice.errors.messages}"
87
+ flash_alert "Cannot create invoice: #{@invoice.errors.messages}"
83
88
  render :new
84
89
  end
85
90
  end
@@ -114,6 +119,14 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
114
119
  redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
115
120
  end
116
121
 
122
+ def send_stripe
123
+ @invoice = Ish::Invoice.find params[:id]
124
+ authorize! :send_stripe, @invoice
125
+ Stripe::Invoice.send_invoice( @invoice.invoice_id )
126
+ flash_notice "Scheduled to send the invoice."
127
+ redirect_to action: :show, id: @invoice.id
128
+ end
129
+
117
130
  def show
118
131
  @invoice = Ish::Invoice.find params[:id]
119
132
  authorize! :show, @invoice
@@ -3,6 +3,7 @@
3
3
  %ul
4
4
  - invoices.each do |i|
5
5
  %li
6
+ = link_to '[view]', invoice_path( i )
6
7
  = i.month_on
7
8
  \::
8
9
  - if i.asset
@@ -22,10 +22,13 @@
22
22
  -# - else
23
23
  -# = f.select :email, options_for_select([[nil,nil]] + @leadset.employees.map { |i| [ i.email, i.email ] } )
24
24
 
25
- .input-field
25
+ .input-row
26
26
  %label item
27
- = select_tag 'invoice[items][][product_id]', options_for_select( @products_list )
28
- .input-field
27
+ = select_tag 'invoice[items][][product_id]', options_for_select( @products_list ), class: 'products'
28
+
29
+ %label price
30
+ = select_tag 'invoice[items][][price_id]'
31
+
29
32
  %label quantity
30
33
  = number_field_tag 'invoice[items][][quantity]'
31
34
 
@@ -37,5 +40,11 @@
37
40
  -# %label Description
38
41
  -# = f.text_area :description
39
42
 
40
- = f.submit 'Save'
43
+ .input-field
44
+ %label Send now?
45
+ = check_box_tag :do_send
46
+
47
+ .actions
48
+
49
+ = f.submit 'Create', data: { confirm: 'Are you sure?' }
41
50
 
@@ -2,7 +2,7 @@
2
2
  - i = @invoice
3
3
 
4
4
  .invoices-show.max-width
5
- %h5 Invoice ##{@invoice.number}
5
+ %h5 Invoice ##{i.number}
6
6
 
7
7
  %ul
8
8
  %li email: #{i.email}
@@ -10,10 +10,14 @@
10
10
  %li invoice_id: #{i.invoice_id}
11
11
  %li items: #{i.items}
12
12
 
13
- = @invoice.inspect
13
+ -# = @invoice.inspect
14
14
 
15
15
  %hr
16
+ %h5
17
+ Stripe Invoice
18
+ = link_to 'pdf', @stripe_invoice[:invoice_pdf], target: :_blank
19
+ .inline-block= button_to 'stripe-send', send_invoice_stripe_path( i.id ), data: { confirm: 'Are you sure?' }
16
20
 
17
- %pre
18
- = @stripe_invoice.inspect
21
+ -# %pre
22
+ -# = @stripe_invoice.inspect
19
23
 
@@ -28,6 +28,7 @@
28
28
  Invoices (#{@leadset.invoices.length})
29
29
  = link_to '[+stripe]', new_invoice_stripe_path({ leadset_id: @leadset.id })
30
30
  = link_to '[+pdf]', new_invoice_pdf_path({ leadset_id: @leadset.id })
31
+
31
32
  = render 'ish_manager/invoices/index_list', invoices: @invoices
32
33
 
33
34
  = form_tag create_monthly_invoice_for_leadset_path({ leadset_id: @leadset.id }) do
data/config/routes.rb CHANGED
@@ -31,6 +31,7 @@ IshManager::Engine.routes.draw do
31
31
  post 'invoices/create-stripe', to: 'invoices#create_stripe', as: :create_invoice_stripe
32
32
  get 'invoices/new_pdf', to: 'invoices#new_pdf', as: :new_invoice_pdf
33
33
  get 'invoices/new_stripe', to: 'invoices#new_stripe', as: :new_invoice_stripe
34
+ post 'invoices/:id/send-stripe', to: 'invoices#send_stripe', as: :send_invoice_stripe
34
35
  resources :invoices
35
36
 
36
37
  get 'iro_positins/roll_prep/:id', to: 'iro_purses#roll_prep', as: :iro_roll_prep
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.465
4
+ version: 0.1.8.466
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-10 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -279,6 +279,7 @@ files:
279
279
  - app/assets/javascripts/ish_manager/email_conversations.js
280
280
  - app/assets/javascripts/ish_manager/email_templates.js
281
281
  - app/assets/javascripts/ish_manager/galleries.js
282
+ - app/assets/javascripts/ish_manager/invoices.js
282
283
  - app/assets/javascripts/ish_manager/iro.js
283
284
  - app/assets/javascripts/ish_manager/iro0.js
284
285
  - app/assets/javascripts/ish_manager/leads.js