caboose-cms 0.5.101 → 0.5.102

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWQ4MDQ1NGJjOTgwZTViMTFjZDVjZDAwZTc0N2JiOGQzZDViOWRlYQ==
4
+ NjMwOWVjNTVlNmZlYWIwMzBjZDdhZTk3MzE3YTA2MGRlZjVmMTAzNg==
5
5
  data.tar.gz: !binary |-
6
- MzhhZmEzYTgzOWFhNWI3MGUwMDczZjczZWRjZjdiYzM2YzQwNjdhZQ==
6
+ NjIzYmNiNDhjNjc0ZDc1MjdmMDg0MzcyMzlkZmM3MWI2MDFhYWU2YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjY5NDhlOWFhOTIzYzcyZmEwNTYzZWMxN2QwY2E2NWE4NzNjOTA5MzU0MTRl
10
- ZDE1N2I0Yzk4MjRmMGRhNjBiN2MyYzIyYzQ4NWEzY2RlODdkNzU4NmY1ZDQy
11
- YzAzYTEyN2RjZWM1OGUzYjA0MWY1NjgzZDFlNDkxYjVhYzNmYjI=
9
+ OWFjYWVlODY5Y2YxNTdmNzU5ZmVmMTQ3YTk3MGUyMDg2YzU0NDYwOWJiYWRm
10
+ NDY5YzI0ODA0NzNkOTA0NzFhY2VhZjU4YTJjZWQ0YTFlYzQ0MmRkYTkyZjgy
11
+ NGNjMzE0NzBmMWI3ZTFlNDQxYWFmOTAwZTIyMTI4N2RjZjQ0ZWY=
12
12
  data.tar.gz: !binary |-
13
- M2MxYzY5YzY1YjA2MGY4OWNhOTFkOTVlMWNhMzAwY2I3YWVmNDU2NzZiZDFk
14
- OGViMjdjN2Q0MGFiNmNjODAxMGIzNjQ1MTI3YmM2NDM2MmVhNThmNTdmNmE1
15
- ODgxMWNhODUzOWMzMmYyNWExNzFmNTk3ZjViMzE3MTgyODExNzE=
13
+ MjgxNzc3ODllY2E4NzY2NzE3ZGNmOTQ1NjAxYmVjOGM0MzU3NmJhYmM5MjZl
14
+ OGNhNWZjYjRiNDM2ZWY3MmIxYzIzYzQzZDQzZjllNjA1NzQyYzYyZWI0NTM0
15
+ YTAyYmMyZDE0NTA5MTg4OWMzYzk3M2EzZmE5ZjM0NDM3ZjVmODY=
@@ -7,14 +7,14 @@ 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
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
18
 
19
19
  attr_accessible :id,
20
20
  :site_id,
@@ -66,176 +66,151 @@ module Caboose
66
66
  # Scopes
67
67
  #
68
68
 
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')
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')
78
78
 
79
79
  #
80
80
  # Validations
81
81
  #
82
82
 
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
- }
92
-
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
+ #}
93
87
  #
94
- # Callbacks
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
+ #}
92
+
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
95
106
  #
96
-
97
- #after_update :calculate
98
-
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
99
116
  #
100
- # Methods
117
+ #def resend_confirmation
118
+ # OrdersMailer.configure_for_site(self.site_id).customer_new_order(self).deliver
119
+ #end
101
120
  #
102
-
103
- def packages
104
- self.order_packages
105
- end
106
-
107
- #def as_json(options={})
108
- # self.attributes.merge({
109
- # :line_items => self.line_items,
110
- # :shipping_address => self.shipping_address,
111
- # :billing_address => self.billing_address
112
- # })
121
+ #def test?
122
+ # self.status == 'testing'
113
123
  #end
114
-
115
- def decrement_quantities
116
- return false if self.decremented
117
-
118
- self.line_items.each do |line_item|
119
- line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
120
- end
121
-
122
- self.update_attribute(:decremented, true)
123
- end
124
-
125
- def increment_quantities
126
- return false if !self.decremented
127
-
128
- self.line_items.each do |line_item|
129
- line_item.variant.update_attribute(:quantity, line_item.variant.quantity_in_stock - line_item.quantity)
130
- end
131
-
132
- self.update_attribute(:decremented, false)
133
- end
134
-
135
- def resend_confirmation
136
- OrdersMailer.configure_for_site(self.site_id).customer_new_order(self).deliver
137
- end
138
-
139
- def test?
140
- self.status == 'testing'
141
- end
142
-
143
- def authorized?
144
- self.financial_status == 'authorized'
145
- end
146
-
147
- def capture
148
- PaymentProcessor.capture(self)
149
- end
150
-
151
- def refuned
152
- PaymentProcessor.refund(self)
153
- end
154
-
155
- def void
156
- PaymentProcessor.void(self)
157
- end
158
-
159
- #def line_item_added(line_item)
160
- # self.calculate
124
+ #
125
+ #def authorized?
126
+ # self.financial_status == 'authorized'
161
127
  #end
162
128
  #
163
- #def line_item_removed(line_item)
164
- # self.calculate
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
165
212
  #end
166
213
 
167
- def calculate
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
- end
175
-
176
- def calculate_subtotal
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
181
- end
182
-
183
- def calculate_tax
184
- return 0.0 if !self.shipping_address
185
- self.subtotal * TaxCalculator.tax_rate(self.shipping_address)
186
- end
187
-
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
193
- end
194
-
195
- def calculate_handling
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
206
- end
207
-
208
- def calculate_total
209
- return (self.subtotal + self.tax + self.shipping + self.handling) - self.discount
210
- end
211
-
212
- def shipping_and_handling
213
- (self.shipping ? self.shipping : 0.0) + (self.handling ? self.handling : 0.0)
214
- end
215
-
216
- def item_count
217
- count = 0
218
- self.line_items.each{ |li| count = count + li.quantity } if self.line_items
219
- return count
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
230
-
231
- def has_empty_shipping_methods?
232
- return true if self.order_packages.nil?
233
- return true if self.order_packages.count == 0
234
- self.order_packages.each do |op|
235
- return true if op.shipping_method_id.nil?
236
- end
237
- return false
238
- end
239
214
  end
240
215
  end
241
216
 
@@ -313,13 +313,13 @@ class Caboose::Schema < Caboose::Utilities::Schema
313
313
  Caboose::Order => [
314
314
  [ :site_id , :integer ],
315
315
  [ :alternate_id , :integer ],
316
- [ :subtotal , :numeric , :default => 0 ],
317
- [ :tax , :numeric , :default => 0 ],
318
- [ :shipping , :numeric , :default => 0 ],
319
- [ :handling , :numeric , :default => 0 ],
320
- [ :custom_discount , :numeric , :default => 0 ],
321
- [ :discount , :numeric , :default => 0 ],
322
- [ :total , :numeric , :default => 0 ],
316
+ [ :subtotal , :numeric , :default => 0.00 ],
317
+ [ :tax , :numeric , :default => 0.00 ],
318
+ [ :shipping , :numeric , :default => 0.00 ],
319
+ [ :handling , :numeric , :default => 0.00 ],
320
+ [ :custom_discount , :numeric , :default => 0.00 ],
321
+ [ :discount , :numeric , :default => 0.00 ],
322
+ [ :total , :numeric , :default => 0.00 ],
323
323
  [ :customer_id , :integer ],
324
324
  [ :financial_status , :string ],
325
325
  [ :shipping_address_id , :integer ],
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.101'
2
+ VERSION = '0.5.102'
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.101
4
+ version: 0.5.102
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry