caboose-cms 0.5.104 → 0.5.105
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWE5ZDkzMzI3NTZkNGQ3ZGIwYjJmOGQzM2ZjYTE4Y2QxMTdhMTk2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODQ3Y2NmZDA1NWE1Y2UxOTg2Zjg5NjZmMWM5NDdmNTBhZWZiZTFhZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTAxMTA5NzkyYjY5ZTZjZWUzNWY0MDhjYTU3ZGFlMzQzODg0ZDdjMWZlMDdk
|
10
|
+
N2VlY2FjOGUxODA4NjM1ZmMyMmExYTZlMTQwYTgyMTQzMDgwMTFjOGI3NzMy
|
11
|
+
ZjE1YWI5YzllZTUzZWMxYWQ2ZjgyNDhmNGU1ZjlhNjE5ZTk1Zjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Y5YjhkMzg5MzEwOGFhN2I1ZTllN2VjMjNmM2QzZTMxZmVkMjI4NDc4YTkz
|
14
|
+
YTZlYjRjM2MwZTE1Zjg4ZTUzNzI3ZGFiZTM3M2JmNzdkNGIwY2Q1ZGE1NjZm
|
15
|
+
OWI0YTE4ODMxOWIzNDNhNTA2OTYxYzczMTMxNDkyNDM4OGRlMjI=
|
data/app/models/caboose/order.rb
CHANGED
@@ -7,209 +7,191 @@ module Caboose
|
|
7
7
|
self.table_name = 'store_orders'
|
8
8
|
self.primary_key = 'id'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# :email,
|
47
|
-
# :payment_id,
|
48
|
-
# :gateway_id,
|
49
|
-
# :transaction_d,
|
50
|
-
# :auth_code,
|
51
|
-
# :amount_discounted,
|
52
|
-
# :shipping_carrier,
|
53
|
-
# :shipping_service_code,
|
54
|
-
# :order_number,
|
55
|
-
# :date_shipped,
|
56
|
-
# :transaction_service,
|
57
|
-
# :transaction_id
|
58
|
-
|
59
|
-
#STATUS_CART = 'cart'
|
60
|
-
#STATUS_PENDING = 'pending'
|
61
|
-
#STATUS_CANCELED = 'canceled'
|
62
|
-
#STATUS_SHIPPED = 'shipped'
|
63
|
-
#STATUS_TESTING = 'testing'
|
10
|
+
belongs_to :site
|
11
|
+
belongs_to :customer, :class_name => 'Caboose::User'
|
12
|
+
belongs_to :shipping_address, :class_name => 'Caboose::Address'
|
13
|
+
belongs_to :billing_address, :class_name => 'Caboose::Address'
|
14
|
+
has_many :discounts
|
15
|
+
has_many :line_items, :order => :id
|
16
|
+
has_many :order_packages, :class_name => 'Caboose::OrderPackage'
|
17
|
+
has_many :order_transactions
|
18
|
+
|
19
|
+
attr_accessible :id,
|
20
|
+
:site_id,
|
21
|
+
:alternate_id,
|
22
|
+
:subtotal,
|
23
|
+
:tax,
|
24
|
+
:shipping,
|
25
|
+
:handling,
|
26
|
+
:custom_discount,
|
27
|
+
:discount,
|
28
|
+
:total,
|
29
|
+
:customer_id,
|
30
|
+
:shipping_address_id,
|
31
|
+
:billing_address_id,
|
32
|
+
:status,
|
33
|
+
:financial_status,
|
34
|
+
:referring_site,
|
35
|
+
:landing_page,
|
36
|
+
:landing_page_ref,
|
37
|
+
:auth_amount,
|
38
|
+
:date_created,
|
39
|
+
:notes
|
40
|
+
|
41
|
+
STATUS_CART = 'cart'
|
42
|
+
STATUS_PENDING = 'pending'
|
43
|
+
STATUS_CANCELED = 'canceled'
|
44
|
+
STATUS_SHIPPED = 'shipped'
|
45
|
+
STATUS_TESTING = 'testing'
|
64
46
|
|
65
47
|
#
|
66
48
|
# Scopes
|
67
49
|
#
|
68
50
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
51
|
+
scope :test , where('status = ?', 'testing')
|
52
|
+
scope :cancelled , where('status = ?', 'cancelled')
|
53
|
+
scope :pending , where('status = ?', 'pending')
|
54
|
+
#TODO scope :fulfilled
|
55
|
+
#TODO scope :unfulfilled
|
56
|
+
scope :authorized , where('financial_status = ?', 'authorized')
|
57
|
+
scope :captured , where('financial_status = ?', 'captured')
|
58
|
+
scope :refunded , where('financial_status = ?', 'refunded')
|
59
|
+
scope :voided , where('financial_status = ?', 'voided')
|
78
60
|
|
79
61
|
#
|
80
62
|
# Validations
|
81
63
|
#
|
82
64
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
65
|
+
validates :status, :inclusion => {
|
66
|
+
:in => ['cart', 'pending', 'cancelled', 'shipped', 'testing'],
|
67
|
+
:message => "%{value} is not a valid status. Must be either 'pending' or 'shipped'"
|
68
|
+
}
|
69
|
+
|
70
|
+
validates :financial_status, :inclusion => {
|
71
|
+
:in => ['pending', 'authorized', 'captured', 'refunded', 'voided'],
|
72
|
+
:message => "%{value} is not a valid financial status. Must be 'authorized', 'captured', 'refunded' or 'voided'"
|
73
|
+
}
|
92
74
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
75
|
+
def packages
|
76
|
+
self.order_packages
|
77
|
+
end
|
78
|
+
|
79
|
+
def decrement_quantities
|
80
|
+
return false if self.decremented
|
81
|
+
|
82
|
+
self.line_items.each do |line_item|
|
83
|
+
line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
|
84
|
+
end
|
85
|
+
|
86
|
+
self.update_attribute(:decremented, true)
|
87
|
+
end
|
88
|
+
|
89
|
+
def increment_quantities
|
90
|
+
return false if !self.decremented
|
91
|
+
|
92
|
+
self.line_items.each do |line_item|
|
93
|
+
line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
|
94
|
+
end
|
95
|
+
|
96
|
+
self.update_attribute(:decremented, false)
|
97
|
+
end
|
98
|
+
|
99
|
+
def resend_confirmation
|
100
|
+
OrdersMailer.configure_for_site(self.site_id).customer_new_order(self).deliver
|
101
|
+
end
|
102
|
+
|
103
|
+
def test?
|
104
|
+
self.status == 'testing'
|
105
|
+
end
|
106
|
+
|
107
|
+
def authorized?
|
108
|
+
self.financial_status == 'authorized'
|
109
|
+
end
|
110
|
+
|
111
|
+
def capture
|
112
|
+
PaymentProcessor.capture(self)
|
113
|
+
end
|
114
|
+
|
115
|
+
def refuned
|
116
|
+
PaymentProcessor.refund(self)
|
117
|
+
end
|
118
|
+
|
119
|
+
def void
|
120
|
+
PaymentProcessor.void(self)
|
121
|
+
end
|
122
|
+
|
123
|
+
def calculate
|
124
|
+
self.update_column(:subtotal , self.calculate_subtotal )
|
125
|
+
self.update_column(:tax , self.calculate_tax )
|
126
|
+
self.update_column(:shipping , self.calculate_shipping )
|
127
|
+
self.update_column(:handling , self.calculate_handling )
|
128
|
+
self.update_column(:discount , self.calculate_discount )
|
129
|
+
self.update_column(:total , self.calculate_total )
|
130
|
+
end
|
131
|
+
|
132
|
+
def calculate_subtotal
|
133
|
+
return 0.0 if self.line_items.empty?
|
134
|
+
x = 0.0
|
135
|
+
self.line_items.each{ |li| x = x + li.variant.price }
|
136
|
+
return x
|
137
|
+
end
|
138
|
+
|
139
|
+
def calculate_tax
|
140
|
+
return 0.0 if !self.shipping_address
|
141
|
+
self.subtotal * TaxCalculator.tax_rate(self.shipping_address)
|
142
|
+
end
|
143
|
+
|
144
|
+
def calculate_shipping
|
145
|
+
return 0.0 if self.order_packages.nil? || self.order_packages.count == 0
|
146
|
+
x = 0.0
|
147
|
+
self.order_packages.each{ |op| x = x + op.total }
|
148
|
+
return x
|
149
|
+
end
|
150
|
+
|
151
|
+
def calculate_handling
|
152
|
+
return 0.0 if self.site.nil? || self.site.store_config.nil?
|
153
|
+
self.subtotal * self.site.store_config.handling_percentage.to_f
|
154
|
+
end
|
155
|
+
|
156
|
+
def calculate_discount
|
157
|
+
return 0.0 if self.discounts.nil? || self.discounts.count == 0
|
158
|
+
x = 0.0
|
159
|
+
self.discounts.each{ |d| x = x + d.amount }
|
160
|
+
x = x + self.custom_discount if self.custom_discount
|
161
|
+
return x
|
162
|
+
end
|
163
|
+
|
164
|
+
def calculate_total
|
165
|
+
return (self.subtotal + self.tax + self.shipping + self.handling) - self.discount
|
166
|
+
end
|
167
|
+
|
168
|
+
def shipping_and_handling
|
169
|
+
(self.shipping ? self.shipping : 0.0) + (self.handling ? self.handling : 0.0)
|
170
|
+
end
|
171
|
+
|
172
|
+
def item_count
|
173
|
+
count = 0
|
174
|
+
self.line_items.each{ |li| count = count + li.quantity } if self.line_items
|
175
|
+
return count
|
176
|
+
end
|
177
|
+
|
178
|
+
def take_gift_card_funds
|
179
|
+
return if self.discounts.nil? || self.discounts.count == 0
|
180
|
+
self.discounts.each do |d|
|
181
|
+
gc = d.gift_card
|
182
|
+
gc.balance = gc.balance - d.amount
|
183
|
+
gc.save
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def has_empty_shipping_methods?
|
188
|
+
return true if self.order_packages.nil?
|
189
|
+
return true if self.order_packages.count == 0
|
190
|
+
self.order_packages.each do |op|
|
191
|
+
return true if op.shipping_method_id.nil?
|
192
|
+
end
|
193
|
+
return false
|
194
|
+
end
|
213
195
|
|
214
196
|
end
|
215
197
|
end
|
@@ -257,7 +257,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
257
257
|
Caboose::Discount => [
|
258
258
|
[ :gift_card_id , :integer ],
|
259
259
|
[ :order_id , :integer ],
|
260
|
-
[ :amount , :decimal , { :precision => 8, :scale => 2
|
260
|
+
[ :amount , :decimal , { :precision => 8, :scale => 2 }]
|
261
261
|
],
|
262
262
|
Caboose::Domain => [
|
263
263
|
[ :site_id , :integer ],
|
@@ -270,9 +270,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
270
270
|
[ :name , :string ],
|
271
271
|
[ :code , :string ],
|
272
272
|
[ :card_type , :string ],
|
273
|
-
[ :total , :decimal , { :precision => 8, :scale => 2
|
274
|
-
[ :balance , :decimal , { :precision => 8, :scale => 2
|
275
|
-
[ :min_order_total , :decimal , { :precision => 8, :scale => 2
|
273
|
+
[ :total , :decimal , { :precision => 8, :scale => 2 }],
|
274
|
+
[ :balance , :decimal , { :precision => 8, :scale => 2 }],
|
275
|
+
[ :min_order_total , :decimal , { :precision => 8, :scale => 2 }],
|
276
276
|
[ :date_available , :datetime ],
|
277
277
|
[ :date_expires , :datetime ],
|
278
278
|
[ :status , :string ]
|
@@ -285,7 +285,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
285
285
|
[ :quantity , :integer , :default => 0 ],
|
286
286
|
[ :status , :string ],
|
287
287
|
[ :tracking_number , :string ],
|
288
|
-
[ :price , :decimal , { :precision => 8, :scale => 2
|
288
|
+
[ :price , :decimal , { :precision => 8, :scale => 2 }],
|
289
289
|
[ :notes , :text ],
|
290
290
|
[ :custom1 , :string ],
|
291
291
|
[ :custom2 , :string ],
|
@@ -312,7 +312,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
312
312
|
[ :order_id , :integer ],
|
313
313
|
[ :date_processed , :datetime ],
|
314
314
|
[ :transaction_type , :string ],
|
315
|
-
[ :amount , :decimal , { :precision => 8, :scale => 2
|
315
|
+
[ :amount , :decimal , { :precision => 8, :scale => 2 }],
|
316
316
|
[ :transaction_id , :string ],
|
317
317
|
[ :auth_code , :string ],
|
318
318
|
[ :response_code , :string ],
|
@@ -328,18 +328,18 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
328
328
|
[ :shipping_package_id , :integer ],
|
329
329
|
[ :status , :string ],
|
330
330
|
[ :tracking_number , :string ],
|
331
|
-
[ :total , :decimal , { :precision => 8, :scale => 2
|
331
|
+
[ :total , :decimal , { :precision => 8, :scale => 2 }]
|
332
332
|
],
|
333
333
|
Caboose::Order => [
|
334
334
|
[ :site_id , :integer ],
|
335
335
|
[ :alternate_id , :integer ],
|
336
|
-
[ :subtotal , :decimal , { :precision => 8, :scale => 2
|
337
|
-
[ :tax , :decimal , { :precision => 8, :scale => 2
|
338
|
-
[ :shipping , :decimal , { :precision => 8, :scale => 2
|
339
|
-
[ :handling , :decimal , { :precision => 8, :scale => 2
|
340
|
-
[ :custom_discount , :decimal , { :precision => 8, :scale => 2
|
341
|
-
[ :discount , :decimal , { :precision => 8, :scale => 2
|
342
|
-
[ :total , :decimal , { :precision => 8, :scale => 2
|
336
|
+
[ :subtotal , :decimal , { :precision => 8, :scale => 2 }],
|
337
|
+
[ :tax , :decimal , { :precision => 8, :scale => 2 }],
|
338
|
+
[ :shipping , :decimal , { :precision => 8, :scale => 2 }],
|
339
|
+
[ :handling , :decimal , { :precision => 8, :scale => 2 }],
|
340
|
+
[ :custom_discount , :decimal , { :precision => 8, :scale => 2 }],
|
341
|
+
[ :discount , :decimal , { :precision => 8, :scale => 2 }],
|
342
|
+
[ :total , :decimal , { :precision => 8, :scale => 2 }],
|
343
343
|
[ :customer_id , :integer ],
|
344
344
|
[ :financial_status , :string ],
|
345
345
|
[ :shipping_address_id , :integer ],
|
@@ -644,8 +644,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
644
644
|
[ :alternate_id , :string ],
|
645
645
|
[ :sku , :string ],
|
646
646
|
[ :barcode , :string ],
|
647
|
-
[ :price , :decimal , { :precision => 8, :scale => 2
|
648
|
-
[ :sale_price , :decimal , { :precision => 8, :scale => 2
|
647
|
+
[ :price , :decimal , { :precision => 8, :scale => 2 }],
|
648
|
+
[ :sale_price , :decimal , { :precision => 8, :scale => 2 }],
|
649
649
|
[ :date_sale_starts , :datetime ],
|
650
650
|
[ :date_sale_end , :datetime ],
|
651
651
|
[ :available , :boolean ],
|
File without changes
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.105
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
@@ -650,9 +650,8 @@ files:
|
|
650
650
|
- app/views/caboose/block_types/admin_edit_icon.html.erb
|
651
651
|
- app/views/caboose/block_types/admin_index.html.erb
|
652
652
|
- app/views/caboose/block_types/admin_new.html.erb
|
653
|
-
- app/views/caboose/blocks/#Untitled-2#
|
654
|
-
- app/views/caboose/blocks/#_checkbox.html.erb#
|
655
653
|
- app/views/caboose/blocks/_block.html.erb
|
654
|
+
- app/views/caboose/blocks/_checkbox.html.erb
|
656
655
|
- app/views/caboose/blocks/_controller_view_content.html.erb
|
657
656
|
- app/views/caboose/blocks/_file.html.erb
|
658
657
|
- app/views/caboose/blocks/_heading.html.erb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
checked = block.value
|
3
|
-
checked = 0 if checked.nil?
|
4
|
-
checked = checked == 1 || checked == '1' ? true : false
|
5
|
-
%>
|
6
|
-
<% if editing %>
|
7
|
-
<div id='block_<%= block.id %>'><%= raw block.block_type.description %> = <%= (checked ? "Yes" : "No") %></div>
|
8
|
-
<% else %>
|
9
|
-
<%= raw block.block_type.description %>
|
10
|
-
<% end %>
|