caboose-cms 0.5.175 → 0.5.176

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
- MTMzOGNmOTc2NTFkYWZkNWNiOThhOTZlNTZmOGMwZTU3OGJlMWYyOQ==
4
+ ODY1NTkwODZhZWFhNDJlMDJkYWE1OGY5NTA4NDViMGM4NWU3OGJkZQ==
5
5
  data.tar.gz: !binary |-
6
- YzEzNDg4OWRkODM2YjMwNWY5MzhkZDNlNGFiYTY5OGU2ZDc1MjZkOQ==
6
+ YzE0M2EwOTJhYjdhYmZjZWM4NTYyZjdkMWJmMWNjYjdkYzNiMTc2ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmYzMTU2ZmE2ZGE2Mzg3Y2FjMzk1NTcwODYzNDI5M2QwYmUxMjg1ZWNlMWQ3
10
- YzBlNTVlMTc3ZjgyNzZhNDM4ZWMzMTMyOTlmZTc3ODk5YmQzMmEyZDJjMTVl
11
- M2ExNzBkNmM5MGZkOGE1MjU4ZWNmYjM5YzU1MTU5M2RhMGZlYTM=
9
+ NzVhYWExY2M0YzIxZDA0YWYyYzdjM2VmZGQ1ZjEzNmM4MjJkMTU1NGFlMDIz
10
+ ZDcwOWY2NzA5MWJlYzg2NDA3YjhhMTM2MTg1MjU1ODBiOWE0MmMxOWUyODgx
11
+ ZTM5ZDBlNzRjMmRkNDI2ODY0NmY3NzhkZDNmNWNhYzM3OWE0YzQ=
12
12
  data.tar.gz: !binary |-
13
- ZTUxMjA2ZjA3NjJlYjUyNTNiMjc4MjkxZjQ5NDY4OTYxNTdiM2YzOGIwOGZl
14
- MzkyMzRmNDJlNGIwNmRlMWM2OGUyMThkYTNkYjgwYjFiZDc1YTVmNjAxMDcx
15
- OWZkYWQ1MmEzZGJkYzUwNmVhNWZhZGJkMjNjMjFmOGNlNTUzOWI=
13
+ MmU2M2JmMzI1OWZjYjFhYWU5NTY4NmEyNjEwNDZkZjcwNTA0OTg2MWFkYWVl
14
+ YmI5ZDdjZGE2YzRjZmVhMjAyZTAyMTkwOWE2M2UyNmRhM2JkY2IzNTY4ZmJj
15
+ YzM4MjdiYTdhYTM2YmQ0ZTk5ZmExZWIyZjg2Y2E5ZThjM2QzMjE=
@@ -16,13 +16,14 @@ OrderController.prototype = {
16
16
  $(document).ready(function() { that.refresh(); });
17
17
  },
18
18
 
19
- refresh: function()
19
+ refresh: function(after)
20
20
  {
21
21
  var that = this;
22
22
  that.refresh_order(function() {
23
23
  $('#order_table').html("<p class='loading'>Getting order...</p>");
24
24
  that.print();
25
- that.make_editable();
25
+ that.make_editable();
26
+ if (after) after();
26
27
  });
27
28
  },
28
29
 
@@ -33,11 +34,23 @@ OrderController.prototype = {
33
34
  url: '/admin/orders/' + that.order_id + '/json',
34
35
  success: function(order) {
35
36
  that.order = order;
36
- if (after) after();
37
+ that.refresh_numbers();
38
+ if (after) after();
37
39
  }
38
40
  });
39
41
  },
40
42
 
43
+ refresh_numbers: function()
44
+ {
45
+ var that = this;
46
+ $('#subtotal').html(curr(that.order.subtotal));
47
+ $('#shipping').html(curr(that.order.shipping));
48
+ $('#total' ).html(curr(that.order.total ));
49
+ $.each(that.order.line_items, function(i, li) {
50
+ $('#li_' + li.id + '_subtotal').html(curr(li.subtotal));
51
+ });
52
+ },
53
+
41
54
  make_editable: function()
42
55
  {
43
56
  var that = this;
@@ -51,7 +64,7 @@ OrderController.prototype = {
51
64
  { name: 'status' , nice_name: 'Status' , type: 'select' , value: op.status , width: 300, fixed_placeholder: true , options_url: '/admin/orders/line-items/status-options' },
52
65
  { name: 'package_method' , nice_name: 'Package/Method' , type: 'select' , value: op.shipping_package_id + '_' + op.shipping_method_id , width: 300, fixed_placeholder: false, options_url: '/admin/shipping-packages/package-method-options' },
53
66
  { name: 'tracking_number' , nice_name: 'Tracking Number' , type: 'text' , value: op.tracking_number , width: 300, fixed_placeholder: true, align: 'right' },
54
- { name: 'total' , nice_name: 'Shipping Total' , type: 'text' , value: curr(op.total) , width: 300, fixed_placeholder: true, align: 'right' }
67
+ { name: 'total' , nice_name: 'Shipping Total' , type: 'text' , value: curr(op.total) , width: 300, fixed_placeholder: true, align: 'right' , after_update: function() { that.refresh_order(); }}
55
68
  ]
56
69
  });
57
70
  });
@@ -64,7 +77,7 @@ OrderController.prototype = {
64
77
  attributes: [
65
78
  { name: 'status' , nice_name: 'Status' , type: 'select' , align: 'left' , value: li.status , text: li.status, width: 150, fixed_placeholder: false, options_url: '/admin/orders/line-items/status-options' },
66
79
  { name: 'tracking_number' , nice_name: 'Tracking Number' , type: 'text' , align: 'left' , value: li.tracking_number , width: 200, fixed_placeholder: false },
67
- { name: 'quantity' , nice_name: 'Quantity' , type: 'text' , align: 'right', value: li.quantity , width: 75, fixed_placeholder: false, after_update: function() { that.refresh(); } }
80
+ { name: 'quantity' , nice_name: 'Quantity' , type: 'text' , align: 'right', value: li.quantity , width: 75, fixed_placeholder: false, after_update: function() { that.refresh_order(); } }
68
81
  ]
69
82
  });
70
83
  });
@@ -75,9 +88,9 @@ OrderController.prototype = {
75
88
  authenticity_token: that.authenticity_token,
76
89
  attributes: [
77
90
  { name: 'status' , nice_name: 'Status' , type: 'select', value: that.order.status , width: 100, fixed_placeholder: false, options_url: '/admin/orders/status-options' },
78
- { name: 'tax' , nice_name: 'Tax' , type: 'text' , value: curr(that.order.tax) , width: 100, fixed_placeholder: false, align: 'right' },
79
- { name: 'handling' , nice_name: 'Handling' , type: 'text' , value: curr(that.order.handling) , width: 100, fixed_placeholder: false, align: 'right' },
80
- { name: 'custom_discount', nice_name: 'Discount' , type: 'text' , value: curr(that.order.custom_discount) , width: 100, fixed_placeholder: false, align: 'right' }
91
+ { name: 'tax' , nice_name: 'Tax' , type: 'text' , value: curr(that.order.tax) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_order(); }},
92
+ { name: 'handling' , nice_name: 'Handling' , type: 'text' , value: curr(that.order.handling) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_order(); }},
93
+ { name: 'custom_discount', nice_name: 'Discount' , type: 'text' , value: curr(that.order.custom_discount) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_order(); }}
81
94
  ]
82
95
  });
83
96
  },
@@ -657,10 +670,10 @@ OrderController.prototype = {
657
670
 
658
671
  if (that.order.line_items.length > 0)
659
672
  {
660
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.order.subtotal))));
661
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Tax' )).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'order_' + that.order.id + '_tax'))));
662
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.order.shipping))));
663
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Handling' )).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'order_' + that.order.id + '_handling'))));
673
+ table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.order.subtotal))));
674
+ table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').append('Tax ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_tax(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'order_' + that.order.id + '_tax'))));
675
+ table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.order.shipping))));
676
+ table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').append('Handling ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_handling(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'order_' + that.order.id + '_handling'))));
664
677
  if (that.order.discounts)
665
678
  {
666
679
  $.each(that.order.discounts, function(i, d) {
@@ -829,13 +842,30 @@ OrderController.prototype = {
829
842
  $.ajax({
830
843
  url: '/admin/orders/' + that.order.id + '/send-for-authorization',
831
844
  success: function(resp) {
832
- if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
833
- if (resp.success) { $('#message').empty(); that.refresh(); }
834
- if (resp.refresh) { $('#message').empty(); that.refresh(); }
845
+ if (resp.error) { that.flash_error(resp.error); }
846
+ if (resp.success) { that.refresh(function() { that.flash_success("An email has been sent successfully to the customer."); }); }
835
847
  }
836
848
  });
837
849
  },
838
850
 
851
+ calculate_tax: function()
852
+ {
853
+ var that = this;
854
+ $.ajax({
855
+ url: '/admin/orders/' + that.order_id + '/calculate-tax',
856
+ success: function(resp) { that.refresh_order(function() { $('#order_' + that.order.id + '_tax').val(that.order.tax); }); }
857
+ });
858
+ },
859
+
860
+ calculate_handling: function()
861
+ {
862
+ var that = this;
863
+ $.ajax({
864
+ url: '/admin/orders/' + that.order_id + '/calculate-handling',
865
+ success: function(resp) { that.refresh_order(function() { $('#order_' + that.order.id + '_handling').val(that.order.handling); }); }
866
+ });
867
+ },
868
+
839
869
  has_shippable_items: function()
840
870
  {
841
871
  var that = this;
@@ -847,6 +877,15 @@ OrderController.prototype = {
847
877
  return needs_shipping;
848
878
  },
849
879
 
880
+ flash_success: function(str, length) { this.flash_message("<p class='note success'>" + str + "</p>", length); },
881
+ flash_error: function(str, length) { this.flash_message("<p class='note error'>" + str + "</p>", length); },
882
+ flash_message: function(str, length)
883
+ {
884
+ if (!length) length = 5000;
885
+ $('#message').empty().append(str);
886
+ setTimeout(function() { $('#message').slideUp(function() { $('#message').empty().show(); }); }, length);
887
+ }
888
+
850
889
  //resend_confirmation: function(order_id)
851
890
  //{
852
891
  // modal.autosize("<p class='loading'>Resending confirmation..</p>");
@@ -885,7 +924,3 @@ OrderController.prototype = {
885
924
  //},
886
925
 
887
926
  };
888
-
889
-
890
-
891
-
@@ -47,23 +47,29 @@ module Caboose
47
47
  when 'order_package_id' then li.order_package_id = value
48
48
  when 'variant_id' then li.variant_id = value
49
49
  when 'parent_id' then li.parent_id = value
50
- when 'unit_price' then li.unit_price = value
51
- when 'subtotal' then li.subtotal = value
50
+ #when 'unit_price' then li.unit_price = value
51
+ #when 'subtotal' then li.subtotal = value
52
52
  when 'notes' then li.notes = value
53
53
  when 'custom1' then li.custom1 = value
54
54
  when 'custom2' then li.custom2 = value
55
55
  when 'custom3' then li.custom3 = value
56
56
  when 'quantity'
57
57
  li.quantity = value
58
+ li.subtotal = li.unit_price * li.quantity
59
+
58
60
  li.save
59
-
61
+
62
+
63
+ li.order.subtotal = li.order.calculate_subtotal
64
+ li.order.total = li.order.calculate_total
65
+
60
66
  # Recalculate everything
61
- r = ShippingCalculator.rate(li.order, li.order.shipping_method_code)
62
- li.order.shipping = r['negotiated_rate'] / 100
63
- li.order.handling = (r['negotiated_rate'] / 100) * 0.05
64
- li.order.tax = TaxCalculator.tax(li.order)
65
- li.order.calculate_total
66
- li.order.save
67
+ #r = ShippingCalculator.rate(li.order, li.order.shipping_method_code)
68
+ #li.order.shipping = r['negotiated_rate'] / 100
69
+ #li.order.handling = (r['negotiated_rate'] / 100) * 0.05
70
+ #li.order.tax = TaxCalculator.tax(li.order)
71
+ #li.order.calculate_total
72
+ #li.order.save
67
73
 
68
74
  when 'tracking_number'
69
75
  li.tracking_number = value
@@ -6,8 +6,8 @@ module Caboose
6
6
 
7
7
  # GET /my-account/orders
8
8
  def index
9
- return if !logged_in?
10
-
9
+ return if !verify_logged_in
10
+
11
11
  @pager = Caboose::PageBarGenerator.new(params, {
12
12
  'customer_id' => logged_in_user.id,
13
13
  'status' => [Order::STATUS_PENDING, Order::STATUS_CANCELED, Order::STATUS_READY_TO_SHIP, Order::STATUS_SHIPPED]
@@ -23,7 +23,7 @@ module Caboose
23
23
 
24
24
  # GET /my-account/orders/:id
25
25
  def edit
26
- return if !logged_in?
26
+ return if !verify_logged_in
27
27
 
28
28
  @order = Order.find(params[:id])
29
29
  if @order.customer_id != logged_in_user.id
@@ -57,8 +57,13 @@ module Caboose
57
57
  op.shipping_method_id = arr[1]
58
58
  end
59
59
  end
60
- op.order.calculate_total
61
- resp.success = save && op.save
60
+
61
+ op.save
62
+ op.order.shipping = op.order.calculate_shipping
63
+ op.order.total = op.order.calculate_total
64
+ op.order.save
65
+
66
+ resp.success = true
62
67
  render :json => resp
63
68
  end
64
69
 
@@ -55,9 +55,29 @@ module Caboose
55
55
  def admin_edit
56
56
  return if !user_is_allowed('orders', 'edit')
57
57
  @order = Order.find(params[:id])
58
- @order.calculate
58
+ #@order.calculate
59
59
  render :layout => 'caboose/admin'
60
60
  end
61
+
62
+ # GET /admin/orders/:id/calculate-tax
63
+ def admin_calculate_tax
64
+ return if !user_is_allowed('orders', 'edit')
65
+ order = Order.find(params[:id])
66
+ order.tax = order.calculate_tax
67
+ order.total = order.calculate_total
68
+ order.save
69
+ render :json => { :success => true }
70
+ end
71
+
72
+ # GET /admin/orders/:id/calculate-handling
73
+ def admin_calculate_handling
74
+ return if !user_is_allowed('orders', 'edit')
75
+ order = Order.find(params[:id])
76
+ order.handling = order.calculate_handling
77
+ order.total = order.calculate_total
78
+ order.save
79
+ render :json => { :success => true }
80
+ end
61
81
 
62
82
  # GET /admin/orders/:id/capture
63
83
  def capture_funds
@@ -146,17 +166,25 @@ module Caboose
146
166
  save = true
147
167
  params.each do |name,value|
148
168
  case name
149
- when 'tax' then order.tax = value
150
- when 'shipping' then order.shipping = value
151
- when 'handling' then order.handling = value
169
+ when 'tax' then
170
+ order.tax = value
171
+ order.total = order.calculate_total
172
+ when 'handling' then
173
+ order.handling = value
174
+ order.total = order.calculate_total
152
175
  when 'custom_discount' then
153
176
  order.custom_discount = value
154
177
  order.discount = order.calculate_discount
178
+ order.total = order.calculate_total
155
179
  when 'status' then order.status = value
156
180
  when 'customer_id' then order.customer_id = value
157
181
  end
158
182
  end
159
- order.calculate_total
183
+
184
+ #order.calculate
185
+ #order.calculate_total
186
+ #resp.attributes['total'] = { 'value' => order.total }
187
+
160
188
  resp.success = save && order.save
161
189
  render :json => resp
162
190
  end
@@ -1,5 +1,5 @@
1
1
  <p><img src='<%= @order.site.logo.url(:thumb) %>' /></p>
2
2
 
3
3
  <h1>Order <%= @order.order_number %> is ready for payment!</h1>
4
- <p>Please <a href='http://<%= raw @order.site.primary_domain %>/my-account/orders/<%= @order.id %>'>review your order</a> and submit payment.</p>
4
+ <p>Please <a href='http://<%= raw @order.site.primary_domain.domain %>/my-account/orders/<%= @order.id %>'>review your order</a> and submit payment.</p>
5
5
  <p>Thank you!</p>
@@ -516,7 +516,9 @@ Caboose::Engine.routes.draw do
516
516
  get "/admin/orders/test-gmail" => "orders#admin_mail_test_gmail"
517
517
  get "/admin/orders/status-options" => "orders#admin_status_options"
518
518
  get "/admin/orders/new" => "orders#admin_new"
519
- get "/admin/orders/print-pending" => "orders#admin_print_pending"
519
+ get "/admin/orders/print-pending" => "orders#admin_print_pending"
520
+ get "/admin/orders/:id/calculate-tax" => "orders#admin_calculate_tax"
521
+ get "/admin/orders/:id/calculate-handling" => "orders#admin_calculate_handling"
520
522
  get "/admin/orders/:id/send-for-authorization" => "orders#admin_send_for_authorization"
521
523
  get "/admin/orders/:id/capture" => "orders#capture_funds"
522
524
  get "/admin/orders/:id/json" => "orders#admin_json"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.175'
2
+ VERSION = '0.5.176'
3
3
  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.5.175
4
+ version: 0.5.176
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg