wco_models 3.1.0.95 → 3.1.0.97
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/wco/application.js +6 -4
- data/app/assets/javascripts/wco/invoices.js +33 -0
- data/app/controllers/wco/invoices_controller.rb +159 -0
- data/app/controllers/wco/leads_controller.rb +1 -1
- data/app/controllers/wco/products_controller.rb +20 -11
- data/app/controllers/wco/unsubscribes_controller.rb +1 -1
- data/app/models/wco/price.rb +4 -6
- data/app/models/wco/product.rb +3 -1
- data/app/views/wco/_alerts_notices.haml +4 -1
- data/app/views/wco/invoices/new_stripe.haml +2 -2
- data/app/views/wco/invoices/show.haml +1 -1
- data/app/views/wco/products/_table.haml +1 -0
- data/app/views/wco/products/new.haml +2 -0
- data/app/views/wco/products/show.jbuilder +16 -0
- data/app/views/{wco_email → wco}/unsubscribes/_header.haml +1 -1
- data/config/routes.rb +2 -0
- metadata +23 -5
- /data/app/models/wco/{premium_item.rb → premium_item.rb-trash} +0 -0
- /data/app/views/{wco_email → wco}/unsubscribes/_table.haml +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d142884790cc222d2fa26774efd391452b802f59ea8c57e30086cf73cb126ce
|
4
|
+
data.tar.gz: cf126ee217e6974ffe1e424d8b43b74200e1bcb4456e931f58f29425ab2774e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dfa0e5f9a271f01890e488b0ead7a17cc9abdb24b2b6e75deca5dafc5708c304ce8441169a260de391016a6dabc2fa86ca3e46dcf2e66ba311044096f210603
|
7
|
+
data.tar.gz: 931258fd6144687e45a0b24acd6b0ebf3e0346a0930fee68d5d44bb2d2f97e8b2c055e193e7e7d1023d4636bfc0cf58ff3259cf6f263cbc9755476faec308e27
|
@@ -14,11 +14,13 @@
|
|
14
14
|
//
|
15
15
|
// require select2
|
16
16
|
//
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
// require ./alerts-notices
|
18
|
+
// require ./collapse-expand
|
19
|
+
// require ./file_upload
|
20
|
+
// require ./office_action_templates
|
21
|
+
//
|
21
22
|
//= require ./shared
|
23
|
+
//= require_tree .
|
22
24
|
//
|
23
25
|
|
24
26
|
$(function() {
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
const AppRouter = {
|
3
|
+
product_path: (id) => `/wco/products/${id}.json`,
|
4
|
+
}
|
5
|
+
|
6
|
+
$(document).ready(function () {
|
7
|
+
|
8
|
+
// const jwt_token = $("#Config").data('jwt-token')
|
9
|
+
// logg(jwt_token, 'jwt_token')
|
10
|
+
// path = `/api/products/${productId}.json?jwt_token=${jwt_token}`
|
11
|
+
|
12
|
+
if ($(".invoices-new").length) {
|
13
|
+
|
14
|
+
$("select[name='invoice[items][][product_id]']").on('change', function(ev) {
|
15
|
+
var productId = ev.target.value
|
16
|
+
logg(productId, 'productId')
|
17
|
+
|
18
|
+
$.get(AppRouter.product_path(productId), function(_data) {
|
19
|
+
logg(_data, '_data')
|
20
|
+
|
21
|
+
$('select[name="invoice[items][][price_id]"]').empty();
|
22
|
+
// $('select[name="invoice[items][][price_id]"]').append($("<option disabled=true selected=true></option>").attr("value", '').text('Choose a price...')
|
23
|
+
$.each(_data.prices, function(_, item) {
|
24
|
+
$('select[name="invoice[items][][price_id]"]').append($("<option></option>").attr("value", item.id).text(item.name));
|
25
|
+
})
|
26
|
+
})
|
27
|
+
})
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
})
|
33
|
+
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'prawn'
|
2
|
+
require 'prawn/table'
|
3
|
+
|
4
|
+
class Wco::InvoicesController < Wco::ApplicationController
|
5
|
+
|
6
|
+
before_action :set_lists
|
7
|
+
|
8
|
+
def create_monthly_pdf
|
9
|
+
month_on = DateTime.strptime(params[:month_on], '%Y-%m-%d').strftime('%Y-%m-01')
|
10
|
+
@leadset = Leadset.find params[:leadset_id]
|
11
|
+
authorize! :create_monthly_invoice_pdf, @leadset
|
12
|
+
|
13
|
+
@invoice = Wco::Invoice.where({ leadset_id: @leadset.id, month_on: month_on }).first
|
14
|
+
if @invoice && !params[:replace]
|
15
|
+
flash_alert "Already created this invoice."
|
16
|
+
redirect_to controller: :leadsets, action: :show, id: @leadset.id
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
if !@invoice
|
21
|
+
@invoice = Wco::Invoice.create({
|
22
|
+
leadset_id: @leadset.id,
|
23
|
+
month_on: month_on,
|
24
|
+
number: @leadset.next_invoice_number,
|
25
|
+
})
|
26
|
+
@leadset.update_attributes({ next_invoice_number: @leadset.next_invoice_number + 1 })
|
27
|
+
end
|
28
|
+
|
29
|
+
@pdf = @invoice.generate_monthly_invoice
|
30
|
+
path = "/tmp/#{@invoice.filename}"
|
31
|
+
@pdf.render_file path
|
32
|
+
data = File.read path
|
33
|
+
|
34
|
+
asset = ::Gameui::Asset3d.new invoice: @invoice
|
35
|
+
f = File.new( path )
|
36
|
+
asset.object = f
|
37
|
+
f.close
|
38
|
+
@invoice.asset = asset
|
39
|
+
if asset.save
|
40
|
+
flash_notice "Saved the asset."
|
41
|
+
end
|
42
|
+
if @invoice.save
|
43
|
+
flash_notice "Saved the invoice."
|
44
|
+
end
|
45
|
+
|
46
|
+
File.delete(path) if File.exist?(path)
|
47
|
+
redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
|
48
|
+
|
49
|
+
# send_data( data, { :filename => @invoice.filename,
|
50
|
+
# :disposition => params[:disposition] ? params[:disposition] : :attachment,
|
51
|
+
# :type => 'application/pdf'
|
52
|
+
# })
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_stripe
|
56
|
+
@invoice = Wco::Invoice.new params[:invoice].permit!
|
57
|
+
authorize! :create, @invoice
|
58
|
+
|
59
|
+
stripe_invoice = Stripe::Invoice.create({
|
60
|
+
customer: @invoice.leadset.customer_id,
|
61
|
+
collection_method: 'send_invoice',
|
62
|
+
days_until_due: 0,
|
63
|
+
# collection_method: 'charge_automatically',
|
64
|
+
pending_invoice_items_behavior: 'exclude',
|
65
|
+
})
|
66
|
+
params[:invoice][:items].each do |item|
|
67
|
+
stripe_price = Wco::Price.find( item[:price_id] ).price_id
|
68
|
+
puts! stripe_price, 'stripe_price'
|
69
|
+
invoice_item = Stripe::InvoiceItem.create({
|
70
|
+
customer: @invoice.leadset.customer_id,
|
71
|
+
price: stripe_price,
|
72
|
+
invoice: stripe_invoice.id,
|
73
|
+
quantity: item[:quantity],
|
74
|
+
})
|
75
|
+
end
|
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
|
81
|
+
@invoice.update_attributes({ invoice_id: stripe_invoice[:id] })
|
82
|
+
|
83
|
+
if @invoice.save
|
84
|
+
flash_notice "Created the invoice."
|
85
|
+
redirect_to action: :show, id: @invoice.id
|
86
|
+
else
|
87
|
+
flash_alert "Cannot create invoice: #{@invoice.errors.messages}"
|
88
|
+
render :new
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def index
|
93
|
+
authorize! :index, Wco::Invoice
|
94
|
+
@invoices = Wco::Invoice.all
|
95
|
+
if params[:leadset_id]
|
96
|
+
@invoices = @invoices.where( leadset_id: params[:leadset_id] )
|
97
|
+
end
|
98
|
+
@invoices = @invoices.includes( :payments )
|
99
|
+
end
|
100
|
+
|
101
|
+
def new_pdf
|
102
|
+
authorize! :new, @invoice
|
103
|
+
@leadset = Leadset.find params[:leadset_id]
|
104
|
+
@products_list = Wco::Product.list
|
105
|
+
end
|
106
|
+
|
107
|
+
def new_stripe
|
108
|
+
authorize! :new, @invoice
|
109
|
+
@leadset = Wco::Leadset.find params[:leadset_id]
|
110
|
+
@products_list = Wco::Product.list
|
111
|
+
end
|
112
|
+
|
113
|
+
def email_send
|
114
|
+
@invoice = Wco::Invoice.find params[:id]
|
115
|
+
authorize! :send_email, @invoice
|
116
|
+
out = ::IshManager::LeadsetMailer.monthly_invoice( @invoice.id.to_s )
|
117
|
+
Rails.env.production? ? out.deliver_later : out.deliver_now
|
118
|
+
flash_notice "Scheduled to send an email."
|
119
|
+
redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
|
120
|
+
end
|
121
|
+
|
122
|
+
def send_stripe
|
123
|
+
@invoice = Wco::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
|
+
|
130
|
+
def show
|
131
|
+
@invoice = Wco::Invoice.find params[:id]
|
132
|
+
authorize! :show, @invoice
|
133
|
+
@stripe_invoice = Stripe::Invoice.retrieve @invoice.invoice_id
|
134
|
+
end
|
135
|
+
|
136
|
+
def update
|
137
|
+
@invoice = Wco::Invoice.find params[:id]
|
138
|
+
authorize! :update, @invoice
|
139
|
+
if @invoice.update_attributes params[:invoice].permit!
|
140
|
+
flash[:notice] = 'Success'
|
141
|
+
redirect_to :action => 'index'
|
142
|
+
else
|
143
|
+
flash[:alert] = "Cannot update invoice: #{@invoice.errors.messages}"
|
144
|
+
end
|
145
|
+
redirect_to :action => 'index'
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
# private
|
150
|
+
#
|
151
|
+
private
|
152
|
+
|
153
|
+
def set_lists
|
154
|
+
@invoice_number = Wco::Invoice.order_by( :number => :desc ).first
|
155
|
+
@invoice_number = @invoice_number ? @invoice_number.number + 1 : 1
|
156
|
+
@new_invoice = Wco::Invoice.new :number => @invoice_number
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
@@ -54,12 +54,12 @@ class Wco::LeadsController < Wco::ApplicationController
|
|
54
54
|
def show
|
55
55
|
@lead = Wco::Lead.where({ id: params[:id] }).first
|
56
56
|
@lead ||= Wco::Lead.where({ email: params[:id] }).first
|
57
|
+
authorize! :show, @lead
|
57
58
|
if !@lead
|
58
59
|
flash_alert "This lead does not exist"
|
59
60
|
redirect_to request.referrer
|
60
61
|
return
|
61
62
|
end
|
62
|
-
authorize! :show, @lead
|
63
63
|
# @schs = Sch.where( lead_id: @lead.id )
|
64
64
|
# @ctxs = Ctx.where( lead_id: @lead.id )
|
65
65
|
# @convs = Conv.find( Office::EmailConversationLead.where( lead_id: @lead.id ).map( &:email_conversation_id ) )
|
@@ -23,17 +23,17 @@ class Wco::ProductsController < Wco::ApplicationController
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def destroy
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
flag = Stripe::Product.delete(
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
@product = Wco::Product.find params[:id]
|
27
|
+
authorize! :destroy, @product
|
28
|
+
|
29
|
+
# flag = Stripe::Product.delete( @product.product_id ) if @product.product_id.present?
|
30
|
+
# flash_notice "Delete stripe product: #{flag}"
|
31
|
+
|
32
|
+
if @product.destroy
|
33
|
+
flash_notice 'Deleted Wco::Product'
|
34
|
+
else
|
35
|
+
flash_alert "Cannot destroy product: #{@product.errors.fill_messages.join(', ')}."
|
36
|
+
end
|
37
37
|
redirect_to action: :index
|
38
38
|
end
|
39
39
|
|
@@ -79,9 +79,18 @@ class Wco::ProductsController < Wco::ApplicationController
|
|
79
79
|
|
80
80
|
end
|
81
81
|
|
82
|
+
def new
|
83
|
+
@product = Wco::Product.new
|
84
|
+
authorize! :new, @product
|
85
|
+
end
|
86
|
+
|
82
87
|
def show
|
83
88
|
authorize! :show, @product
|
84
89
|
@product = Wco::Product.find params[:id]
|
90
|
+
respond_to do |format|
|
91
|
+
format.html
|
92
|
+
format.json { render 'show.jbuilder', layout: false }
|
93
|
+
end
|
85
94
|
end
|
86
95
|
|
87
96
|
def update
|
data/app/models/wco/price.rb
CHANGED
@@ -13,11 +13,6 @@ class Wco::Price
|
|
13
13
|
|
14
14
|
field :amount_cents, type: Integer
|
15
15
|
|
16
|
-
def to_s
|
17
|
-
price = self
|
18
|
-
"$#{ price[:amount_cents].to_f/100 }/#{ price.interval||'onetime' }"
|
19
|
-
end
|
20
|
-
|
21
16
|
INTERVAL_DAY = 'day'
|
22
17
|
INTERVAL_WEEK = 'week'
|
23
18
|
INTERVAL_MONTH = 'month'
|
@@ -27,10 +22,13 @@ class Wco::Price
|
|
27
22
|
|
28
23
|
field :price_id # stripe
|
29
24
|
|
25
|
+
def to_s
|
26
|
+
price = self
|
27
|
+
"$#{ price[:amount_cents].to_f/100 }/#{ price.interval||'onetime' }"
|
28
|
+
end
|
30
29
|
def self.list
|
31
30
|
[[nil,nil]] + all.map { |p| [ "#{p.product.name} :: #{p.amount_cents.to_f/100}/#{p.interval||'onetime'}", p.id ] }
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
33
|
|
36
34
|
|
data/app/models/wco/product.rb
CHANGED
@@ -7,13 +7,13 @@
|
|
7
7
|
|
8
8
|
.row
|
9
9
|
.col.s12.col.m6.col-md-offset-3
|
10
|
-
%h5 New Stripe Invoice for `#{link_to @leadset
|
10
|
+
%h5 New Stripe Invoice for `#{link_to @leadset, leadset_path(@leadset)}`:
|
11
11
|
|
12
12
|
= form_for invoice, :as => :invoice, :url => url do |f|
|
13
13
|
= hidden_field_tag 'invoice[leadset_id]', @leadset.id
|
14
14
|
|
15
15
|
.input-field
|
16
|
-
%label Email
|
16
|
+
%label <b>Email:</b>
|
17
17
|
= @leadset.email
|
18
18
|
-# - if @leadset.email
|
19
19
|
-# = f.text_field :email, value: @leadset.email
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wco_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.97
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 3.20.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: jbuilder
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.11.5
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.11.5
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: haml
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -359,6 +373,7 @@ files:
|
|
359
373
|
- app/assets/javascripts/wco/application.js
|
360
374
|
- app/assets/javascripts/wco/collapse-expand.js
|
361
375
|
- app/assets/javascripts/wco/file_upload.js
|
376
|
+
- app/assets/javascripts/wco/invoices.js
|
362
377
|
- app/assets/javascripts/wco/office_action_templates.js
|
363
378
|
- app/assets/javascripts/wco/shared.js
|
364
379
|
- app/assets/stylesheets/vendor/bootstrap-4.6.2.min.css
|
@@ -373,6 +388,7 @@ files:
|
|
373
388
|
- app/controllers/wco/application_controller.rb
|
374
389
|
- app/controllers/wco/galleries_controller.rb
|
375
390
|
- app/controllers/wco/headlines_controller.rb
|
391
|
+
- app/controllers/wco/invoices_controller.rb
|
376
392
|
- app/controllers/wco/leads_controller.rb
|
377
393
|
- app/controllers/wco/leadsets_controller.rb
|
378
394
|
- app/controllers/wco/logs_controller.rb
|
@@ -405,7 +421,7 @@ files:
|
|
405
421
|
- app/models/wco/office_action_template.rb
|
406
422
|
- app/models/wco/office_action_template_tie.rb
|
407
423
|
- app/models/wco/photo.rb
|
408
|
-
- app/models/wco/premium_item.rb
|
424
|
+
- app/models/wco/premium_item.rb-trash
|
409
425
|
- app/models/wco/price.rb
|
410
426
|
- app/models/wco/product.rb
|
411
427
|
- app/models/wco/profile.rb
|
@@ -526,7 +542,9 @@ files:
|
|
526
542
|
- app/views/wco/products/_table.haml
|
527
543
|
- app/views/wco/products/edit.haml
|
528
544
|
- app/views/wco/products/index.haml
|
545
|
+
- app/views/wco/products/new.haml
|
529
546
|
- app/views/wco/products/show.haml
|
547
|
+
- app/views/wco/products/show.jbuilder
|
530
548
|
- app/views/wco/publishers/_form.haml
|
531
549
|
- app/views/wco/publishers/_header.haml
|
532
550
|
- app/views/wco/publishers/edit.haml
|
@@ -552,6 +570,8 @@ files:
|
|
552
570
|
- app/views/wco/tags/index.haml
|
553
571
|
- app/views/wco/tags/new.haml
|
554
572
|
- app/views/wco/tags/show.haml
|
573
|
+
- app/views/wco/unsubscribes/_header.haml
|
574
|
+
- app/views/wco/unsubscribes/_table.haml
|
555
575
|
- app/views/wco/videos/_form.haml
|
556
576
|
- app/views/wco/videos/_header.haml
|
557
577
|
- app/views/wco/videos/_index.haml
|
@@ -594,8 +614,6 @@ files:
|
|
594
614
|
- app/views/wco_email/email_layouts/_slug-3.html.erb
|
595
615
|
- app/views/wco_email/email_layouts/_test_tracking_footer.haml
|
596
616
|
- app/views/wco_email/email_layouts/_wasyaco_roundborders.html.erb
|
597
|
-
- app/views/wco_email/unsubscribes/_header.haml
|
598
|
-
- app/views/wco_email/unsubscribes/_table.haml
|
599
617
|
- app/views/wco_hosting/docker-compose/dc-any.erb
|
600
618
|
- app/views/wco_hosting/docker-compose/dc-helloworld.erb
|
601
619
|
- app/views/wco_hosting/docker-compose/dc-wordpress.erb
|
File without changes
|
File without changes
|