ish_manager 0.1.8.462 → 0.1.8.463
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 +4 -4
- data/app/controllers/ish_manager/invoices_controller.rb +68 -25
- data/app/views/ish_manager/leadsets/show.haml +5 -0
- data/config/routes.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3d19cd10fe96e5cb993413b121bc44c107cd793ca8280f193d18a5967b6fd1
|
4
|
+
data.tar.gz: 8269b21b2d010573fbb04ea80282e96507a5bc01bbf98c98e0cdd46157d3c1e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d623e2070e7f1f933960fc4c71aad603e77a6391aa7886e9a22b610d3c7c76d89e184aa346d8096f2416234d85623a4c59b58caa78ec3fb0b7b9bb19ef488c32
|
7
|
+
data.tar.gz: 58fe7332a16091c22fb181fd76f6c33cfeb44093d52196f198f5bf01dc66ef749566539c09646269799bd5002c4e3512031fbded7968d5090dcdafa7332600be
|
@@ -1,28 +1,52 @@
|
|
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
|
-
|
8
|
+
def create_monthly_pdf
|
9
|
+
@leadset = Leadset.find params[:leadset_id]
|
10
|
+
authorize! :create_monthly_invoice_pdf, @leadset
|
11
|
+
|
12
|
+
@invoice = Ish::Invoice.where({ leadset_id: @leadset.id, month_on: params[:month_on] }).first
|
13
|
+
if @invoice
|
14
|
+
flash_alert "Already created this invoice."
|
15
|
+
redirect_to controller: :leadsets, action: :show, id: @leadset.id
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
@invoice = Ish::Invoice.create({ leadset_id: @leadset.id, month_on: params[:month_on] })
|
20
|
+
|
21
|
+
@pdf = @invoice.generate_monthly_invoice params[:month_on]
|
22
|
+
filename = "invoice-#{@invoice.number}.pdf"
|
23
|
+
path = Rails.root.join 'tmp', filename
|
24
|
+
@pdf.render_file path
|
25
|
+
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
|
9
36
|
##
|
10
37
|
def create_pdf
|
11
38
|
@invoice = Ish::Invoice.new
|
12
39
|
authorize! :new, @invoice
|
13
40
|
|
14
|
-
tree_img_url = "https://wasya.co/wp-content/uploads/2023/09/tree-1.jpg"
|
15
41
|
tree_img_url = "#{Rails.root.join('public')}/tree-1.jpg"
|
16
42
|
wasya_co_logo_url = "#{Rails.root.join('public')}/259x66-WasyaCo-logo.png"
|
17
43
|
|
18
|
-
## canvas width: 612, height: 792
|
19
44
|
pdf = Prawn::Document.new
|
20
45
|
|
21
46
|
pdf.canvas do
|
22
47
|
pdf.image tree_img_url, at: [ 0, 792 ], width: 612
|
23
48
|
|
24
49
|
pdf.fill_color 'ffffff'
|
25
|
-
# pdf.stroke_color '000000'
|
26
50
|
pdf.transparent( 0.75 ) do
|
27
51
|
pdf.fill_rectangle [0, 792], 612, 792
|
28
52
|
end
|
@@ -30,38 +54,57 @@ class ::IshManager::InvoicesController < IshManager::ApplicationController
|
|
30
54
|
|
31
55
|
pdf.image wasya_co_logo_url, at: [252, 720], width: 108 ## 1.5"
|
32
56
|
|
33
|
-
pdf.bounding_box( [0.75*72, 9.
|
34
|
-
pdf.
|
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"
|
35
61
|
end
|
36
62
|
|
37
|
-
pdf.bounding_box( [4.5*72, 9.
|
38
|
-
pdf.
|
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' }"
|
39
67
|
end
|
40
68
|
|
41
|
-
pdf.bounding_box( [0.75*72, 8.
|
42
|
-
pdf.
|
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"
|
43
72
|
end
|
44
73
|
|
45
|
-
pdf.bounding_box( [4.5*72, 8.
|
46
|
-
pdf.
|
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."
|
47
77
|
end
|
48
78
|
|
49
|
-
pdf.
|
50
|
-
|
51
|
-
|
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
|
+
} )
|
52
104
|
|
53
105
|
pdf.text_box "Thank you!", at: [ 3.25*72, 1.25*72 ], width: 2*72, height: 1*72, align: :center
|
54
106
|
end
|
55
107
|
|
56
|
-
|
57
|
-
|
58
|
-
# pdf.text "hello, world?", align: :center
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
108
|
filename = "a-summary.pdf"
|
66
109
|
path = Rails.root.join 'tmp', filename
|
67
110
|
pdf.render_file path
|
@@ -29,6 +29,11 @@
|
|
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 Create invoice for month
|
35
|
+
= text_field_tag 'month_on'
|
36
|
+
= submit_tag 'Submit', data: { confirm: 'Are you sure?' }
|
32
37
|
%hr
|
33
38
|
|
34
39
|
.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/create-monthly-for/:leadset_id', to: 'invoices#create_monthly_pdf', as: :create_monthly_invoice_for_leadset
|
28
29
|
post 'invoices/create-pdf', to: 'invoices#create_pdf', as: :create_invoice_pdf
|
29
30
|
post 'invoices/create-stripe', to: 'invoices#create_stripe', as: :create_invoice_stripe
|
30
31
|
get 'invoices/new_pdf', to: 'invoices#new_pdf', as: :new_invoice_pdf
|