ish_manager 0.1.8.463 → 0.1.8.464

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: 3e3d19cd10fe96e5cb993413b121bc44c107cd793ca8280f193d18a5967b6fd1
4
- data.tar.gz: 8269b21b2d010573fbb04ea80282e96507a5bc01bbf98c98e0cdd46157d3c1e2
3
+ metadata.gz: 129a6f70a1dca0e0a0a6520c9cb3b47e588649c5cbb28c17020f1a05d928de0f
4
+ data.tar.gz: 6929d2066273ed6ba47f8c3e9528303c7862798238fb0a60470e46f305e295f8
5
5
  SHA512:
6
- metadata.gz: d623e2070e7f1f933960fc4c71aad603e77a6391aa7886e9a22b610d3c7c76d89e184aa346d8096f2416234d85623a4c59b58caa78ec3fb0b7b9bb19ef488c32
7
- data.tar.gz: 58fe7332a16091c22fb181fd76f6c33cfeb44093d52196f198f5bf01dc66ef749566539c09646269799bd5002c4e3512031fbded7968d5090dcdafa7332600be
6
+ metadata.gz: df339f9e3bbce4f31231cb70492eec9c43ce3d0678bbb4a58f5154aaa68b907efbd9e986406e7b900da7fd23914566748cc8ed875dd2deffe28e621311f942e7
7
+ data.tar.gz: 106dabcf7f541a6f46969792718c000e4a2f05719b3eb15063c3f8480ff3b9e56a156bf6315c8d3c5800ee3492c1146347837d36a1c7fac7cea4ef3affd5406b
@@ -6,115 +6,50 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
6
6
  before_action :set_lists
7
7
 
8
8
  def create_monthly_pdf
9
+ month_on = DateTime.strptime(params[:month_on], '%Y-%m-%d').strftime('%Y-%m-01')
9
10
  @leadset = Leadset.find params[:leadset_id]
10
11
  authorize! :create_monthly_invoice_pdf, @leadset
11
12
 
12
- @invoice = Ish::Invoice.where({ leadset_id: @leadset.id, month_on: params[:month_on] }).first
13
- if @invoice
13
+ @invoice = Ish::Invoice.where({ leadset_id: @leadset.id, month_on: month_on }).first
14
+ if @invoice && !params[:replace]
14
15
  flash_alert "Already created this invoice."
15
16
  redirect_to controller: :leadsets, action: :show, id: @leadset.id
16
17
  return
17
18
  end
18
19
 
19
- @invoice = Ish::Invoice.create({ leadset_id: @leadset.id, month_on: params[:month_on] })
20
+ if !@invoice
21
+ @invoice = Ish::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
20
28
 
21
- @pdf = @invoice.generate_monthly_invoice params[:month_on]
22
- filename = "invoice-#{@invoice.number}.pdf"
23
- path = Rails.root.join 'tmp', filename
29
+ @pdf = @invoice.generate_monthly_invoice
30
+ path = Rails.root.join 'tmp', @invoice.filename
24
31
  @pdf.render_file path
25
32
  data = File.read path
26
- File.delete(path) if File.exist?(path)
27
-
28
- send_data( data, { :filename => filename,
29
- :disposition => params[:disposition] ? params[:disposition] : :attachment,
30
- :type => 'application/pdf'
31
- })
32
- end
33
-
34
-
35
- ## @TODO: obsolete, remove
36
- ##
37
- def create_pdf
38
- @invoice = Ish::Invoice.new
39
- authorize! :new, @invoice
40
33
 
41
- tree_img_url = "#{Rails.root.join('public')}/tree-1.jpg"
42
- wasya_co_logo_url = "#{Rails.root.join('public')}/259x66-WasyaCo-logo.png"
43
-
44
- pdf = Prawn::Document.new
45
-
46
- pdf.canvas do
47
- pdf.image tree_img_url, at: [ 0, 792 ], width: 612
48
-
49
- pdf.fill_color 'ffffff'
50
- pdf.transparent( 0.75 ) do
51
- pdf.fill_rectangle [0, 792], 612, 792
52
- end
53
- pdf.fill_color '000000'
54
-
55
- pdf.image wasya_co_logo_url, at: [252, 720], width: 108 ## 1.5"
56
-
57
- pdf.bounding_box( [0.75*72, 9.25*72], width: 3.25*72, height: 0.75*72 ) do
58
- pdf.text "From:"
59
- pdf.text "Wasya Co"
60
- pdf.text "(415) 948-0368"
61
- end
62
-
63
- pdf.bounding_box( [4.5*72, 9.25*72], width: 3.25*72, height: 0.75*72 ) do
64
- pdf.text "Stats:"
65
- pdf.text "Date: #{ '2023-09-07' }"
66
- pdf.text "Invoice # #{ '111' }"
67
- end
68
-
69
- pdf.bounding_box( [0.75*72, 8.25*72], width: 3.25*72, height: 0.75*72 ) do
70
- pdf.text "To:"
71
- pdf.text "Creen Enterprise"
72
- end
73
-
74
- pdf.bounding_box( [4.5*72, 8.25*72], width: 3.25*72, height: 0.75*72 ) do
75
- pdf.text "Notes:"
76
- pdf.text "Support & various, for the month of August '23."
77
- end
78
-
79
- pdf.move_down 20
80
-
81
- pdf.table([
82
- [ 'Description', 'Type', 'Hours', 'Subtotal' ],
83
- [ 'Part 2/2', 'indep. proj.', '-', '$3,501' ],
84
- ], {
85
- position: :center,
86
- width: 7.5*72,
87
- cell_style: {
88
- inline_format: true,
89
- borders: [ :bottom ]
90
- },
91
- } )
92
-
93
- pdf.table([
94
- [ 'Total' ],
95
- [ '$3,501' ],
96
- ], {
97
- position: 7*72,
98
- width: 1*72,
99
- cell_style: {
100
- inline_format: true,
101
- borders: [ :bottom ]
102
- },
103
- } )
104
-
105
- pdf.text_box "Thank you!", at: [ 3.25*72, 1.25*72 ], width: 2*72, height: 1*72, align: :center
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."
106
44
  end
107
45
 
108
- filename = "a-summary.pdf"
109
- path = Rails.root.join 'tmp', filename
110
- pdf.render_file path
111
- data = File.read path
112
46
  File.delete(path) if File.exist?(path)
47
+ redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
113
48
 
114
- send_data( data, { :filename => filename,
115
- :disposition => params[:disposition] ? params[:disposition] : :attachment,
116
- :type => 'application/pdf'
117
- })
49
+ # send_data( data, { :filename => @invoice.filename,
50
+ # :disposition => params[:disposition] ? params[:disposition] : :attachment,
51
+ # :type => 'application/pdf'
52
+ # })
118
53
  end
119
54
 
120
55
  def create_stripe
@@ -170,6 +105,15 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
170
105
  @products_list = Wco::Product.list
171
106
  end
172
107
 
108
+ def email_send
109
+ @invoice = Ish::Invoice.find params[:id]
110
+ authorize! :send_email, @invoice
111
+ out = ::IshManager::LeadsetMailer.monthly_invoice( @invoice.id )
112
+ Rails.env.production? ? out.deliver_later : out.deliver_now
113
+ flash_notice "Scheduled to send an email."
114
+ redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
115
+ end
116
+
173
117
  def show
174
118
  @invoice = Ish::Invoice.find params[:id]
175
119
  authorize! :show, @invoice
@@ -0,0 +1,22 @@
1
+ require 'open-uri'
2
+
3
+ class IshManager::LeadsetMailer < IshManager::ApplicationMailer
4
+ default from: 'WasyaCo Consulting <hello@wasya.co>'
5
+
6
+ # layout 'mailer'
7
+
8
+ def monthly_invoice invoice_id
9
+ @invoice = ::Ish::Invoice.find invoice_id
10
+ @leadset = @invoice.leadset
11
+
12
+ path = Rails.root.join 'tmp', @invoice.filename
13
+ download = open( @invoice.asset.object.url(:original) )
14
+ IO.copy_stream( download, path )
15
+ attachments[@invoice.filename] = File.read( path )
16
+
17
+ mail( to: @leadset.email,
18
+ subject: "WasyaCo invoice for #{@invoice.month_on.strftime('%B')}",
19
+ )
20
+ end
21
+
22
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  class IshManager::OfficeMailer < IshManager::ApplicationMailer
3
- default from: 'WasyaCo Consulting & Software Development <hello@wasya.co>'
3
+ default from: 'WasyaCo Consulting & Software Development <no-reply@mail.wasyaco.com>'
4
4
 
5
5
  ## 2023-04-02 _vp_ Continue.
6
6
  def send_context_email ctx_id
@@ -3,4 +3,10 @@
3
3
  %ul
4
4
  - invoices.each do |i|
5
5
  %li
6
- = i.inspect
6
+ = i.month_on
7
+ \::
8
+ - if i.asset
9
+ = link_to i.number, i.asset.object.url(:original)
10
+ .inline-block= button_to 'Send', send_invoice_path(i), data: { confirm: 'Are you sure?' }
11
+ - else
12
+ = i.number
@@ -0,0 +1,6 @@
1
+
2
+ <p>Hello! Please see the invoice attached.</p>
3
+
4
+ <p>Regards,<br />
5
+ --<br />
6
+ WasyaCo RRT</p>
@@ -6,18 +6,23 @@
6
6
  .input-field
7
7
  = f.label :company_url
8
8
  = f.text_field :company_url
9
+
9
10
  .input-field
10
11
  = f.label :name
11
12
  = f.text_field :name
13
+
12
14
  .input-field
13
15
  = f.label :email
14
16
  = f.text_field :email
15
- -# .input-field
16
- -# = f.label :tag
17
- -# = f.text_field :tag
18
- -# .input-field
19
- -# %label Stripe customer_id
20
- -# = f.text_field :customer_id
17
+
18
+ .input-field
19
+ = f.label :next_invoice_number
20
+ = f.text_field :next_invoice_number
21
+
22
+ .input-field
23
+ %label Stripe customer_id
24
+ = f.text_field :customer_id
25
+
21
26
  .actions
22
27
  = f.submit
23
28
 
@@ -1,3 +1,4 @@
1
1
 
2
- %h1 Edit leadset
3
- = render 'form', :leadset => @leadset
2
+ .leadsets-edit.max-width
3
+ %h1 Edit leadset `#{link_to @leadset.name, leadset_path(@leadset)}`
4
+ = render 'form', :leadset => @leadset
@@ -1,5 +1,6 @@
1
1
 
2
- .row
3
- .col.s6.col-sm-offset-3
4
- %h5 New Leadset
5
- = render 'form', :leadset => @new_leadset
2
+ .leadsets-new.max-width
3
+ .row
4
+ .col.s6.col-sm-offset-3
5
+ %h5 New Leadset
6
+ = render 'form', :leadset => @new_leadset
@@ -31,9 +31,11 @@
31
31
  = render 'ish_manager/invoices/index_list', invoices: @invoices
32
32
 
33
33
  = form_tag create_monthly_invoice_for_leadset_path({ leadset_id: @leadset.id }) do
34
- %label Create invoice for month
34
+ %label Invoice for month
35
35
  = text_field_tag 'month_on'
36
- = submit_tag 'Submit', data: { confirm: 'Are you sure?' }
36
+ %label (x?)
37
+ = check_box_tag 'replace'
38
+ = submit_tag '>', data: { confirm: 'Are you sure?' }
37
39
  %hr
38
40
 
39
41
  .col-md-6
data/config/routes.rb CHANGED
@@ -25,6 +25,7 @@ IshManager::Engine.routes.draw do
25
25
 
26
26
  get 'image_assets', to: 'image_assets#index', as: :image_assets
27
27
 
28
+ post 'invoices/send/:id', to: 'invoices#email_send', as: :send_invoice
28
29
  post 'invoices/create-monthly-for/:leadset_id', to: 'invoices#create_monthly_pdf', as: :create_monthly_invoice_for_leadset
29
30
  post 'invoices/create-pdf', to: 'invoices#create_pdf', as: :create_invoice_pdf
30
31
  post 'invoices/create-stripe', to: 'invoices#create_stripe', as: :create_invoice_stripe
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.463
4
+ version: 0.1.8.464
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-08 00:00:00.000000000 Z
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -525,6 +525,7 @@ files:
525
525
  - app/jobs/ish_manager/email_campaign_job.rb-trash
526
526
  - app/jobs/ish_manager/test_email_job.rb
527
527
  - app/mailers/ish_manager/application_mailer.rb
528
+ - app/mailers/ish_manager/leadset_mailer.rb
528
529
  - app/mailers/ish_manager/meeting_mailer.rb
529
530
  - app/mailers/ish_manager/office_mailer.rb
530
531
  - app/mailers/ish_manager/offier_mailer.rb-trash
@@ -727,6 +728,7 @@ files:
727
728
  - app/views/ish_manager/leads/index.haml
728
729
  - app/views/ish_manager/leads/new.haml
729
730
  - app/views/ish_manager/leads/show.haml
731
+ - app/views/ish_manager/leadset_mailer/monthly_invoice.html.erb
730
732
  - app/views/ish_manager/leadsets/_form.haml
731
733
  - app/views/ish_manager/leadsets/edit.haml
732
734
  - app/views/ish_manager/leadsets/index.haml