caboose-cms 0.7.16 → 0.7.17

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5296ff62df1d3dca4dc184aa275bb11324a4a5d5
4
- data.tar.gz: 7170556acc8d764c0859353cf077576ec72d08fb
3
+ metadata.gz: 820bfc8858e33c2b4af5c694a2692f03dde511bc
4
+ data.tar.gz: 95f81b1e0e4cf78778adbbef05b6757e195e0b3e
5
5
  SHA512:
6
- metadata.gz: 7597b374c85781663a6af491668112579c21cce9dbe32d550ffbd8ddcc27b8a57e9044a9f9a49c5323d05f9357591db65e5745a398f3abbf808abb98a8214ed1
7
- data.tar.gz: 4ca180a513d793b898def98f75d5a7db0f6f486de6e7cf7d76738d75c801f75575c77d33df732d5614f095fa8b49dcee31b5286f240633c79b5f44e2d6ebff0f
6
+ metadata.gz: 4e0b9ac6bb9dd120791dc4b99f658995811538683283b4914f70c1a602194aaa9fe86665f8c44be7a5ca88d6e824e29f207042b5a07abf91d3b6b12ef1fdd86d
7
+ data.tar.gz: 7bb4c217b83766dcffbc2a3df9c1d177aba0ea691fb0a763fb270e43cc7e47a51ba5c9561738f4486deb6ad98ef7023fd04bfd74b50a38fa4a5f755057d5cb09
@@ -263,6 +263,7 @@ PageContentController.prototype = {
263
263
 
264
264
  $('#block_' + b.id).attr('onclick','').unbind('click');
265
265
  $('#block_' + b.id).click(function(e) {
266
+ e.preventDefault();
266
267
  e.stopPropagation();
267
268
  that.edit_block(b.id);
268
269
  });
@@ -17,6 +17,7 @@ BoundDateTime = BoundControl.extend({
17
17
  $('#'+this.el).wrap($('<div/>')
18
18
  .attr('id', this.el + '_container')
19
19
  .addClass('mb_container')
20
+ .addClass('mb_date_time_container')
20
21
  .css('position', 'relative')
21
22
  );
22
23
  $('#'+this.el+'_container').empty();
@@ -339,6 +339,9 @@ module Caboose
339
339
  order.status = Order::STATUS_PENDING
340
340
  order.order_number = @site.store_config.next_order_number
341
341
  order.date_authorized = DateTime.now.utc
342
+
343
+ # Tell taxcloud the order was authorized
344
+ Caboose::TaxCalculator.authorized(order)
342
345
 
343
346
  # Take funds from any gift cards that were used on the order
344
347
  order.take_gift_card_funds
@@ -89,7 +89,10 @@ module Caboose
89
89
  return if !user_is_allowed('orders', 'edit')
90
90
 
91
91
  order = Order.find(params[:id])
92
- resp = order.capture_funds
92
+ resp = order.capture_funds
93
+
94
+ # Tell taxcloud the order was captured
95
+ Caboose::TaxCalculator.captured(order)
93
96
 
94
97
  render :json => resp
95
98
  end
@@ -228,6 +228,13 @@ module Caboose
228
228
  return false
229
229
  end
230
230
 
231
+ def has_taxable_items?
232
+ self.line_items.each do |li|
233
+ return true if li.variant.taxable && li.variant.taxable == true
234
+ end
235
+ return false
236
+ end
237
+
231
238
  # Capture funds from a previously authorized transaction
232
239
  def capture_funds
233
240
 
@@ -9,24 +9,48 @@ module Caboose
9
9
 
10
10
  def self.tax(order)
11
11
  return 0.00 if !order.shipping_address
12
+ return 0.00 if !order.has_taxable_items?
12
13
 
13
- sc = order.site.store_config
14
- if !sc.auto_calculate_tax
15
- tax = self.custom_tax(sc, order)
16
- return tax
17
- end
14
+ sc = order.site.store_config
15
+ return self.custom_tax(sc, order) if !sc.auto_calculate_tax
16
+ return order.subtotal * order.tax_rate if order.tax_rate # See if the tax rate has already been calculated
17
+
18
+ t = self.transaction(order)
19
+ Caboose.log(t.inspect)
20
+ lookup = t.lookup
21
+ tax = lookup.tax_amount
18
22
 
19
- # See if the tax rate has already been calculated
20
- # If so, use that instead of doing another web service call
21
- if order.tax_rate
22
- return order.subtotal * order.tax_rate
23
- end
23
+ # Save the tax rate
24
+ order.tax_rate = tax/order.subtotal
25
+ order.save
26
+
27
+ # Return the tax amount
28
+ return tax
29
+ end
30
+
31
+ def self.authorized(order)
32
+ t = self.transaction(order)
33
+ return if t.nil?
34
+ t.order_id = order.id
35
+ t.authorized
36
+ end
37
+
38
+ def self.captured(order)
39
+ t = self.transaction(order)
40
+ return if t.nil?
41
+ t.order_id = order.id
42
+ t.captured
43
+ end
44
+
45
+ def self.transaction(order)
46
+ sc = order.site.store_config
47
+ return nil if sc.nil? || !sc.auto_calculate_tax
24
48
 
25
49
  sa = order.shipping_address
26
50
  if sa.nil? || sa.address1.nil? || sa.city.nil? || sa.state.nil? || sa.zip.nil?
27
51
  sa = order.billing_address
28
52
  end
29
- return 0.00 if sa.nil? || sa.address1.nil? || sa.city.nil? || sa.state.nil? || sa.zip.nil?
53
+ return nil if sa.nil? || sa.address1.nil? || sa.city.nil? || sa.state.nil? || sa.zip.nil?
30
54
 
31
55
  TaxCloud.configure do |config|
32
56
  config.api_login_id = sc.taxcloud_api_id
@@ -34,26 +58,9 @@ module Caboose
34
58
  config.usps_username = sc.usps_username
35
59
  end
36
60
 
37
- origin = TaxCloud::Address.new(
38
- :address1 => sc.origin_address1,
39
- :address2 => sc.origin_address2,
40
- :city => sc.origin_city,
41
- :state => sc.origin_state,
42
- :zip5 => sc.origin_zip
43
- )
44
- destination = TaxCloud::Address.new(
45
- :address1 => sa.address1,
46
- :address2 => sa.address2,
47
- :city => sa.city,
48
- :state => sa.state,
49
- :zip5 => sa.zip
50
- )
51
- transaction = TaxCloud::Transaction.new(
52
- :customer_id => order.customer_id,
53
- :cart_id => order.id,
54
- :origin => origin,
55
- :destination => destination
56
- )
61
+ origin = TaxCloud::Address.new(:address1 => sc.origin_address1 , :address2 => sc.origin_address2 , :city => sc.origin_city , :state => sc.origin_state , :zip5 => sc.origin_zip )
62
+ destination = TaxCloud::Address.new(:address1 => sa.address1 , :address2 => sa.address2 , :city => sa.city , :state => sa.state , :zip5 => sa.zip )
63
+ transaction = TaxCloud::Transaction.new(:customer_id => order.customer_id, :cart_id => order.id, :origin => origin, :destination => destination)
57
64
  order.line_items.each_with_index do |li, i|
58
65
  next if !li.variant.taxable # Skip any non-taxable items
59
66
  transaction.cart_items << TaxCloud::CartItem.new(
@@ -64,35 +71,76 @@ module Caboose
64
71
  :quantity => li.quantity
65
72
  )
66
73
  end
67
- lookup = transaction.lookup
68
- tax = lookup.tax_amount
69
-
70
- # Save the tax rate
71
- order.tax_rate = tax/order.subtotal
72
- order.save
73
-
74
- # Return the tax amount
75
- return tax
76
-
77
- #return 0.00 if address.nil? || address.city.nil? || address.state.nil?
78
- #return 0 if address.state.downcase != 'al'
79
- #return 0.09
80
-
81
- #rate = 0.00
82
- #city = address.city.downcase
83
- #rate = rate + 0.05 if city == 'brookwood'
84
- #rate = rate + 0.05 if city == 'coaling'
85
- #rate = rate + 0.05 if city == 'coker'
86
- #rate = rate + 0.05 if city == 'holt'
87
- #rate = rate + 0.05 if city == 'holt CDP'
88
- #rate = rate + 0.05 if city == 'lake View'
89
- #rate = rate + 0.05 if city == 'moundville'
90
- #rate = rate + 0.05 if city == 'northport'
91
- #rate = rate + 0.05 if city == 'tuscaloosa'
92
- #rate = rate + 0.05 if city == 'vance'
93
- #rate = rate + 0.05 if city == 'woodstock'
94
- #rate = rate + 0.04 if address.state.downcase == 'al' || address.state.downcase == 'alabama'
95
- #return rate.round(2)
74
+ return transaction
96
75
  end
76
+
77
+ #def self.tax(order)
78
+ # return 0.00 if !order.shipping_address
79
+ #
80
+ # sc = order.site.store_config
81
+ # if !sc.auto_calculate_tax
82
+ # tax = self.custom_tax(sc, order)
83
+ # return tax
84
+ # end
85
+ #
86
+ # # See if the tax rate has already been calculated
87
+ # # If so, use that instead of doing another web service call
88
+ # if order.tax_rate
89
+ # return order.subtotal * order.tax_rate
90
+ # end
91
+ #
92
+ # sa = order.shipping_address
93
+ # if sa.nil? || sa.address1.nil? || sa.city.nil? || sa.state.nil? || sa.zip.nil?
94
+ # sa = order.billing_address
95
+ # end
96
+ # return 0.00 if sa.nil? || sa.address1.nil? || sa.city.nil? || sa.state.nil? || sa.zip.nil?
97
+ #
98
+ # TaxCloud.configure do |config|
99
+ # config.api_login_id = sc.taxcloud_api_id
100
+ # config.api_key = sc.taxcloud_api_key
101
+ # config.usps_username = sc.usps_username
102
+ # end
103
+ #
104
+ # origin = TaxCloud::Address.new(
105
+ # :address1 => sc.origin_address1,
106
+ # :address2 => sc.origin_address2,
107
+ # :city => sc.origin_city,
108
+ # :state => sc.origin_state,
109
+ # :zip5 => sc.origin_zip
110
+ # )
111
+ # destination = TaxCloud::Address.new(
112
+ # :address1 => sa.address1,
113
+ # :address2 => sa.address2,
114
+ # :city => sa.city,
115
+ # :state => sa.state,
116
+ # :zip5 => sa.zip
117
+ # )
118
+ # transaction = TaxCloud::Transaction.new(
119
+ # :customer_id => order.customer_id,
120
+ # :cart_id => order.id,
121
+ # :origin => origin,
122
+ # :destination => destination
123
+ # )
124
+ # order.line_items.each_with_index do |li, i|
125
+ # next if !li.variant.taxable # Skip any non-taxable items
126
+ # transaction.cart_items << TaxCloud::CartItem.new(
127
+ # :index => i,
128
+ # :item_id => li.variant.id,
129
+ # :tic => TaxCloud::TaxCodes::GENERAL,
130
+ # :price => li.unit_price,
131
+ # :quantity => li.quantity
132
+ # )
133
+ # end
134
+ # lookup = transaction.lookup
135
+ # tax = lookup.tax_amount
136
+ #
137
+ # # Save the tax rate
138
+ # order.tax_rate = tax/order.subtotal
139
+ # order.save
140
+ #
141
+ # # Return the tax amount
142
+ # return tax
143
+ #end
144
+
97
145
  end
98
146
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.16'
2
+ VERSION = '0.7.17'
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.7.16
4
+ version: 0.7.17
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-10-27 00:00:00.000000000 Z
11
+ date: 2015-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg