spree_core 3.3.6 → 3.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +17 -18
- data/app/helpers/spree/products_helper.rb +5 -5
- data/app/models/concerns/spree/calculated_adjustments.rb +4 -3
- data/app/models/concerns/spree/default_price.rb +4 -5
- data/app/models/concerns/spree/display_money.rb +1 -1
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/ransackable_attributes.rb +5 -6
- data/app/models/concerns/spree/user_address.rb +6 -6
- data/app/models/concerns/spree/user_methods.rb +3 -3
- data/app/models/concerns/spree/user_payment_source.rb +4 -2
- data/app/models/concerns/spree/user_reporting.rb +1 -1
- data/app/models/spree/ability.rb +3 -3
- data/app/models/spree/address.rb +13 -9
- data/app/models/spree/adjustable/adjuster/promotion.rb +1 -1
- data/app/models/spree/adjustable/adjustments_updater.rb +2 -2
- data/app/models/spree/adjustable/promotion_accumulator.rb +6 -4
- data/app/models/spree/adjustment.rb +2 -3
- data/app/models/spree/app_configuration.rb +5 -6
- data/app/models/spree/base.rb +1 -1
- data/app/models/spree/calculator/default_tax.rb +4 -5
- data/app/models/spree/calculator/flat_percent_item_total.rb +1 -1
- data/app/models/spree/calculator/flat_rate.rb +3 -3
- data/app/models/spree/calculator/flexi_rate.rb +5 -5
- data/app/models/spree/calculator/price_sack.rb +9 -9
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -1
- data/app/models/spree/calculator/shipping/flat_rate.rb +3 -3
- data/app/models/spree/calculator/shipping/flexi_rate.rb +7 -7
- data/app/models/spree/calculator/shipping/per_item.rb +2 -2
- data/app/models/spree/calculator/shipping/price_sack.rb +4 -4
- data/app/models/spree/calculator/tiered_flat_rate.rb +3 -2
- data/app/models/spree/calculator/tiered_percent.rb +4 -3
- data/app/models/spree/calculator.rb +4 -4
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/exchange.rb +4 -5
- data/app/models/spree/gateway/bogus.rb +20 -20
- data/app/models/spree/gateway/bogus_simple.rb +2 -4
- data/app/models/spree/gateway.rb +4 -4
- data/app/models/spree/image.rb +3 -3
- data/app/models/spree/inventory_unit.rb +30 -30
- data/app/models/spree/line_item.rb +7 -9
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/order/checkout.rb +5 -5
- data/app/models/spree/order/currency_updater.rb +1 -4
- data/app/models/spree/order/payments.rb +4 -4
- data/app/models/spree/order/store_credit.rb +2 -2
- data/app/models/spree/order.rb +11 -29
- data/app/models/spree/order_contents.rb +6 -5
- data/app/models/spree/order_inventory.rb +3 -4
- data/app/models/spree/order_updater.rb +13 -14
- data/app/models/spree/payment/processing.rb +25 -26
- data/app/models/spree/payment.rb +72 -79
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/payment_method/check.rb +1 -1
- data/app/models/spree/payment_method/store_credit.rb +5 -5
- data/app/models/spree/payment_method.rb +7 -7
- data/app/models/spree/preferences/configuration.rb +6 -9
- data/app/models/spree/preferences/preferable.rb +11 -11
- data/app/models/spree/preferences/preferable_class_methods.rb +2 -3
- data/app/models/spree/preferences/scoped_store.rb +6 -5
- data/app/models/spree/preferences/store.rb +9 -14
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product/scopes.rb +49 -49
- data/app/models/spree/product.rb +16 -16
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +2 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/first_order.rb +7 -6
- data/app/models/spree/promotion/rules/item_total.rb +3 -5
- data/app/models/spree/promotion/rules/one_use_per_user.rb +1 -2
- data/app/models/spree/promotion/rules/option_value.rb +14 -6
- data/app/models/spree/promotion/rules/product.rb +4 -4
- data/app/models/spree/promotion/rules/taxon.rb +6 -6
- data/app/models/spree/promotion/rules/user.rb +3 -3
- data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
- data/app/models/spree/promotion.rb +15 -16
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_handler/cart.rb +3 -2
- data/app/models/spree/promotion_handler/free_shipping.rb +1 -3
- data/app/models/spree/promotion_handler/page.rb +3 -3
- data/app/models/spree/promotion_rule.rb +5 -4
- data/app/models/spree/refund.rb +8 -8
- data/app/models/spree/reimbursement/credit.rb +1 -1
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -3
- data/app/models/spree/reimbursement.rb +4 -8
- data/app/models/spree/reimbursement_performer.rb +0 -5
- data/app/models/spree/reimbursement_tax_calculator.rb +5 -12
- data/app/models/spree/reimbursement_type.rb +2 -2
- data/app/models/spree/return_authorization.rb +22 -26
- data/app/models/spree/return_item/eligibility_validator/default.rb +3 -3
- data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/order_completed.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/rma_required.rb +2 -3
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +2 -2
- data/app/models/spree/return_item.rb +15 -19
- data/app/models/spree/returns_calculator.rb +1 -2
- data/app/models/spree/shipment.rb +14 -35
- data/app/models/spree/shipment_handler.rb +10 -12
- data/app/models/spree/shipping_calculator.rb +5 -6
- data/app/models/spree/shipping_method.rb +3 -3
- data/app/models/spree/shipping_rate.rb +2 -2
- data/app/models/spree/state.rb +2 -2
- data/app/models/spree/stock/availability_validator.rb +1 -1
- data/app/models/spree/stock/content_item.rb +2 -3
- data/app/models/spree/stock/coordinator.rb +3 -2
- data/app/models/spree/stock/differentiator.rb +3 -2
- data/app/models/spree/stock/estimator.rb +7 -5
- data/app/models/spree/stock/package.rb +5 -5
- data/app/models/spree/stock/packer.rb +1 -1
- data/app/models/spree/stock/prioritizer.rb +5 -7
- data/app/models/spree/stock/quantifier.rb +0 -1
- data/app/models/spree/stock/splitter/backordered.rb +2 -4
- data/app/models/spree/stock/splitter/base.rb +3 -2
- data/app/models/spree/stock/splitter/shipping_category.rb +2 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +12 -11
- data/app/models/spree/stock_movement.rb +1 -3
- data/app/models/spree/stock_transfer.rb +1 -1
- data/app/models/spree/store.rb +4 -4
- data/app/models/spree/store_credit.rb +3 -3
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +10 -10
- data/app/models/spree/taxon.rb +13 -13
- data/app/models/spree/taxonomy.rb +9 -8
- data/app/models/spree/validations/db_maximum_length_validator.rb +2 -3
- data/app/models/spree/variant.rb +30 -41
- data/app/models/spree/zone.rb +10 -10
- data/app/validators/db_maximum_length_validator.rb +5 -5
- data/config/initializers/acts_as_taggable_on.rb +3 -3
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/friendly_id.rb +1 -1
- data/config/initializers/premailer_assets.rb +1 -1
- data/config/locales/en.yml +8 -2
- data/db/default/spree/states.rb +1 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +12 -15
- data/lib/generators/spree/install/install_generator.rb +45 -32
- data/lib/spree/core/components.rb +3 -3
- data/lib/spree/core/controller_helpers/auth.rb +5 -10
- data/lib/spree/core/controller_helpers/common.rb +2 -3
- data/lib/spree/core/controller_helpers/order.rb +3 -7
- data/lib/spree/core/controller_helpers/respond_with.rb +4 -4
- data/lib/spree/core/engine.rb +3 -3
- data/lib/spree/core/environment/calculators.rb +0 -1
- data/lib/spree/core/environment_extension.rb +8 -8
- data/lib/spree/core/importer/order.rb +64 -67
- data/lib/spree/core/importer/product.rb +10 -9
- data/lib/spree/core/product_filters.rb +17 -18
- data/lib/spree/core/routes.rb +2 -6
- data/lib/spree/core/search/base.rb +62 -59
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +4 -6
- data/lib/spree/i18n.rb +3 -5
- data/lib/spree/localized_number.rb +0 -2
- data/lib/spree/migrations.rb +8 -7
- data/lib/spree/money.rb +3 -7
- data/lib/spree/permitted_attributes.rb +2 -2
- data/lib/spree/responder.rb +4 -5
- data/lib/spree/testing_support/authorization_helpers.rb +3 -3
- data/lib/spree/testing_support/caching.rb +5 -5
- data/lib/spree/testing_support/capybara_ext.rb +16 -18
- data/lib/spree/testing_support/common_rake.rb +8 -9
- data/lib/spree/testing_support/controller_requests.rb +6 -6
- data/lib/spree/testing_support/extension_rake.rb +2 -3
- data/lib/spree/testing_support/factories/address_factory.rb +1 -1
- data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +1 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -3
- data/lib/spree/testing_support/factories/image_factory.rb +2 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +2 -2
- data/lib/spree/testing_support/factories/options_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -4
- data/lib/spree/testing_support/factories/price_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/prototype_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +2 -2
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +2 -2
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +3 -3
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +2 -2
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tag_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +2 -2
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tracker_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -2
- data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_member_factory.rb +1 -1
- data/lib/spree/testing_support/factories.rb +3 -3
- data/lib/spree/testing_support/flash.rb +1 -3
- data/lib/spree/testing_support/i18n.rb +5 -6
- data/lib/spree/testing_support/kernel.rb +1 -2
- data/lib/spree/testing_support/order_walkthrough.rb +12 -15
- data/lib/spree/testing_support/preferences.rb +0 -1
- data/lib/tasks/core.rake +47 -56
- data/lib/tasks/email.rake +2 -2
- data/lib/tasks/exchanges.rake +5 -5
- data/spree_core.gemspec +1 -1
- metadata +5 -9
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/config/initializers/premailer_rails.rb +0 -3
- data/lib/spree/core/delegate_belongs_to.rb +0 -99
- data/lib/spree/testing_support/microdata.rb +0 -192
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c01ec77a94de597431df6260fdfe18a88817c241
|
4
|
+
data.tar.gz: 72dcbd2cd49f05b804e3bf427d47899d3f11a3a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ba01f3578d5bebce43b70a421996ca9b6c7a7493b03b27841fd45a08bddfdabc79eb31e266a8d33a0c870e48962f47f2a34735e8cf1eccac1cd849b239d8ab
|
7
|
+
data.tar.gz: 1ab924152669666ce1d0e1dd4bbfd6b056b6cd66149d19bdd26b8bb0c8244dbd583a31a7e9aebb8944650e49e00885d9da6fd3c582eb51d49133ff60c48998ab
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
module BaseHelper
|
3
|
-
|
4
3
|
def available_countries
|
5
4
|
checkout_zone = Zone.find_by(name: Spree::Config[:checkout_zone])
|
6
5
|
|
7
|
-
if checkout_zone && checkout_zone.kind == 'country'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
countries = if checkout_zone && checkout_zone.kind == 'country'
|
7
|
+
checkout_zone.country_list
|
8
|
+
else
|
9
|
+
Country.all
|
10
|
+
end
|
12
11
|
|
13
12
|
countries.collect do |country|
|
14
13
|
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
|
@@ -33,27 +32,27 @@ module Spree
|
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
def logo(image_path=Spree::Config[:logo])
|
35
|
+
def logo(image_path = Spree::Config[:logo])
|
37
36
|
link_to image_tag(image_path), spree.respond_to?(:root_path) ? spree.root_path : main_app.root_path
|
38
37
|
end
|
39
38
|
|
40
39
|
def meta_data
|
41
|
-
object = instance_variable_get('@'+controller_name.singularize)
|
40
|
+
object = instance_variable_get('@' + controller_name.singularize)
|
42
41
|
meta = {}
|
43
42
|
|
44
|
-
if object.
|
43
|
+
if object.is_a? ApplicationRecord
|
45
44
|
meta[:keywords] = object.meta_keywords if object[:meta_keywords].present?
|
46
45
|
meta[:description] = object.meta_description if object[:meta_description].present?
|
47
46
|
end
|
48
47
|
|
49
|
-
if meta[:description].blank? && object.
|
48
|
+
if meta[:description].blank? && object.is_a?(Spree::Product)
|
50
49
|
meta[:description] = truncate(strip_tags(object.description), length: 160, separator: ' ')
|
51
50
|
end
|
52
51
|
|
53
|
-
meta.
|
54
|
-
keywords: current_store.meta_keywords,
|
55
|
-
|
56
|
-
|
52
|
+
if meta[:keywords].blank? || meta[:description].blank?
|
53
|
+
meta.reverse_merge!(keywords: current_store.meta_keywords,
|
54
|
+
description: current_store.meta_description)
|
55
|
+
end
|
57
56
|
meta
|
58
57
|
end
|
59
58
|
|
@@ -66,22 +65,22 @@ module Spree
|
|
66
65
|
def method_missing(method_name, *args, &block)
|
67
66
|
if image_style = image_style_from_method_name(method_name)
|
68
67
|
define_image_method(image_style)
|
69
|
-
|
68
|
+
send(method_name, *args)
|
70
69
|
else
|
71
70
|
super
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
74
|
def pretty_time(time)
|
76
|
-
[I18n.l(time.to_date, format: :long), time.strftime(
|
75
|
+
[I18n.l(time.to_date, format: :long), time.strftime('%l:%M %p')].join(' ')
|
77
76
|
end
|
78
77
|
|
79
78
|
def seo_url(taxon)
|
80
|
-
|
79
|
+
spree.nested_taxons_path(taxon.permalink)
|
81
80
|
end
|
82
81
|
|
83
82
|
# human readable list of variant options
|
84
|
-
def variant_options(v,
|
83
|
+
def variant_options(v, _options = {})
|
85
84
|
v.options_text
|
86
85
|
end
|
87
86
|
|
@@ -24,7 +24,7 @@ module Spree
|
|
24
24
|
def variant_full_price(variant)
|
25
25
|
product = variant.product
|
26
26
|
unless product.variants.active(current_currency).all? { |v| v.price == product.price }
|
27
|
-
Spree::Money.new(variant.price,
|
27
|
+
Spree::Money.new(variant.price, currency: current_currency).to_html
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ module Spree
|
|
38
38
|
description.blank? ? Spree.t(:product_has_no_description) : raw(description)
|
39
39
|
end
|
40
40
|
|
41
|
-
def line_item_description_text
|
41
|
+
def line_item_description_text(description_text)
|
42
42
|
if description_text.present?
|
43
43
|
truncate(strip_tags(description_text.gsub(' ', ' ').squish), length: 100)
|
44
44
|
else
|
@@ -50,16 +50,16 @@ module Spree
|
|
50
50
|
count = @products.count
|
51
51
|
max_updated_at = (@products.maximum(:updated_at) || Date.today).to_s(:number)
|
52
52
|
products_cache_keys = "spree/products/all-#{params[:page]}-#{max_updated_at}-#{count}"
|
53
|
-
(common_product_cache_keys + [products_cache_keys]).compact.join(
|
53
|
+
(common_product_cache_keys + [products_cache_keys]).compact.join('/')
|
54
54
|
end
|
55
55
|
|
56
56
|
def cache_key_for_product(product = @product)
|
57
|
-
(common_product_cache_keys + [product.cache_key, product.possible_promotions]).compact.join(
|
57
|
+
(common_product_cache_keys + [product.cache_key, product.possible_promotions]).compact.join('/')
|
58
58
|
end
|
59
59
|
|
60
60
|
def available_status(product) # will return a human readable string
|
61
61
|
return Spree.t(:discontinued) if product.discontinued?
|
62
|
-
return Spree.t(:deleted)
|
62
|
+
return Spree.t(:deleted) if product.deleted?
|
63
63
|
|
64
64
|
if product.available?
|
65
65
|
Spree.t(:available)
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
has_one
|
6
|
+
has_one :calculator, class_name: 'Spree::Calculator', as: :calculable, inverse_of: :calculable, dependent: :destroy, autosave: true
|
7
7
|
accepts_nested_attributes_for :calculator
|
8
8
|
validates :calculator, presence: true
|
9
9
|
delegate :compute, to: :calculator
|
@@ -18,12 +18,13 @@ module Spree
|
|
18
18
|
|
19
19
|
def calculator_type=(calculator_type)
|
20
20
|
klass = calculator_type.constantize if calculator_type
|
21
|
-
self.calculator = klass.new if klass && !
|
21
|
+
self.calculator = klass.new if klass && !calculator.is_a?(klass)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
|
+
|
25
26
|
def self.model_name_without_spree_namespace
|
26
|
-
|
27
|
+
to_s.tableize.tr('/', '_').sub('spree_', '')
|
27
28
|
end
|
28
29
|
|
29
30
|
def self.spree_calculators
|
@@ -4,9 +4,9 @@ module Spree
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
has_one :default_price,
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
-> { where currency: Spree::Config[:currency] },
|
8
|
+
class_name: 'Spree::Price',
|
9
|
+
dependent: :destroy
|
10
10
|
|
11
11
|
delegate :display_price, :display_amount, :price, :currency, :price=,
|
12
12
|
:price_including_vat_for, :currency=, to: :find_or_build_default_price
|
@@ -18,10 +18,9 @@ module Spree
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def has_default_price?
|
21
|
-
!
|
21
|
+
!default_price.nil?
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
24
|
def find_or_build_default_price
|
26
25
|
default_price || build_default_price
|
27
26
|
end
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
scope :active, -> { where(active: true) }
|
7
|
-
default_scope { order("LOWER(#{
|
7
|
+
default_scope { order("LOWER(#{table_name}.name)") }
|
8
8
|
|
9
9
|
validates :name, presence: true, uniqueness: { case_sensitive: false }
|
10
10
|
end
|
@@ -8,17 +8,16 @@ module Spree::RansackableAttributes
|
|
8
8
|
class_attribute :default_ransackable_attributes
|
9
9
|
self.default_ransackable_attributes = %w[id name updated_at created_at]
|
10
10
|
|
11
|
-
def self.ransackable_associations(*
|
12
|
-
|
11
|
+
def self.ransackable_associations(*_args)
|
12
|
+
whitelisted_ransackable_associations || []
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.ransackable_attributes(*
|
16
|
-
|
15
|
+
def self.ransackable_attributes(*_args)
|
16
|
+
default_ransackable_attributes | (whitelisted_ransackable_attributes || [])
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.ransackable_scopes(*
|
19
|
+
def self.ransackable_scopes(*_args)
|
20
20
|
whitelisted_ransackable_scopes || []
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
@@ -4,27 +4,27 @@ module Spree
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address',
|
7
|
-
|
7
|
+
optional: true
|
8
8
|
alias_attribute :billing_address, :bill_address
|
9
9
|
|
10
10
|
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address',
|
11
|
-
|
11
|
+
optional: true
|
12
12
|
alias_attribute :shipping_address, :ship_address
|
13
13
|
|
14
14
|
accepts_nested_attributes_for :ship_address, :bill_address
|
15
15
|
|
16
16
|
def persist_order_address(order)
|
17
|
-
b_address =
|
17
|
+
b_address = bill_address || build_bill_address
|
18
18
|
b_address.attributes = order.bill_address.attributes.except('id', 'updated_at', 'created_at')
|
19
19
|
b_address.save
|
20
|
-
|
20
|
+
update_attributes(bill_address_id: b_address.id)
|
21
21
|
|
22
22
|
# May not be present if delivery step has been removed
|
23
23
|
if order.ship_address
|
24
|
-
s_address =
|
24
|
+
s_address = ship_address || build_ship_address
|
25
25
|
s_address.attributes = order.ship_address.attributes.except('id', 'updated_at', 'created_at')
|
26
26
|
s_address.save
|
27
|
-
|
27
|
+
update_attributes(ship_address_id: s_address.id)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -17,7 +17,7 @@ module Spree
|
|
17
17
|
has_many :promotion_rule_users, class_name: 'Spree::PromotionRuleUser', foreign_key: :user_id, dependent: :destroy
|
18
18
|
has_many :promotion_rules, through: :promotion_rule_users, class_name: 'Spree::PromotionRule'
|
19
19
|
|
20
|
-
has_many :orders, foreign_key: :user_id, class_name:
|
20
|
+
has_many :orders, foreign_key: :user_id, class_name: 'Spree::Order'
|
21
21
|
has_many :store_credits, foreign_key: :user_id, class_name: 'Spree::StoreCredit'
|
22
22
|
|
23
23
|
belongs_to :ship_address, class_name: 'Spree::Address', optional: true
|
@@ -32,8 +32,8 @@ module Spree
|
|
32
32
|
spree_roles.any? { |role| role.name == role_in_question.to_s }
|
33
33
|
end
|
34
34
|
|
35
|
-
def last_incomplete_spree_order
|
36
|
-
orders.incomplete.
|
35
|
+
def last_incomplete_spree_order(store)
|
36
|
+
orders.where(store: store).incomplete.
|
37
37
|
includes(line_items: [variant: [:images, :option_values, :product]]).
|
38
38
|
order('created_at DESC').
|
39
39
|
first
|
@@ -3,8 +3,10 @@ module Spree
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
has_many :credit_cards, class_name:
|
7
|
-
def default_credit_card
|
6
|
+
has_many :credit_cards, class_name: 'Spree::CreditCard', foreign_key: :user_id
|
7
|
+
def default_credit_card
|
8
|
+
credit_cards.default.first
|
9
|
+
end
|
8
10
|
|
9
11
|
def payment_sources
|
10
12
|
credit_cards.with_payment_profile
|
data/app/models/spree/ability.rb
CHANGED
@@ -15,15 +15,15 @@ module Spree
|
|
15
15
|
# the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class
|
16
16
|
# and therefore should be easy to test in isolation.
|
17
17
|
def self.register_ability(ability)
|
18
|
-
|
18
|
+
abilities.add(ability)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.remove_ability(ability)
|
22
|
-
|
22
|
+
abilities.delete(ability)
|
23
23
|
end
|
24
24
|
|
25
25
|
def initialize(user)
|
26
|
-
|
26
|
+
clear_aliased_actions
|
27
27
|
|
28
28
|
# override cancan default aliasing (we don't want to differentiate between read and index)
|
29
29
|
alias_action :delete, to: :destroy
|
data/app/models/spree/address.rb
CHANGED
@@ -10,8 +10,8 @@ module Spree
|
|
10
10
|
'TO', 'TV', 'UG', 'AE', 'VU', 'YE', 'ZW'
|
11
11
|
].freeze
|
12
12
|
|
13
|
-
belongs_to :country, class_name:
|
14
|
-
belongs_to :state, class_name:
|
13
|
+
belongs_to :country, class_name: 'Spree::Country'
|
14
|
+
belongs_to :state, class_name: 'Spree::State', optional: true
|
15
15
|
|
16
16
|
has_many :shipments, inverse_of: :address
|
17
17
|
|
@@ -31,11 +31,15 @@ module Spree
|
|
31
31
|
self.whitelisted_ransackable_attributes = %w[firstname lastname company]
|
32
32
|
|
33
33
|
def self.build_default
|
34
|
-
country =
|
34
|
+
country = begin
|
35
|
+
Spree::Country.find(Spree::Config[:default_country_id])
|
36
|
+
rescue
|
37
|
+
Spree::Country.first
|
38
|
+
end
|
35
39
|
new(country: country)
|
36
40
|
end
|
37
41
|
|
38
|
-
def self.default(user = nil, kind =
|
42
|
+
def self.default(user = nil, kind = 'bill')
|
39
43
|
if user && user_address = user.public_send(:"#{kind}_address")
|
40
44
|
user_address.clone
|
41
45
|
else
|
@@ -68,11 +72,11 @@ module Spree
|
|
68
72
|
end
|
69
73
|
|
70
74
|
def clone
|
71
|
-
self.class.new(
|
75
|
+
self.class.new(attributes.except('id', 'updated_at', 'created_at'))
|
72
76
|
end
|
73
77
|
|
74
78
|
def ==(other_address)
|
75
|
-
self_attrs =
|
79
|
+
self_attrs = attributes
|
76
80
|
other_attrs = other_address.respond_to?(:attributes) ? other_address.attributes : {}
|
77
81
|
|
78
82
|
[self_attrs, other_attrs].each { |attrs| attrs.except!('id', 'created_at', 'updated_at') }
|
@@ -99,7 +103,7 @@ module Spree
|
|
99
103
|
end
|
100
104
|
|
101
105
|
def require_phone?
|
102
|
-
|
106
|
+
Spree::Config[:address_requires_phone]
|
103
107
|
end
|
104
108
|
|
105
109
|
def require_zipcode?
|
@@ -165,10 +169,10 @@ module Spree
|
|
165
169
|
|
166
170
|
def postal_code_validate
|
167
171
|
return if country.blank? || country.iso.blank? || !require_zipcode?
|
168
|
-
return
|
172
|
+
return unless TwitterCldr::Shared::PostalCodes.territories.include?(country.iso.downcase.to_sym)
|
169
173
|
|
170
174
|
postal_code = TwitterCldr::Shared::PostalCodes.for_territory(country.iso)
|
171
|
-
errors.add(:zipcode, :invalid)
|
175
|
+
errors.add(:zipcode, :invalid) unless postal_code.valid?(zipcode.to_s.strip)
|
172
176
|
end
|
173
177
|
end
|
174
178
|
end
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
|
27
27
|
def best_promo_adjustment
|
28
28
|
@best_promo_adjustment ||= begin
|
29
|
-
adjustments.competing_promos.eligible.reorder(
|
29
|
+
adjustments.competing_promos.eligible.reorder('amount ASC, created_at DESC, id DESC').first
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -29,8 +29,8 @@ module Spree
|
|
29
29
|
def persist_totals(totals)
|
30
30
|
attributes = totals
|
31
31
|
attributes[:adjustment_total] = totals[:non_taxable_adjustment_total] +
|
32
|
-
|
33
|
-
|
32
|
+
totals[:taxable_adjustment_total] +
|
33
|
+
totals[:additional_tax_total]
|
34
34
|
attributes[:updated_at] = Time.current
|
35
35
|
@adjustable.update_columns(totals)
|
36
36
|
end
|
@@ -16,7 +16,9 @@ module Spree
|
|
16
16
|
|
17
17
|
def initialize(adjustable)
|
18
18
|
@adjustable = adjustable
|
19
|
-
@adjustments
|
19
|
+
@adjustments = []
|
20
|
+
@sources = []
|
21
|
+
@promotions = []
|
20
22
|
all_adjustments.each { |a| add_adjustment(a) }
|
21
23
|
end
|
22
24
|
|
@@ -30,7 +32,7 @@ module Spree
|
|
30
32
|
add(promotions, promotion, source.promotion_id)
|
31
33
|
end
|
32
34
|
|
33
|
-
def promotions_adjustments(promotion_id, adjustments = adjustments
|
35
|
+
def promotions_adjustments(promotion_id, adjustments = adjustments)
|
34
36
|
where(sources, promotion_id: promotion_id).map do |source|
|
35
37
|
where(adjustments, source_id: source.id)
|
36
38
|
end.flatten
|
@@ -56,7 +58,7 @@ module Spree
|
|
56
58
|
|
57
59
|
def all_adjustments
|
58
60
|
order.all_adjustments.promotion.includes(source: [:promotion]).where.
|
59
|
-
not(
|
61
|
+
not('adjustable_id = ? AND adjustable_type = ?', adjustable.id, adjustable.class.to_s)
|
60
62
|
end
|
61
63
|
|
62
64
|
def add(array, object, id)
|
@@ -64,7 +66,7 @@ module Spree
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def item_adjustments
|
67
|
-
adjustments.
|
69
|
+
adjustments.reject { |a| a.adjustable_type == 'Spree::Shipment' }
|
68
70
|
end
|
69
71
|
|
70
72
|
def where(array, opts = {})
|
@@ -53,7 +53,7 @@ module Spree
|
|
53
53
|
scope :tax, -> { where(source_type: 'Spree::TaxRate') }
|
54
54
|
scope :non_tax, -> do
|
55
55
|
source_type = arel_table[:source_type]
|
56
|
-
where(source_type.not_eq('Spree::TaxRate').or
|
56
|
+
where(source_type.not_eq('Spree::TaxRate').or(source_type.eq(nil)))
|
57
57
|
end
|
58
58
|
scope :price, -> { where(adjustable_type: 'Spree::LineItem') }
|
59
59
|
scope :shipping, -> { where(adjustable_type: 'Spree::Shipment') }
|
@@ -63,7 +63,7 @@ module Spree
|
|
63
63
|
scope :credit, -> { where("#{quoted_table_name}.amount < 0") }
|
64
64
|
scope :nonzero, -> { where("#{quoted_table_name}.amount != 0") }
|
65
65
|
scope :promotion, -> { where(source_type: 'Spree::PromotionAction') }
|
66
|
-
scope :return_authorization, -> { where(source_type:
|
66
|
+
scope :return_authorization, -> { where(source_type: 'Spree::ReturnAuthorization') }
|
67
67
|
scope :is_included, -> { where(included: true) }
|
68
68
|
scope :additional, -> { where(included: false) }
|
69
69
|
scope :competing_promos, -> { where(source_type: competing_promos_source_types) }
|
@@ -99,6 +99,5 @@ module Spree
|
|
99
99
|
# Cause adjustable's total to be recalculated
|
100
100
|
Adjustable::AdjustmentsUpdater.update(adjustable)
|
101
101
|
end
|
102
|
-
|
103
102
|
end
|
104
103
|
end
|
@@ -15,12 +15,13 @@
|
|
15
15
|
# a.get :color
|
16
16
|
# a.preferred_color
|
17
17
|
#
|
18
|
-
require
|
18
|
+
require 'spree/core/search/base'
|
19
19
|
|
20
20
|
module Spree
|
21
21
|
class AppConfiguration < Preferences::Configuration
|
22
22
|
# Alphabetized to more easily lookup particular preferences
|
23
23
|
preference :address_requires_state, :boolean, default: true # should state/state_name be required
|
24
|
+
preference :address_requires_phone, :boolean, default: true # Determines whether we require phone in address
|
24
25
|
preference :admin_interface_logo, :string, default: 'admin/logo.png'
|
25
26
|
preference :admin_path, :string, default: '/admin'
|
26
27
|
preference :admin_products_per_page, :integer, default: Kaminari.config.default_per_page
|
@@ -41,7 +42,7 @@ module Spree
|
|
41
42
|
preference :binary_inventory_cache, :boolean, default: false # only invalidate product cache when a stock item changes whether it is in_stock
|
42
43
|
preference :checkout_zone, :string, default: nil # replace with the name of a zone if you would like to limit the countries
|
43
44
|
preference :company, :boolean, default: false # Request company field for billing and shipping addr
|
44
|
-
preference :currency, :string, default:
|
45
|
+
preference :currency, :string, default: 'USD'
|
45
46
|
preference :default_country_id, :integer
|
46
47
|
preference :expedited_exchanges, :boolean, default: false # NOTE this requires payment profiles to be supported on your gateway of choice as well as a delayed job handler to be configured with activejob. kicks off an exchange shipment upon return authorization save. charge customer if they do not return items within timely manner.
|
47
48
|
preference :expedited_exchanges_days_window, :integer, default: 14 # the amount of days the customer has to return their item after the expedited exchange is shipped in order to avoid being charged
|
@@ -55,7 +56,7 @@ module Spree
|
|
55
56
|
preference :send_core_emails, :boolean, default: true # Default mail headers settings
|
56
57
|
preference :shipping_instructions, :boolean, default: false # Request instructions/info for shipping
|
57
58
|
preference :show_only_complete_orders_by_default, :boolean, default: true
|
58
|
-
preference :show_variant_full_price, :boolean, default: false #Displays variant full price or difference with product price. Default false to be compatible with older behavior
|
59
|
+
preference :show_variant_full_price, :boolean, default: false # Displays variant full price or difference with product price. Default false to be compatible with older behavior
|
59
60
|
preference :show_products_without_price, :boolean, default: false
|
60
61
|
preference :show_raw_product_description, :boolean, default: false
|
61
62
|
preference :tax_using_ship_address, :boolean, default: true
|
@@ -70,8 +71,6 @@ module Spree
|
|
70
71
|
@searcher_class ||= Spree::Core::Search::Base
|
71
72
|
end
|
72
73
|
|
73
|
-
|
74
|
-
@searcher_class = sclass
|
75
|
-
end
|
74
|
+
attr_writer :searcher_class
|
76
75
|
end
|
77
76
|
end
|
data/app/models/spree/base.rb
CHANGED
@@ -11,14 +11,13 @@ module Spree
|
|
11
11
|
# Orders created before Spree 2.1 had tax adjustments applied to the order, as a whole.
|
12
12
|
# Orders created with Spree 2.2 and after, have them applied to the line items individually.
|
13
13
|
def compute_order(order)
|
14
|
-
|
15
14
|
matched_line_items = order.line_items.select do |line_item|
|
16
15
|
line_item.tax_category == rate.tax_category
|
17
16
|
end
|
18
17
|
|
19
18
|
line_items_total = matched_line_items.sum(&:total)
|
20
19
|
if rate.included_in_price
|
21
|
-
round_to_two_places(line_items_total - (
|
20
|
+
round_to_two_places(line_items_total - (line_items_total / (1 + rate.amount)))
|
22
21
|
else
|
23
22
|
round_to_two_places(line_items_total * rate.amount)
|
24
23
|
end
|
@@ -33,8 +32,8 @@ module Spree
|
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
alias compute_shipment compute_shipment_or_line_item
|
36
|
+
alias compute_line_item compute_shipment_or_line_item
|
38
37
|
|
39
38
|
def compute_shipping_rate(shipping_rate)
|
40
39
|
if rate.included_in_price
|
@@ -49,7 +48,7 @@ module Spree
|
|
49
48
|
private
|
50
49
|
|
51
50
|
def rate
|
52
|
-
|
51
|
+
calculable
|
53
52
|
end
|
54
53
|
|
55
54
|
def deduced_total_by_rate(pre_tax_amount, rate)
|
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def compute(object)
|
12
|
-
computed_amount
|
12
|
+
computed_amount = (object.amount * preferred_flat_percent / 100).round(2)
|
13
13
|
|
14
14
|
# We don't want to cause the promotion adjustments to push the order into a negative total.
|
15
15
|
if computed_amount > object.amount
|
@@ -3,14 +3,14 @@ require_dependency 'spree/calculator'
|
|
3
3
|
module Spree
|
4
4
|
class Calculator::FlatRate < Calculator
|
5
5
|
preference :amount, :decimal, default: 0
|
6
|
-
preference :currency, :string, default: ->{ Spree::Config[:currency] }
|
6
|
+
preference :currency, :string, default: -> { Spree::Config[:currency] }
|
7
7
|
|
8
8
|
def self.description
|
9
9
|
Spree.t(:flat_rate_per_order)
|
10
10
|
end
|
11
11
|
|
12
|
-
def compute(object=nil)
|
13
|
-
if object && preferred_currency.
|
12
|
+
def compute(object = nil)
|
13
|
+
if object && preferred_currency.casecmp(object.currency.upcase).zero?
|
14
14
|
preferred_amount
|
15
15
|
else
|
16
16
|
0
|
@@ -5,25 +5,25 @@ module Spree
|
|
5
5
|
preference :first_item, :decimal, default: 0.0
|
6
6
|
preference :additional_item, :decimal, default: 0.0
|
7
7
|
preference :max_items, :integer, default: 0
|
8
|
-
preference :currency, :string, default: ->{ Spree::Config[:currency] }
|
8
|
+
preference :currency, :string, default: -> { Spree::Config[:currency] }
|
9
9
|
|
10
10
|
def self.description
|
11
11
|
Spree.t(:flexible_rate)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.available?(
|
14
|
+
def self.available?(_object)
|
15
15
|
true
|
16
16
|
end
|
17
17
|
|
18
18
|
def compute(object)
|
19
19
|
sum = 0
|
20
|
-
max =
|
20
|
+
max = preferred_max_items.to_i
|
21
21
|
items_count = object.quantity
|
22
22
|
items_count.times do |i|
|
23
23
|
if i == 0
|
24
|
-
sum +=
|
24
|
+
sum += preferred_first_item.to_f
|
25
25
|
elsif ((max > 0) && (i <= (max - 1))) || (max == 0)
|
26
|
-
sum +=
|
26
|
+
sum += preferred_additional_item.to_f
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|