solidus_core 2.0.3 → 2.1.0.beta1

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.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -3
  3. data/app/assets/javascripts/spree.js.coffee.erb +4 -1
  4. data/app/helpers/spree/base_helper.rb +7 -48
  5. data/app/models/spree/address.rb +5 -1
  6. data/app/models/spree/adjustment.rb +3 -3
  7. data/app/models/spree/app_configuration.rb +13 -0
  8. data/app/models/spree/calculator.rb +3 -2
  9. data/app/models/spree/calculator/default_tax.rb +6 -10
  10. data/app/models/spree/calculator/flat_percent_item_total.rb +0 -4
  11. data/app/models/spree/calculator/flat_rate.rb +0 -4
  12. data/app/models/spree/calculator/flexi_rate.rb +0 -4
  13. data/app/models/spree/calculator/free_shipping.rb +0 -3
  14. data/app/models/spree/calculator/percent_on_line_item.rb +0 -4
  15. data/app/models/spree/calculator/percent_per_item.rb +0 -4
  16. data/app/models/spree/calculator/price_sack.rb +0 -4
  17. data/app/models/spree/calculator/returns/default_refund_amount.rb +0 -3
  18. data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +0 -4
  19. data/app/models/spree/calculator/shipping/flat_rate.rb +0 -4
  20. data/app/models/spree/calculator/shipping/flexi_rate.rb +0 -4
  21. data/app/models/spree/calculator/shipping/per_item.rb +0 -4
  22. data/app/models/spree/calculator/shipping/price_sack.rb +0 -4
  23. data/app/models/spree/calculator/tiered_flat_rate.rb +0 -4
  24. data/app/models/spree/calculator/tiered_percent.rb +0 -4
  25. data/app/models/spree/credit_card.rb +27 -14
  26. data/app/models/spree/gateway.rb +4 -0
  27. data/app/models/spree/inventory_unit.rb +2 -0
  28. data/app/models/spree/line_item.rb +31 -26
  29. data/app/models/spree/option_type.rb +0 -3
  30. data/app/models/spree/order.rb +28 -31
  31. data/app/models/spree/order/checkout.rb +0 -2
  32. data/app/models/spree/order_contents.rb +0 -45
  33. data/app/models/spree/order_merger.rb +6 -6
  34. data/app/models/spree/order_update_attributes.rb +0 -2
  35. data/app/models/spree/order_updater.rb +91 -13
  36. data/app/models/spree/payment.rb +9 -2
  37. data/app/models/spree/payment/processing.rb +15 -9
  38. data/app/models/spree/payment_method.rb +48 -5
  39. data/app/models/spree/price.rb +7 -9
  40. data/app/models/spree/product.rb +1 -25
  41. data/app/models/spree/promotion.rb +22 -14
  42. data/app/models/spree/promotion/actions/create_adjustment.rb +12 -1
  43. data/app/models/spree/promotion/actions/create_item_adjustments.rb +15 -1
  44. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +5 -3
  45. data/app/models/spree/promotion/actions/free_shipping.rb +14 -0
  46. data/app/models/spree/promotion/rules/taxon.rb +7 -2
  47. data/app/models/spree/promotion/rules/user_role.rb +43 -0
  48. data/app/models/spree/promotion_action.rb +19 -2
  49. data/app/models/spree/promotion_handler/coupon.rb +1 -4
  50. data/app/models/spree/promotion_handler/free_shipping.rb +22 -17
  51. data/app/models/spree/promotion_rule_role.rb +6 -0
  52. data/app/models/spree/property.rb +0 -3
  53. data/app/models/spree/return_authorization.rb +2 -0
  54. data/app/models/spree/shipment.rb +5 -21
  55. data/app/models/spree/shipping_method.rb +23 -2
  56. data/app/models/spree/shipping_rate.rb +3 -0
  57. data/app/models/spree/stock/estimator.rb +1 -1
  58. data/app/models/spree/stock_location.rb +3 -0
  59. data/app/models/spree/store.rb +7 -0
  60. data/app/models/spree/tax/item_adjuster.rb +27 -12
  61. data/app/models/spree/tax/order_adjuster.rb +2 -5
  62. data/app/models/spree/tax/tax_helpers.rb +4 -8
  63. data/app/models/spree/tax_rate.rb +1 -15
  64. data/app/models/spree/taxon.rb +0 -3
  65. data/app/models/spree/transfer_item.rb +1 -1
  66. data/app/models/spree/user_class_handle.rb +14 -9
  67. data/app/models/spree/variant/pricing_options.rb +1 -1
  68. data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
  69. data/app/models/spree/zone.rb +20 -13
  70. data/config/locales/en.yml +144 -62
  71. data/db/migrate/20120831092320_spree_one_two.rb +0 -7
  72. data/db/migrate/20150723224133_remove_unnecessary_indexes.rb +0 -2
  73. data/db/migrate/20160924135758_remove_is_default_from_prices.rb +5 -0
  74. data/db/migrate/20161009141333_remove_currency_from_line_items.rb +5 -0
  75. data/db/migrate/20161014221052_add_available_to_columns_and_remove_display_on_from_payment_methods.rb +28 -0
  76. data/db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb +20 -0
  77. data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +4 -0
  78. data/lib/generators/spree/dummy/dummy_generator.rb +0 -2
  79. data/lib/spree/core.rb +0 -5
  80. data/lib/spree/core/controller_helpers/pricing.rb +2 -1
  81. data/lib/spree/core/engine.rb +14 -0
  82. data/lib/spree/core/version.rb +1 -1
  83. data/lib/spree/deprecation.rb +1 -1
  84. data/lib/spree/localized_number.rb +3 -2
  85. data/lib/spree/permission_sets/configuration_display.rb +0 -1
  86. data/lib/spree/permission_sets/configuration_management.rb +0 -1
  87. data/lib/spree/permission_sets/product_display.rb +0 -1
  88. data/lib/spree/permission_sets/product_management.rb +0 -1
  89. data/lib/spree/permission_sets/user_management.rb +2 -4
  90. data/lib/spree/permitted_attributes.rb +3 -2
  91. data/lib/spree/testing_support/capybara_ext.rb +0 -12
  92. data/lib/spree/testing_support/factories/address_factory.rb +1 -1
  93. data/lib/spree/testing_support/factories/line_item_factory.rb +0 -1
  94. data/lib/spree/testing_support/factories/payment_factory.rb +4 -0
  95. data/lib/spree/testing_support/factories/payment_method_factory.rb +8 -1
  96. data/lib/spree/testing_support/factories/user_factory.rb +2 -2
  97. data/solidus_core.gemspec +4 -3
  98. data/spec/helpers/base_helper_spec.rb +0 -40
  99. data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +16 -0
  100. data/spec/lib/spree/core/importer/order_spec.rb +27 -18
  101. data/spec/lib/spree/core/price_migrator_spec.rb +3 -1
  102. data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +16 -0
  103. data/spec/lib/spree/core/unreturned_item_charger_spec.rb +0 -2
  104. data/spec/lib/tasks/exchanges_spec.rb +4 -2
  105. data/spec/lib/tasks/migrations/create_vat_prices_spec.rb +5 -3
  106. data/spec/models/spree/adjustment_spec.rb +136 -0
  107. data/spec/models/spree/calculator/default_tax_spec.rb +13 -7
  108. data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +3 -0
  109. data/spec/models/spree/calculator/flat_rate_spec.rb +3 -0
  110. data/spec/models/spree/calculator/flexi_rate_spec.rb +3 -0
  111. data/spec/models/spree/calculator/free_shipping_spec.rb +6 -0
  112. data/spec/models/spree/calculator/percent_on_line_item_spec.rb +9 -4
  113. data/spec/models/spree/calculator/percent_per_item_spec.rb +10 -0
  114. data/spec/models/spree/calculator/price_sack_spec.rb +3 -0
  115. data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +3 -0
  116. data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +3 -0
  117. data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +3 -0
  118. data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +3 -0
  119. data/spec/models/spree/calculator/shipping/per_item_spec.rb +3 -0
  120. data/spec/models/spree/calculator/shipping/price_sack_spec.rb +4 -1
  121. data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +3 -0
  122. data/spec/models/spree/calculator/tiered_percent_spec.rb +3 -0
  123. data/spec/models/spree/credit_card_spec.rb +27 -1
  124. data/spec/models/spree/line_item_spec.rb +58 -65
  125. data/spec/models/spree/order/checkout_spec.rb +2 -1
  126. data/spec/models/spree/order/payment_spec.rb +9 -10
  127. data/spec/models/spree/order/tax_spec.rb +22 -7
  128. data/spec/models/spree/order/updating_spec.rb +1 -3
  129. data/spec/models/spree/order_cancellations_spec.rb +6 -4
  130. data/spec/models/spree/order_contents_spec.rb +34 -50
  131. data/spec/models/spree/order_inventory_spec.rb +3 -5
  132. data/spec/models/spree/order_merger_spec.rb +20 -0
  133. data/spec/models/spree/order_spec.rb +28 -64
  134. data/spec/models/spree/order_update_attributes_spec.rb +1 -5
  135. data/spec/models/spree/order_updater_spec.rb +251 -0
  136. data/spec/models/spree/payment_method_spec.rb +178 -28
  137. data/spec/models/spree/payment_spec.rb +35 -19
  138. data/spec/models/spree/permission_sets/configuration_display.rb +0 -4
  139. data/spec/models/spree/permission_sets/configuration_management_spec.rb +0 -2
  140. data/spec/models/spree/permission_sets/product_display_spec.rb +0 -4
  141. data/spec/models/spree/permission_sets/product_management_spec.rb +0 -2
  142. data/spec/models/spree/permission_sets/user_management_spec.rb +9 -2
  143. data/spec/models/spree/price_spec.rb +16 -1
  144. data/spec/models/spree/product_spec.rb +0 -75
  145. data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +20 -0
  146. data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +39 -15
  147. data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +203 -22
  148. data/spec/models/spree/promotion/actions/free_shipping_spec.rb +22 -3
  149. data/spec/models/spree/promotion/rules/taxon_spec.rb +26 -0
  150. data/spec/models/spree/promotion/rules/user_role_spec.rb +86 -0
  151. data/spec/models/spree/promotion_action_spec.rb +38 -0
  152. data/spec/models/spree/promotion_handler/coupon_spec.rb +36 -33
  153. data/spec/models/spree/promotion_handler/free_shipping_spec.rb +21 -22
  154. data/spec/models/spree/promotion_spec.rb +46 -6
  155. data/spec/models/spree/reimbursement_spec.rb +1 -1
  156. data/spec/models/spree/reimbursement_tax_calculator_spec.rb +2 -2
  157. data/spec/models/spree/shipment_spec.rb +68 -50
  158. data/spec/models/spree/shipping_method_spec.rb +41 -0
  159. data/spec/models/spree/shipping_rate_spec.rb +9 -3
  160. data/spec/models/spree/stock/estimator_spec.rb +4 -2
  161. data/spec/models/spree/store_credit_spec.rb +3 -3
  162. data/spec/models/spree/tax/item_adjuster_spec.rb +31 -21
  163. data/spec/models/spree/tax/order_adjuster_spec.rb +6 -10
  164. data/spec/models/spree/tax/taxation_integration_spec.rb +19 -0
  165. data/spec/models/spree/tax_rate_spec.rb +5 -26
  166. data/spec/models/spree/transfer_item_spec.rb +11 -0
  167. data/spec/models/spree/variant/pricing_options_spec.rb +7 -17
  168. data/spec/models/spree/variant_spec.rb +2 -4
  169. data/spec/models/spree/zone_spec.rb +60 -20
  170. data/spec/shared_examples/calculator_shared_examples.rb +8 -0
  171. metadata +19 -24
  172. data/app/models/spree/item_adjustments.rb +0 -89
  173. data/app/models/spree/option_type_prototype.rb +0 -6
  174. data/app/models/spree/property_prototype.rb +0 -6
  175. data/app/models/spree/prototype.rb +0 -14
  176. data/app/models/spree/prototype_taxon.rb +0 -6
  177. data/app/models/spree/tracker.rb +0 -8
  178. data/db/migrate/20150128032538_remove_environment_from_tracker.rb +0 -6
  179. data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +0 -1
  180. data/lib/spree/core/delegate_belongs_to.rb +0 -94
  181. data/lib/spree/testing_support/factories/prototype_factory.rb +0 -8
  182. data/lib/spree/testing_support/factories/tracker_factory.rb +0 -6
  183. data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -24
  184. data/spec/lib/spree/core/testing_support/factories/prototype_factory_spec.rb +0 -12
  185. data/spec/lib/spree/core/testing_support/factories/tracker_factory_spec.rb +0 -12
  186. data/spec/models/spree/item_adjustments_spec.rb +0 -306
  187. data/spec/models/spree/tracker_spec.rb +0 -21
@@ -1,4 +1,11 @@
1
1
  module Spree
2
+ # Records store specific configuration such as store name and URL.
3
+ #
4
+ # `Spree::Store` provides the foundational ActiveRecord model for recording information
5
+ # specific to your store such as its name, URL, and tax location. This model will
6
+ # provide the foundation upon which [support for multiple stores](https://github.com/solidusio/solidus/issues/112)
7
+ # hosted by a single Solidus implementation can be built.
8
+ #
2
9
  class Store < Spree::Base
3
10
  has_many :store_payment_methods, inverse_of: :store
4
11
  has_many :payment_methods, through: :store_payment_methods
@@ -1,3 +1,7 @@
1
+ # @api private
2
+ # @note This is a helper class for Tax::OrderAdjuster. It is marked as api
3
+ # private because taxes should always be calculated on the entire order, so
4
+ # external code should call Tax::OrderAdjuster instead of Tax::ItemAdjuster.
1
5
  module Spree
2
6
  module Tax
3
7
  # Adjust a single taxable item (line item or shipment)
@@ -12,24 +16,35 @@ module Spree
12
16
  @item = item
13
17
  @order = @item.order
14
18
  # set instance variable so `TaxRate.match` is only called when necessary
15
- @rates_for_order_zone = options[:rates_for_order_zone]
19
+ @rates_for_order = options[:rates_for_order]
16
20
  @rates_for_default_zone = options[:rates_for_default_zone]
17
- @order_tax_zone = options[:order_tax_zone]
18
21
  end
19
22
 
20
- # Deletes all existing tax adjustments and creates new adjustments for all
21
- # (geographically and category-wise) applicable tax rates.
22
- #
23
- # Creating the adjustments will also run the ItemAdjustments class and
24
- # persist all taxation and promotion totals on the item.
25
- #
26
- # @return [Array<Spree::Adjustment>] newly created adjustments
23
+ # This updates the amounts for adjustments which already exist and
24
+ # creates and remove adjustments as needed to match the applicable
25
+ # (geographically and category-wise) tax rates.
27
26
  def adjust!
28
- return unless order_tax_zone(order)
27
+ rates = rates_for_item(item)
29
28
 
30
- item.adjustments.destroy(item.adjustments.select(&:tax?))
29
+ tax_adjustments = item.adjustments.select(&:tax?)
30
+ active_adjustments = rates.map do |rate|
31
+ # Find an existing adjustment from the same source.
32
+ # All tax adjustments already have source_type == 'Spree::TaxRate' so
33
+ # we need only check source_id.
34
+ adjustment = tax_adjustments.detect{|a| a.source_id == rate.id }
35
+ if adjustment
36
+ adjustment.update!
37
+ adjustment
38
+ else
39
+ # Create a new adjustment
40
+ rate.adjust(nil, item)
41
+ end
42
+ end
31
43
 
32
- rates_for_item(item).map { |rate| rate.adjust(order_tax_zone(order), item) }
44
+ unmatched_adjustments = tax_adjustments - active_adjustments
45
+
46
+ # Remove any tax adjustments tied to rates which no longer match
47
+ item.adjustments.destroy(unmatched_adjustments)
33
48
  end
34
49
  end
35
50
  end
@@ -14,8 +14,6 @@ module Spree
14
14
  # Creates tax adjustments for all taxable items (shipments and line items)
15
15
  # in the given order.
16
16
  def adjust!
17
- return unless order_tax_zone(order)
18
-
19
17
  (order.line_items + order.shipments).each do |item|
20
18
  ItemAdjuster.new(item, order_wide_options).adjust!
21
19
  end
@@ -25,9 +23,8 @@ module Spree
25
23
 
26
24
  def order_wide_options
27
25
  {
28
- rates_for_order_zone: rates_for_order_zone(order),
29
- rates_for_default_zone: rates_for_default_zone,
30
- order_tax_zone: order_tax_zone(order),
26
+ rates_for_order: rates_for_order(order),
27
+ rates_for_default_zone: rates_for_default_zone
31
28
  }
32
29
  end
33
30
  end
@@ -17,26 +17,22 @@ module Spree
17
17
  #
18
18
  # For further discussion, see https://github.com/spree/spree/issues/4397 and https://github.com/spree/spree/issues/4327.
19
19
  def applicable_rates(order)
20
- order_zone_tax_categories = rates_for_order_zone(order).map(&:tax_category)
20
+ order_zone_tax_categories = rates_for_order(order).map(&:tax_category)
21
21
  default_rates_with_unmatched_tax_category = rates_for_default_zone.to_a.delete_if do |default_rate|
22
22
  order_zone_tax_categories.include?(default_rate.tax_category)
23
23
  end
24
24
 
25
- (rates_for_order_zone(order) + default_rates_with_unmatched_tax_category).uniq
25
+ (rates_for_order(order) + default_rates_with_unmatched_tax_category).uniq
26
26
  end
27
27
 
28
- def rates_for_order_zone(order)
29
- @rates_for_order_zone ||= Spree::TaxRate.for_zone(order_tax_zone(order))
28
+ def rates_for_order(order)
29
+ @rates_for_order ||= Spree::TaxRate.for_address(order.tax_address)
30
30
  end
31
31
 
32
32
  def rates_for_default_zone
33
33
  @rates_for_default_zone ||= Spree::TaxRate.for_zone(Spree::Zone.default_tax)
34
34
  end
35
35
 
36
- def order_tax_zone(order)
37
- @order_tax_zone ||= order.tax_zone
38
- end
39
-
40
36
  def sum_of_included_tax_rates(item)
41
37
  rates_for_item(item).map(&:amount).sum
42
38
  end
@@ -65,23 +65,9 @@ module Spree
65
65
  scope :for_zone, ->(zone) { where(zone_id: Spree::Zone.with_shared_members(zone).pluck(:id)) }
66
66
  scope :included_in_price, -> { where(included_in_price: true) }
67
67
 
68
- # Create tax adjustments for some items that have the same tax zone.
69
- #
70
- # @deprecated Please use Spree::Tax::OrderAdjuster or Spree::Tax::ItemAdjuster instead.
71
- #
72
- # @param [Spree::Zone] order_tax_zone is the smalles applicable zone to the order's tax address
73
- # @param [Array<Spree::LineItem,Spree::Shipment>] items to be adjusted
74
- def self.adjust(order_tax_zone, items)
75
- Spree::Deprecation.warn("Please use Spree::Tax::OrderAdjuster or Spree::Tax::ItemAdjuster instead", caller)
76
- items.map do |item|
77
- Spree::Tax::ItemAdjuster.new(item, rates_for_order_zone: for_zone(order_tax_zone)).adjust!
78
- end
79
- end
80
-
81
68
  # Creates necessary tax adjustments for the order.
82
- def adjust(order_tax_zone, item)
69
+ def adjust(_order_tax_zone, item)
83
70
  amount = compute_amount(item)
84
- return if amount == 0
85
71
 
86
72
  included = included_in_price && amount > 0
87
73
 
@@ -6,9 +6,6 @@ module Spree
6
6
  has_many :classifications, -> { order(:position) }, dependent: :delete_all, inverse_of: :taxon
7
7
  has_many :products, through: :classifications
8
8
 
9
- has_many :prototype_taxons, dependent: :destroy
10
- has_many :prototypes, through: :prototype_taxons
11
-
12
9
  has_many :promotion_rule_taxons
13
10
  has_many :promotion_rules, through: :promotion_rule_taxons
14
11
 
@@ -2,7 +2,7 @@ module Spree
2
2
  class TransferItem < Spree::Base
3
3
  acts_as_paranoid
4
4
  belongs_to :stock_transfer, inverse_of: :transfer_items
5
- belongs_to :variant
5
+ belongs_to :variant, -> { with_deleted }
6
6
 
7
7
  validate :stock_availability, if: :check_stock?
8
8
  validates :stock_transfer, :variant, presence: true
@@ -1,15 +1,20 @@
1
1
  module Spree
2
- # Placeholder for name of Spree.user_class to ensure later evaluation at
3
- # runtime.
2
+ # Configuration point for User model implementation.
4
3
  #
5
- # Unfortunately, it is possible for classes to get loaded before
6
- # Spree.user_class has been set in the initializer. As a result, they end up
7
- # with class_name: "" in their association definitions. For obvious reasons,
8
- # that doesn't work.
4
+ # `Spree::UserClassHandle` allows you to configure your own implementation of a
5
+ # User class or use an extnesion like `solidus_auth_devise`.
9
6
  #
10
- # For now, Rails does not call to_s on the instance passed in until runtime.
11
- # So this little hack provides a wrapper around Spree.user_class so that we
12
- # can basically lazy-evaluate it. Yay! Problem solved forever.
7
+ # @note Placeholder for name of Spree.user_class to ensure later evaluation at
8
+ # runtime.
9
+ #
10
+ # Unfortunately, it is possible for classes to get loaded before
11
+ # Spree.user_class has been set in the initializer. As a result, they end up
12
+ # with class_name: "" in their association definitions. For obvious reasons,
13
+ # that doesn't work.
14
+ #
15
+ # For now, Rails does not call to_s on the instance passed in until runtime.
16
+ # So this little hack provides a wrapper around Spree.user_class so that we
17
+ # can basically lazy-evaluate it. Yay! Problem solved forever.
13
18
  class UserClassHandle
14
19
  # @return [String] the name of the user class as a string.
15
20
  # @raise [RuntimeError] if Spree.user_class is nil
@@ -33,7 +33,7 @@ module Spree
33
33
  def self.from_line_item(line_item)
34
34
  tax_address = line_item.order.try!(:tax_address)
35
35
  new(
36
- currency: line_item.order.try(:currency) || line_item.currency || Spree::Config.currency,
36
+ currency: line_item.currency || Spree::Config.currency,
37
37
  country_iso: tax_address && tax_address.country.try!(:iso)
38
38
  )
39
39
  end
@@ -9,7 +9,7 @@ class Spree::Wallet::AddPaymentSourcesToWallet
9
9
  # This is called after an order transistions to complete and should save the
10
10
  # order's payment source/s in the user's "wallet" for future use.
11
11
  #
12
- # @return [undefined]
12
+ # @return [void]
13
13
  def add_to_wallet
14
14
  if !order.temporary_credit_card &&
15
15
  order.user_id &&
@@ -16,18 +16,16 @@ module Spree
16
16
  after_save :remove_previous_default
17
17
 
18
18
  scope :with_member_ids, ->(state_ids, country_ids) do
19
- if !state_ids.present? && !country_ids.present?
20
- none
21
- else
22
- spree_zone_members_table = Spree::ZoneMember.arel_table
23
- matching_state =
24
- spree_zone_members_table[:zoneable_type].eq("Spree::State").
25
- and(spree_zone_members_table[:zoneable_id].in(state_ids))
26
- matching_country =
27
- spree_zone_members_table[:zoneable_type].eq("Spree::Country").
28
- and(spree_zone_members_table[:zoneable_id].in(country_ids))
29
- joins(:zone_members).where(matching_state.or(matching_country)).distinct
30
- end
19
+ return none if !state_ids.present? && !country_ids.present?
20
+
21
+ spree_zone_members_table = Spree::ZoneMember.arel_table
22
+ matching_state =
23
+ spree_zone_members_table[:zoneable_type].eq("Spree::State").
24
+ and(spree_zone_members_table[:zoneable_id].in(state_ids))
25
+ matching_country =
26
+ spree_zone_members_table[:zoneable_type].eq("Spree::Country").
27
+ and(spree_zone_members_table[:zoneable_id].in(country_ids))
28
+ joins(:zone_members).where(matching_state.or(matching_country)).distinct
31
29
  end
32
30
 
33
31
  scope :for_address, ->(address) do
@@ -43,14 +41,22 @@ module Spree
43
41
 
44
42
  self.whitelisted_ransackable_attributes = ['description']
45
43
 
44
+ # Returns the zone marked as `default_tax`.
45
+ # @deprecated Please run the `solidus:migrations:create_vat_prices` rake task
46
46
  def self.default_tax
47
- where(default_tax: true).first
47
+ default_tax_zone = where(default_tax: true).first
48
+ if default_tax_zone
49
+ Spree::Deprecation.warn("Please run the `solidus:migrations:create_vat_prices` rake task.", caller)
50
+ default_tax_zone
51
+ end
48
52
  end
49
53
 
50
54
  # Returns the most specific matching zone for an address. Specific means:
51
55
  # A State zone wins over a country zone, and a zone with few members wins
52
56
  # over one with many members. If there is no match, returns nil.
53
57
  def self.match(address)
58
+ Spree::Deprecation.warn("Spree::Zone.match is deprecated. Please use Spree::Zone.for_address instead.", caller)
59
+
54
60
  return unless address && (matches =
55
61
  with_member_ids(address.state_id, address.country_id).
56
62
  order(:zone_members_count, :created_at, :id).
@@ -160,6 +166,7 @@ module Spree
160
166
  (target.zoneables.collect(&:country).collect(&:id) - zoneables.collect(&:id)).empty?
161
167
  end
162
168
  end
169
+ deprecate :contains?, deprecator: Spree::Deprecation
163
170
 
164
171
  private
165
172
 
@@ -178,8 +178,6 @@ en:
178
178
  spree/property:
179
179
  name: Name
180
180
  presentation: Presentation
181
- spree/prototype:
182
- name: Name
183
181
  spree/refund:
184
182
  amount: Amount
185
183
  description: Description
@@ -252,6 +250,7 @@ en:
252
250
  seo_title: Seo Title
253
251
  name: Site Name
254
252
  mail_from_address: Mail From Address
253
+ cart_tax_country_iso: Tax Country for Empty Carts
255
254
  spree/store_credit:
256
255
  amount: Amount
257
256
  amount_authorized: Amount Authorized
@@ -359,8 +358,56 @@ en:
359
358
  one: Adjustment Reason
360
359
  other: Adjustment Reasons
361
360
  spree/calculator:
362
- one: Calculator
363
- other: Calculators
361
+ one: Base Calculator
362
+ other: Base Calculators
363
+ spree/calculator/default_tax:
364
+ one: Default Tax
365
+ other: Default Tax
366
+ spree/calculator/flat_percent_item_total:
367
+ one: Flat Percent
368
+ other: Flat Percent
369
+ spree/calculator/flat_rate:
370
+ one: Flat Rate
371
+ other: Flat Rate
372
+ spree/calculator/flexi_rate:
373
+ one: Flexible Rate
374
+ other: Flexible Rate
375
+ spree/calculator/free_shipping:
376
+ one: Free Shipping
377
+ other: Free Shipping
378
+ spree/calculator/percent_on_line_item:
379
+ one: Percent Per Item
380
+ other: Percent Per Item
381
+ spree/calculator/percent_per_item:
382
+ one: Percent Per Item
383
+ other: Percent Per Item
384
+ spree/calculator/price_sack:
385
+ one: Price Sack
386
+ other: Price Sack
387
+ spree/calculator/tiered_percent:
388
+ one: Tiered Percent
389
+ other: Tiered Percent
390
+ spree/calculator/tiered_flat_rate:
391
+ one: Tiered Flat Rate
392
+ other: Tiered Flat Rate
393
+ spree/calculator/returns/default_refund_amount:
394
+ one: Default Refund Amount
395
+ other: Default Refund Amount
396
+ spree/calculator/shipping/flat_percent_item_total:
397
+ one: Flat Percent
398
+ other: Flat Percent
399
+ spree/calculator/shipping/flat_rate:
400
+ one: Flat rate
401
+ other: Flat rate
402
+ spree/calculator/shipping/flexi_rate:
403
+ one: Flexible Rate per package item
404
+ other: Flexible Rate per package item
405
+ spree/calculator/shipping/per_item:
406
+ one: Flat rate per package item
407
+ other: Flat rate per package item
408
+ spree/calculator/shipping/price_sack:
409
+ one: Price sack
410
+ other: Price sack
364
411
  spree/country:
365
412
  one: Country
366
413
  other: Countries
@@ -424,9 +471,6 @@ en:
424
471
  spree/property:
425
472
  one: Property Type
426
473
  other: Property Types
427
- spree/prototype:
428
- one: Prototype
429
- other: Prototypes
430
474
  spree/refund:
431
475
  one: Refund
432
476
  other: Refunds
@@ -538,8 +582,8 @@ en:
538
582
  cannot_destroy_shipment_state: "Cannot destroy an inventory unit for a %{state} shipment"
539
583
  spree/line_item:
540
584
  attributes:
541
- currency:
542
- must_match_order_currency: "Must match order currency"
585
+ price:
586
+ not_a_number: "is not valid"
543
587
  spree/price:
544
588
  attributes:
545
589
  currency:
@@ -682,6 +726,8 @@ en:
682
726
  adjustment: Adjustment
683
727
  adjustment_amount: Amount
684
728
  adjustment_labels:
729
+ line_item: '%{promotion} (%{promotion_name})'
730
+ order: '%{promotion} (%{promotion_name})'
685
731
  tax_rates:
686
732
  sales_tax: '%{name}'
687
733
  vat: '%{name} (Included in Price)'
@@ -697,42 +743,33 @@ en:
697
743
  adjustment_total: Adjustment Total
698
744
  adjustments: Adjustments
699
745
  admin:
700
- tab:
701
- areas: Locations
702
- checkout: Refunds and Returns
703
- configuration: Configuration
704
- display_order: Display Order
705
- general: Store
706
- option_types: Option Types
707
- orders: Orders
708
- overview: Overview
709
- payments: Payments
710
- products: Products
711
- promotions: Promotions
712
- promotion_categories: Promotion Categories
713
- properties: Property Types
714
- prototypes: Prototypes
715
- reports: Reports
716
- rma: RMA
717
- settings: Settings
718
- shipping: Shipping
719
- stock: Stock
720
- stock_items: Store Stock
721
- stock_transfers: Stock Transfers
722
- taxes: Taxes
723
- taxonomies: Taxonomies
724
- taxons: Taxons
725
- users: Users
726
- user:
727
- account: Account
728
- addresses: Addresses
729
- items: Items
730
- items_purchased: Items Purchased
731
- order_history: Order History
732
- order_num: "Order #"
733
- orders: Orders
734
- store_credit: Store Credit
735
- user_information: User Information
746
+ general_settings:
747
+ edit:
748
+ no_cart_tax_country: "No taxes on carts without address"
749
+ images:
750
+ index:
751
+ choose_files: Choose files to upload
752
+ drag_and_drop: or drag and drop them here
753
+ image_process_failed: Server failed to process the image
754
+ upload_images: Upload Images
755
+ payments:
756
+ source_forms:
757
+ storecredit:
758
+ not_supported: "Creating store credit payments via the admin is not currently supported."
759
+ prices:
760
+ any_country: "Any Country"
761
+ index:
762
+ amount_greater_than: Amount greater than
763
+ amount_less_than: Amount less than
764
+ new_price: New Price
765
+ edit:
766
+ edit_price: Edit Price
767
+ new:
768
+ new_price: New Price
769
+ promotions:
770
+ form:
771
+ starts_at_placeholder: Immediately
772
+ expires_at_placeholder: Never
736
773
  store_credits:
737
774
  add: "Add store credit"
738
775
  amount_authorized: "Amount Authorized"
@@ -766,6 +803,7 @@ en:
766
803
  select_amount_update_reason: "Select a reason for updating the amount"
767
804
  total_unused: "Total unused"
768
805
  type_html_header: "Credit Type"
806
+ view: "View store credit"
769
807
  errors:
770
808
  cannot_change_used_store_credit: "Store credit that has been claimed cannot be changed"
771
809
  cannot_be_modified: "cannot be modified"
@@ -773,8 +811,46 @@ en:
773
811
  amount_authorized_exceeds_total_credit: " exceeds the available credit"
774
812
  amount_used_not_zero: "is greater than zero. Can not delete store credit"
775
813
  update_reason_required: "A reason for the change must be selected"
814
+ tab:
815
+ areas: Locations
816
+ checkout: Refunds and Returns
817
+ configuration: Configuration
818
+ display_order: Display Order
819
+ general: Store
820
+ option_types: Option Types
821
+ orders: Orders
822
+ overview: Overview
823
+ payments: Payments
824
+ products: Products
825
+ promotions: Promotions
826
+ promotion_categories: Promotion Categories
827
+ properties: Property Types
828
+ reports: Reports
829
+ rma: RMA
830
+ settings: Settings
831
+ shipping: Shipping
832
+ stock: Stock
833
+ stock_items: Store Stock
834
+ stock_transfers: Stock Transfers
835
+ taxes: Taxes
836
+ taxonomies: Taxonomies
837
+ taxons: Taxons
838
+ users: Users
776
839
  taxons:
777
840
  display_order: Display Order
841
+ user:
842
+ account: Account
843
+ addresses: Addresses
844
+ items: Items
845
+ items_purchased: Items Purchased
846
+ order_history: Order History
847
+ order_num: "Order #"
848
+ orders: Orders
849
+ store_credit: Store Credit
850
+ user_information: User Information
851
+ users:
852
+ user_page_actions:
853
+ create_order: Create order for this user
778
854
  variants:
779
855
  table_filter:
780
856
  show_deleted: Show deleted variants
@@ -787,16 +863,6 @@ en:
787
863
  use_product_tax_category: Use Product Tax Category
788
864
  pricing: Pricing
789
865
  pricing_hint: These values are populated from the product details page and can be overridden below
790
- prices:
791
- any_country: "Any Country"
792
- index:
793
- amount_greater_than: Amount greater than
794
- amount_less_than: Amount less than
795
- new_price: New Price
796
- edit:
797
- edit_price: Edit Price
798
- new:
799
- new_price: New Price
800
866
  administration: Administration
801
867
  agree_to_privacy_policy: Agree to Privacy Policy
802
868
  agree_to_terms_of_service: Agree to Terms of Service
@@ -849,7 +915,6 @@ en:
849
915
  back_to_promotions_list: Back To Promotions List
850
916
  back_to_promotion_categories_list: Back To Promotions Categories List
851
917
  back_to_properties_list: Back To Property Types List
852
- back_to_prototypes_list: Back To Prototypes List
853
918
  back_to_reports_list: Back To Reports List
854
919
  back_to_refund_reason_list: Back To Refund Reason List
855
920
  back_to_reimbursement_type_list: Back To Reimbursement Type List
@@ -970,7 +1035,6 @@ en:
970
1035
  customer_returns: Customer Returns
971
1036
  create: Create
972
1037
  create_a_new_account: Create a new account
973
- create_new_order: Create new order
974
1038
  create_reimbursement: Create reimbursement
975
1039
  create_one: Create One.
976
1040
  created_at: Created At
@@ -1036,7 +1100,6 @@ en:
1036
1100
  editing_promotion: Editing Promotion
1037
1101
  editing_promotion_category: Editing Promotion Category
1038
1102
  editing_property: Editing Property Type
1039
- editing_prototype: Editing Prototype
1040
1103
  edit_refund_reason: Edit Refund Reason
1041
1104
  editing_refund: Editing Refund
1042
1105
  editing_refund_reason: Editing Refund Reason
@@ -1057,6 +1120,7 @@ en:
1057
1120
  eligibility_errors:
1058
1121
  messages:
1059
1122
  has_excluded_product: Your cart contains a product that prevents this coupon code from being applied.
1123
+ has_excluded_taxon: Your cart contains a product from an excluded category that prevents this coupon code from being applied.
1060
1124
  item_total_less_than: This coupon code can't be applied to orders less than %{amount}.
1061
1125
  item_total_less_than_or_equal: This coupon code can't be applied to orders less than or equal to %{amount}.
1062
1126
  limit_once_per_user: This coupon code can only be used once per user.
@@ -1114,12 +1178,22 @@ en:
1114
1178
  hints:
1115
1179
  spree/price:
1116
1180
  country: "This determines in what country the price is valid.<br/>Default: Any Country"
1181
+ master_variant: "Changing master variant prices will not change variant prices below, but will be used to populate all new variants"
1182
+ options: "These options are used to create variants in the variants table. They can be changed in the variants tab"
1117
1183
  spree/product:
1118
1184
  promotionable: "This determines whether or not promotions can apply to this product.<br/>Default: Checked"
1119
1185
  shipping_category: "This determines what kind of shipping this product requires.<br/> Default: Default"
1120
1186
  tax_category: "This determines what kind of taxation is applied to this product.<br/> Default: None"
1187
+ spree/promotion:
1188
+ starts_at: "This determines when the promotion can be applied to orders. <br/> If no value is specified, the promotion will be immediately available."
1189
+ expires_at: "This determines when the promotion expires. <br/> If no value is specified, the promotion will never expires."
1190
+ spree/store:
1191
+ cart_tax_country_iso: "This determines which country is used for taxes on carts (orders which don't yet have an address).<br/> Default: None."
1121
1192
  spree/variant:
1122
1193
  tax_category: "This determines what kind of taxation is applied to this variant.<br/> Default: Use tax category of the product associated with this variant"
1194
+ deleted: "Deleted Variant"
1195
+ deleted_explanation: "This variant was deleted on %{date}."
1196
+ deleted_explanation_with_replacement: "This variant was deleted on %{date}. It has since been replaced by another with the same SKU."
1123
1197
  failed_payment_attempts: Failed Payment Attempts
1124
1198
  failure: Failure
1125
1199
  filename: Filename
@@ -1207,6 +1281,7 @@ en:
1207
1281
  inventory_adjustment: Inventory Adjustment
1208
1282
  inventory_canceled: Inventory canceled
1209
1283
  inventory_error_flash_for_insufficient_quantity: An item in your cart has become unavailable.
1284
+ inventory_not_available: Inventory not available for %{item}.
1210
1285
  inventory_state: Inventory State
1211
1286
  inventory_states:
1212
1287
  backordered: backordered
@@ -1265,6 +1340,7 @@ en:
1265
1340
  manual_intervention_required: Manual intervention required
1266
1341
  manage_variants: Manage Variants
1267
1342
  master_price: Master Price
1343
+ master_variant: Master Variant
1268
1344
  match_choices:
1269
1345
  all: All
1270
1346
  none: None
@@ -1301,7 +1377,6 @@ en:
1301
1377
  new_promotion: New Promotion
1302
1378
  new_promotion_category: New Promotion Category
1303
1379
  new_property: New Property Type
1304
- new_prototype: New Prototype
1305
1380
  new_refund: New Refund
1306
1381
  new_refund_reason: New Refund Reason
1307
1382
  new_rma_reason: New RMA Reason
@@ -1565,6 +1640,9 @@ en:
1565
1640
  description: Available only to user who have not purchased in a while
1566
1641
  name: First Repeat Purchase Since
1567
1642
  form_text: "Apply this promotion to users whose last order was more than X days ago: "
1643
+ user_role:
1644
+ description: Order includes User with specified Role(s)
1645
+ name: User Role(s)
1568
1646
  promotions: Promotions
1569
1647
  promotion_successfully_created: Promotion has been successfully created!
1570
1648
  promotion_total_changed_before_complete: "One or more of the promotions on your order have become ineligible and were removed. Please check the new order amounts and try again."
@@ -1572,8 +1650,6 @@ en:
1572
1650
  propagate_all_variants: Propagate all variants
1573
1651
  properties: Property Types
1574
1652
  property: Property Type
1575
- prototype: Prototype
1576
- prototypes: Prototypes
1577
1653
  provider: Provider
1578
1654
  provider_settings_warning: If you are changing the provider type, you must save first before you can edit the provider settings
1579
1655
  qty: Qty
@@ -1670,7 +1746,6 @@ en:
1670
1746
  secure_connection_type: Secure Connection Type
1671
1747
  security_settings: Security Settings
1672
1748
  select: Select
1673
- select_from_prototype: Select From Prototype
1674
1749
  select_a_reason: Select a reason
1675
1750
  select_a_stock_location: Select a stock location
1676
1751
  select_stock: Select stock
@@ -1837,6 +1912,7 @@ en:
1837
1912
  label: Order must contain %{select} of these taxons
1838
1913
  match_all: all
1839
1914
  match_any: at least one
1915
+ match_none: none
1840
1916
  taxonomies: Taxonomies
1841
1917
  taxonomy: Taxonomy
1842
1918
  taxonomy_edit: Edit taxonomy
@@ -1903,6 +1979,11 @@ en:
1903
1979
  user: User
1904
1980
  user_rule:
1905
1981
  choose_users: Choose users
1982
+ user_role_rule:
1983
+ choose_roles: Choose Roles
1984
+ label: User must contain %{select} of these roles
1985
+ match_all: all
1986
+ match_any: at least one
1906
1987
  users: Users
1907
1988
  validation:
1908
1989
  unpaid_amount_not_zero: "Amount was not fully reimbursed. Still due: %{amount}"
@@ -1915,6 +1996,7 @@ en:
1915
1996
  value: Value
1916
1997
  variant: Variant
1917
1998
  variant_placeholder: Choose a variant
1999
+ variant_pricing: Variant Pricing
1918
2000
  variant_properties: Variant Properties
1919
2001
  variant_search: Variant Search
1920
2002
  variant_search_placeholder: "SKU or Option Value"