ish_manager 0.1.8.462 → 0.1.8.464

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d544fb840059764a4d3c9c557416c0ec338ca5ce9f2e109aff72bc3743e844a6
4
- data.tar.gz: 82efc85b76bde5801fb399907e341d0f944f7813d4800a569f5e6109d3572878
3
+ metadata.gz: 129a6f70a1dca0e0a0a6520c9cb3b47e588649c5cbb28c17020f1a05d928de0f
4
+ data.tar.gz: 6929d2066273ed6ba47f8c3e9528303c7862798238fb0a60470e46f305e295f8
5
5
  SHA512:
6
- metadata.gz: 9a308e33cb23380dcc77f7b7518cfde43587d3f2260745dd9c808990c9acbefa9412a52e13e8341da39cc3b17f467957426590366927c5f1431740d54f3ffc80
7
- data.tar.gz: 49c3077ff88f4139b3bc2a25f57202b21ae0f26784dca13eb486f24c1a0e7a02bbb12f1c593a04ff4da571d24523f7c348f942e7cfdfa437d00e830f8bb0223f
6
+ metadata.gz: df339f9e3bbce4f31231cb70492eec9c43ce3d0678bbb4a58f5154aaa68b907efbd9e986406e7b900da7fd23914566748cc8ed875dd2deffe28e621311f942e7
7
+ data.tar.gz: 106dabcf7f541a6f46969792718c000e4a2f05719b3eb15063c3f8480ff3b9e56a156bf6315c8d3c5800ee3492c1146347837d36a1c7fac7cea4ef3affd5406b
@@ -1,77 +1,55 @@
1
1
  require 'prawn'
2
+ require 'prawn/table'
2
3
 
3
4
  class ::IshManager::InvoicesController < IshManager::ApplicationController
4
5
 
5
6
  before_action :set_lists
6
7
 
7
- ##
8
- ## Prawn/pdf unit of measure is 1/72" .
9
- ##
10
- def create_pdf
11
- @invoice = Ish::Invoice.new
12
- authorize! :new, @invoice
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
19
- pdf = Prawn::Document.new
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
- ])
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
52
12
 
53
- pdf.text_box "Thank you!", at: [ 3.25*72, 1.25*72 ], width: 2*72, height: 1*72, align: :center
13
+ @invoice = Ish::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
54
18
  end
55
19
 
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
56
28
 
29
+ @pdf = @invoice.generate_monthly_invoice
30
+ path = Rails.root.join 'tmp', @invoice.filename
31
+ @pdf.render_file path
32
+ data = File.read path
57
33
 
58
- # pdf.text "hello, world?", align: :center
59
-
60
-
61
-
62
-
63
-
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
64
45
 
65
- filename = "a-summary.pdf"
66
- path = Rails.root.join 'tmp', filename
67
- pdf.render_file path
68
- data = File.read path
69
46
  File.delete(path) if File.exist?(path)
47
+ redirect_to controller: :leadsets, action: :show, id: @invoice.leadset_id
70
48
 
71
- send_data( data, { :filename => filename,
72
- :disposition => params[:disposition] ? params[:disposition] : :attachment,
73
- :type => 'application/pdf'
74
- })
49
+ # send_data( data, { :filename => @invoice.filename,
50
+ # :disposition => params[:disposition] ? params[:disposition] : :attachment,
51
+ # :type => 'application/pdf'
52
+ # })
75
53
  end
76
54
 
77
55
  def create_stripe
@@ -127,6 +105,15 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
127
105
  @products_list = Wco::Product.list
128
106
  end
129
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
+
130
117
  def show
131
118
  @invoice = Ish::Invoice.find params[:id]
132
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
@@ -29,6 +29,13 @@
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
  = render 'ish_manager/invoices/index_list', invoices: @invoices
32
+
33
+ = form_tag create_monthly_invoice_for_leadset_path({ leadset_id: @leadset.id }) do
34
+ %label Invoice for month
35
+ = text_field_tag 'month_on'
36
+ %label (x?)
37
+ = check_box_tag 'replace'
38
+ = submit_tag '>', data: { confirm: 'Are you sure?' }
32
39
  %hr
33
40
 
34
41
  .col-md-6
data/config/routes.rb CHANGED
@@ -25,6 +25,8 @@ 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
29
+ post 'invoices/create-monthly-for/:leadset_id', to: 'invoices#create_monthly_pdf', as: :create_monthly_invoice_for_leadset
28
30
  post 'invoices/create-pdf', to: 'invoices#create_pdf', as: :create_invoice_pdf
29
31
  post 'invoices/create-stripe', to: 'invoices#create_stripe', as: :create_invoice_stripe
30
32
  get 'invoices/new_pdf', to: 'invoices#new_pdf', as: :new_invoice_pdf
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.462
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