spree_core 0.70.0.rc2 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/LICENSE +1 -1
  2. data/app/assets/javascripts/admin/taxonomy.js +1 -1
  3. data/app/controllers/admin/tax_rates_controller.rb +2 -2
  4. data/app/helpers/admin/base_helper.rb +1 -1
  5. data/app/helpers/spree/base_helper.rb +1 -1
  6. data/app/mailers/order_mailer.rb +5 -5
  7. data/app/mailers/shipment_mailer.rb +3 -3
  8. data/app/mailers/test_mailer.rb +1 -1
  9. data/app/models/calculator.rb +7 -9
  10. data/app/models/calculator/flat_percent_item_total.rb +0 -5
  11. data/app/models/calculator/flat_rate.rb +0 -5
  12. data/app/models/calculator/flexi_rate.rb +0 -5
  13. data/app/models/calculator/per_item.rb +0 -5
  14. data/app/models/calculator/price_bucket.rb +0 -6
  15. data/app/models/calculator/sales_tax.rb +1 -6
  16. data/app/models/calculator/vat.rb +6 -11
  17. data/app/models/creditcard.rb +12 -10
  18. data/app/models/order.rb +1 -1
  19. data/app/models/payment.rb +1 -1
  20. data/app/models/payment_method.rb +1 -7
  21. data/app/views/admin/adjustments/_adjustments_table.html.erb +3 -3
  22. data/app/views/admin/adjustments/_form.html.erb +4 -4
  23. data/app/views/admin/adjustments/edit.html.erb +7 -7
  24. data/app/views/admin/adjustments/index.html.erb +2 -2
  25. data/app/views/admin/adjustments/new.html.erb +6 -6
  26. data/app/views/admin/configurations/index.html.erb +29 -29
  27. data/app/views/admin/general_settings/edit.html.erb +5 -5
  28. data/app/views/admin/general_settings/show.html.erb +4 -5
  29. data/app/views/admin/images/_form.html.erb +2 -2
  30. data/app/views/admin/images/edit.html.erb +8 -8
  31. data/app/views/admin/images/index.html.erb +11 -11
  32. data/app/views/admin/images/new.html.erb +1 -1
  33. data/app/views/admin/inventory_settings/edit.html.erb +7 -7
  34. data/app/views/admin/inventory_settings/show.html.erb +4 -4
  35. data/app/views/admin/inventory_units/adjust.html.erb +11 -11
  36. data/app/views/admin/mail_methods/_form.html.erb +23 -26
  37. data/app/views/admin/mail_methods/edit.html.erb +4 -4
  38. data/app/views/admin/mail_methods/index.html.erb +6 -6
  39. data/app/views/admin/mail_methods/new.html.erb +4 -4
  40. data/app/views/admin/option_types/_available.html.erb +9 -9
  41. data/app/views/admin/option_types/_form.html.erb +2 -2
  42. data/app/views/admin/option_types/_option_value_fields.html.erb +3 -3
  43. data/app/views/admin/option_types/_selected.html.erb +4 -4
  44. data/app/views/admin/option_types/available.js.erb +1 -1
  45. data/app/views/admin/option_types/edit.html.erb +10 -10
  46. data/app/views/admin/option_types/index.html.erb +7 -7
  47. data/app/views/admin/option_types/new.html.erb +4 -4
  48. data/app/views/admin/option_types/selected.html.erb +1 -1
  49. data/app/views/admin/orders/_add_product.html.erb +6 -6
  50. data/app/views/admin/orders/_form.html.erb +15 -15
  51. data/app/views/admin/orders/_line_item.html.erb +4 -4
  52. data/app/views/admin/orders/_user_form.html.erb +11 -11
  53. data/app/views/admin/orders/edit.html.erb +8 -8
  54. data/app/views/admin/orders/history.html.erb +8 -8
  55. data/app/views/admin/orders/index.html.erb +28 -29
  56. data/app/views/admin/orders/new.html.erb +5 -5
  57. data/app/views/admin/orders/show.html.erb +7 -7
  58. data/app/views/admin/orders/user.html.erb +6 -6
  59. data/app/views/admin/payment_methods/_form.html.erb +15 -15
  60. data/app/views/admin/payment_methods/edit.html.erb +5 -5
  61. data/app/views/admin/payment_methods/index.html.erb +9 -10
  62. data/app/views/admin/payment_methods/new.html.erb +4 -4
  63. data/app/views/admin/payments/_bill_address_form.html.erb +1 -1
  64. data/app/views/admin/payments/_form.html.erb +5 -5
  65. data/app/views/admin/payments/_list.html.erb +5 -5
  66. data/app/views/admin/payments/_transaction_list.html.erb +6 -6
  67. data/app/views/admin/payments/credit.html.erb +5 -5
  68. data/app/views/admin/payments/index.html.erb +8 -8
  69. data/app/views/admin/payments/new.html.erb +6 -6
  70. data/app/views/admin/payments/show.html.erb +2 -2
  71. data/app/views/admin/payments/source_forms/_gateway.html.erb +8 -8
  72. data/app/views/admin/payments/source_views/_gateway.html.erb +7 -7
  73. data/app/views/admin/product_groups/_preview.html.erb +2 -2
  74. data/app/views/admin/product_groups/_product_scope.html.erb +3 -3
  75. data/app/views/admin/product_groups/edit.html.erb +9 -9
  76. data/app/views/admin/product_groups/index.html.erb +8 -8
  77. data/app/views/admin/product_groups/new.html.erb +3 -3
  78. data/app/views/admin/product_groups/show.html.erb +1 -1
  79. data/app/views/admin/product_groups/update.js.erb +3 -3
  80. data/app/views/admin/product_properties/_product_property_fields.html.erb +3 -3
  81. data/app/views/admin/product_properties/index.html.erb +15 -15
  82. data/app/views/admin/product_scopes/create.js.erb +3 -3
  83. data/app/views/admin/product_scopes/destroy.js.erb +3 -3
  84. data/app/views/admin/products/_form.html.erb +25 -25
  85. data/app/views/admin/products/_option_types.html.erb +14 -14
  86. data/app/views/admin/products/_properties_form.erb +1 -1
  87. data/app/views/admin/products/edit.html.erb +3 -3
  88. data/app/views/admin/products/index.html.erb +12 -12
  89. data/app/views/admin/products/new.html.erb +14 -14
  90. data/app/views/admin/products/show.html.erb +1 -1
  91. data/app/views/admin/properties/_form.html.erb +2 -2
  92. data/app/views/admin/properties/edit.html.erb +3 -3
  93. data/app/views/admin/properties/index.html.erb +6 -6
  94. data/app/views/admin/properties/new.html.erb +3 -3
  95. data/app/views/admin/prototypes/_form.html.erb +6 -6
  96. data/app/views/admin/prototypes/_prototypes.html.erb +3 -4
  97. data/app/views/admin/prototypes/edit.html.erb +4 -4
  98. data/app/views/admin/prototypes/index.html.erb +6 -6
  99. data/app/views/admin/prototypes/new.html.erb +3 -3
  100. data/app/views/admin/reports/index.html.erb +3 -3
  101. data/app/views/admin/reports/sales_total.html.erb +7 -7
  102. data/app/views/admin/return_authorizations/_form.html.erb +13 -14
  103. data/app/views/admin/return_authorizations/edit.html.erb +10 -10
  104. data/app/views/admin/return_authorizations/index.html.erb +9 -9
  105. data/app/views/admin/return_authorizations/new.html.erb +7 -7
  106. data/app/views/admin/shared/_additional_field.html.erb +1 -1
  107. data/app/views/admin/shared/_address_form.html.erb +24 -24
  108. data/app/views/admin/shared/_calculator_fields.html.erb +4 -4
  109. data/app/views/admin/shared/_configuration_menu.html.erb +12 -12
  110. data/app/views/admin/shared/_destroy.js.erb +1 -1
  111. data/app/views/admin/shared/_edit_resource_links.html.erb +2 -2
  112. data/app/views/admin/shared/_group_from_products_form.html.erb +6 -6
  113. data/app/views/admin/shared/_head.html.erb +5 -5
  114. data/app/views/admin/shared/_new_adjustment_button.html.erb +2 -2
  115. data/app/views/admin/shared/_new_resource_links.html.erb +2 -2
  116. data/app/views/admin/shared/_order_tabs.html.erb +25 -25
  117. data/app/views/admin/shared/_product_tabs.html.erb +14 -14
  118. data/app/views/admin/shared/_report_criteria.html.erb +4 -4
  119. data/app/views/admin/shared/_show_resource_links.html.erb +3 -3
  120. data/app/views/admin/shared/_update_order_state.js +4 -4
  121. data/app/views/admin/shipments/_form.html.erb +15 -15
  122. data/app/views/admin/shipments/edit.html.erb +11 -11
  123. data/app/views/admin/shipments/index.html.erb +11 -11
  124. data/app/views/admin/shipments/new.html.erb +6 -6
  125. data/app/views/admin/shipping_categories/_form.html.erb +2 -2
  126. data/app/views/admin/shipping_categories/edit.html.erb +4 -4
  127. data/app/views/admin/shipping_categories/index.html.erb +8 -8
  128. data/app/views/admin/shipping_categories/new.html.erb +4 -4
  129. data/app/views/admin/shipping_methods/_form.html.erb +5 -5
  130. data/app/views/admin/shipping_methods/edit.html.erb +5 -5
  131. data/app/views/admin/shipping_methods/index.html.erb +9 -10
  132. data/app/views/admin/shipping_methods/new.html.erb +4 -4
  133. data/app/views/admin/states/_form.html.erb +3 -3
  134. data/app/views/admin/states/_state_list.html.erb +6 -8
  135. data/app/views/admin/states/edit.html.erb +4 -4
  136. data/app/views/admin/states/index.html.erb +4 -4
  137. data/app/views/admin/states/new.html.erb +3 -3
  138. data/app/views/admin/states/new.js.erb +1 -1
  139. data/app/views/admin/tax_categories/_form.html.erb +6 -6
  140. data/app/views/admin/tax_categories/edit.html.erb +4 -4
  141. data/app/views/admin/tax_categories/index.html.erb +8 -9
  142. data/app/views/admin/tax_categories/new.html.erb +4 -4
  143. data/app/views/admin/tax_rates/_form.html.erb +5 -5
  144. data/app/views/admin/tax_rates/edit.html.erb +5 -5
  145. data/app/views/admin/tax_rates/index.html.erb +10 -10
  146. data/app/views/admin/tax_rates/new.html.erb +4 -4
  147. data/app/views/admin/tax_settings/edit.html.erb +10 -10
  148. data/app/views/admin/tax_settings/show.html.erb +6 -6
  149. data/app/views/admin/taxonomies/_form.html.erb +1 -1
  150. data/app/views/admin/taxonomies/_js_head.html.erb +4 -4
  151. data/app/views/admin/taxonomies/_list.html.erb +4 -4
  152. data/app/views/admin/taxonomies/_taxon.html.erb +2 -2
  153. data/app/views/admin/taxonomies/edit.erb +31 -32
  154. data/app/views/admin/taxonomies/get_children.json.erb +7 -7
  155. data/app/views/admin/taxonomies/index.html.erb +4 -4
  156. data/app/views/admin/taxonomies/new.html.erb +5 -5
  157. data/app/views/admin/taxons/_form.html.erb +3 -3
  158. data/app/views/admin/taxons/_taxon_table.html.erb +4 -4
  159. data/app/views/admin/taxons/edit.html.erb +3 -3
  160. data/app/views/admin/taxons/remove.html.erb +1 -1
  161. data/app/views/admin/taxons/select.js.erb +1 -1
  162. data/app/views/admin/taxons/selected.html.erb +5 -5
  163. data/app/views/admin/trackers/_form.html.erb +10 -10
  164. data/app/views/admin/trackers/edit.html.erb +5 -5
  165. data/app/views/admin/trackers/index.html.erb +8 -8
  166. data/app/views/admin/trackers/new.html.erb +4 -4
  167. data/app/views/admin/users/_form.html.erb +6 -6
  168. data/app/views/admin/users/edit.html.erb +4 -4
  169. data/app/views/admin/users/index.html.erb +8 -8
  170. data/app/views/admin/users/new.html.erb +4 -4
  171. data/app/views/admin/users/show.html.erb +5 -5
  172. data/app/views/admin/variants/_form.html.erb +5 -5
  173. data/app/views/admin/variants/edit.html.erb +3 -3
  174. data/app/views/admin/variants/index.html.erb +14 -18
  175. data/app/views/admin/variants/new.html.erb +3 -3
  176. data/app/views/admin/variants/new.js.erb +1 -1
  177. data/app/views/admin/zones/_country_member.html.erb +1 -1
  178. data/app/views/admin/zones/_form.html.erb +14 -14
  179. data/app/views/admin/zones/_state_member.html.erb +1 -1
  180. data/app/views/admin/zones/edit.html.erb +5 -5
  181. data/app/views/admin/zones/index.html.erb +5 -5
  182. data/app/views/admin/zones/new.html.erb +5 -5
  183. data/app/views/checkout/_address.html.erb +25 -25
  184. data/app/views/checkout/_confirm.html.erb +1 -1
  185. data/app/views/checkout/_delivery.html.erb +7 -7
  186. data/app/views/checkout/_payment.html.erb +3 -3
  187. data/app/views/checkout/_summary.html.erb +2 -2
  188. data/app/views/checkout/edit.html.erb +3 -3
  189. data/app/views/checkout/payment/_gateway.html.erb +9 -9
  190. data/app/views/checkout/registration.html.erb +6 -6
  191. data/app/views/content/cvv.html.erb +6 -6
  192. data/app/views/home/index.html.erb +2 -2
  193. data/app/views/layouts/admin.html.erb +9 -11
  194. data/app/views/layouts/spree_application.html.erb +3 -3
  195. data/app/views/order_mailer/cancel_email.text.erb +2 -2
  196. data/app/views/orders/_form.html.erb +5 -5
  197. data/app/views/orders/_line_item.html.erb +3 -3
  198. data/app/views/orders/edit.html.erb +11 -11
  199. data/app/views/orders/new.html.erb +3 -3
  200. data/app/views/orders/show.html.erb +3 -3
  201. data/app/views/products/_cart_form.html.erb +8 -8
  202. data/app/views/products/_taxons.html.erb +1 -1
  203. data/app/views/products/_thumbnails.html.erb +2 -2
  204. data/app/views/products/index.html.erb +4 -4
  205. data/app/views/products/show.html.erb +1 -1
  206. data/app/views/shared/_filters.html.erb +2 -3
  207. data/app/views/shared/_google_analytics.html.erb +6 -6
  208. data/app/views/shared/_head.html.erb +3 -3
  209. data/app/views/shared/_order_details.html.erb +12 -12
  210. data/app/views/shared/_store_menu.html.erb +1 -1
  211. data/app/views/shared/_taxonomies.html.erb +1 -1
  212. data/app/views/shipment_mailer/shipped_email.text.erb +2 -2
  213. data/app/views/taxons/_taxon.html.erb +1 -1
  214. data/app/views/taxons/show.html.erb +4 -4
  215. data/app/views/test_mailer/test_email.text.erb +2 -2
  216. data/config/locales/en.yml +4 -2
  217. data/lib/environment_extension.rb +26 -0
  218. data/lib/generators/spree/site/site_generator.rb +8 -0
  219. data/lib/product_filters.rb +8 -0
  220. data/lib/spree/calculated_adjustments.rb +8 -8
  221. data/lib/spree/environment.rb +12 -0
  222. data/lib/spree/environment/calculators.rb +10 -0
  223. data/lib/spree_core.rb +1 -1
  224. data/lib/spree_core/railtie.rb +36 -46
  225. data/lib/spree_core/ssl_requirement.rb +1 -1
  226. data/lib/spree_core/version.rb +1 -1
  227. metadata +13 -18
  228. data/config/initializers/sprockets_precompile_patch.rb +0 -16
  229. data/lib/subclass_registration.rb +0 -21
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2010, Rails Dog LLC and other contributors
1
+ Copyright (c) 2007-2011, Rails Dog LLC and other contributors
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
@@ -1,6 +1,6 @@
1
1
  var handle_ajax_error = function(XMLHttpRequest, textStatus, errorThrown){
2
2
  $.jstree.rollback(last_rollback);
3
- $("#ajax_error").show().html("<strong>" + server_error + "</strong><br/>" + taxonomy_tree_error);
3
+ $("#ajax_error").show().html("<strong>" + server_error + "</strong><br />" + taxonomy_tree_error);
4
4
  };
5
5
 
6
6
  //var handle_move = function(li, target, droppped, tree, rb) {
@@ -5,11 +5,11 @@ class Admin::TaxRatesController < Admin::ResourceController
5
5
  create.after :create_after
6
6
 
7
7
  private
8
-
8
+
9
9
  def load_data
10
10
  @available_zones = Zone.order(:name)
11
11
  @available_categories = TaxCategory.order(:name)
12
- @calculators = TaxRate.calculators
12
+ @calculators = TaxRate.calculators.sort_by(&:name)
13
13
  end
14
14
 
15
15
  def update_after
@@ -13,7 +13,7 @@ module Admin::BaseHelper
13
13
  obj = object.respond_to?(:errors) ? object : instance_variable_get("@#{object}")
14
14
 
15
15
  if obj && obj.errors[method].present?
16
- errors = obj.errors[method].map{|err| h(err)}.join('<br/>').html_safe
16
+ errors = obj.errors[method].map{|err| h(err)}.join('<br />').html_safe
17
17
  content_tag(:span, errors, :class => 'formError')
18
18
  else
19
19
  ''
@@ -146,7 +146,7 @@ module Spree::BaseHelper
146
146
  def format_price(price, options={})
147
147
  options.assert_valid_keys(:show_vat_text)
148
148
  options.reverse_merge! :show_vat_text => Spree::Config[:show_price_inc_vat]
149
- formatted_price = number_to_currency(price)
149
+ formatted_price = number_to_currency price
150
150
  if options[:show_vat_text]
151
151
  I18n.t(:price_with_vat_included, :price => formatted_price)
152
152
  else
@@ -1,18 +1,18 @@
1
1
  class OrderMailer < ActionMailer::Base
2
- helper "spree/base"
2
+ helper 'spree/base'
3
3
 
4
4
  def confirm_email(order, resend=false)
5
5
  @order = order
6
- subject = (resend ? "[RESEND] " : "")
7
- subject += "#{Spree::Config[:site_name]} #{t('subject', :scope =>'order_mailer.confirm_email')} ##{order.number}"
6
+ subject = (resend ? "[#{t(:resend).upcase}] " : "")
7
+ subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{order.number}"
8
8
  mail(:to => order.email,
9
9
  :subject => subject)
10
10
  end
11
11
 
12
12
  def cancel_email(order, resend=false)
13
13
  @order = order
14
- subject = (resend ? "[RESEND] " : "")
15
- subject += "#{Spree::Config[:site_name]} #{t('subject', :scope => 'order_mailer.cancel_email')} ##{order.number}"
14
+ subject = (resend ? "[#{t(:resend).upcase}] " : "")
15
+ subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
16
16
  mail(:to => order.email,
17
17
  :subject => subject)
18
18
  end
@@ -1,10 +1,10 @@
1
1
  class ShipmentMailer < ActionMailer::Base
2
- helper "spree/base"
2
+ helper 'spree/base'
3
3
 
4
4
  def shipped_email(shipment, resend=false)
5
5
  @shipment = shipment
6
- subject = (resend ? "[RESEND] " : "")
7
- subject += "#{Spree::Config[:site_name]} #{t('subject', :scope => 'shipment_mailer.shipped_email')} ##{shipment.order.number}"
6
+ subject = (resend ? "[#{t(:resend).upcase}] " : "")
7
+ subject += "#{Spree::Config[:site_name]} #{t('shipment_mailer.shipped_email.subject')} ##{shipment.order.number}"
8
8
  mail(:to => shipment.order.email,
9
9
  :subject => subject)
10
10
  end
@@ -2,7 +2,7 @@ class TestMailer < ActionMailer::Base
2
2
 
3
3
  def test_email(mail_method, user)
4
4
  @mail_method = mail_method
5
- subject = "#{Spree::Config[:site_name]} #{t('subject', :scope => 'test_mailer.test_email')}"
5
+ subject = "#{Spree::Config[:site_name]} #{t('test_mailer.test_email.subject')}"
6
6
  mail(:to => user.email,
7
7
  :subject => subject)
8
8
  end
@@ -15,21 +15,19 @@ class Calculator < ActiveRecord::Base
15
15
 
16
16
  ###################################################################
17
17
 
18
- @@calculators = Set.new
19
- # Registers calculator to be used with selected kinds of operations
20
18
  def self.register(*klasses)
21
- @@calculators.add(self)
22
- klasses.each do |klass|
23
- klass = klass.constantize if klass.is_a?(String)
24
- klass.register_calculator(self)
25
- end
26
- self
19
+ # @@calculators.add(self)
20
+ # klasses.each do |klass|
21
+ # klass = klass.constantize if klass.is_a?(String)
22
+ # klass.register_calculator(self)
23
+ # end
24
+ # self
27
25
  end
28
26
 
29
27
  # Returns all calculators applicable for kind of work
30
28
  # If passed nil, will return only general calculators
31
29
  def self.calculators
32
- @@calculators.to_a
30
+ Rails.application.config.spree.calculators.all
33
31
  end
34
32
 
35
33
  def to_s
@@ -5,11 +5,6 @@ class Calculator::FlatPercentItemTotal < Calculator
5
5
  I18n.t("flat_percent")
6
6
  end
7
7
 
8
- def self.register
9
- super
10
- ShippingMethod.register_calculator(self)
11
- end
12
-
13
8
  def compute(object)
14
9
  return unless object.present? and object.line_items.present?
15
10
  item_total = object.line_items.map(&:amount).sum
@@ -5,11 +5,6 @@ class Calculator::FlatRate < Calculator
5
5
  I18n.t("flat_rate_per_order")
6
6
  end
7
7
 
8
- def self.register
9
- super
10
- ShippingMethod.register_calculator(self)
11
- end
12
-
13
8
  def compute(object=nil)
14
9
  self.preferred_amount
15
10
  end
@@ -11,11 +11,6 @@ class Calculator::FlexiRate < Calculator
11
11
  true
12
12
  end
13
13
 
14
- def self.register
15
- super
16
- ShippingMethod.register_calculator(self)
17
- end
18
-
19
14
  def compute(object)
20
15
  sum = 0
21
16
  max = self.preferred_max_items
@@ -5,11 +5,6 @@ class Calculator::PerItem < Calculator
5
5
  I18n.t("flat_rate_per_item")
6
6
  end
7
7
 
8
- def self.register
9
- super
10
- ShippingMethod.register_calculator(self)
11
- end
12
-
13
8
  def compute(object=nil)
14
9
  self.preferred_amount * object.line_items.length
15
10
  end
@@ -7,12 +7,6 @@ class Calculator::PriceBucket < Calculator
7
7
  I18n.t("price_bucket")
8
8
  end
9
9
 
10
- def self.register
11
- super
12
- #Promotion.register_calculator(self)
13
- ShippingMethod.register_calculator(self)
14
- end
15
-
16
10
  # as object we always get line items, as calculable we have Coupon, ShippingMethod
17
11
  def compute(object)
18
12
  if object.is_a?(Array)
@@ -4,11 +4,6 @@ class Calculator::SalesTax < Calculator
4
4
  I18n.t("sales_tax")
5
5
  end
6
6
 
7
- def self.register
8
- super
9
- TaxRate.register_calculator(self)
10
- end
11
-
12
7
  def self.calculate_tax(order, rates)
13
8
  ActiveSupport::Deprecation.warn("please use Calculator::SalesTax#compute instead", caller)
14
9
 
@@ -45,4 +40,4 @@ class Calculator::SalesTax < Calculator
45
40
  sum += line_item.total * rate.amount
46
41
  }
47
42
  end
48
- end
43
+ end
@@ -4,18 +4,13 @@ class Calculator::Vat < Calculator
4
4
  I18n.t("vat")
5
5
  end
6
6
 
7
- def self.register
8
- super
9
- TaxRate.register_calculator(self)
7
+ def self.calculate_tax_on(taxable)
8
+ # taxable may be product or variant
9
+ taxable = taxable.product if taxable.respond_to?(:product)
10
+ (taxable.price * taxable.effective_tax_rate).round(2, BigDecimal::ROUND_HALF_UP)
10
11
  end
11
12
 
12
- def self.calculate_tax_on(product_or_variant)
13
- product = product_or_variant.try(:product) || product_or_variant
14
-
15
- (product_or_variant.price * product.effective_tax_rate).round(2, BigDecimal::ROUND_HALF_UP)
16
- end
17
-
18
- # computes vat for line_items associated with order, and tax rate and
13
+ # computes vat for line_items associated with order, and tax rate and
19
14
  # now coupon discounts are taken into account in tax calcs
20
15
  # and tax is added to shipment if :shipment_inc_vat is set
21
16
  # coupons and shipment are applied if this object is the rate for the default category
@@ -24,7 +19,7 @@ class Calculator::Vat < Calculator
24
19
  rate = self.calculable
25
20
  tax = 0
26
21
 
27
- if rate.tax_category.is_default
22
+ if rate.tax_category.is_default
28
23
  order.adjustments.each do | adjust |
29
24
  next if adjust.originator_type == "TaxRate"
30
25
  next if adjust.originator_type == "ShippingMethod" and not Spree::Config[:shipment_inc_vat]
@@ -89,8 +89,8 @@ class Creditcard < ActiveRecord::Base
89
89
  payment.failure
90
90
  gateway_error(response)
91
91
  end
92
- rescue ActiveMerchant::ConnectionError
93
- gateway_error I18n.t(:unable_to_connect_to_gateway)
92
+ rescue ActiveMerchant::ConnectionError => e
93
+ gateway_error e
94
94
  end
95
95
 
96
96
  def purchase(amount, payment)
@@ -109,8 +109,8 @@ class Creditcard < ActiveRecord::Base
109
109
  payment.failure
110
110
  gateway_error(response) unless response.success?
111
111
  end
112
- rescue ActiveMerchant::ConnectionError
113
- gateway_error I18n.t(:unable_to_connect_to_gateway)
112
+ rescue ActiveMerchant::ConnectionError => e
113
+ gateway_error e
114
114
  end
115
115
 
116
116
  def capture(payment)
@@ -136,8 +136,8 @@ class Creditcard < ActiveRecord::Base
136
136
  payment.failure
137
137
  gateway_error(response)
138
138
  end
139
- rescue ActiveMerchant::ConnectionError
140
- gateway_error I18n.t(:unable_to_connect_to_gateway)
139
+ rescue ActiveMerchant::ConnectionError => e
140
+ gateway_error e
141
141
  end
142
142
 
143
143
  def void(payment)
@@ -153,8 +153,8 @@ class Creditcard < ActiveRecord::Base
153
153
  else
154
154
  gateway_error(response)
155
155
  end
156
- rescue ActiveMerchant::ConnectionError
157
- gateway_error I18n.t(:unable_to_connect_to_gateway)
156
+ rescue ActiveMerchant::ConnectionError => e
157
+ gateway_error e
158
158
  end
159
159
 
160
160
  def credit(payment)
@@ -180,8 +180,8 @@ class Creditcard < ActiveRecord::Base
180
180
  else
181
181
  gateway_error(response)
182
182
  end
183
- rescue ActiveMerchant::ConnectionError
184
- gateway_error I18n.t(:unable_to_connect_to_gateway)
183
+ rescue ActiveMerchant::ConnectionError => e
184
+ gateway_error e
185
185
  end
186
186
 
187
187
  def actions
@@ -217,6 +217,8 @@ class Creditcard < ActiveRecord::Base
217
217
  def gateway_error(error)
218
218
  if error.is_a? ActiveMerchant::Billing::Response
219
219
  text = error.params['message'] || error.params['response_reason_text'] || error.message
220
+ elsif error.is_a? ActiveMerchant::ConnectionError
221
+ text = I18n.t(:unable_to_connect_to_gateway)
220
222
  else
221
223
  text = error.to_s
222
224
  end
data/app/models/order.rb CHANGED
@@ -272,7 +272,7 @@ class Order < ActiveRecord::Base
272
272
  rate.zone.country_list.collect{|c| c.id}.include?(Spree::Config[:default_country_id]) }
273
273
  end
274
274
  matching_rates.each do |rate|
275
- rate.create_adjustment( "#{I18n.t(:vat)} #{rate.amount*100}%" , self, self, true)
275
+ rate.create_adjustment( "#{rate.calculator.description} #{rate.amount*100}%" , self, self, true)
276
276
  end
277
277
  end
278
278
 
@@ -102,7 +102,7 @@ class Payment < ActiveRecord::Base
102
102
  return unless source.is_a?(Creditcard) && source.number && !source.has_payment_profile?
103
103
  payment_method.create_profile(self)
104
104
  rescue ActiveMerchant::ConnectionError => e
105
- gateway_error I18n.t(:unable_to_connect_to_gateway)
105
+ gateway_error e
106
106
  end
107
107
 
108
108
  def update_order
@@ -2,14 +2,8 @@ class PaymentMethod < ActiveRecord::Base
2
2
  DISPLAY = [:both, :front_end, :back_end]
3
3
  default_scope where(:deleted_at => nil)
4
4
 
5
- @provider = nil
6
- @@providers = Set.new
7
- def self.register
8
- @@providers.add(self)
9
- end
10
-
11
5
  def self.providers
12
- @@providers.to_a
6
+ Rails.application.config.spree.payment_methods
13
7
  end
14
8
 
15
9
  def provider_class
@@ -1,8 +1,8 @@
1
1
  <table class="index" data-hook="adjustments">
2
2
  <tr data-hook="adjustmment_head">
3
3
  <th><%= "#{t('spree.date')}/#{t('spree.time')}" %></th>
4
- <th><%= t("description") %></th>
5
- <th><%= t("amount") %></th>
4
+ <th><%= t(:description) %></th>
5
+ <th><%= t(:amount) %></th>
6
6
  <th></th>
7
7
  </tr>
8
8
  <% @order.adjustments.each do |adjustment|
@@ -12,7 +12,7 @@
12
12
  <tr id="<%= dom_id(adjustment) %>" data-hook="adjustment_row">
13
13
  <td><%= adjustment.created_at.to_s(:date_time24) %></td>
14
14
  <td><%= adjustment.label %></td>
15
- <td><%= number_to_currency(adjustment.amount) %></td>
15
+ <td><%= number_to_currency adjustment.amount %></td>
16
16
  <td class='actions'>
17
17
  <%= link_to_edit adjustment, :class => 'edit' %>
18
18
  &nbsp;
@@ -1,12 +1,12 @@
1
1
  <%= f.field_container :amount do %>
2
- <%= f.label :amount, t("amount")%> <span class="required">*</span><br />
3
- <%= text_field :adjustment, :amount, {:style => "width:80px;"} %>
2
+ <%= f.label :amount, t(:amount) %> <span class="required">*</span><br />
3
+ <%= text_field :adjustment, :amount, {:style => 'width:80px;'} %>
4
4
  <%= f.error_message_on :amount %>
5
5
  <% end %>
6
6
 
7
7
  <%= f.field_container :label do %>
8
- <%= f.label :label, t("description")%> <span class="required">*</span><br />
9
- <%= text_field :adjustment, :label, {:style => "width:180px;"} %>
8
+ <%= f.label :label, t(:description) %> <span class="required">*</span><br />
9
+ <%= text_field :adjustment, :label, {:style => 'width:180px;'} %>
10
10
  <%= f.error_message_on :label %>
11
11
  <% end %>
12
12
 
@@ -1,13 +1,13 @@
1
- <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => "Adjustments"} %>
1
+ <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => 'Adjustments'} %>
2
2
 
3
- <h2><%= t("adjustment")%></h2>
3
+ <h2><%= t(:adjustment) %></h2>
4
4
 
5
- <%= render "shared/error_messages", :target => @adjustment %>
6
- <%= form_for(@adjustment, :url => admin_order_adjustment_path(@order, @adjustment), :html => { :method => :put}) do |f| %>
7
- <%= render :partial => "form", :locals => {:f => f} %>
5
+ <%= render 'shared/error_messages', :target => @adjustment %>
6
+ <%= form_for @adjustment, :url => admin_order_adjustment_path(@order, @adjustment), :html => { :method => :put} do |f| %>
7
+ <%= render :partial => 'form', :locals => {:f => f} %>
8
8
 
9
9
  <p class="form-buttons" data-hook="buttons">
10
- <%= button t('continue') %>
11
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_order_adjustments_url(@order) %>
10
+ <%= button t(:continue) %>
11
+ <%= t(:or) %> <%= link_to t('actions.cancel'), admin_order_adjustments_url(@order) %>
12
12
  </p>
13
13
  <% end %>
@@ -1,4 +1,4 @@
1
1
  <%= render 'admin/shared/new_adjustment_button' %>
2
- <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => "Adjustments"} %>
2
+ <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => 'Adjustments'} %>
3
3
  <%= render 'adjustments_table' %>
4
- <%= button_link_to t('continue'), @order.cart? ? new_admin_order_payment_url(@order) : admin_orders_url %>
4
+ <%= button_link_to t(:continue), @order.cart? ? new_admin_order_payment_url(@order) : admin_orders_url %>
@@ -1,14 +1,14 @@
1
- <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => "Adjustments"} %>
1
+ <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => 'Adjustments'} %>
2
2
 
3
- <h2><%= t("new_adjustment")%></h2>
3
+ <h2><%= t(:new_adjustment) %></h2>
4
4
 
5
- <%= render "shared/error_messages", :target => @adjustment %>
5
+ <%= render 'shared/error_messages', :target => @adjustment %>
6
6
 
7
7
  <%= form_for @adjustment, :url => admin_order_adjustments_path do |f| %>
8
- <%= render :partial => "form", :locals => {:f => f} %>
8
+ <%= render :partial => 'form', :locals => {:f => f} %>
9
9
 
10
10
  <p class="form-buttons" data-hook="buttons">
11
- <%= button t('continue') %>
12
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_order_adjustments_url(@order) %>
11
+ <%= button t(:continue) %>
12
+ <%= t(:or) %> <%= link_to t('actions.cancel'), admin_order_adjustments_url(@order) %>
13
13
  </p>
14
14
  <% end %>
@@ -1,64 +1,64 @@
1
- <h1><%= t("configurations") %></h1>
1
+ <h1><%= t(:configurations) %></h1>
2
2
 
3
3
  <table class="index" data-hook="configuration">
4
4
  <thead>
5
5
  <tr>
6
- <th><%= t("system") %></th>
7
- <th><%= t("description") %></th>
6
+ <th><%= t(:system) %></th>
7
+ <th><%= t(:description) %></th>
8
8
  </tr>
9
9
  </thead>
10
10
  <tbody data-hook="admin_configurations_menu">
11
11
  <tr>
12
- <td><%= link_to t("general_settings"), admin_general_settings_path %></td>
13
- <td><%= t("general_settings_description") %></td>
12
+ <td><%= link_to t(:general_settings), admin_general_settings_path %></td>
13
+ <td><%= t(:general_settings_description) %></td>
14
14
  </tr>
15
15
  <tr>
16
- <td><%= link_to t("mail_methods"), admin_mail_methods_path %></td>
17
- <td><%= t("email_server_settings_description") %></td>
16
+ <td><%= link_to t(:mail_methods), admin_mail_methods_path %></td>
17
+ <td><%= t(:email_server_settings_description) %></td>
18
18
  </tr>
19
19
  <tr>
20
- <td><%= link_to t("tax_categories"), admin_tax_categories_path %></td>
21
- <td><%= t("tax_categories_setting_description") %></td>
20
+ <td><%= link_to t(:tax_categories), admin_tax_categories_path %></td>
21
+ <td><%= t(:tax_categories_setting_description) %></td>
22
22
  </tr>
23
23
  <tr>
24
- <td><%= link_to t("zones"), admin_zones_path %></td>
25
- <td><%= t("zone_setting_description") %></td>
24
+ <td><%= link_to t(:zones), admin_zones_path %></td>
25
+ <td><%= t(:zone_setting_description) %></td>
26
26
  </tr>
27
27
  <tr>
28
- <td><%= link_to t("states"), admin_country_states_path(Spree::Config[:default_country_id]) %></td>
29
- <td><%= t("state_setting_description") %></td>
28
+ <td><%= link_to t(:states), admin_country_states_path(Spree::Config[:default_country_id]) %></td>
29
+ <td><%= t(:state_setting_description) %></td>
30
30
  </tr>
31
31
  <tr>
32
- <td><%= link_to t("payment_methods"), admin_payment_methods_path %></td>
33
- <td><%= t("payment_methods_setting_description") %></td>
32
+ <td><%= link_to t(:payment_methods), admin_payment_methods_path %></td>
33
+ <td><%= t(:payment_methods_setting_description) %></td>
34
34
  </tr>
35
35
  <tr>
36
- <td><%= link_to t("taxonomies"), admin_taxonomies_path %></td>
37
- <td><%= t("taxonomies_setting_description") %></td>
36
+ <td><%= link_to t(:taxonomies), admin_taxonomies_path %></td>
37
+ <td><%= t(:taxonomies_setting_description) %></td>
38
38
  </tr>
39
39
  <tr>
40
- <td><%= link_to t("shipping_methods"), admin_shipping_methods_path %></td>
41
- <td><%= t("shipping_methods_description") %></td>
40
+ <td><%= link_to t(:shipping_methods), admin_shipping_methods_path %></td>
41
+ <td><%= t(:shipping_methods_description) %></td>
42
42
  </tr>
43
43
  <tr>
44
- <td><%= link_to t("shipping_categories"), admin_shipping_categories_path %></td>
45
- <td><%= t("shipping_categories_description") %></td>
44
+ <td><%= link_to t(:shipping_categories), admin_shipping_categories_path %></td>
45
+ <td><%= t(:shipping_categories_description) %></td>
46
46
  </tr>
47
47
  <tr>
48
- <td><%= link_to t("inventory_settings"), admin_inventory_settings_path %></td>
49
- <td><%= t("inventory_setting_description") %></td>
48
+ <td><%= link_to t(:inventory_settings), admin_inventory_settings_path %></td>
49
+ <td><%= t(:inventory_setting_description) %></td>
50
50
  </tr>
51
51
  <tr>
52
- <td><%= link_to t("tax_rates"), admin_tax_rates_path %></td>
53
- <td><%= t("tax_rates_description") %></td>
52
+ <td><%= link_to t(:tax_rates), admin_tax_rates_path %></td>
53
+ <td><%= t(:tax_rates_description) %></td>
54
54
  </tr>
55
55
  <tr>
56
- <td><%= link_to t("tax_settings"), admin_tax_settings_path %></td>
57
- <td><%= t("tax_settings_description") %></td>
56
+ <td><%= link_to t(:tax_settings), admin_tax_settings_path %></td>
57
+ <td><%= t(:tax_settings_description) %></td>
58
58
  </tr>
59
59
  <tr>
60
- <td><%= link_to t("analytics_trackers"), admin_trackers_path %></td>
61
- <td><%= t("google_analytics_setting_description") %></td>
60
+ <td><%= link_to t(:analytics_trackers), admin_trackers_path %></td>
61
+ <td><%= t(:google_analytics_setting_description) %></td>
62
62
  </tr>
63
63
  </tbody>
64
64
  </table>