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
- NTc4MzdjM2Q1ZDYwZmFmODU1ODNjZDkzMGQ0MGNhMTBjOTE4N2VkMQ==
4
+ MWE5ZDkzMzI3NTZkNGQ3ZGIwYjJmOGQzM2ZjYTE4Y2QxMTdhMTk2ZQ==
5
5
  data.tar.gz: !binary |-
6
- OTE2MzIwNTY0ZGE4ODE2ZWJlOGFiMTg3OGU3MzBmMGE3MzJhMGU3Nw==
6
+ ODQ3Y2NmZDA1NWE1Y2UxOTg2Zjg5NjZmMWM5NDdmNTBhZWZiZTFhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjMwYTFiNmJhMzY0YWJiNmYzMjJiNTI3ZDUwMGZiNTczNDE5YWUyMzE1Y2Qy
10
- MmMwN2NmZjc3YzlkNWZkZGMxMDI1NjAyMzIwNzk4NDZmY2ZlNzU0ZWFmOTU3
11
- NTFhMTY5N2MwYWNmMGI1NjU4NWFhMjhhNjFjN2ZlMTg2MzQ4N2E=
9
+ NTAxMTA5NzkyYjY5ZTZjZWUzNWY0MDhjYTU3ZGFlMzQzODg0ZDdjMWZlMDdk
10
+ N2VlY2FjOGUxODA4NjM1ZmMyMmExYTZlMTQwYTgyMTQzMDgwMTFjOGI3NzMy
11
+ ZjE1YWI5YzllZTUzZWMxYWQ2ZjgyNDhmNGU1ZjlhNjE5ZTk1Zjk=
12
12
  data.tar.gz: !binary |-
13
- MzlhZjhmNjBiZmJkMGI2MzYwYzUzNDY5NDYzOThkODM3ZjMwZTk2NTM4Njdk
14
- NzNlMTFmNTdjNWFkNzljZTg1NzhkODVkNmM3ZTkzODJkNmJiN2JiMTdlNTJj
15
- MjI4MGViOWQ1OTVmNWJjYjFhY2E2MjhiZDI4ZmM3MmE5ZGFjNDk=
13
+ M2Y5YjhkMzg5MzEwOGFhN2I1ZTllN2VjMjNmM2QzZTMxZmVkMjI4NDc4YTkz
14
+ YTZlYjRjM2MwZTE1Zjg4ZTUzNzI3ZGFiZTM3M2JmNzdkNGIwY2Q1ZGE1NjZm
15
+ OWI0YTE4ODMxOWIzNDNhNTA2OTYxYzczMTMxNDkyNDM4OGRlMjI=
@@ -7,209 +7,191 @@ module Caboose
7
7
  self.table_name = 'store_orders'
8
8
  self.primary_key = 'id'
9
9
 
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
- # :payment_status,
42
- # :cancel_reason,
43
- # :date_authorized,
44
- # :date_captured,
45
- # :date_cancelled,
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
- #scope :test , where('status = ?', 'testing')
70
- #scope :cancelled , where('status = ?', 'cancelled')
71
- #scope :pending , where('status = ?', 'pending')
72
- ##TODO scope :fulfilled
73
- ##TODO scope :unfulfilled
74
- #scope :authorized , where('financial_status = ?', 'authorized')
75
- #scope :captured , where('financial_status = ?', 'captured')
76
- #scope :refunded , where('financial_status = ?', 'refunded')
77
- #scope :voided , where('financial_status = ?', 'voided')
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
- #validates :status, :inclusion => {
84
- # :in => ['cart', 'pending', 'cancelled', 'shipped', 'testing'],
85
- # :message => "%{value} is not a valid status. Must be either 'pending' or 'shipped'"
86
- #}
87
- #
88
- #validates :financial_status, :inclusion => {
89
- # :in => ['pending', 'authorized', 'captured', 'refunded', 'voided'],
90
- # :message => "%{value} is not a valid financial status. Must be 'authorized', 'captured', 'refunded' or 'voided'"
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
- #def packages
94
- # self.order_packages
95
- #end
96
- #
97
- #def decrement_quantities
98
- # return false if self.decremented
99
- #
100
- # self.line_items.each do |line_item|
101
- # line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
102
- # end
103
- #
104
- # self.update_attribute(:decremented, true)
105
- #end
106
- #
107
- #def increment_quantities
108
- # return false if !self.decremented
109
- #
110
- # self.line_items.each do |line_item|
111
- # line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
112
- # end
113
- #
114
- # self.update_attribute(:decremented, false)
115
- #end
116
- #
117
- #def resend_confirmation
118
- # OrdersMailer.configure_for_site(self.site_id).customer_new_order(self).deliver
119
- #end
120
- #
121
- #def test?
122
- # self.status == 'testing'
123
- #end
124
- #
125
- #def authorized?
126
- # self.financial_status == 'authorized'
127
- #end
128
- #
129
- #def capture
130
- # PaymentProcessor.capture(self)
131
- #end
132
- #
133
- #def refuned
134
- # PaymentProcessor.refund(self)
135
- #end
136
- #
137
- #def void
138
- # PaymentProcessor.void(self)
139
- #end
140
- #
141
- #def calculate
142
- # self.update_column(:subtotal , self.calculate_subtotal )
143
- # self.update_column(:tax , self.calculate_tax )
144
- # self.update_column(:shipping , self.calculate_shipping )
145
- # self.update_column(:handling , self.calculate_handling )
146
- # self.update_column(:discount , self.calculate_discount )
147
- # self.update_column(:total , self.calculate_total )
148
- #end
149
- #
150
- #def calculate_subtotal
151
- # return 0.0 if self.line_items.empty?
152
- # x = 0.0
153
- # self.line_items.each{ |li| x = x + li.variant.price }
154
- # return x
155
- #end
156
- #
157
- #def calculate_tax
158
- # return 0.0 if !self.shipping_address
159
- # self.subtotal * TaxCalculator.tax_rate(self.shipping_address)
160
- #end
161
- #
162
- #def calculate_shipping
163
- # return 0.0 if self.order_packages.nil? || self.order_packages.count == 0
164
- # x = 0.0
165
- # self.order_packages.each{ |op| x = x + op.total }
166
- # return x
167
- #end
168
- #
169
- #def calculate_handling
170
- # return 0.0 if self.site.nil? || self.site.store_config.nil?
171
- # self.subtotal * self.site.store_config.handling_percentage.to_f
172
- #end
173
- #
174
- #def calculate_discount
175
- # return 0.0 if self.discounts.nil? || self.discounts.count == 0
176
- # x = 0.0
177
- # self.discounts.each{ |d| x = x + d.amount }
178
- # x = x + self.custom_discount if self.custom_discount
179
- # return x
180
- #end
181
- #
182
- #def calculate_total
183
- # return (self.subtotal + self.tax + self.shipping + self.handling) - self.discount
184
- #end
185
- #
186
- #def shipping_and_handling
187
- # (self.shipping ? self.shipping : 0.0) + (self.handling ? self.handling : 0.0)
188
- #end
189
- #
190
- #def item_count
191
- # count = 0
192
- # self.line_items.each{ |li| count = count + li.quantity } if self.line_items
193
- # return count
194
- #end
195
- #
196
- #def take_gift_card_funds
197
- # return if self.discounts.nil? || self.discounts.count == 0
198
- # self.discounts.each do |d|
199
- # gc = d.gift_card
200
- # gc.balance = gc.balance - d.amount
201
- # gc.save
202
- # end
203
- #end
204
- #
205
- #def has_empty_shipping_methods?
206
- # return true if self.order_packages.nil?
207
- # return true if self.order_packages.count == 0
208
- # self.order_packages.each do |op|
209
- # return true if op.shipping_method_id.nil?
210
- # end
211
- # return false
212
- #end
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, :default => 0.00 }]
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, :default => 0.00 }],
274
- [ :balance , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
275
- [ :min_order_total , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
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, :default => 0.00 }],
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, :default => 0 }],
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, :default => 0.00 }]
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, :default => 0.00 }],
337
- [ :tax , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
338
- [ :shipping , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
339
- [ :handling , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
340
- [ :custom_discount , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
341
- [ :discount , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
342
- [ :total , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
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, :default => 0.00 }],
648
- [ :sale_price , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
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 ],
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.104'
2
+ VERSION = '0.5.105'
3
3
  end
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.104
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 %>