caboose-cms 0.5.69 → 0.5.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/admin.js +2 -1
  3. data/app/assets/javascripts/caboose/admin_edit_order.js +0 -13
  4. data/app/assets/javascripts/caboose/admin_main.js +13 -0
  5. data/app/assets/javascripts/caboose/cart.js +145 -161
  6. data/app/assets/javascripts/caboose/cart_old.js +176 -0
  7. data/app/assets/javascripts/caboose/checkout.js +1 -1
  8. data/app/assets/javascripts/caboose/{checkout_step2.js → checkout_addresses.js} +3 -3
  9. data/app/assets/javascripts/caboose/checkout_gift_cards.js +47 -0
  10. data/app/assets/javascripts/caboose/{checkout_step1.js → checkout_login_register.js} +5 -53
  11. data/app/assets/javascripts/caboose/checkout_module.js +3 -4
  12. data/app/assets/javascripts/caboose/{checkout_step4.js → checkout_payment.js} +8 -8
  13. data/app/assets/javascripts/caboose/{checkout_step3.js → checkout_shipping.js} +5 -5
  14. data/app/assets/javascripts/caboose/imageZoom.js +66 -0
  15. data/app/assets/javascripts/caboose/model/attribute.js +2 -1
  16. data/app/assets/javascripts/caboose/model/bound_select.js +15 -6
  17. data/app/assets/javascripts/caboose/product.js +12 -2
  18. data/app/assets/stylesheets/caboose/checkout.css.scss +1 -0
  19. data/app/assets/templates/caboose/checkout/address.jst.ejs +1 -1
  20. data/app/controllers/caboose/cart_controller.rb +60 -8
  21. data/app/controllers/caboose/checkout_controller.rb +42 -71
  22. data/app/controllers/caboose/gift_cards_controller.rb +216 -0
  23. data/app/controllers/caboose/users_controller.rb +2 -2
  24. data/app/helpers/caboose/checkout_helper.rb +6 -5
  25. data/app/models/caboose/core_plugin.rb +2 -1
  26. data/app/models/caboose/discount.rb +8 -13
  27. data/app/models/caboose/gift_card.rb +49 -0
  28. data/app/models/caboose/order.rb +66 -46
  29. data/app/models/caboose/order_package.rb +11 -4
  30. data/app/models/caboose/order_package_calculator.rb +102 -0
  31. data/app/models/caboose/product_image.rb +10 -0
  32. data/app/models/caboose/schema.rb +38 -29
  33. data/app/models/caboose/shipping_calculator.rb +4 -2
  34. data/app/models/caboose/shipping_package.rb +7 -0
  35. data/app/views/caboose/cart/index.html.erb +12 -2
  36. data/app/views/caboose/checkout/#Untitled-1# +2 -0
  37. data/app/views/caboose/checkout/_cart.html.erb +45 -48
  38. data/app/views/caboose/checkout/_cart_old.html.erb +49 -0
  39. data/app/views/caboose/checkout/_confirm.html.erb +6 -4
  40. data/app/views/caboose/checkout/_confirm_table.html.erb +0 -0
  41. data/app/views/caboose/checkout/{step_two.html.erb → addresses.html.erb} +2 -2
  42. data/app/views/caboose/checkout/gift_cards.html.erb +35 -0
  43. data/app/views/caboose/checkout/index.html.erb +53 -42
  44. data/app/views/caboose/checkout/payment.html.erb +108 -75
  45. data/app/views/caboose/checkout/shipping.html.erb +62 -13
  46. data/app/views/caboose/gift_cards/admin_edit.html.erb +89 -0
  47. data/app/views/caboose/gift_cards/admin_index.html.erb +52 -0
  48. data/config/routes.rb +39 -19
  49. data/lib/caboose/engine.rb +1 -0
  50. data/lib/caboose/version.rb +1 -1
  51. metadata +20 -14
  52. data/app/assets/javascripts/caboose/cart2.js +0 -98
  53. data/app/views/caboose/checkout/step_four.html.erb +0 -67
  54. data/app/views/caboose/checkout/step_four_old.html.erb +0 -63
  55. data/app/views/caboose/checkout/step_one.html.erb +0 -54
  56. data/app/views/caboose/checkout/step_one_old.html.erb +0 -13
  57. data/app/views/caboose/checkout/step_three.html.erb +0 -55
  58. data/app/views/caboose/checkout/step_two_old.html.erb +0 -14
@@ -289,8 +289,8 @@ module Caboose
289
289
  # GET /admin/users/options
290
290
  def options
291
291
  return if !user_is_allowed('users', 'view')
292
- @users = User.reorder('last_name, first_name').all
293
- options = @users.collect { |u| { 'value' => u.id, 'text' => "#{u.first_name} #{u.last_name}"}}
292
+ @users = User.where('id <> 2').reorder('last_name, first_name').all
293
+ options = @users.collect { |u| { 'value' => u.id, 'text' => "#{u.first_name} #{u.last_name} (#{u.email})"}}
294
294
  render json: options
295
295
  end
296
296
 
@@ -5,11 +5,12 @@ module Caboose
5
5
  str = ""
6
6
  str << "<div id='checkout-nav'>"
7
7
  str << " <ul>"
8
- str << " <li class='odd' id='checkout_nav1'><a href='#{i <= 1 ? '#' : '/checkout/step-one' }' class='#{i == 1 ? 'current' : (i < 1 ? 'not_done' : 'done')}'><span>User Account </span></a></li>"
9
- str << " <li class='even' id='checkout_nav2'><a href='#{i <= 2 ? '#' : '/checkout/step-two' }' class='#{i == 2 ? 'current' : (i < 2 ? 'not_done' : 'done')}'><span>Addresses </span></a></li>"
10
- str << " <li class='odd' id='checkout_nav3'><a href='#{i <= 3 ? '#' : '/checkout/step-three' }' class='#{i == 3 ? 'current' : (i < 3 ? 'not_done' : 'done')}'><span>Shipping </span></a></li>"
11
- str << " <li class='even' id='checkout_nav4'><a href='#{i <= 4 ? '#' : '/checkout/step-four' }' class='#{i == 4 ? 'current' : (i < 4 ? 'not_done' : 'done')}'><span>Payment </span></a></li>"
12
- str << " <li class='odd' id='checkout_nav5'><a href='#{i <= 5 ? '#' : '/checkout/step-five' }' class='#{i == 5 ? 'current' : (i < 5 ? 'not_done' : 'done')}'><span>Confirm </span></a></li>"
8
+ str << " <li class='odd' id='checkout_nav1'><a href='#{i <= 1 ? '#' : '/checkout' }' class='#{i == 1 ? 'current' : (i < 1 ? 'not_done' : 'done')}'><span>User Account </span></a></li>"
9
+ str << " <li class='even' id='checkout_nav2'><a href='#{i <= 2 ? '#' : '/checkout/addresses' }' class='#{i == 2 ? 'current' : (i < 2 ? 'not_done' : 'done')}'><span>Addresses </span></a></li>"
10
+ str << " <li class='odd' id='checkout_nav3'><a href='#{i <= 3 ? '#' : '/checkout/shipping' }' class='#{i == 3 ? 'current' : (i < 3 ? 'not_done' : 'done')}'><span>Shipping </span></a></li>"
11
+ str << " <li class='even' id='checkout_nav4'><a href='#{i <= 4 ? '#' : '/checkout/gift-cards' }' class='#{i == 4 ? 'current' : (i < 4 ? 'not_done' : 'done')}'><span>Gift Cards </span></a></li>"
12
+ str << " <li class='even' id='checkout_nav5'><a href='#{i <= 4 ? '#' : '/checkout/payment' }' class='#{i == 4 ? 'current' : (i < 4 ? 'not_done' : 'done')}'><span>Payment </span></a></li>"
13
+ str << " <li class='odd' id='checkout_nav6'><a href='#{i <= 5 ? '#' : '/checkout/confirm' }' class='#{i == 5 ? 'current' : (i < 5 ? 'not_done' : 'done')}'><span>Confirm </span></a></li>"
13
14
  str << " </ul>"
14
15
  str << "</div>"
15
16
  return str
@@ -27,7 +27,8 @@ class Caboose::CorePlugin < Caboose::CaboosePlugin
27
27
 
28
28
  if site.use_store
29
29
  item = { 'id' => 'store', 'text' => 'Store', 'children' => [] }
30
- item['children'] << { 'id' => 'categories' , 'href' => '/admin/categories' , 'text' => 'Categories' , 'modal' => false } if user.is_allowed('categories' , 'view')
30
+ item['children'] << { 'id' => 'categories' , 'href' => '/admin/categories' , 'text' => 'Categories' , 'modal' => false } if user.is_allowed('categories' , 'view')
31
+ item['children'] << { 'id' => 'giftcards' , 'href' => '/admin/gift-cards' , 'text' => 'Gift Cards' , 'modal' => false } if user.is_allowed('giftcards' , 'view')
31
32
  item['children'] << { 'id' => 'orders' , 'href' => '/admin/orders' , 'text' => 'Orders' , 'modal' => false } if user.is_allowed('orders' , 'view')
32
33
  item['children'] << { 'id' => 'products' , 'href' => '/admin/products' , 'text' => 'Products' , 'modal' => false } if user.is_allowed('products' , 'view')
33
34
  item['children'] << { 'id' => 'shippingpackages' , 'href' => '/admin/shipping-packages' , 'text' => 'Shipping Packages' , 'modal' => false } if user.is_allowed('shippingpackages' , 'view')
@@ -1,19 +1,14 @@
1
1
  module Caboose
2
2
  class Discount < ActiveRecord::Base
3
- self.table_name = 'store_discounts'
3
+ self.table_name = 'store_order_discounts'
4
4
  self.primary_key = 'id'
5
-
6
- belongs_to :site
7
-
5
+
6
+ belongs_to :gift_card
7
+ belongs_to :order
8
8
  attr_accessible :id,
9
- :site_id,
10
- :name, # The name of this discount
11
- :code, # The code the customer has to input to apply for this discount
12
- :amount_current,
13
- :amount_total,
14
- :amount_flat, # Amount of the savings flat off the total
15
- :amount_percentage, # Amount of savings as a percentage off the total
16
- :no_shipping, # Whether or not it's a free shipping discount
17
- :no_tax # Whether or not it's a free shipping discount
9
+ :gift_card_id,
10
+ :order_id,
11
+ :amount
12
+
18
13
  end
19
14
  end
@@ -0,0 +1,49 @@
1
+ module Caboose
2
+ class GiftCard < ActiveRecord::Base
3
+ self.table_name = 'store_gift_cards'
4
+ self.primary_key = 'id'
5
+
6
+ belongs_to :site
7
+ has_many :discounts
8
+ has_many :orders, :through => :discounts
9
+ attr_accessible :id,
10
+ :site_id,
11
+ :name, # The name of this discount
12
+ :code, # The code the customer has to input to apply for this discount
13
+ :card_type,
14
+ :total,
15
+ :balance,
16
+ :min_order_total, # The minimum order total required to be able to use the card
17
+ :date_available,
18
+ :date_expires,
19
+ :status
20
+
21
+ STATUS_INACTIVE = 'Inactive'
22
+ STATUS_ACTIVE = 'Active'
23
+ STATUS_EXPIRED = 'Expired'
24
+
25
+ CARD_TYPE_AMOUNT = 'Amount'
26
+ CARD_TYPE_PERCENTAGE = 'Percentage'
27
+ CARD_TYPE_NO_SHIPPING = 'No Shipping'
28
+ CARD_TYPE_NO_TAX = 'No Tax'
29
+
30
+ def valid_for_order?(order)
31
+ return false if self.status != GiftCard::STATUS_ACTIVE
32
+ return false if self.date_available && DateTime.now.utc < self.date_available
33
+ return false if self.date_expires && DateTime.now.utc > self.date_expires
34
+ return false if self.card_type == GiftCard::CARD_TYPE_AMOUNT && self.balance <= 0
35
+ return false if self.min_order_total && order.total < self.min_order_total
36
+ return true
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ # Flat amount - $10 off
43
+ # Flat amount off if you spend over a certain amount
44
+ # Percentage off
45
+ # Percentage amount off if you spend over a certain amount
46
+ # Free shipping
47
+ # Free shipping if you spend over a certain amount
48
+ # No Tax
49
+ # No tax if you spend over a certain amount
@@ -11,51 +11,50 @@ module Caboose
11
11
  belongs_to :customer, :class_name => 'Caboose::User'
12
12
  belongs_to :shipping_address, :class_name => 'Address'
13
13
  belongs_to :billing_address, :class_name => 'Address'
14
- has_many :discounts, :through => :order_discounts
15
- has_many :order_discounts
14
+ has_many :discounts
16
15
  has_many :line_items, :after_add => :line_item_added, :after_remove => :line_item_removed, :order => :id
17
16
  has_many :order_packages, :class_name => 'Caboose::OrderPackage'
18
17
  has_many :order_transactions
19
18
 
20
19
  attr_accessible :id,
21
20
  :site_id,
22
- :order_number,
21
+ :alternate_id,
23
22
  :subtotal,
24
- :tax,
25
- :shipping_carrier,
26
- :shipping_service_code,
23
+ :tax,
27
24
  :shipping,
28
25
  :handling,
29
- :discount,
30
- :amount_discounted,
26
+ :custom_discount,
27
+ :discount,
31
28
  :total,
32
- :status,
33
- :payment_status,
34
- :notes,
35
- :referring_site,
36
- :landing_site,
37
- :landing_site_ref,
38
- :cancel_reason,
39
- :date_created,
40
- :date_authorized,
41
- :date_captured,
42
- :date_cancelled,
43
- :email,
44
- :customer_id,
45
- :payment_id,
46
- :gateway_id,
47
- :financial_status,
29
+ :customer_id,
48
30
  :shipping_address_id,
49
31
  :billing_address_id,
32
+ :status,
33
+ :financial_status,
34
+ :referring_site,
50
35
  :landing_page,
51
- :landing_page_ref,
52
- :transaction_d,
53
- :auth_code,
54
- :alternate_id,
36
+ :landing_page_ref,
55
37
  :auth_amount,
56
- :date_shipped,
57
- :transaction_service,
58
- :transaction_id
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
59
58
 
60
59
  STATUS_CART = 'cart'
61
60
  STATUS_PENDING = 'pending'
@@ -166,36 +165,48 @@ module Caboose
166
165
  end
167
166
 
168
167
  def calculate
169
- self.update_column(:subtotal, (self.calculate_subtotal * 100).ceil / 100.00)
170
- self.update_column(:tax, (self.calculate_tax * 100).ceil / 100.00)
171
- #self.update_column(:shipping, (self.calculate_shipping * 100).ceil / 100.00)
172
- self.update_column(:handling, (self.calculate_handling * 100).ceil / 100.00)
173
- self.update_column(:total, (self.calculate_total * 100).ceil / 100.00)
168
+ self.update_column(:subtotal , self.calculate_subtotal )
169
+ self.update_column(:tax , self.calculate_tax )
170
+ self.update_column(:shipping , self.calculate_shipping )
171
+ self.update_column(:handling , self.calculate_handling )
172
+ self.update_column(:discount , self.calculate_discount )
173
+ self.update_column(:total , self.calculate_total )
174
174
  end
175
175
 
176
176
  def calculate_subtotal
177
- return 0 if self.line_items.empty?
178
- self.line_items.collect { |line_item| line_item.price }.inject { |sum, price| sum + price }
177
+ return 0.0 if self.line_items.empty?
178
+ x = 0.0
179
+ self.line_items.each{ |li| x = x + li.variant.price }
180
+ return x
179
181
  end
180
182
 
181
183
  def calculate_tax
182
- return 0 if !self.shipping_address
184
+ return 0.0 if !self.shipping_address
183
185
  self.subtotal * TaxCalculator.tax_rate(self.shipping_address)
184
186
  end
185
187
 
186
- def calculate_shipping
187
- return 0 if !self.shipping_address || !self.shipping_service_code
188
- return 0.0
189
- #ShippingCalculator.rates(self)
188
+ def calculate_shipping
189
+ return 0.0 if self.order_packages.nil? || self.order_packages.count == 0
190
+ x = 0.0
191
+ self.order_packages.each{ |op| x = x + op.total }
192
+ return x
190
193
  end
191
194
 
192
195
  def calculate_handling
193
- return 0 if !Caboose::store_handling_percentage
194
- self.shipping * Caboose::store_handling_percentage.to_f
196
+ return 0.0 if self.site.nil? || self.site.store_config.nil?
197
+ self.subtotal * self.site.store_config.handling_percentage.to_f
198
+ end
199
+
200
+ def calculate_discount
201
+ return 0.0 if self.discounts.nil? || self.discounts.count == 0
202
+ x = 0.0
203
+ self.discounts.each{ |d| x = x + d.amount }
204
+ x = x + self.custom_discount if self.custom_discount
205
+ return x
195
206
  end
196
207
 
197
208
  def calculate_total
198
- [self.subtotal, self.tax, self.shipping, self.handling].compact.inject { |sum, price| sum + price }
209
+ return (self.subtotal + self.tax + self.shipping + self.handling) - self.discount
199
210
  end
200
211
 
201
212
  def shipping_and_handling
@@ -207,6 +218,15 @@ module Caboose
207
218
  self.line_items.each{ |li| count = count + li.quantity } if self.line_items
208
219
  return count
209
220
  end
221
+
222
+ def take_gift_card_funds
223
+ return if self.discounts.nil? || self.discounts.count == 0
224
+ self.discounts.each do |d|
225
+ gc = d.gift_card
226
+ gc.balance = gc.balance - d.amount
227
+ gc.save
228
+ end
229
+ end
210
230
  end
211
231
  end
212
232
 
@@ -17,12 +17,19 @@ module Caboose
17
17
  STATUS_PENDING = 'Pending'
18
18
  STATUS_SHIPPED = 'Shipped'
19
19
 
20
+ def self.custom_order_packages(store_config, order)
21
+ eval(store_config.order_packages_function)
22
+ end
23
+
20
24
  # Calculates the shipping packages required for all the items in the order
21
25
  def self.create_for_order(order)
22
-
23
- store_config = order.site.store_config
24
- return if !store_config.calculate_packages
25
26
 
27
+ store_config = order.site.store_config
28
+ if !store_config.calculate_packages
29
+ self.custom_order_packages(store_config, order)
30
+ return
31
+ end
32
+
26
33
  # Make sure all the line items in the order have a quantity of 1
27
34
  extra_line_items = []
28
35
  order.line_items.each do |li|
@@ -87,7 +94,7 @@ module Caboose
87
94
  end
88
95
  end
89
96
 
90
- end
97
+ end
91
98
  end
92
99
 
93
100
  def fits(line_item = nil)
@@ -0,0 +1,102 @@
1
+ require 'active_shipping'
2
+ include ActiveMerchant::Shipping
3
+
4
+ module Caboose
5
+ class OrderPackageCalculator
6
+
7
+ def self.custom_order_packages(store_config, order)
8
+ return eval(store_config.order_packages_function)
9
+ end
10
+
11
+ def self.order_packages(order)
12
+ return [] if Caboose::store_shipping.nil?
13
+
14
+ sc = order.site.store_config
15
+ if sc.order_packages_function
16
+ order_packages = self.custom_order_packages(sc, order)
17
+ return order_packages
18
+ end
19
+
20
+ # Remove any order packages
21
+ LineItem.where(:order_id => order.id).update_all(:order_package_id => nil)
22
+ OrderPackage.where(:order_id => order.id).destroy_all
23
+
24
+ # Calculate what shipping packages we'll need
25
+ OrderPackage.create_for_order(order)
26
+
27
+ return all_rates
28
+ end
29
+
30
+ def self.rate(order)
31
+ return nil if !order.shipping_service_code
32
+ self.rates(order).each { |rate| return rate if rate[:service_code] == order.shipping_service_code }
33
+ return nil
34
+ end
35
+
36
+ # Calculates the packages required for all the items in the order
37
+ #def self.packages_for_order(order)
38
+ #
39
+ # # Make sure all the items in the order have attributes set
40
+ # order.line_items.each do |li|
41
+ # v = li.variant
42
+ # Caboose.log("Error: variant #{v.id} has a zero weight") and return false if v.weight.nil? || v.weight == 0
43
+ # next if v.volume && v.volume > 0
44
+ # Caboose.log("Error: variant #{v.id} has a zero length") and return false if v.length.nil? || v.length == 0
45
+ # Caboose.log("Error: variant #{v.id} has a zero width" ) and return false if v.width.nil? || v.width == 0
46
+ # Caboose.log("Error: variant #{v.id} has a zero height") and return false if v.height.nil? || v.height == 0
47
+ # v.volume = v.length * v.width * v.height
48
+ # v.save
49
+ # end
50
+ #
51
+ # # Reorder the items in the order by volume
52
+ # h = {}
53
+ # order.line_items.each do |li|
54
+ # (1..li.quantity).each do |i|
55
+ # v = li.variant
56
+ # h[v.volume] = v
57
+ # end
58
+ # end
59
+ # variants = h.sort_by{ |k,v| k }.collect{ |x| x[1] }
60
+ #
61
+ # all_packages = ShippingPackage.reorder(:price).all
62
+ # packages = []
63
+ #
64
+ # # Now go through each variant and fit it in a new or existing package
65
+ # variants.each do |v|
66
+ #
67
+ # # See if the item will fit in any of the existing packages
68
+ # it_fits = false
69
+ # packages.each do |h|
70
+ # it_fits = h.shipping_package.fits(h.variants, v)
71
+ # if it_fits
72
+ # h.variants << v
73
+ # break
74
+ # end
75
+ # end
76
+ # next if it_fits
77
+ #
78
+ # # Otherwise find the cheapest package the item will fit into
79
+ # all_packages.each do |p|
80
+ # if p.fits(v)
81
+ # packages << StdClass.new('shipping_package' => p, 'variants' => [v])
82
+ # break
83
+ # end
84
+ # end
85
+ #
86
+ # end
87
+ #
88
+ # return packages
89
+ #
90
+ # #arr = []
91
+ # #packages.each do |h|
92
+ # # p = h.package
93
+ # # weight = 0.0
94
+ # # h.variants.each{ |v| weight = weight + v.weight }
95
+ # # weight = weight * 0.035274
96
+ # # arr << Package.new(weight, [p.length, p.width, p.height], :units => :imperial)
97
+ # #end
98
+ # #return arr
99
+ #
100
+ #end
101
+ end
102
+ end
@@ -47,6 +47,16 @@ module Caboose
47
47
  self.image.url(size)
48
48
  end
49
49
 
50
+ def urls
51
+ {
52
+ :tiny => self.url(:tiny),
53
+ :thumb => self.url(:thumb),
54
+ :medium => self.url(:medium),
55
+ :large => self.url(:large),
56
+ :huge => self.url(:huge)
57
+ }
58
+ end
59
+
50
60
  def as_json(options={})
51
61
  self.attributes.merge({
52
62
  :urls => {
@@ -235,15 +235,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
235
235
  [ :updated_at , :datetime , :null => true ]
236
236
  ],
237
237
  Caboose::Discount => [
238
- [ :site_id , :integer ],
239
- [ :name , :string ],
240
- [ :code , :string ],
241
- [ :amount_current , :numeric ],
242
- [ :amount_total , :numeric ],
243
- [ :amount_flat , :numeric ],
244
- [ :amount_percentage , :numeric ],
245
- [ :no_shipping , :boolean ],
246
- [ :no_tax , :boolean ]
238
+ [ :gift_card_id , :integer ],
239
+ [ :order_id , :integer ],
240
+ [ :amount , :numeric , { :default => 0.0 }]
247
241
  ],
248
242
  Caboose::Domain => [
249
243
  [ :site_id , :integer ],
@@ -251,6 +245,18 @@ class Caboose::Schema < Caboose::Utilities::Schema
251
245
  [ :primary , :boolean, { :default => false }],
252
246
  [ :under_construction , :boolean, { :default => false }]
253
247
  ],
248
+ Caboose::GiftCard => [
249
+ [ :site_id , :integer ],
250
+ [ :name , :string ],
251
+ [ :code , :string ],
252
+ [ :card_type , :string ],
253
+ [ :total , :numeric , { :default => 0.0 }],
254
+ [ :balance , :numeric , { :default => 0.0 }],
255
+ [ :min_order_total , :numeric , { :default => 0.0 }],
256
+ [ :date_available , :datetime ],
257
+ [ :date_expires , :datetime ],
258
+ [ :status , :string ]
259
+ ],
254
260
  Caboose::LineItem => [
255
261
  [ :order_id , :integer ],
256
262
  [ :order_package_id , :integer ],
@@ -306,41 +312,43 @@ class Caboose::Schema < Caboose::Utilities::Schema
306
312
  ],
307
313
  Caboose::Order => [
308
314
  [ :site_id , :integer ],
309
- [ :email , :string ],
310
- [ :order_number , :string ],
315
+ [ :alternate_id , :integer ],
311
316
  [ :subtotal , :numeric , :default => 0 ],
312
317
  [ :tax , :numeric , :default => 0 ],
313
318
  [ :shipping , :numeric , :default => 0 ],
314
319
  [ :handling , :numeric , :default => 0 ],
320
+ [ :custom_discount , :numeric , :default => 0 ],
315
321
  [ :discount , :numeric , :default => 0 ],
316
322
  [ :total , :numeric , :default => 0 ],
317
323
  [ :customer_id , :integer ],
318
- [ :payment_id , :integer ],
319
- [ :gateway_id , :integer ],
320
324
  [ :financial_status , :string ],
321
325
  [ :shipping_address_id , :integer ],
322
326
  [ :billing_address_id , :integer ],
323
327
  [ :notes , :text ],
324
328
  [ :status , :string ],
325
329
  [ :date_created , :datetime ],
326
- [ :date_authorized , :datetime ],
327
- [ :date_captured , :datetime ],
328
- [ :date_cancelled , :datetime ],
329
330
  [ :referring_site , :text ],
330
331
  [ :landing_page , :string ],
331
- [ :landing_page_ref , :string ],
332
- [ :shipping_carrier , :string ],
333
- [ :shipping_service_code , :string ],
334
- [ :shipping_service_name , :string ],
335
- [ :transaction_id , :string ],
336
- [ :auth_code , :string ],
337
- [ :alternate_id , :integer ],
338
- [ :auth_amount , :numeric ],
339
- [ :date_shipped , :datetime ],
340
- [ :transaction_id , :string ],
341
- [ :transaction_service , :string ],
342
- [ :amount_discounted , :numeric ],
343
- [ :decremented , :boolean ]
332
+ [ :landing_page_ref , :string ],
333
+ [ :auth_amount , :numeric ]
334
+
335
+ #[ :email , :string ],
336
+ #[ :order_number , :string ],
337
+ #[ :payment_id , :integer ],
338
+ #[ :gateway_id , :integer ],
339
+ #[ :date_authorized , :datetime ],
340
+ #[ :date_captured , :datetime ],
341
+ #[ :date_cancelled , :datetime ],
342
+ #[ :shipping_carrier , :string ],
343
+ #[ :shipping_service_code , :string ],
344
+ #[ :shipping_service_name , :string ],
345
+ #[ :transaction_id , :string ],
346
+ #[ :transaction_id , :string ],
347
+ #[ :transaction_service , :string ],
348
+ #[ :amount_discounted , :numeric ],
349
+ #[ :auth_code , :string ],
350
+ #[ :date_shipped , :datetime ],
351
+ #[ :decremented , :boolean ]
344
352
  ],
345
353
  Caboose::Page => [
346
354
  [ :site_id , :integer ],
@@ -568,6 +576,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
568
576
  [ :shipping_email , :string ],
569
577
  [ :handling_percentage , :string ],
570
578
  [ :calculate_packages , :boolean , { :default => true }],
579
+ [ :order_packages_function , :text ],
571
580
  [ :shipping_rates_function , :text ],
572
581
  [ :length_unit , :string , { :default => 'in' }],
573
582
  [ :weight_unit , :string , { :default => 'oz' }]