ish_models 0.0.33.266 → 0.0.33.268
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gameui/asset3d.rb +2 -1
- data/lib/ish/invoice.rb +95 -17
- data/lib/ish_models.rb +1 -0
- data/lib/wco/price.rb +27 -0
- data/lib/wco/product.rb +12 -5
- data/lib/wco/subscription.rb +9 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd66d24c0e32d8c2062bb683a462892ec79779902e66cd184d5a087bb1e439ad
|
4
|
+
data.tar.gz: 164dbb6e924555332d22f0f8e07dfc172910810c232c64784d089e5459a3f697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4719d9a45e7de490242687d6022a0ebd478529ca584ba6d475f889d02c2f964fd3fb513c5b11b87c4fd831e9e063bf6fa248e45b13570fa98155af884ccb7fbe
|
7
|
+
data.tar.gz: a0438c17da408bff68f51947332b7f4c110b29eeee46837555097c29343db513afb8b58e591b0cd302b05025cf915d8338a086d95aee5354df752a954125c1b7
|
data/lib/gameui/asset3d.rb
CHANGED
@@ -9,6 +9,7 @@ class ::Gameui::Asset3d
|
|
9
9
|
include Ish::Utils
|
10
10
|
|
11
11
|
belongs_to :marker, class_name: 'Gameui::Marker', optional: true
|
12
|
+
belongs_to :invoice, class_name: 'Ish::Invoice', optional: true
|
12
13
|
|
13
14
|
has_mongoid_attached_file :object,
|
14
15
|
:storage => :s3,
|
@@ -22,7 +23,7 @@ class ::Gameui::Asset3d
|
|
22
23
|
|
23
24
|
def export_fields
|
24
25
|
%w|
|
25
|
-
marker_id
|
26
|
+
marker_id invoice_id
|
26
27
|
asset3d_file_name asset3d_content_type asset3d_file_size asset3d_updated_at asset3d_fingerprint
|
27
28
|
|;
|
28
29
|
end
|
data/lib/ish/invoice.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'autoinc'
|
2
|
-
|
2
|
+
require 'prawn'
|
3
|
+
require 'prawn/table'
|
3
4
|
|
4
5
|
##
|
5
6
|
## Invoice - for wasya.co
|
@@ -23,26 +24,103 @@ class Ish::Invoice
|
|
23
24
|
end
|
24
25
|
|
25
26
|
field :number, type: Integer
|
26
|
-
increments :number
|
27
27
|
|
28
|
-
field :
|
28
|
+
field :month_on, type: Date
|
29
29
|
|
30
|
-
|
31
|
-
field :paid_amount_cents, type: Integer, :default => 0 ## @TODO: unused? _vp_ 2023-08-18
|
30
|
+
has_one :asset, class_name: '::Gameui::Asset3d'
|
32
31
|
|
33
|
-
|
32
|
+
def filename
|
33
|
+
"invoice-#{number}.pdf"
|
34
|
+
end
|
35
|
+
|
36
|
+
# field :amount_cents, type: Integer
|
37
|
+
# has_many :payments, :class_name => 'Ish::Payment'
|
38
|
+
# field :paid_amount_cents, type: Integer, :default => 0 ## @TODO: unused? _vp_ 2023-08-18
|
39
|
+
# field :description, type: String
|
40
|
+
# field :items, type: Array
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
## Prawn/pdf unit of measure is 1/72"
|
45
|
+
## Canvas width: 612, height: 792
|
46
|
+
def generate_monthly_invoice
|
47
|
+
tree_img_url = "#{Rails.root.join('public')}/tree-1.jpg"
|
48
|
+
wasya_co_logo_url = "#{Rails.root.join('public')}/259x66-WasyaCo-logo.png"
|
49
|
+
|
50
|
+
## canvas width: 612, height: 792
|
51
|
+
pdf = Prawn::Document.new
|
52
|
+
|
53
|
+
pdf.canvas do
|
54
|
+
pdf.image tree_img_url, at: [ 0, 792 ], width: 612
|
55
|
+
|
56
|
+
pdf.fill_color 'ffffff'
|
57
|
+
pdf.transparent( 0.75 ) do
|
58
|
+
pdf.fill_rectangle [0, 792], 612, 792
|
59
|
+
end
|
60
|
+
pdf.fill_color '000000'
|
61
|
+
|
62
|
+
pdf.image wasya_co_logo_url, at: [252, 720], width: 108 ## 1.5"
|
34
63
|
|
35
|
-
|
64
|
+
pdf.bounding_box( [0.75*72, 9.25*72], width: 3.25*72, height: 0.75*72 ) do
|
65
|
+
pdf.text "From:"
|
66
|
+
pdf.text "Wasya Co"
|
67
|
+
pdf.text "victor@wasya.co"
|
68
|
+
end
|
36
69
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
70
|
+
pdf.bounding_box( [4.5*72, 9.25*72], width: 3.25*72, height: 0.75*72 ) do
|
71
|
+
pdf.text "Stats:"
|
72
|
+
pdf.text "Date: #{ Time.now.to_date.to_s }"
|
73
|
+
pdf.text "Invoice #: #{ number }"
|
74
|
+
end
|
75
|
+
|
76
|
+
pdf.bounding_box( [0.75*72, 8.25*72], width: 3.25*72, height: 0.75*72 ) do
|
77
|
+
pdf.text "To:"
|
78
|
+
pdf.text leadset.name
|
79
|
+
pdf.text leadset.email
|
80
|
+
end
|
81
|
+
|
82
|
+
pdf.bounding_box( [4.5*72, 8.25*72], width: 3.25*72, height: 0.75*72 ) do
|
83
|
+
pdf.text "Notes:"
|
84
|
+
pdf.text "Support & various tasks, for the month of #{ month_on.strftime('%B') }."
|
85
|
+
end
|
86
|
+
|
87
|
+
lineitems_with_header = [
|
88
|
+
[ 'Description', 'Per Unit', '# of Units', 'Subtotal' ]
|
89
|
+
]
|
90
|
+
total = 0
|
91
|
+
leadset.subscriptions.each do |i|
|
92
|
+
subtotal = (i.price.amount_cents * i.quantity).to_f/100
|
93
|
+
lineitems_with_header.push([ i.price.product.name, i.price.to_s, i.quantity, subtotal ])
|
94
|
+
total += subtotal
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
pdf.move_down 20
|
99
|
+
pdf.table(lineitems_with_header, {
|
100
|
+
position: :center,
|
101
|
+
width: 7.5*72,
|
102
|
+
cell_style: {
|
103
|
+
inline_format: true,
|
104
|
+
borders: [ :bottom ]
|
105
|
+
},
|
106
|
+
} )
|
107
|
+
|
108
|
+
pdf.table([
|
109
|
+
[ 'Total' ],
|
110
|
+
[ total ],
|
111
|
+
], {
|
112
|
+
position: 7*72,
|
113
|
+
width: 1*72,
|
114
|
+
cell_style: {
|
115
|
+
inline_format: true,
|
116
|
+
borders: [ :bottom ]
|
117
|
+
},
|
118
|
+
} )
|
119
|
+
|
120
|
+
pdf.text_box "Thank you!", at: [ 3.25*72, 1.25*72 ], width: 2*72, height: 1*72, align: :center
|
121
|
+
end
|
122
|
+
|
123
|
+
return pdf
|
124
|
+
end
|
47
125
|
|
48
126
|
end
|
data/lib/ish_models.rb
CHANGED
data/lib/wco/price.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
##
|
3
|
+
## Not used. _vp_ 2023-09-07
|
4
|
+
## Just replicating the Stripe structure.
|
5
|
+
##
|
6
|
+
class Wco::Price
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Timestamps
|
9
|
+
|
10
|
+
belongs_to :product, class_name: '::Wco::Product', inverse_of: :prices
|
11
|
+
|
12
|
+
has_many :subscriptions, class_name: '::Wco::Subscription', inverse_of: :price, foreign_key: :wco_price_id
|
13
|
+
|
14
|
+
field :amount_cents, type: Integer
|
15
|
+
|
16
|
+
INTERVALS = [ nil, 'day', 'week', 'month', 'year' ]
|
17
|
+
field :interval, type: String
|
18
|
+
|
19
|
+
field :price_id # stripe
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
"$#{ amount_cents.to_f/100 } / #{interval}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
data/lib/wco/product.rb
CHANGED
@@ -6,14 +6,21 @@ class Wco::Product
|
|
6
6
|
field :name
|
7
7
|
|
8
8
|
field :product_id # stripe
|
9
|
-
field :price_id # stripe
|
10
9
|
|
11
|
-
|
10
|
+
## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
|
11
|
+
# INTERVALS = [ nil, 'day', 'week', 'month', 'year' ]
|
12
|
+
# field :interval, type: String
|
12
13
|
|
13
|
-
|
14
|
-
field :
|
14
|
+
## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
|
15
|
+
# field :price_id # stripe
|
15
16
|
|
16
|
-
|
17
|
+
## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
|
18
|
+
# field :price_cents, type: Integer
|
19
|
+
|
20
|
+
## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
|
21
|
+
# has_many :subscriptions, class_name: '::Wco::Subscription', inverse_of: :subscription
|
22
|
+
|
23
|
+
has_many :prices, class_name: '::Wco::Price', inverse_of: :product
|
17
24
|
|
18
25
|
def self.list
|
19
26
|
[ [nil,nil] ] + self.all.map { |i| [i.name, i.id] }
|
data/lib/wco/subscription.rb
CHANGED
@@ -7,11 +7,18 @@ class Wco::Subscription
|
|
7
7
|
field :price_id, type: :string # stripe
|
8
8
|
|
9
9
|
field :leadset_id
|
10
|
+
def leadset
|
11
|
+
Leadset.find leadset_id
|
12
|
+
end
|
10
13
|
|
11
|
-
|
14
|
+
field :quantity, type: :integer
|
12
15
|
|
13
|
-
belongs_to :
|
16
|
+
belongs_to :product, class_name: '::Wco::Product', inverse_of: :subscriptions
|
17
|
+
belongs_to :price, class_name: '::Wco::Price', inverse_of: :subscriptions, foreign_key: :wco_price_id
|
14
18
|
|
19
|
+
## This was for ACL on wco dashboard? Should that be the same class?
|
20
|
+
## @TODO: optional ?!
|
21
|
+
belongs_to :profile, class_name: '::Ish::UserProfile', inverse_of: :subscriptions, optional: true
|
15
22
|
|
16
23
|
end
|
17
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.33.
|
4
|
+
version: 0.0.33.268
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/video.rb
|
188
188
|
- lib/wco/appliance.rb
|
189
189
|
- lib/wco/appliance_tmpl.rb
|
190
|
+
- lib/wco/price.rb
|
190
191
|
- lib/wco/product.rb
|
191
192
|
- lib/wco/serverhost.rb
|
192
193
|
- lib/wco/subscription.rb
|