spree_core 2.0.13 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/base_controller.rb +3 -0
- data/app/helpers/spree/base_helper.rb +6 -16
- data/app/helpers/spree/products_helper.rb +3 -8
- data/app/helpers/spree/taxons_helper.rb +1 -1
- data/app/mailers/spree/base_mailer.rb +0 -5
- data/app/models/spree/ability.rb +10 -7
- data/app/models/spree/address.rb +7 -17
- data/app/models/spree/adjustment.rb +15 -11
- data/app/models/spree/app_configuration.rb +0 -5
- data/app/models/spree/billing_integration.rb +0 -1
- data/app/models/spree/calculator/flat_percent_item_total.rb +1 -3
- data/app/models/spree/calculator/flat_rate.rb +2 -4
- data/app/models/spree/calculator/flexi_rate.rb +6 -9
- data/app/models/spree/calculator/per_item.rb +2 -4
- data/app/models/spree/calculator/percent_per_item.rb +1 -3
- data/app/models/spree/calculator/price_sack.rb +4 -9
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -2
- data/app/models/spree/calculator/shipping/flat_rate.rb +2 -4
- data/app/models/spree/calculator/shipping/flexi_rate.rb +4 -9
- data/app/models/spree/calculator/shipping/per_item.rb +2 -3
- data/app/models/spree/calculator/shipping/price_sack.rb +4 -9
- data/app/models/spree/classification.rb +0 -3
- data/app/models/spree/country.rb +1 -3
- data/app/models/spree/credit_card.rb +37 -38
- data/app/models/spree/gateway/bogus_simple.rb +0 -8
- data/app/models/spree/gateway.rb +1 -3
- data/app/models/spree/image.rb +1 -3
- data/app/models/spree/inventory_unit.rb +5 -8
- data/app/models/spree/legacy_user.rb +0 -4
- data/app/models/spree/line_item.rb +2 -15
- data/app/models/spree/option_type.rb +2 -5
- data/app/models/spree/option_value.rb +1 -3
- data/app/models/spree/order/checkout.rb +4 -13
- data/app/models/spree/order.rb +47 -99
- data/app/models/spree/order_contents.rb +4 -7
- data/app/models/spree/order_inventory.rb +4 -8
- data/app/models/spree/order_updater.rb +13 -12
- data/app/models/spree/payment/processing.rb +12 -19
- data/app/models/spree/payment.rb +17 -30
- data/app/models/spree/payment_method.rb +2 -3
- data/app/models/spree/preference.rb +1 -1
- data/app/models/spree/preferences/configuration.rb +1 -1
- data/app/models/spree/preferences/preferable.rb +1 -1
- data/app/models/spree/preferences/store.rb +1 -1
- data/app/models/spree/price.rb +0 -7
- data/app/models/spree/product/scopes.rb +16 -17
- data/app/models/spree/product.rb +27 -62
- data/app/models/spree/product_property.rb +3 -5
- data/app/models/spree/promotion/actions/create_adjustment.rb +9 -8
- data/app/models/spree/promotion/actions/create_line_items.rb +1 -2
- data/app/models/spree/promotion/rules/first_order.rb +1 -1
- data/app/models/spree/promotion/rules/item_total.rb +2 -4
- data/app/models/spree/promotion/rules/product.rb +2 -2
- data/app/models/spree/promotion/rules/user.rb +1 -3
- data/app/models/spree/promotion.rb +23 -24
- data/app/models/spree/promotion_action.rb +0 -2
- data/app/models/spree/promotion_action_line_item.rb +1 -3
- data/app/models/spree/promotion_rule.rb +0 -2
- data/app/models/spree/property.rb +2 -4
- data/app/models/spree/prototype.rb +0 -2
- data/app/models/spree/return_authorization.rb +6 -9
- data/app/models/spree/role.rb +0 -2
- data/app/models/spree/shipment.rb +19 -25
- data/app/models/spree/shipping_calculator.rb +0 -2
- data/app/models/spree/shipping_category.rb +0 -2
- data/app/models/spree/shipping_method.rb +6 -20
- data/app/models/spree/shipping_rate.rb +12 -10
- data/app/models/spree/state.rb +2 -4
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/estimator.rb +6 -20
- data/app/models/spree/stock/packer.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +2 -3
- data/app/models/spree/stock/splitter/base.rb +1 -1
- data/app/models/spree/stock_item.rb +8 -18
- data/app/models/spree/stock_location.rb +2 -11
- data/app/models/spree/stock_movement.rb +2 -5
- data/app/models/spree/stock_transfer.rb +0 -2
- data/app/models/spree/tax_category.rb +0 -2
- data/app/models/spree/tax_rate.rb +12 -12
- data/app/models/spree/taxon.rb +1 -13
- data/app/models/spree/taxonomy.rb +3 -6
- data/app/models/spree/tracker.rb +0 -2
- data/app/models/spree/variant/scopes.rb +2 -2
- data/app/models/spree/variant.rb +13 -31
- data/app/models/spree/zone.rb +2 -7
- data/app/models/spree/zone_member.rb +0 -2
- data/app/views/spree/payments/_payment.html.erb +1 -3
- data/config/locales/en.yml +11 -26
- data/db/default/spree/countries.rb +230 -229
- data/db/default/spree/states.rb +57 -56
- data/db/default/spree/zones.rb +5 -5
- data/db/migrate/20130213191427_create_default_stock.rb +4 -7
- data/db/migrate/20130417120035_update_adjustment_states.rb +2 -2
- data/db/migrate/20130417123427_add_shipping_rates_to_shipments.rb +1 -1
- data/db/migrate/20130509115210_add_number_to_stock_transfer.rb +1 -1
- data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
- data/db/migrate/20130611185927_add_user_id_index_to_spree_orders.rb +5 -0
- data/db/migrate/20130618041418_add_updated_at_to_spree_countries.rb +9 -0
- data/db/migrate/20130619012236_add_updated_at_to_spree_states.rb +9 -0
- data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +4 -5
- data/db/migrate/20130806145853_set_default_stock_location_on_shipments.rb +1 -1
- data/lib/generators/spree/dummy/dummy_generator.rb +3 -14
- data/lib/generators/spree/dummy/templates/rails/database.yml +0 -10
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -7
- data/lib/generators/spree/install/install_generator.rb +11 -8
- data/lib/spree/core/calculated_adjustments.rb +9 -8
- data/lib/spree/core/controller_helpers/auth.rb +2 -3
- data/lib/spree/core/controller_helpers/order.rb +8 -13
- data/lib/spree/core/controller_helpers/ssl.rb +13 -22
- data/lib/spree/core/controller_helpers/strong_parameters.rb +36 -0
- data/lib/spree/core/delegate_belongs_to.rb +0 -2
- data/lib/spree/core/engine.rb +1 -5
- data/lib/spree/core/ext/active_record.rb +2 -9
- data/lib/spree/core/permalinks.rb +1 -5
- data/lib/spree/core/product_duplicator.rb +2 -16
- data/lib/spree/core/product_filters.rb +37 -33
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +3 -31
- data/lib/spree/i18n.rb +0 -1
- data/lib/spree/money.rb +2 -177
- data/lib/spree/permitted_attributes.rb +95 -0
- data/lib/spree/promo/coupon_applicator.rb +4 -12
- data/lib/spree/testing_support/capybara_ext.rb +13 -17
- data/lib/spree/testing_support/common_rake.rb +1 -1
- data/lib/spree/testing_support/controller_requests.rb +3 -3
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +0 -4
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +1 -3
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +0 -15
- data/lib/spree/testing_support/factories.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +1 -1
- data/lib/tasks/core.rake +2 -2
- data/vendor/assets/javascripts/jquery.payment.js +497 -0
- metadata +166 -172
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -17
- data/db/migrate/20130417120034_add_index_to_source_columns_on_adjustments.rb +0 -5
- data/db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb +0 -15
- data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +0 -19
- data/db/migrate/20130909115621_change_states_required_for_countries.rb +0 -9
- data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +0 -12
- data/db/migrate/20131026154747_add_track_inventory_to_variant.rb +0 -5
- data/db/migrate/20131113035136_add_channel_to_spree_orders.rb +0 -5
- data/db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb +0 -5
- data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +0 -11
- data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +0 -5
- data/lib/spree/core/preference_rescue.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9cba2b6dea5945419319d944c119f1a1c74de1a8
|
|
4
|
+
data.tar.gz: b8f83cbeb8810e3436fcbe3221f671c8e60c95fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e83e8be4a6963a38ce47a7812363f43616ab10487d579dff3919480a9471df507bd8b2ee2434bbca5e1310eda105250d1c971f5132319504d13c588639c49532
|
|
7
|
+
data.tar.gz: eaf05a02e45b23144edbc3b478593b4263196147c2c19981a0208e80f66695486ebe07deb5068b8a6ffad7c4418820ec1e9e89bb41f09eb80d35673eabc74a79
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'cancan'
|
|
2
|
+
require_dependency 'spree/core/controller_helpers/strong_parameters'
|
|
2
3
|
|
|
3
4
|
class Spree::BaseController < ApplicationController
|
|
4
5
|
include Spree::Core::ControllerHelpers::Auth
|
|
@@ -6,6 +7,8 @@ class Spree::BaseController < ApplicationController
|
|
|
6
7
|
include Spree::Core::ControllerHelpers::SSL
|
|
7
8
|
include Spree::Core::ControllerHelpers::Common
|
|
8
9
|
include Spree::Core::ControllerHelpers::Search
|
|
10
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
|
11
|
+
include Spree::Core::ControllerHelpers::Search
|
|
9
12
|
|
|
10
13
|
respond_to :html
|
|
11
14
|
end
|
|
@@ -18,7 +18,7 @@ module Spree
|
|
|
18
18
|
text = text ? h(text) : Spree.t('cart')
|
|
19
19
|
css_class = nil
|
|
20
20
|
|
|
21
|
-
if current_order.nil? or current_order.
|
|
21
|
+
if current_order.nil? or current_order.item_count.zero?
|
|
22
22
|
text = "#{text}: (#{Spree.t('empty')})"
|
|
23
23
|
css_class = 'empty'
|
|
24
24
|
else
|
|
@@ -34,7 +34,7 @@ module Spree
|
|
|
34
34
|
v.options_text
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def
|
|
37
|
+
def meta_data_tags
|
|
38
38
|
object = instance_variable_get('@'+controller_name.singularize)
|
|
39
39
|
meta = {}
|
|
40
40
|
|
|
@@ -51,11 +51,8 @@ module Spree
|
|
|
51
51
|
keywords: Spree::Config[:default_meta_keywords],
|
|
52
52
|
description: Spree::Config[:default_meta_description]
|
|
53
53
|
})
|
|
54
|
-
meta
|
|
55
|
-
end
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
meta_data.map do |name, content|
|
|
55
|
+
meta.map do |name, content|
|
|
59
56
|
tag('meta', name: name, content: content)
|
|
60
57
|
end.join("\n")
|
|
61
58
|
end
|
|
@@ -109,7 +106,7 @@ module Spree
|
|
|
109
106
|
end
|
|
110
107
|
|
|
111
108
|
def available_countries
|
|
112
|
-
checkout_zone = Zone.
|
|
109
|
+
checkout_zone = Zone.find_by(name: Spree::Config[:checkout_zone])
|
|
113
110
|
|
|
114
111
|
if checkout_zone && checkout_zone.kind == 'country'
|
|
115
112
|
countries = checkout_zone.country_list
|
|
@@ -120,7 +117,7 @@ module Spree
|
|
|
120
117
|
countries.collect do |country|
|
|
121
118
|
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
|
|
122
119
|
country
|
|
123
|
-
end.
|
|
120
|
+
end.sort { |a, b| a.name <=> b.name }
|
|
124
121
|
end
|
|
125
122
|
|
|
126
123
|
def seo_url(taxon)
|
|
@@ -135,11 +132,6 @@ module Spree
|
|
|
135
132
|
Gem.available?(name)
|
|
136
133
|
end
|
|
137
134
|
|
|
138
|
-
def money(amount)
|
|
139
|
-
ActiveSupport::Deprecation.warn("[SPREE] Spree::BaseHelper#money will be deprecated. It relies upon a single master currency. You can instead create a Spree::Money.new(amount, { :currency => your_currency}) or see if the object you're working with returns a Spree::Money object to use.")
|
|
140
|
-
Spree::Money.new(amount)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
135
|
def display_price(product_or_variant)
|
|
144
136
|
product_or_variant.price_in(current_currency).display_price.to_html
|
|
145
137
|
end
|
|
@@ -169,10 +161,9 @@ module Spree
|
|
|
169
161
|
end
|
|
170
162
|
|
|
171
163
|
private
|
|
172
|
-
|
|
173
164
|
# Returns style of image or nil
|
|
174
165
|
def image_style_from_method_name(method_name)
|
|
175
|
-
if
|
|
166
|
+
if style = method_name.to_s.sub(/_image$/, '')
|
|
176
167
|
possible_styles = Spree::Image.attachment_definitions[:attachment][:styles]
|
|
177
168
|
style if style.in? possible_styles.with_indifferent_access
|
|
178
169
|
end
|
|
@@ -201,6 +192,5 @@ module Spree
|
|
|
201
192
|
end
|
|
202
193
|
end
|
|
203
194
|
end
|
|
204
|
-
|
|
205
195
|
end
|
|
206
196
|
end
|
|
@@ -40,14 +40,9 @@ module Spree
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def line_item_description(variant)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def line_item_description_text description_text
|
|
49
|
-
if description_text.present?
|
|
50
|
-
truncate(strip_tags(description_text.gsub(' ', ' ')), length: 100)
|
|
43
|
+
description = variant.product.description
|
|
44
|
+
if description.present?
|
|
45
|
+
truncate(strip_tags(description.gsub(' ', ' ')), length: 100)
|
|
51
46
|
else
|
|
52
47
|
Spree.t(:product_has_no_description)
|
|
53
48
|
end
|
|
@@ -5,7 +5,7 @@ module Spree
|
|
|
5
5
|
# to show the most popular products for a particular taxon (that is an exercise left to the developer.)
|
|
6
6
|
def taxon_preview(taxon, max=4)
|
|
7
7
|
products = taxon.active_products.limit(max)
|
|
8
|
-
if (products.size < max)
|
|
8
|
+
if (products.size < max)
|
|
9
9
|
taxon.descendants.each do |taxon|
|
|
10
10
|
to_get = max - products.length
|
|
11
11
|
products += taxon.active_products.limit(to_get)
|
data/app/models/spree/ability.rb
CHANGED
|
@@ -26,40 +26,43 @@ module Spree
|
|
|
26
26
|
self.clear_aliased_actions
|
|
27
27
|
|
|
28
28
|
# override cancan default aliasing (we don't want to differentiate between read and index)
|
|
29
|
+
alias_action :delete, to: :destroy
|
|
29
30
|
alias_action :edit, to: :update
|
|
30
31
|
alias_action :new, to: :create
|
|
31
32
|
alias_action :new_action, to: :create
|
|
32
33
|
alias_action :show, to: :read
|
|
33
|
-
alias_action :delete, to: :destroy
|
|
34
34
|
|
|
35
35
|
user ||= Spree.user_class.new
|
|
36
|
+
|
|
36
37
|
if user.respond_to?(:has_spree_role?) && user.has_spree_role?('admin')
|
|
37
38
|
can :manage, :all
|
|
38
39
|
else
|
|
39
|
-
|
|
40
|
-
can [:read
|
|
41
|
-
can :
|
|
42
|
-
|
|
40
|
+
can [:index, :read], Country
|
|
41
|
+
can [:index, :read], OptionType
|
|
42
|
+
can [:index, :read], OptionValue
|
|
43
|
+
can :create, Order
|
|
43
44
|
can :read, Order do |order, token|
|
|
44
45
|
order.user == user || order.token && token == order.token
|
|
45
46
|
end
|
|
46
47
|
can :update, Order do |order, token|
|
|
47
48
|
order.user == user || order.token && token == order.token
|
|
48
49
|
end
|
|
49
|
-
can :create, Order
|
|
50
50
|
can [:index, :read], Product
|
|
51
51
|
can [:index, :read], ProductProperty
|
|
52
52
|
can [:index, :read], Property
|
|
53
53
|
can :create, Spree.user_class
|
|
54
54
|
can [:read, :update, :destroy], Spree.user_class, id: user.id
|
|
55
55
|
can [:index, :read], State
|
|
56
|
+
can [:index, :read], StockItem
|
|
57
|
+
can [:index, :read], StockLocation
|
|
58
|
+
can [:index, :read], StockMovement
|
|
56
59
|
can [:index, :read], Taxon
|
|
57
60
|
can [:index, :read], Taxonomy
|
|
58
61
|
can [:index, :read], Variant
|
|
59
62
|
can [:index, :read], Zone
|
|
60
63
|
end
|
|
61
64
|
|
|
62
|
-
#
|
|
65
|
+
# Include any abilities registered by extensions, etc.
|
|
63
66
|
Ability.abilities.each do |clazz|
|
|
64
67
|
ability = clazz.send(:new, user)
|
|
65
68
|
@rules = rules + ability.send(:rules)
|
data/app/models/spree/address.rb
CHANGED
|
@@ -5,30 +5,18 @@ module Spree
|
|
|
5
5
|
|
|
6
6
|
has_many :shipments
|
|
7
7
|
|
|
8
|
-
validates :firstname, :lastname, :address1, :city, :
|
|
8
|
+
validates :firstname, :lastname, :address1, :city, :country, presence: true
|
|
9
|
+
validates :zipcode, presence: true, if: :require_zipcode?
|
|
9
10
|
validates :phone, presence: true, if: :require_phone?
|
|
10
11
|
|
|
11
12
|
validate :state_validate
|
|
12
13
|
|
|
13
|
-
attr_accessible :firstname, :lastname, :address1, :address2,
|
|
14
|
-
:city, :zipcode, :country_id, :state_id,
|
|
15
|
-
:country, :state, :phone, :state_name,
|
|
16
|
-
:company, :alternative_phone
|
|
17
|
-
|
|
18
14
|
alias_attribute :first_name, :firstname
|
|
19
15
|
alias_attribute :last_name, :lastname
|
|
20
16
|
|
|
21
|
-
# Disconnected since there's no code to display error messages yet OR matching client-side validation
|
|
22
|
-
def phone_validate
|
|
23
|
-
return if phone.blank?
|
|
24
|
-
n_digits = phone.scan(/[0-9]/).size
|
|
25
|
-
valid_chars = (phone =~ /^[-+()\/\s\d]+$/)
|
|
26
|
-
errors.add :phone, :invalid unless (n_digits > 5 && valid_chars)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
17
|
def self.default
|
|
30
18
|
country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
|
|
31
|
-
new(
|
|
19
|
+
new(country: country)
|
|
32
20
|
end
|
|
33
21
|
|
|
34
22
|
# Can modify an address if it's not been used in an order (but checkouts controller has finer control)
|
|
@@ -87,11 +75,14 @@ module Spree
|
|
|
87
75
|
end
|
|
88
76
|
|
|
89
77
|
private
|
|
90
|
-
|
|
91
78
|
def require_phone?
|
|
92
79
|
true
|
|
93
80
|
end
|
|
94
81
|
|
|
82
|
+
def require_zipcode?
|
|
83
|
+
true
|
|
84
|
+
end
|
|
85
|
+
|
|
95
86
|
def state_validate
|
|
96
87
|
# Skip state validation without country (also required)
|
|
97
88
|
# or when disabled by preference
|
|
@@ -128,6 +119,5 @@ module Spree
|
|
|
128
119
|
# ensure at least one state field is populated
|
|
129
120
|
errors.add :state, :blank if state.blank? && state_name.blank?
|
|
130
121
|
end
|
|
131
|
-
|
|
132
122
|
end
|
|
133
123
|
end
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
# it might be reinstated.
|
|
25
25
|
module Spree
|
|
26
26
|
class Adjustment < ActiveRecord::Base
|
|
27
|
-
attr_accessible :amount, :label
|
|
28
|
-
|
|
29
27
|
belongs_to :adjustable, polymorphic: true
|
|
30
28
|
belongs_to :source, polymorphic: true
|
|
31
29
|
belongs_to :originator, polymorphic: true
|
|
@@ -55,8 +53,8 @@ module Spree
|
|
|
55
53
|
scope :shipping, -> { where(originator_type: 'Spree::ShippingMethod') }
|
|
56
54
|
scope :optional, -> { where(mandatory: false) }
|
|
57
55
|
scope :eligible, -> { where(eligible: true) }
|
|
58
|
-
scope :charge, -> { where(
|
|
59
|
-
scope :credit, -> { where(
|
|
56
|
+
scope :charge, -> { where('amount >= 0') }
|
|
57
|
+
scope :credit, -> { where('amount < 0') }
|
|
60
58
|
scope :promotion, -> { where(originator_type: 'Spree::PromotionAction') }
|
|
61
59
|
scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") }
|
|
62
60
|
|
|
@@ -68,7 +66,7 @@ module Spree
|
|
|
68
66
|
# count towards the order's adjustment_total.
|
|
69
67
|
def set_eligibility
|
|
70
68
|
result = mandatory || ((amount != 0 || promotion?) && eligible_for_originator?)
|
|
71
|
-
|
|
69
|
+
update_column(:eligible, result)
|
|
72
70
|
end
|
|
73
71
|
|
|
74
72
|
# Allow originator of the adjustment to perform an additional eligibility of the adjustment
|
|
@@ -82,17 +80,23 @@ module Spree
|
|
|
82
80
|
# delegate updating of amount to their Originator when present, but only if
|
|
83
81
|
# +locked+ is false. Adjustments that are +locked+ will never change their amount.
|
|
84
82
|
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
|
|
83
|
+
# Adjustments delegate updating of amount to their Originator when present,
|
|
84
|
+
# but only if when they're in "open" state, closed or finalized adjustments
|
|
85
|
+
# are not recalculated.
|
|
86
|
+
#
|
|
87
|
+
# It receives +calculable+ as the updated source here so calculations can be
|
|
88
|
+
# performed on the current values of that source. If we used +source+ it
|
|
89
|
+
# could load the old record from db for the association. e.g. when updating
|
|
90
|
+
# more than on line items at once via accepted_nested_attributes the order
|
|
91
|
+
# object on the association would be in a old state and therefore the
|
|
92
|
+
# adjustment calculations would not performed on proper values
|
|
93
|
+
def update!(calculable = nil)
|
|
89
94
|
return if immutable?
|
|
90
95
|
# Fix for #3381
|
|
91
96
|
# If we attempt to call 'source' before the reload, then source is currently
|
|
92
97
|
# the order object. After calling a reload, the source is the Shipment.
|
|
93
98
|
reload
|
|
94
|
-
calculable
|
|
95
|
-
originator.update_adjustment(self, calculable) if originator.present?
|
|
99
|
+
originator.update_adjustment(self, calculable || source) if originator.present?
|
|
96
100
|
set_eligibility
|
|
97
101
|
end
|
|
98
102
|
|
|
@@ -32,17 +32,14 @@ module Spree
|
|
|
32
32
|
preference :allow_ssl_in_staging, :boolean, default: true
|
|
33
33
|
preference :alternative_billing_phone, :boolean, default: false # Request extra phone for bill addr
|
|
34
34
|
preference :alternative_shipping_phone, :boolean, default: false # Request extra phone for ship addr
|
|
35
|
-
preference :always_include_confirm_step, :boolean, default: false # Ensures confirmation step is always in checkout_progress bar, but does not force a confirm step if your payment methods do not support it.
|
|
36
35
|
preference :always_put_site_name_in_title, :boolean, default: true
|
|
37
36
|
preference :auto_capture, :boolean, default: false # automatically capture the credit card (as opposed to just authorize and capture later)
|
|
38
|
-
preference :cache_static_content, :boolean, default: true
|
|
39
37
|
preference :check_for_spree_alerts, :boolean, default: true
|
|
40
38
|
preference :checkout_zone, :string, default: nil # replace with the name of a zone if you would like to limit the countries
|
|
41
39
|
preference :company, :boolean, default: false # Request company field for billing and shipping addr
|
|
42
40
|
preference :currency, :string, default: "USD"
|
|
43
41
|
preference :currency_decimal_mark, :string, default: "."
|
|
44
42
|
preference :currency_symbol_position, :string, default: "before"
|
|
45
|
-
preference :currency_sign_before_symbol, :boolean, default: true
|
|
46
43
|
preference :currency_thousands_separator, :string, default: ","
|
|
47
44
|
preference :display_currency, :boolean, default: false
|
|
48
45
|
preference :default_country_id, :integer
|
|
@@ -62,7 +59,6 @@ module Spree
|
|
|
62
59
|
preference :require_master_price, :boolean, default: true
|
|
63
60
|
preference :shipment_inc_vat, :boolean, default: false
|
|
64
61
|
preference :shipping_instructions, :boolean, default: false # Request instructions/info for shipping
|
|
65
|
-
preference :show_descendents, :boolean, default: true
|
|
66
62
|
preference :show_only_complete_orders_by_default, :boolean, default: true
|
|
67
63
|
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
|
|
68
64
|
preference :show_products_without_price, :boolean, default: false
|
|
@@ -88,7 +84,6 @@ module Spree
|
|
|
88
84
|
|
|
89
85
|
# Default mail headers settings
|
|
90
86
|
preference :enable_mail_delivery, :boolean, :default => false
|
|
91
|
-
preference :send_core_emails, :boolean, :default => true
|
|
92
87
|
preference :mails_from, :string, :default => 'spree@example.com'
|
|
93
88
|
preference :mail_bcc, :string, :default => 'spree@example.com'
|
|
94
89
|
preference :intercept_email, :string, :default => nil
|
|
@@ -8,7 +8,6 @@ module Spree
|
|
|
8
8
|
def provider
|
|
9
9
|
integration_options = options
|
|
10
10
|
ActiveMerchant::Billing::Base.integration_mode = integration_options[:server].to_sym
|
|
11
|
-
integration_options = options
|
|
12
11
|
integration_options[:test] = true if integration_options[:test_mode]
|
|
13
12
|
@provider ||= provider_class.new(integration_options)
|
|
14
13
|
end
|
|
@@ -2,9 +2,7 @@ require_dependency 'spree/calculator'
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
class Calculator::FlatPercentItemTotal < Calculator
|
|
5
|
-
preference :flat_percent, :decimal, :
|
|
6
|
-
|
|
7
|
-
attr_accessible :preferred_flat_percent
|
|
5
|
+
preference :flat_percent, :decimal, default: 0
|
|
8
6
|
|
|
9
7
|
def self.description
|
|
10
8
|
Spree.t(:flat_percent)
|
|
@@ -2,10 +2,8 @@ require_dependency 'spree/calculator'
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
class Calculator::FlatRate < Calculator
|
|
5
|
-
preference :amount, :decimal, :
|
|
6
|
-
preference :currency, :string, :
|
|
7
|
-
|
|
8
|
-
attr_accessible :preferred_amount, :preferred_currency
|
|
5
|
+
preference :amount, :decimal, default: 0
|
|
6
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
9
7
|
|
|
10
8
|
def self.description
|
|
11
9
|
Spree.t(:flat_rate_per_order)
|
|
@@ -2,12 +2,10 @@ require_dependency 'spree/calculator'
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
class Calculator::FlexiRate < Calculator
|
|
5
|
-
preference :first_item, :decimal, :
|
|
6
|
-
preference :additional_item, :decimal, :
|
|
7
|
-
preference :max_items, :integer, :
|
|
8
|
-
preference :currency, :string, :
|
|
9
|
-
|
|
10
|
-
attr_accessible :preferred_first_item, :preferred_additional_item, :preferred_max_items, :preferred_currency
|
|
5
|
+
preference :first_item, :decimal, default: 0.0
|
|
6
|
+
preference :additional_item, :decimal, default: 0.0
|
|
7
|
+
preference :max_items, :integer, default: 0
|
|
8
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
11
9
|
|
|
12
10
|
def self.description
|
|
13
11
|
Spree.t(:flexible_rate)
|
|
@@ -22,10 +20,9 @@ module Spree
|
|
|
22
20
|
max = self.preferred_max_items.to_i
|
|
23
21
|
items_count = object.line_items.map(&:quantity).sum
|
|
24
22
|
items_count.times do |i|
|
|
25
|
-
|
|
26
|
-
if (max == 0 && i == 0) || (max > 0) && (i % max == 0)
|
|
23
|
+
if i == 0
|
|
27
24
|
sum += self.preferred_first_item.to_f
|
|
28
|
-
|
|
25
|
+
elsif ((max > 0) && (i <= (max - 1))) || (max == 0)
|
|
29
26
|
sum += self.preferred_additional_item.to_f
|
|
30
27
|
end
|
|
31
28
|
end
|
|
@@ -2,10 +2,8 @@ require_dependency 'spree/calculator'
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
class Calculator::PerItem < Calculator
|
|
5
|
-
preference :amount, :decimal, :
|
|
6
|
-
preference :currency, :string, :
|
|
7
|
-
|
|
8
|
-
attr_accessible :preferred_amount, :preferred_currency
|
|
5
|
+
preference :amount, :decimal, default: 0
|
|
6
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
9
7
|
|
|
10
8
|
def self.description
|
|
11
9
|
Spree.t(:flat_rate_per_item)
|
|
@@ -6,9 +6,7 @@ module Spree
|
|
|
6
6
|
# off the entire order.
|
|
7
7
|
|
|
8
8
|
class Calculator::PercentPerItem < Calculator
|
|
9
|
-
preference :percent, :decimal, :
|
|
10
|
-
|
|
11
|
-
attr_accessible :preferred_percent
|
|
9
|
+
preference :percent, :decimal, default: 0
|
|
12
10
|
|
|
13
11
|
def self.description
|
|
14
12
|
Spree.t(:percent_per_item)
|
|
@@ -4,15 +4,10 @@ require 'bigdecimal/util'
|
|
|
4
4
|
|
|
5
5
|
module Spree
|
|
6
6
|
class Calculator::PriceSack < Calculator
|
|
7
|
-
preference :minimal_amount, :decimal, :
|
|
8
|
-
preference :normal_amount, :decimal, :
|
|
9
|
-
preference :discount_amount, :decimal, :
|
|
10
|
-
preference :currency, :string, :
|
|
11
|
-
|
|
12
|
-
attr_accessible :preferred_minimal_amount,
|
|
13
|
-
:preferred_normal_amount,
|
|
14
|
-
:preferred_discount_amount,
|
|
15
|
-
:preferred_currency
|
|
7
|
+
preference :minimal_amount, :decimal, default: 0
|
|
8
|
+
preference :normal_amount, :decimal, default: 0
|
|
9
|
+
preference :discount_amount, :decimal, default: 0
|
|
10
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
16
11
|
|
|
17
12
|
def self.description
|
|
18
13
|
Spree.t(:price_sack)
|
|
@@ -3,8 +3,7 @@ require_dependency 'spree/shipping_calculator'
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Calculator::Shipping
|
|
5
5
|
class FlatPercentItemTotal < ShippingCalculator
|
|
6
|
-
preference :flat_percent, :decimal, :
|
|
7
|
-
attr_accessible :preferred_flat_percent
|
|
6
|
+
preference :flat_percent, :decimal, default: 0
|
|
8
7
|
|
|
9
8
|
def self.description
|
|
10
9
|
Spree.t(:flat_percent)
|
|
@@ -3,10 +3,8 @@ require_dependency 'spree/shipping_calculator'
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Calculator::Shipping
|
|
5
5
|
class FlatRate < ShippingCalculator
|
|
6
|
-
preference :amount, :decimal, :
|
|
7
|
-
preference :currency, :string, :
|
|
8
|
-
|
|
9
|
-
attr_accessible :preferred_amount, :preferred_currency
|
|
6
|
+
preference :amount, :decimal, default: 0
|
|
7
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
10
8
|
|
|
11
9
|
def self.description
|
|
12
10
|
Spree.t(:shipping_flat_rate_per_order)
|
|
@@ -3,15 +3,10 @@ require_dependency 'spree/shipping_calculator'
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Calculator::Shipping
|
|
5
5
|
class FlexiRate < ShippingCalculator
|
|
6
|
-
preference :first_item, :decimal, :
|
|
7
|
-
preference :additional_item, :decimal, :
|
|
8
|
-
preference :max_items, :integer, :
|
|
9
|
-
preference :currency, :string, :
|
|
10
|
-
|
|
11
|
-
attr_accessible :preferred_first_item,
|
|
12
|
-
:preferred_additional_item,
|
|
13
|
-
:preferred_max_items,
|
|
14
|
-
:preferred_currency
|
|
6
|
+
preference :first_item, :decimal, default: 0.0
|
|
7
|
+
preference :additional_item, :decimal, default: 0.0
|
|
8
|
+
preference :max_items, :integer, default: 0
|
|
9
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
15
10
|
|
|
16
11
|
def self.description
|
|
17
12
|
Spree.t(:shipping_flexible_rate)
|
|
@@ -3,9 +3,8 @@ require_dependency 'spree/shipping_calculator'
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Calculator::Shipping
|
|
5
5
|
class PerItem < ShippingCalculator
|
|
6
|
-
preference :amount, :decimal, :
|
|
7
|
-
preference :currency, :string, :
|
|
8
|
-
attr_accessible :preferred_amount, :preferred_currency
|
|
6
|
+
preference :amount, :decimal, default: 0
|
|
7
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
9
8
|
|
|
10
9
|
def self.description
|
|
11
10
|
Spree.t(:shipping_flat_rate_per_item)
|
|
@@ -5,15 +5,10 @@ require 'bigdecimal/util'
|
|
|
5
5
|
module Spree
|
|
6
6
|
module Calculator::Shipping
|
|
7
7
|
class PriceSack < ShippingCalculator
|
|
8
|
-
preference :minimal_amount, :decimal, :
|
|
9
|
-
preference :normal_amount, :decimal, :
|
|
10
|
-
preference :discount_amount, :decimal, :
|
|
11
|
-
preference :currency, :string, :
|
|
12
|
-
|
|
13
|
-
attr_accessible :preferred_minimal_amount,
|
|
14
|
-
:preferred_normal_amount,
|
|
15
|
-
:preferred_discount_amount,
|
|
16
|
-
:preferred_currency
|
|
8
|
+
preference :minimal_amount, :decimal, default: 0
|
|
9
|
+
preference :normal_amount, :decimal, default: 0
|
|
10
|
+
preference :discount_amount, :decimal, default: 0
|
|
11
|
+
preference :currency, :string, default: Spree::Config[:currency]
|
|
17
12
|
|
|
18
13
|
def self.description
|
|
19
14
|
Spree.t(:shipping_price_sack)
|
|
@@ -3,8 +3,5 @@ module Spree
|
|
|
3
3
|
self.table_name = 'spree_products_taxons'
|
|
4
4
|
belongs_to :product, class_name: "Spree::Product"
|
|
5
5
|
belongs_to :taxon, class_name: "Spree::Taxon"
|
|
6
|
-
|
|
7
|
-
# For #3494
|
|
8
|
-
validates_uniqueness_of :taxon_id, :scope => :product_id, :message => :already_linked
|
|
9
6
|
end
|
|
10
7
|
end
|
data/app/models/spree/country.rb
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
class Country < ActiveRecord::Base
|
|
3
|
-
has_many :states,
|
|
3
|
+
has_many :states, -> { order('name ASC') }
|
|
4
4
|
|
|
5
5
|
validates :name, :iso_name, presence: true
|
|
6
6
|
|
|
7
|
-
attr_accessible :name, :iso_name, :states_required
|
|
8
|
-
|
|
9
7
|
def self.states_required_by_country_id
|
|
10
8
|
states_required = Hash.new(true)
|
|
11
9
|
all.each { |country| states_required[country.id.to_s]= country.states_required }
|