spree_core 2.1.12 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +4 -7
  3. data/app/helpers/spree/products_helper.rb +11 -9
  4. data/app/helpers/spree/store_helper.rb +5 -0
  5. data/app/models/spree/ability.rb +4 -0
  6. data/app/models/spree/address.rb +6 -6
  7. data/app/models/spree/adjustment.rb +40 -61
  8. data/app/models/spree/app_configuration.rb +1 -14
  9. data/app/models/spree/calculator.rb +12 -4
  10. data/app/models/spree/calculator/default_tax.rb +42 -38
  11. data/app/models/spree/calculator/flat_percent_item_total.rb +2 -4
  12. data/app/models/spree/calculator/free_shipping.rb +5 -2
  13. data/app/models/spree/calculator/percent_on_line_item.rb +15 -0
  14. data/app/models/spree/calculator/percent_per_item.rb +3 -0
  15. data/app/models/spree/classification.rb +3 -2
  16. data/app/models/spree/credit_card.rb +7 -25
  17. data/app/models/spree/gateway/bogus.rb +5 -5
  18. data/app/models/spree/gateway/bogus_simple.rb +0 -8
  19. data/app/models/spree/image.rb +0 -9
  20. data/app/models/spree/inventory_unit.rb +10 -4
  21. data/app/models/spree/item_adjustments.rb +65 -0
  22. data/app/models/spree/legacy_user.rb +1 -0
  23. data/app/models/spree/line_item.rb +33 -13
  24. data/app/models/spree/option_type.rb +2 -2
  25. data/app/models/spree/option_value.rb +1 -1
  26. data/app/models/spree/order.rb +109 -89
  27. data/app/models/spree/order/checkout.rb +48 -0
  28. data/app/models/spree/order_contents.rb +72 -37
  29. data/app/models/spree/order_inventory.rb +65 -68
  30. data/app/models/spree/order_populator.rb +3 -17
  31. data/app/models/spree/order_updater.rb +63 -44
  32. data/app/models/spree/payment.rb +20 -5
  33. data/app/models/spree/payment/processing.rb +19 -25
  34. data/app/models/spree/payment_capture_event.rb +9 -0
  35. data/app/models/spree/payment_method/check.rb +0 -2
  36. data/app/models/spree/price.rb +1 -1
  37. data/app/models/spree/product.rb +14 -16
  38. data/app/models/spree/product/scopes.rb +4 -6
  39. data/app/models/spree/product_option_type.rb +2 -2
  40. data/app/models/spree/product_property.rb +2 -2
  41. data/app/models/spree/promotion.rb +71 -50
  42. data/app/models/spree/promotion/actions/create_adjustment.rb +31 -32
  43. data/app/models/spree/promotion/actions/create_item_adjustments.rb +83 -0
  44. data/app/models/spree/promotion/actions/free_shipping.rb +36 -0
  45. data/app/models/spree/promotion/rules/first_order.rb +4 -0
  46. data/app/models/spree/promotion/rules/item_total.rb +5 -1
  47. data/app/models/spree/promotion/rules/product.rb +4 -0
  48. data/app/models/spree/promotion/rules/user.rb +5 -6
  49. data/app/models/spree/promotion/rules/user_logged_in.rb +4 -0
  50. data/app/models/spree/promotion_action.rb +1 -5
  51. data/app/models/spree/promotion_handler/cart.rb +38 -0
  52. data/app/models/spree/promotion_handler/coupon.rb +76 -0
  53. data/app/models/spree/promotion_handler/free_shipping.rb +31 -0
  54. data/app/models/spree/promotion_handler/page.rb +24 -0
  55. data/app/models/spree/promotion_rule.rb +15 -7
  56. data/app/models/spree/property.rb +1 -1
  57. data/app/models/spree/return_authorization.rb +7 -1
  58. data/app/models/spree/shipment.rb +113 -49
  59. data/app/models/spree/shipping_calculator.rb +4 -5
  60. data/app/models/spree/shipping_category.rb +2 -2
  61. data/app/models/spree/shipping_method.rb +12 -6
  62. data/app/models/spree/shipping_rate.rb +27 -7
  63. data/app/models/spree/stock/availability_validator.rb +1 -1
  64. data/app/models/spree/stock/estimator.rb +13 -1
  65. data/app/models/spree/stock/package.rb +11 -7
  66. data/app/models/spree/stock/packer.rb +3 -3
  67. data/app/models/spree/stock/quantifier.rb +9 -1
  68. data/app/models/spree/stock_item.rb +11 -6
  69. data/app/models/spree/stock_movement.rb +1 -2
  70. data/app/models/spree/tax_category.rb +6 -1
  71. data/app/models/spree/tax_rate.rb +57 -49
  72. data/app/models/spree/taxon.rb +10 -5
  73. data/app/models/spree/taxonomy.rb +5 -2
  74. data/app/models/spree/variant.rb +33 -16
  75. data/app/models/spree/zone.rb +24 -24
  76. data/app/views/spree/shared/_routes.html.erb +3 -0
  77. data/config/locales/en.yml +42 -26
  78. data/db/migrate/20130213191427_create_default_stock.rb +3 -3
  79. data/db/migrate/20130413230529_add_name_to_spree_credit_cards.rb +5 -0
  80. data/db/migrate/20130414000512_update_name_fields_on_spree_credit_cards.rb +13 -0
  81. data/db/migrate/20130417120035_update_adjustment_states.rb +2 -2
  82. data/db/migrate/20130417123427_add_shipping_rates_to_shipments.rb +1 -1
  83. data/db/migrate/20130509115210_add_number_to_stock_transfer.rb +1 -1
  84. data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
  85. data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +7 -5
  86. data/db/migrate/20130807024301_upgrade_adjustments.rb +39 -0
  87. data/db/migrate/20130807024302_rename_adjustment_fields.rb +17 -0
  88. data/db/migrate/20130813004002_add_shipment_total_to_spree_orders.rb +5 -0
  89. data/db/migrate/20130813232134_rename_activators_to_promotions.rb +5 -0
  90. data/db/migrate/20130815000406_add_adjustment_total_to_line_items.rb +5 -0
  91. data/db/migrate/20130815024413_add_adjustment_total_to_shipments.rb +5 -0
  92. data/db/migrate/20130828234942_add_tax_total_to_line_items_shipments_and_orders.rb +8 -0
  93. data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +1 -1
  94. data/db/migrate/20130903183026_add_code_to_spree_promotion_rules.rb +5 -0
  95. data/db/migrate/20130917024658_remove_promotions_event_name_field.rb +5 -0
  96. data/db/migrate/20130924040529_add_promo_total_to_line_items_and_shipments_and_orders.rb +7 -0
  97. data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +7 -3
  98. data/db/migrate/20131107132123_add_tax_category_to_variants.rb +6 -0
  99. data/db/migrate/20131118043959_add_included_to_adjustments.rb +5 -0
  100. data/db/migrate/20131118050234_rename_tax_total_fields.rb +11 -0
  101. data/db/migrate/20131118183431_add_line_item_id_to_spree_inventory_units.rb +21 -0
  102. data/db/migrate/20131127001002_add_position_to_classifications.rb +5 -0
  103. data/db/migrate/20131211112807_create_spree_orders_promotions.rb +8 -0
  104. data/db/migrate/20131218054603_add_item_count_to_spree_orders.rb +5 -0
  105. data/db/migrate/20140106224208_rename_permalink_to_slug_for_products.rb +5 -0
  106. data/db/migrate/20140124023232_rename_activator_id_in_rules_and_actions_to_promotion_id.rb +6 -0
  107. data/db/migrate/20140203161722_add_approver_id_and_approved_at_to_orders.rb +6 -0
  108. data/db/migrate/20140204115338_add_confirmation_delivered_to_spree_orders.rb +5 -0
  109. data/db/migrate/20140205120320_create_spree_payment_capture_events.rb +12 -0
  110. data/db/migrate/20140205144710_add_uncaptured_amount_to_payments.rb +5 -0
  111. data/db/migrate/20140207085910_add_tax_category_id_to_shipping_methods.rb +5 -0
  112. data/db/migrate/20140207093021_add_tax_rate_id_to_shipping_rates.rb +5 -0
  113. data/db/migrate/20140211040159_add_pre_tax_amount_to_line_items_and_shipments.rb +6 -0
  114. data/db/migrate/20140213184916_add_more_indexes.rb +13 -0
  115. data/db/migrate/20140219060952_add_considered_risky_to_orders.rb +5 -0
  116. data/lib/generators/spree/dummy/dummy_generator.rb +1 -6
  117. data/lib/generators/spree/install/install_generator.rb +6 -6
  118. data/lib/generators/spree/install/templates/{app/assets/javascripts/admin → vendor/assets/javascripts/spree/backend}/all.js +3 -3
  119. data/lib/generators/spree/install/templates/{app/assets/javascripts/store → vendor/assets/javascripts/spree/frontend}/all.js +3 -3
  120. data/lib/generators/spree/install/templates/{app/assets/stylesheets/store → vendor/assets/stylesheets/spree/backend}/all.css +3 -3
  121. data/lib/generators/spree/install/templates/{app/assets/stylesheets/admin → vendor/assets/stylesheets/spree/frontend}/all.css +3 -3
  122. data/lib/spree/core.rb +21 -8
  123. data/lib/spree/core/calculated_adjustments.rb +0 -40
  124. data/lib/spree/core/controller_helpers.rb +5 -0
  125. data/lib/spree/core/controller_helpers/auth.rb +2 -2
  126. data/lib/spree/core/controller_helpers/common.rb +0 -5
  127. data/lib/spree/core/controller_helpers/order.rb +8 -9
  128. data/lib/spree/core/engine.rb +10 -17
  129. data/lib/spree/core/permalinks.rb +1 -1
  130. data/lib/spree/core/product_duplicator.rb +3 -8
  131. data/lib/spree/core/user_address.rb +1 -1
  132. data/lib/spree/core/validators/email.rb +23 -1
  133. data/lib/spree/core/version.rb +1 -1
  134. data/lib/spree/money.rb +1 -1
  135. data/lib/spree/permitted_attributes.rb +2 -2
  136. data/lib/spree/testing_support/caching.rb +47 -0
  137. data/lib/spree/testing_support/factories/adjustment_factory.rb +11 -2
  138. data/lib/spree/testing_support/factories/credit_card_factory.rb +2 -1
  139. data/lib/spree/testing_support/factories/order_factory.rb +10 -5
  140. data/lib/spree/testing_support/factories/payment_factory.rb +2 -2
  141. data/lib/spree/testing_support/factories/payment_method_factory.rb +3 -3
  142. data/lib/spree/testing_support/factories/promotion_factory.rb +16 -1
  143. data/lib/spree/testing_support/factories/shipment_factory.rb +8 -4
  144. data/lib/spree/testing_support/factories/shipping_method_factory.rb +1 -3
  145. data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
  146. data/lib/spree/testing_support/factories/tax_rate_factory.rb +2 -2
  147. data/lib/spree/testing_support/order_walkthrough.rb +1 -1
  148. data/lib/tasks/core.rake +2 -2
  149. data/vendor/assets/fonts/FontAwesome.otf +0 -0
  150. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  151. data/vendor/assets/fonts/fontawesome-webfont.svg +399 -0
  152. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  153. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  154. data/vendor/assets/stylesheets/font-awesome.scss +1475 -0
  155. metadata +73 -44
  156. data/app/assets/javascripts/admin/handlebar_extensions.js +0 -9
  157. data/app/helpers/spree/admin/adjustments_helper.rb +0 -26
  158. data/app/helpers/spree/admin/images_helper.rb +0 -18
  159. data/app/helpers/spree/promotion_rules_helper.rb +0 -13
  160. data/app/models/spree/activator.rb +0 -29
  161. data/app/models/spree/calculator/per_item.rb +0 -41
  162. data/app/models/spree/stock/remaining_packer.rb +0 -22
  163. data/app/views/spree/payments/_payment.html.erb +0 -18
  164. data/db/migrate/20131118041203_add_tax_total_to_spree_orders.rb +0 -5
  165. data/db/migrate/20131118043021_add_order_id_to_spree_adjustments.rb +0 -6
  166. data/db/migrate/20131118074808_add_included_to_spree_adjustments.rb +0 -5
  167. data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +0 -5
  168. data/lib/spree/core/gateway_error.rb +0 -5
  169. data/lib/spree/core/preference_rescue.rb +0 -25
  170. data/lib/spree/core/s3_support.rb +0 -25
  171. data/lib/spree/promo/coupon_applicator.rb +0 -71
  172. data/lib/spree/testing_support/factories/activator_factory.rb +0 -8
@@ -1,22 +0,0 @@
1
- module Spree
2
- module Stock
3
- class RemainingPacker < Packer
4
- attr_reader :order_counter
5
-
6
- def initialize(stock_location, order, order_counter=nil)
7
- super
8
- @order_counter = order_counter || Stock::OrderCounter.new(order)
9
- end
10
-
11
- def default_package
12
- package = Package.new(stock_location, order)
13
- order_counter.variants_with_remaining.each do |variant|
14
- on_hand, backordered = stock_status(variant, order_counter.remaining(variant))
15
- package.add variant, on_hand, :on_hand if on_hand > 0
16
- package.add variant, backordered, :backordered if backordered > 0
17
- end
18
- package
19
- end
20
- end
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- <% source = payment.source %>
2
- <% if source.is_a?(Spree::CreditCard) %>
3
- <span class="cc-type">
4
- <% unless (cc_type = source.cc_type).blank? %>
5
- <%= image_tag "credit_cards/icons/#{cc_type}.png" %>
6
- <% end %>
7
- <% if source.last_digits %>
8
- <%= Spree.t(:ending_in) %> <%= source.last_digits %>
9
- <% end %>
10
- </span>
11
- <br />
12
- <span class="full-name">
13
- <%= source.first_name %>
14
- <%= source.last_name %>
15
- </span>
16
- <% else %>
17
- <%= content_tag(:span, payment.payment_method.name) %>
18
- <% end %>
@@ -1,5 +0,0 @@
1
- class AddTaxTotalToSpreeOrders < ActiveRecord::Migration
2
- def change
3
- add_column :spree_orders, :tax_total, :decimal, precision: 10, scale: 2, default: 0.0, null: false
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- class AddOrderIdToSpreeAdjustments < ActiveRecord::Migration
2
- def change
3
- add_column :spree_adjustments, :order_id, :integer
4
- add_index :spree_adjustments, :order_id
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddIncludedToSpreeAdjustments < ActiveRecord::Migration
2
- def change
3
- add_column :spree_adjustments, :included, :boolean, :default => false
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddUserIdCreatedByIdIndexToOrder < ActiveRecord::Migration
2
- def change
3
- add_index :spree_orders, [:user_id, :created_by_id]
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module Spree
2
- module Core
3
- class GatewayError < RuntimeError; end
4
- end
5
- end
@@ -1,25 +0,0 @@
1
- module Spree
2
- class OldPrefs < ActiveRecord::Base
3
- self.table_name = "spree_preferences"
4
- belongs_to :owner, :polymorphic => true
5
- attr_accessor :owner_klass
6
- end
7
-
8
- class PreferenceRescue
9
- def self.try
10
- OldPrefs.where(:key => nil).each do |old_pref|
11
- next unless owner = (old_pref.owner rescue nil)
12
- unless old_pref.owner_type == "Spree::Activator" || old_pref.owner_type == "Spree::Configuration"
13
- begin
14
- old_pref.key = [owner.class.name, old_pref.name, owner.id].join('::').underscore
15
- old_pref.value_type = owner.preference_type(old_pref.name)
16
- puts "Migrating Preference: #{old_pref.key}"
17
- old_pref.save
18
- rescue NoMethodError => ex
19
- puts ex.message
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module Spree
2
- module Core
3
- # This module exists to reduce duplication in S3 settings between
4
- # the Image and Taxon models in Spree
5
- module S3Support
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- def self.supports_s3(field)
10
- # Load user defined paperclip settings
11
- config = Spree::Config
12
- if config[:use_s3]
13
- s3_creds = { :access_key_id => config[:s3_access_key], :secret_access_key => config[:s3_secret], :bucket => config[:s3_bucket] }
14
- self.attachment_definitions[field][:storage] = :s3
15
- self.attachment_definitions[field][:s3_credentials] = s3_creds
16
- self.attachment_definitions[field][:s3_headers] = ActiveSupport::JSON.decode(config[:s3_headers])
17
- self.attachment_definitions[field][:bucket] = config[:s3_bucket]
18
- self.attachment_definitions[field][:s3_protocol] = config[:s3_protocol].blank? ? '' : config[:s3_protocol].downcase
19
- self.attachment_definitions[field][:s3_host_alias] = config[:s3_host_alias] unless config[:s3_host_alias].blank?
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,71 +0,0 @@
1
- module Spree
2
- module Promo
3
- class CouponApplicator
4
- attr_reader :order
5
-
6
- def initialize(order)
7
- @order = order
8
- end
9
-
10
- def apply
11
- if @order.coupon_code.present?
12
- # check if coupon code is already applied
13
- if @order.adjustments.promotion.eligible.detect { |p| p.originator.promotion.code == @order.coupon_code }.present?
14
- return { :coupon_applied? => true, :notice => Spree.t(:coupon_code_already_applied) }
15
- else
16
- promotion = Spree::Promotion.find_by(code: @order.coupon_code)
17
- if promotion.present?
18
- handle_present_promotion(promotion)
19
- else
20
- return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_found) }
21
- end
22
- end
23
- else
24
- return { :coupon_applied? => true }
25
- end
26
- end
27
-
28
- private
29
-
30
- def handle_present_promotion(promotion)
31
- return promotion_expired if promotion.expired?
32
- return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded?
33
-
34
- event_name = "spree.checkout.coupon_code_added"
35
- if promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
36
- promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
37
- if promo.present?
38
- determine_promotion_application_result(promo)
39
- else
40
- # if action is create line items
41
- return { :coupon_applied? => true, :success => Spree.t(:coupon_code_applied) }
42
- end
43
- else
44
- return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_eligible) }
45
- end
46
- end
47
-
48
- def promotion_expired
49
- { :coupon_applied? => false, :error => Spree.t(:coupon_code_expired) }
50
- end
51
-
52
- def promotion_usage_limit_exceeded
53
- { :coupon_applied? => false, :error => Spree.t(:coupon_code_max_usage) }
54
- end
55
-
56
- def determine_promotion_application_result(promo)
57
- previous_promo = @order.adjustments.promotion.eligible.first
58
- if promo.present? and promo.eligible
59
- return { :coupon_applied? => true, :success => Spree.t(:coupon_code_applied) }
60
- elsif previous_promo.present? and promo.present?
61
- return { :coupon_applied? => false, :error => Spree.t(:coupon_code_better_exists) }
62
- elsif promo.present?
63
- return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_eligible) }
64
- else
65
- # if the promotion was created after the order
66
- return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_found) }
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,8 +0,0 @@
1
- FactoryGirl.define do
2
- factory :activator, class: Spree::Activator do
3
- name 'Activator name'
4
- event_name 'spree.order.contents_changed'
5
- starts_at { 2.weeks.ago }
6
- expires_at { 2.weeks.from_now }
7
- end
8
- end