caboose-cms 0.8.85 → 0.8.87

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c733a7f3995558a46f3453e11a29dd3f0c5a1d
4
- data.tar.gz: 293ae7956fc12b5c071ec94650c59de6572ec6c8
3
+ metadata.gz: 0af06f8f26a6c537627299c1ccd323b5ca9033d3
4
+ data.tar.gz: 47d8742aac68010be20aa7b4f8d90a28b20a6601
5
5
  SHA512:
6
- metadata.gz: 61ec5173bb6007cae13d6130e6ad0ee37d23a132693ba4df015fdf056b7478671811948a60f0eb5292aa33541f76f30b13c419df576695e15e456b3299e68dcb
7
- data.tar.gz: 355fedb418323553d24700e953e018ac7c4b007410625747ebe9aac9a08635c4a7990a0a4aee0ef4141edb4999a70fc45423c48a233af94aecbec03c5e9397c2
6
+ metadata.gz: ebd290abf21ca8bbb0c02ebea94925725e9e4aad05659d667fd405cf177a58075f4dc6ca3224ee4c878f8038a7cde5ff9abd438d708563d8e075345cbcac1f8f
7
+ data.tar.gz: d1003bc8a568bbb802122cfe3eaeaadf6d481c19f19caf9527fe2633864d6e2e1121224e7ab95990df2ec6d84c501368d476c19f0bdca3b73a45a41e04314d51
@@ -1044,6 +1044,30 @@ IndexTable.prototype = {
1044
1044
  });
1045
1045
  td.append(select);
1046
1046
  }
1047
+ //else if (f.type == 'checkbox_multiple')
1048
+ //{
1049
+ // var options = false;
1050
+ // if (!f.options && f.options_url)
1051
+ // {
1052
+ // $.ajax({
1053
+ // url: f.options_url,
1054
+ // type: 'get',
1055
+ // success: function(resp) { f.options = resp; },
1056
+ // async: false
1057
+ // });
1058
+ // }
1059
+ // var div = $('<div/>');
1060
+ // //if (f.empty_option_text)
1061
+ // //{
1062
+ // // div.append($('<input/>').attr('type', 'checkbox').attr('id', f.name + '_empty').val(''))
1063
+ // // .append($('<label/>').attr('for', f.name + '_empty').html(f.empty_option_text));
1064
+ // //}
1065
+ // $.each(f.options, function(j, option) {
1066
+ // div.append($('<input/>').attr('type', 'checkbox').attr('id', f.name + '_' + j).val(option.value).prop('checked', pp[f.name].indexOf(option.value) > -1))
1067
+ // .append($('<label/>').attr('for', f.name + '_' + j).html(option.text));
1068
+ // });
1069
+ // td.append(div);
1070
+ //}
1047
1071
  tr.append(td);
1048
1072
  tbody.append(tr);
1049
1073
  });
@@ -83,6 +83,14 @@ module Caboose
83
83
  @invoice.landing_page_ref = params[:ref] || nil
84
84
  @invoice.payment_terms = @site.store_config.default_payment_terms
85
85
  @invoice.save
86
+
87
+ InvoiceLog.create(
88
+ :invoice_id => @invoice.id,
89
+ :user_id => logged_in_user.id,
90
+ :date_logged => DateTime.now.utc,
91
+ :invoice_action => InvoiceLog::ACTION_INVOICE_CREATED
92
+ )
93
+
86
94
  # Save the cart ID in the session
87
95
  session[:cart_id] = @invoice.id
88
96
  end
@@ -42,29 +42,45 @@ module Caboose
42
42
  v = Variant.find(params[:variant_id])
43
43
  qty = params[:quantity] ? params[:quantity].to_i : 1
44
44
 
45
+ resp = StdClass.new
46
+
45
47
  if @invoice.line_items.exists?(:variant_id => v.id)
46
48
  li = @invoice.line_items.find_by_variant_id(v.id)
47
49
  li.quantity += qty
48
50
  li.subtotal = li.unit_price * li.quantity
51
+ InvoiceLog.create(
52
+ :invoice_id => @invoice.id,
53
+ :line_item_id => li.id,
54
+ :user_id => logged_in_user.id,
55
+ :date_logged => DateTime.now.utc,
56
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_UPDATED,
57
+ :field => 'quantity',
58
+ :old_value => li.quantity - qty,
59
+ :new_value => li.quantity
60
+ )
49
61
  else
50
62
  unit_price = v.clearance && v.clearance_price ? v.clearance_price : (v.on_sale? ? v.sale_price : v.price)
51
- li = LineItem.new(
63
+ li = LineItem.create(
52
64
  :invoice_id => @invoice.id,
53
65
  :variant_id => v.id,
54
66
  :quantity => qty,
55
67
  :unit_price => unit_price,
56
68
  :subtotal => unit_price * qty,
57
69
  :status => 'pending'
70
+ )
71
+ InvoiceLog.create(
72
+ :invoice_id => @invoice.id,
73
+ :line_item_id => li.id,
74
+ :user_id => logged_in_user.id,
75
+ :date_logged => DateTime.now.utc,
76
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_CREATED
58
77
  )
59
78
  end
60
-
61
79
  GA.delay(:queue => 'caboose_store').event(@site.id, 'cart', 'add', "Product #{v.product.id}, Variant #{v.id}")
62
-
63
- render :json => {
64
- :success => li.save,
65
- :errors => li.errors.full_messages,
66
- :item_count => @invoice.item_count
67
- }
80
+
81
+ resp.success = true
82
+ resp.item_count = @invoice.item_count
83
+ render :json => resp
68
84
  end
69
85
 
70
86
  # @route PUT /cart/:line_item_id
@@ -73,7 +89,20 @@ module Caboose
73
89
  li = LineItem.find(params[:line_item_id])
74
90
 
75
91
  save = true
92
+ fields_to_log = ['quantity', 'is_gift', 'include_gift_message', 'gift_message', 'gift_wrap', 'hide_prices']
76
93
  params.each do |name,value|
94
+ if fields_to_log.include?(name)
95
+ InvoiceLog.create(
96
+ :invoice_id => @invoice.id,
97
+ :line_item_id => li.id,
98
+ :user_id => logged_in_user.id,
99
+ :date_logged => DateTime.now.utc,
100
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_UPDATED,
101
+ :field => name,
102
+ :old_value => li[name.to_sym],
103
+ :new_value => value
104
+ )
105
+ end
77
106
  case name
78
107
  when 'quantity' then
79
108
  if value.to_i != li.quantity
@@ -92,6 +121,13 @@ module Caboose
92
121
  li.quantity = value.to_i
93
122
  if li.quantity == 0
94
123
  li.destroy
124
+ InvoiceLog.create(
125
+ :invoice_id => @invoice.id,
126
+ :line_item_id => li.id,
127
+ :user_id => logged_in_user.id,
128
+ :date_logged => DateTime.now.utc,
129
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_DELETED
130
+ )
95
131
  else
96
132
  li.subtotal = li.unit_price * li.quantity
97
133
  li.save
@@ -112,7 +148,14 @@ module Caboose
112
148
 
113
149
  # @route DELETE /cart/:line_item_id
114
150
  def remove
115
- li = LineItem.find(params[:line_item_id]).destroy
151
+ li = LineItem.find(params[:line_item_id]).destroy
152
+ InvoiceLog.create(
153
+ :invoice_id => @invoice.id,
154
+ :line_item_id => params[:line_item_id],
155
+ :user_id => logged_in_user.id,
156
+ :date_logged => DateTime.now.utc,
157
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_DELETED
158
+ )
116
159
  op = li.invoice_package
117
160
  if op
118
161
  op.shipping_method_id = nil
@@ -140,7 +183,7 @@ module Caboose
140
183
  elsif gc.card_type == GiftCard::CARD_TYPE_AMOUNT && gc.balance <= 0 then resp.error = "That gift card has a zero balance."
141
184
  elsif gc.min_invoice_total && @invoice.total < gc.min_invoice_total then resp.error = "Your invoice must be at least $#{sprintf('%.2f',gc.min_invoice_total)} to use this gift card."
142
185
  elsif Discount.where(:invoice_id => @invoice.id, :gift_card_id => gc.id).exists? then resp.error = "That gift card has already been applied to this invoice."
143
- else
186
+ else
144
187
  # Create the discount and recalculate the invoice
145
188
  d = Discount.create(:invoice_id => @invoice.id, :gift_card_id => gc.id, :amount => 0.0)
146
189
  d.calculate_amount
@@ -26,7 +26,15 @@ module Caboose
26
26
  :shipping_method_id => params[:shipping_method_id],
27
27
  :status => InvoicePackage::STATUS_PENDING
28
28
  )
29
- op.save
29
+ op.save
30
+
31
+ InvoiceLog.create(
32
+ :invoice_id => params[:invoice_id],
33
+ :invoice_packag_id => op.id,
34
+ :user_id => logged_in_user.id,
35
+ :date_logged => DateTime.now.utc,
36
+ :invoice_action => InvoiceLog::ACTION_INVOICE_PACKAGE_CREATED
37
+ )
30
38
  resp.new_id = op.id
31
39
  resp.redirect = "/admin/invoices/#{params[:invoice_id]}/packages/#{op.id}"
32
40
 
@@ -42,8 +50,21 @@ module Caboose
42
50
  resp = Caboose::StdClass.new
43
51
  op = InvoicePackage.find(params[:id])
44
52
 
45
- save = true
53
+ save = true
54
+ fields_to_log = ['invoice_id','shipping_method_id','shipping_package_id','status','tracking_number','total','package_method']
46
55
  params.each do |name,value|
56
+ if fields_to_log.include?(name)
57
+ InvoiceLog.create(
58
+ :invoice_id => params[:invoice_id],
59
+ :invoice_package_id => op.id,
60
+ :user_id => logged_in_user.id,
61
+ :date_logged => DateTime.now.utc,
62
+ :invoice_action => InvoiceLog::ACTION_INVOICE_PACKAGE_UPDATED,
63
+ :field => name,
64
+ :old_value => op[name.to_sym],
65
+ :new_value => value
66
+ )
67
+ end
47
68
  case name
48
69
  when 'invoice_id' then op.invoice_id = value
49
70
  when 'shipping_method_id' then op.shipping_method_id = value
@@ -113,6 +134,13 @@ module Caboose
113
134
  op = InvoicePackage.find(params[:id])
114
135
  if op.line_items.nil? || op.line_items.count == 0
115
136
  op.destroy
137
+ InvoiceLog.create(
138
+ :invoice_id => params[:invoice_id],
139
+ :invoice_package_id => params[:id],
140
+ :user_id => logged_in_user.id,
141
+ :date_logged => DateTime.now.utc,
142
+ :invoice_action => InvoiceLog::ACTION_INVOICE_PACKAGE_DELETED
143
+ )
116
144
  resp.redirect = "/admin/invoices/#{params[:invoice_id]}"
117
145
  else
118
146
  resp.error = "Only empty packages can be deleted."
@@ -17,7 +17,7 @@ module Caboose
17
17
  @pager = Caboose::PageBarGenerator.new(params, {
18
18
  'site_id' => @site.id,
19
19
  'customer_id' => params[:user_id] ? params[:user_id] : '',
20
- 'status' => Invoice::STATUS_PENDING,
20
+ 'status' => Invoice::STATUS_PENDING,
21
21
  'shipping_method_code' => '',
22
22
  'id' => '',
23
23
  'invoice_number' => '',
@@ -67,7 +67,13 @@ module Caboose
67
67
  :status => Invoice::STATUS_PENDING,
68
68
  :financial_status => Invoice::FINANCIAL_STATUS_PENDING,
69
69
  :invoice_number => @site.store_config.next_invoice_number
70
- )
70
+ )
71
+ InvoiceLog.create(
72
+ :invoice_id => invoice.id,
73
+ :user_id => logged_in_user.id,
74
+ :date_logged => DateTime.now.utc,
75
+ :invoice_action => InvoiceLog::ACTION_INVOICE_CREATED
76
+ )
71
77
  render :json => { :sucess => true, :redirect => "/admin/invoices/#{invoice.id}" }
72
78
  end
73
79
 
@@ -216,8 +222,20 @@ module Caboose
216
222
  resp = Caboose::StdClass.new({'attributes' => {}})
217
223
  invoice = Invoice.find(params[:id])
218
224
 
219
- save = true
220
- params.each do |name,value|
225
+ save = true
226
+ fields_to_log = ['tax','handling','custom_discount','financial_status','customer_id','notes','customer_notes','payment_terms','date_due','status']
227
+ params.each do |name,value|
228
+ if fields_to_log.include?(name)
229
+ InvoiceLog.create(
230
+ :invoice_id => invoice.id,
231
+ :user_id => logged_in_user.id,
232
+ :date_logged => DateTime.now.utc,
233
+ :invoice_action => InvoiceLog::ACTION_INVOICE_UPDATED,
234
+ :field => name,
235
+ :old_value => invoice[name.to_sym],
236
+ :new_value => value
237
+ )
238
+ end
221
239
  case name
222
240
  when 'tax'
223
241
  invoice.tax = value
@@ -229,9 +247,9 @@ module Caboose
229
247
  invoice.custom_discount = value
230
248
  invoice.discount = invoice.calculate_discount
231
249
  invoice.total = invoice.calculate_total
232
- when 'status'
233
- invoice.status = value
234
- invoice.date_shipped = DateTime.now.utc if value == 'Shipped'
250
+ when 'status'
251
+ invoice.status = value
252
+ invoice.date_processed = DateTime.now.utc if value == Invoice::STATUS_PROCESSED
235
253
 
236
254
  when 'financial_status' then invoice.financial_status = value
237
255
  when 'customer_id' then invoice.customer_id = value
@@ -240,7 +258,7 @@ module Caboose
240
258
  when 'payment_terms' then invoice.payment_terms = value
241
259
  when 'date_due' then invoice.date_due = value
242
260
 
243
- end
261
+ end
244
262
  end
245
263
 
246
264
  #invoice.calculate
@@ -254,7 +272,13 @@ module Caboose
254
272
  # @route DELETE /admin/invoices/:id
255
273
  def admin_delete
256
274
  return if !user_is_allowed('invoices', 'delete')
257
- Invoice.find(params[:id]).destroy
275
+ Invoice.find(params[:id]).destroy
276
+ InvoiceLog.create(
277
+ :invoice_id => params[:id],
278
+ :user_id => logged_in_user.id,
279
+ :date_logged => DateTime.now.utc,
280
+ :invoice_action => InvoiceLog::ACTION_INVOICE_DELETED
281
+ )
258
282
  render :json => Caboose::StdClass.new({
259
283
  :redirect => '/admin/invoices'
260
284
  })
@@ -309,8 +333,7 @@ module Caboose
309
333
  Invoice::STATUS_CART,
310
334
  Invoice::STATUS_PENDING,
311
335
  Invoice::STATUS_READY_TO_SHIP,
312
- Invoice::STATUS_SHIPPED,
313
- Invoice::STATUS_PAID,
336
+ Invoice::STATUS_PROCESSED,
314
337
  Invoice::STATUS_CANCELED
315
338
  ]
316
339
  options = statuses.collect{ |s| { 'text' => s.capitalize, 'value' => s }}
@@ -346,16 +369,16 @@ module Caboose
346
369
  if Caboose::Setting.exists?(:name => 'google_feed_date_last_submitted')
347
370
  d1 = Caboose::Setting.where(:name => 'google_feed_date_last_submitted').first.value
348
371
  d1 = DateTime.parse(d1)
349
- elsif Invoice.exists?("status = ? and date_authorized is not null", Invoice::STATUS_SHIPPED)
350
- d1 = Invoice.where("status = ? and date_authorized is not null", Invoice::STATUS_SHIPPED).reorder("date_authorized DESC").limit(1).pluck('date_authorized')
372
+ elsif Invoice.exists?("status = ? and date_authorized is not null", Invoice::STATUS_PROCESSED)
373
+ d1 = Invoice.where("status = ? and date_authorized is not null", Invoice::STATUS_PROCESSED).reorder("date_authorized DESC").limit(1).pluck('date_authorized')
351
374
  d1 = DateTime.parse(d1)
352
375
  end
353
376
 
354
377
  # Google Feed Docs
355
378
  # https://support.google.com/trustedstoresmerchant/answer/3272612?hl=en&ref_topic=3272286?hl=en
356
379
  tsv = ["merchant invoice id\ttracking number\tcarrier code\tother carrier name\tship date"]
357
- if Invoice.exists?("status = ? and date_authorized > '#{d1.strftime("%F %T")}'", Invoice::STATUS_SHIPPED)
358
- Invoice.where("status = ? and date_authorized > ?", Invoice::STATUS_SHIPPED, d1).reorder(:id).all.each do |invoice|
380
+ if Invoice.exists?("status = ? and date_authorized > '#{d1.strftime("%F %T")}'", Invoice::STATUS_PROCESSED)
381
+ Invoice.where("status = ? and date_authorized > ?", Invoice::STATUS_PROCESSED, d1).reorder(:id).all.each do |invoice|
359
382
  tracking_numbers = invoice.line_items.collect{ |li| li.tracking_number }.compact.uniq
360
383
  tn = tracking_numbers && tracking_numbers.count >= 1 ? tracking_numbers[0] : ""
361
384
  tsv << "#{invoice.id}\t#{tn}\tUPS\t\t#{invoice.date_shipped.strftime("%F")}"
@@ -21,15 +21,24 @@ module Caboose
21
21
 
22
22
  resp = StdClass.new
23
23
  v = Variant.find(params[:variant_id])
24
- li = LineItem.new(
25
- :invoice_id => params[:invoice_id],
24
+ li = LineItem.create(
25
+ :invoice_id => params[:invoice_id],
26
26
  :variant_id => params[:variant_id],
27
27
  :quantity => 1,
28
28
  :unit_price => v.price,
29
29
  :subtotal => v.price,
30
- :status => 'pending'
31
- )
32
- resp.success = li.save
30
+ :status => LineItem::STATUS_PENDING
31
+ )
32
+ resp.success = true
33
+ resp.new_id = li.id
34
+
35
+ InvoiceLog.create(
36
+ :invoice_id => params[:invoice_id],
37
+ :line_item_id => li.id,
38
+ :user_id => logged_in_user.id,
39
+ :date_logged => DateTime.now.utc,
40
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_CREATED
41
+ )
33
42
  render :json => resp
34
43
  end
35
44
 
@@ -42,7 +51,20 @@ module Caboose
42
51
 
43
52
  save = true
44
53
  send_status_email = false
45
- params.each do |name,value|
54
+ fields_to_log = ['invoice_id','invoice_package_id','variant_id','parent_id','notes','custom1','custom2','custom3','unit_price','quantity','tracking_number','status']
55
+ params.each do |name,value|
56
+ if fields_to_log.include?(name)
57
+ InvoiceLog.create(
58
+ :invoice_id => params[:invoice_id],
59
+ :line_item_id => li.id,
60
+ :user_id => logged_in_user.id,
61
+ :date_logged => DateTime.now.utc,
62
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_UPDATED,
63
+ :field => name,
64
+ :old_value => li[name.to_sym],
65
+ :new_value => value
66
+ )
67
+ end
46
68
  case name
47
69
  when 'invoice_id' then li.invoice_id = value
48
70
  when 'invoice_package_id' then li.invoice_package_id = value
@@ -53,15 +75,14 @@ module Caboose
53
75
  when 'custom1' then li.custom1 = value
54
76
  when 'custom2' then li.custom2 = value
55
77
  when 'custom3' then li.custom3 = value
56
- when 'unit_price'
57
- Caboose.log("li.unit_price = #{li.unit_price}")
78
+ when 'unit_price'
58
79
  li.unit_price = value
59
- li.save
60
- Caboose.log("li.unit_price = #{li.unit_price}")
80
+ li.save
61
81
  li.subtotal = li.unit_price * li.quantity
62
82
  li.save
63
83
  li.invoice.subtotal = li.invoice.calculate_subtotal
64
84
  li.invoice.total = li.invoice.calculate_total
85
+
65
86
  when 'quantity'
66
87
  li.quantity = value
67
88
  li.subtotal = li.unit_price * li.quantity
@@ -69,14 +90,6 @@ module Caboose
69
90
  li.invoice.subtotal = li.invoice.calculate_subtotal
70
91
  li.invoice.total = li.invoice.calculate_total
71
92
 
72
- # Recalculate everything
73
- #r = ShippingCalculator.rate(li.invoice, li.invoice.shipping_method_code)
74
- #li.invoice.shipping = r['negotiated_rate'] / 100
75
- #li.invoice.handling = (r['negotiated_rate'] / 100) * 0.05
76
- #li.invoice.tax = TaxCalculator.tax(li.invoice)
77
- #li.invoice.calculate_total
78
- #li.invoice.save
79
-
80
93
  when 'tracking_number'
81
94
  li.tracking_number = value
82
95
  send_status_email = true
@@ -104,6 +117,14 @@ module Caboose
104
117
  invoice.total = invoice.calculate_total
105
118
  invoice.save
106
119
 
120
+ InvoiceLog.create(
121
+ :invoice_id => params[:invoice_id],
122
+ :line_item_id => params[:id],
123
+ :user_id => logged_in_user.id,
124
+ :date_logged => DateTime.now.utc,
125
+ :invoice_action => InvoiceLog::ACTION_LINE_ITEM_DELETED
126
+ )
127
+
107
128
  render :json => Caboose::StdClass.new({
108
129
  :redirect => '/admin/invoices'
109
130
  })
@@ -118,15 +139,13 @@ module Caboose
118
139
  end
119
140
 
120
141
  # @route GET /admin/invoices/line-items/status-options
121
- def admin_status_options
122
- arr = ['pending', 'ready to ship', 'shipped', 'backinvoiceed', 'canceled']
123
- options = []
124
- arr.each do |status|
125
- options << {
126
- :value => status,
127
- :text => status
128
- }
129
- end
142
+ def admin_status_options
143
+ options = [
144
+ { :value => LineItem::STATUS_PENDING , :text => 'Pending' },
145
+ { :value => LineItem::STATUS_BACKORDERED , :text => 'Backordered' },
146
+ { :value => LineItem::STATUS_CANCELED , :text => 'Canceled' },
147
+ { :value => LineItem::STATUS_PROCESSED , :text => 'Processed' }
148
+ ]
130
149
  render :json => options
131
150
  end
132
151
 
@@ -61,8 +61,7 @@ module Caboose
61
61
  end
62
62
 
63
63
  # @route POST /my-account/confirm
64
- def confirm
65
- Caboose::log(params)
64
+ def confirm
66
65
  sc = @site.store_config
67
66
  @invoice = Invoice.find(params[:id])
68
67
 
@@ -111,7 +110,7 @@ module Caboose
111
110
  capture_resp = @invoice.capture_funds
112
111
  if capture_resp.success == true
113
112
  @invoice.take_gift_card_funds
114
- @invoice.status = Caboose::Invoice::STATUS_PAID
113
+ @invoice.status = Caboose::Invoice::STATUS_PROCESSED
115
114
  end
116
115
  end
117
116
  end
@@ -54,8 +54,7 @@ module Caboose
54
54
  STATUS_PENDING = 'pending'
55
55
  STATUS_CANCELED = 'canceled'
56
56
  STATUS_READY_TO_SHIP = 'ready to ship'
57
- STATUS_SHIPPED = 'shipped'
58
- STATUS_PAID = 'paid'
57
+ STATUS_PROCESSED = 'processed'
59
58
  STATUS_TESTING = 'testing'
60
59
 
61
60
  # New
@@ -99,21 +98,7 @@ module Caboose
99
98
  scope :captured , where('financial_status = ?', 'captured')
100
99
  scope :refunded , where('financial_status = ?', 'refunded')
101
100
  scope :voided , where('financial_status = ?', 'voided')
102
-
103
- #
104
- # Validations
105
- #
106
-
107
- validates :status, :inclusion => {
108
- :in => ['cart', 'pending', 'canceled', 'ready to ship', 'shipped', 'paid', 'testing'],
109
- :message => "%{value} is not a valid status. Must be either 'pending' or 'shipped'"
110
- }
111
-
112
- validates :financial_status, :inclusion => {
113
- :in => ['pending', 'authorized', 'captured', 'refunded', 'voided', 'paid by check', 'paid by other means'],
114
- :message => "%{value} is not a valid financial status. Must be 'authorized', 'captured', 'refunded' or 'voided'"
115
- }
116
-
101
+
117
102
  after_initialize :check_nil_fields
118
103
 
119
104
  def check_nil_fields
@@ -0,0 +1,30 @@
1
+ module Caboose
2
+ class InvoiceLog < ActiveRecord::Base
3
+ self.table_name = 'store_invoice_logs'
4
+
5
+ belongs_to :invoice
6
+ belongs_to :user
7
+ attr_accessible :id ,
8
+ :invoice_id ,
9
+ :invoice_package_id ,
10
+ :line_item_id ,
11
+ :user_id ,
12
+ :date_logged ,
13
+ :invoice_action ,
14
+ :field ,
15
+ :old_value ,
16
+ :new_value
17
+
18
+ ACTION_INVOICE_CREATED = 'invoice created'
19
+ ACTION_INVOICE_UPDATED = 'invoice updated'
20
+ ACTION_INVOICE_DELETED = 'invoice deleted'
21
+ ACTION_INVOICE_PACKAGE_CREATED = 'invoice package created'
22
+ ACTION_INVOICE_PACKAGE_UPDATED = 'invoice package updated'
23
+ ACTION_INVOICE_PACKAGE_DELETED = 'invoice package deleted'
24
+ ACTION_LINE_ITEM_CREATED = 'line item created'
25
+ ACTION_LINE_ITEM_UPDATED = 'line item updated'
26
+ ACTION_LINE_ITEM_DELETED = 'line item deleted'
27
+
28
+ end
29
+ end
30
+
@@ -15,8 +15,9 @@ module Caboose
15
15
  :total,
16
16
  :instore_pickup
17
17
 
18
- STATUS_PENDING = 'Pending'
19
- STATUS_SHIPPED = 'Shipped'
18
+ STATUS_PENDING = 'Pending'
19
+ STATUS_READY_TO_SHIP = 'Ready to Ship'
20
+ STATUS_SHIPPED = 'Shipped'
20
21
 
21
22
  after_initialize :check_nil_fields
22
23
 
@@ -30,15 +30,17 @@ module Caboose
30
30
  :date_starts ,
31
31
  :date_ends
32
32
 
33
- STATUS_PENDING = 'pending'
34
- STATUS_SHIPPED = 'shipped'
33
+ STATUS_PENDING = 'pending'
34
+ STATUS_BACKORDERED = 'backordered'
35
+ STATUS_CANCELED = 'canceled'
36
+ STATUS_PROCESSED = 'processed'
35
37
 
36
38
  #
37
39
  # Scopes
38
40
  #
39
- scope :pending, where('status = ?', 'pending')
40
- scope :fulfilled, where('status = ?', 'shipped')
41
- scope :unfulfilled, where('status != ?', 'shipped')
41
+ scope :pending , where('status = ?', 'pending')
42
+ scope :fulfilled , where('status = ?', 'shipped')
43
+ scope :unfulfilled , where('status != ?', 'shipped')
42
44
 
43
45
  #validates :quantity, :numericality => { :greater_than_or_equal_to => 0 }
44
46
  #validate :quantity_in_stock
@@ -408,6 +408,17 @@ class Caboose::Schema < Caboose::Utilities::Schema
408
408
  [ :invoice_id , :integer ],
409
409
  [ :discount_id , :integer ]
410
410
  ],
411
+ Caboose::InvoiceLog => [
412
+ [ :invoice_id , :integer ],
413
+ [ :invoice_package_id , :integer ],
414
+ [ :line_item_id , :integer ],
415
+ [ :user_id , :integer ],
416
+ [ :date_logged , :datetime ],
417
+ [ :invoice_action , :string ],
418
+ [ :field , :string ],
419
+ [ :old_value , :text ],
420
+ [ :new_value , :text ]
421
+ ],
411
422
  Caboose::InvoicePackage => [
412
423
  [ :invoice_id , :integer ],
413
424
  [ :instore_pickup , :boolean , { :default => false }],
@@ -444,6 +455,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
444
455
  [ :date_authorized , :datetime ],
445
456
  [ :date_captured , :datetime ],
446
457
  [ :date_shipped , :datetime ],
458
+ [ :date_processed , :datetime ],
447
459
  [ :date_due , :date ],
448
460
  [ :referring_site , :text ],
449
461
  [ :landing_page , :string ],
@@ -1162,5 +1174,11 @@ class Caboose::Schema < Caboose::Utilities::Schema
1162
1174
  smtp.save
1163
1175
  end
1164
1176
 
1177
+ # Change the invoice statuses
1178
+ Caboose::Invoice.where("status = ? or status = ?", 'shipped', 'paid').all.each do |invoice|
1179
+ invoice.status = 'processed'
1180
+ invoice.save
1181
+ end
1182
+
1165
1183
  end
1166
1184
  end
@@ -2,6 +2,11 @@
2
2
  <% if @edituser %>
3
3
  <%= render :partial => 'caboose/users/admin_header' %>
4
4
  <% else %>
5
+ <div id='crumbtrail'>
6
+ <a href='/admin'>Admin</a> >
7
+ <a href='/admin/invoices'>Invoices</a> >
8
+ Invoice #<%= @invoice.id %>
9
+ </div>
5
10
  <h1>Edit Invoice #<%= @invoice.id %></h1>
6
11
  <% end %>
7
12
 
@@ -2,6 +2,10 @@
2
2
  <% if @edituser %>
3
3
  <%= render :partial => 'caboose/users/admin_header' %>
4
4
  <% else %>
5
+ <div id='crumbtrail'>
6
+ <a href='/admin'>Admin</a> >
7
+ Invoices
8
+ </div>
5
9
  <h1>Invoices</h1>
6
10
  <% end %>
7
11
 
@@ -33,7 +37,9 @@
33
37
  <% end %>
34
38
  <p><input type='text' name='total_gte' placeholder='Total Min' value="<%= @pager.params['total_gte'] %>" style='width: 100px;' /></p>
35
39
  <p><input type='text' name='total_lte' placeholder='Total Max' value="<%= @pager.params['total_lte'] %>" style='width: 100px;' /></p>
36
- <p><select name='status'>
40
+ <p>
41
+ <!--
42
+ <select name='status'>
37
43
  <optgroup label='Status'>
38
44
  <option value=''>-- All statuses --</option>
39
45
  <% statuses = ['cart','pending','canceled','ready to ship','shipped','paid'] %>
@@ -41,7 +47,28 @@
41
47
  <option value='<%= status %>'<%= @pager.params['status'] == status ? " selected='true'" : '' %>><%= status.capitalize %></option>
42
48
  <% end %>
43
49
  </optgroup>
44
- </select></p>
50
+ </select>
51
+ -->
52
+ <%
53
+ statuses = [
54
+ Caboose::Invoice::STATUS_CART ,
55
+ Caboose::Invoice::STATUS_PENDING ,
56
+ Caboose::Invoice::STATUS_READY_TO_SHIP ,
57
+ Caboose::Invoice::STATUS_PROCESSED ,
58
+ Caboose::Invoice::STATUS_CANCELED
59
+ ]
60
+ all_checked = true
61
+ statuses.each do |status|
62
+ all_checked = false if !@pager.params['status'].include?(status)
63
+ end
64
+ Caboose.log(@pager.params['status'])
65
+ %>
66
+ Status:
67
+ <% statuses.each do |status| %>
68
+ <input type='checkbox' name='status[]' id='status_<%= status %>' value='<%= status %>' <% if @pager.params['status'].include?(status) %> checked='true'<% end %> />
69
+ <label for='status_<%= status %>'><%= status.capitalize %></label>
70
+ <% end %>
71
+ </p>
45
72
  <p>
46
73
  <input type='submit' value='Search' />
47
74
  <input type='button' value='Clear' onclick="window.location='/admin<%= @edituser ? "/users/#{@edituser.id}" : '' %>/invoices';" />
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.85'
2
+ VERSION = '0.8.87'
3
3
  end
@@ -7,6 +7,10 @@ namespace :caboose do
7
7
  Caboose::Subscription.migrate_from_user_subscriptions
8
8
  end
9
9
 
10
+ task :create_subscription_invoices => :environment do
11
+ Caboose::Subscription.create_invoices
12
+ end
13
+
10
14
  desc "Save sample asset"
11
15
  task :save_sample_asset => :environment do
12
16
 
@@ -151,7 +155,7 @@ namespace :caboose do
151
155
 
152
156
  desc "Calculate invoice profits"
153
157
  task :calculate_invoice_profits => :environment do
154
- Caboose::Invoice.where("status = ? or status = ? or status = ?", Caboose::Invoice::STATUS_PENDING, Caboose::Invoice::STATUS_READY_TO_SHIP, Caboose::Invoice::STATUS_SHIPPED).reinvoice(:id).all.each do |invoice|
158
+ Caboose::Invoice.where("status = ? or status = ? or status = ?", Caboose::Invoice::STATUS_PENDING, Caboose::Invoice::STATUS_READY_TO_SHIP, Caboose::Invoice::STATUS_PROCESSED).reinvoice(:id).all.each do |invoice|
155
159
  invoice.update_column(:cost , invoice.calculate_cost )
156
160
  invoice.update_column(:profit , invoice.calculate_profit )
157
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.85
4
+ version: 0.8.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -881,6 +881,7 @@ files:
881
881
  - app/models/caboose/gift_card.rb
882
882
  - app/models/caboose/invoice.rb
883
883
  - app/models/caboose/invoice_discount.rb
884
+ - app/models/caboose/invoice_log.rb
884
885
  - app/models/caboose/invoice_package.rb
885
886
  - app/models/caboose/invoice_package_calculator.rb
886
887
  - app/models/caboose/invoice_pdf.rb