solidus_core 2.2.2 → 2.3.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.
- checksums.yaml +4 -4
- data/README.md +4 -7
- data/app/assets/javascripts/spree.js.erb +2 -2
- data/app/helpers/spree/base_helper.rb +3 -4
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/adjustment.rb +3 -1
- data/app/models/spree/app_configuration.rb +43 -0
- data/app/models/spree/billing_integration.rb +2 -2
- data/app/models/spree/calculator/default_tax.rb +3 -1
- data/app/models/spree/calculator/distributed_amount.rb +24 -0
- data/app/models/spree/calculator/free_shipping.rb +0 -1
- data/app/models/spree/calculator/tiered_flat_rate.rb +17 -3
- data/app/models/spree/calculator/tiered_percent.rb +18 -3
- data/app/models/spree/distributed_amounts_handler.rb +43 -0
- data/app/models/spree/gateway/bogus.rb +7 -83
- data/app/models/spree/gateway/bogus_simple.rb +7 -20
- data/app/models/spree/gateway.rb +8 -58
- data/app/models/spree/image.rb +1 -1
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order/checkout.rb +1 -4
- data/app/models/spree/order/number_generator.rb +43 -0
- data/app/models/spree/order.rb +33 -38
- data/app/models/spree/order_contents.rb +1 -1
- data/app/models/spree/order_taxation.rb +79 -0
- data/app/models/spree/order_update_attributes.rb +0 -2
- data/app/models/spree/order_updater.rb +55 -33
- data/app/models/spree/payment.rb +0 -1
- data/app/models/spree/payment_method/bogus_credit_card.rb +87 -0
- data/app/models/spree/payment_method/check.rb +14 -6
- data/app/models/spree/payment_method/credit_card.rb +41 -0
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +24 -0
- data/app/models/spree/payment_method/store_credit.rb +5 -13
- data/app/models/spree/payment_method.rb +126 -40
- data/app/models/spree/preferences/preferable.rb +5 -1
- data/app/models/spree/preferences/store.rb +2 -2
- data/app/models/spree/product/scopes.rb +14 -1
- data/app/models/spree/product.rb +10 -4
- data/app/models/spree/promotion_action.rb +4 -0
- data/app/models/spree/promotion_code/batch_builder.rb +3 -2
- data/app/models/spree/promotion_rule.rb +4 -0
- data/app/models/spree/role.rb +2 -0
- data/app/models/spree/role_user.rb +2 -0
- data/app/models/spree/shipment.rb +4 -2
- data/app/models/spree/shipping_method.rb +3 -1
- data/app/models/spree/shipping_rate.rb +1 -1
- data/app/models/spree/state.rb +10 -2
- data/app/models/spree/stock_item.rb +3 -3
- data/app/models/spree/store.rb +5 -0
- data/app/models/spree/store_credit.rb +2 -2
- data/app/models/spree/store_credit_event.rb +1 -1
- data/app/models/spree/store_selector/by_server_name.rb +30 -0
- data/app/models/spree/store_selector/legacy.rb +48 -0
- data/app/models/spree/tax/item_tax.rb +20 -0
- data/app/models/spree/tax/order_adjuster.rb +2 -14
- data/app/models/spree/tax/order_tax.rb +18 -0
- data/app/models/spree/tax/shipping_rate_taxer.rb +4 -13
- data/app/models/spree/tax/tax_helpers.rb +5 -3
- data/app/models/spree/tax_calculator/default.rb +83 -0
- data/app/models/spree/tax_calculator/shipping_rate.rb +46 -0
- data/app/models/spree/tax_category.rb +9 -1
- data/app/models/spree/tax_rate.rb +31 -7
- data/app/models/spree/tax_rate_tax_category.rb +6 -0
- data/app/models/spree/taxon.rb +1 -1
- data/app/models/spree/variant.rb +1 -1
- data/app/views/spree/{shipment_mailer → carton_mailer}/shipped_email.html.erb +3 -3
- data/app/views/spree/order_mailer/cancel_email.html.erb +3 -3
- data/app/views/spree/order_mailer/confirm_email.html.erb +2 -2
- data/app/views/spree/order_mailer/inventory_cancellation_email.html.erb +26 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +2 -2
- data/app/views/spree/test_mailer/test_email.html.erb +2 -2
- data/config/locales/en.yml +66 -57
- data/db/default/spree/refund_reasons.rb +1 -0
- data/db/default/spree/shipping_categories.rb +1 -0
- data/db/default/spree/stock_locations.rb +2 -0
- data/db/default/spree/stores.rb +3 -4
- data/db/migrate/20170412103617_transform_tax_rate_category_relation.rb +48 -0
- data/db/migrate/20170422134804_add_roles_unique_constraints.rb +6 -0
- data/db/migrate/20170522143442_add_time_range_to_tax_rate.rb +6 -0
- data/db/migrate/20170608074534_rename_bogus_gateways.rb +13 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +1 -1
- data/lib/generators/spree/dummy/dummy_generator.rb +10 -4
- data/lib/generators/spree/dummy/templates/rails/database.yml +12 -12
- data/lib/generators/spree/install/install_generator.rb +5 -5
- data/lib/generators/spree/install/templates/config/initializers/{spree.rb → solidus.rb} +0 -0
- data/lib/solidus/migrations/rename_gateways.rb +39 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -1
- data/lib/spree/core/controller_helpers/order.rb +10 -5
- data/lib/spree/core/controller_helpers/store.rb +1 -9
- data/lib/spree/core/current_store.rb +6 -14
- data/lib/spree/core/engine.rb +4 -3
- data/lib/spree/core/importer/order.rb +4 -4
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +0 -1
- data/lib/spree/localized_number.rb +2 -1
- data/lib/spree/permitted_attributes.rb +12 -6
- data/lib/spree/testing_support/capybara_ext.rb +0 -1
- data/lib/spree/testing_support/factories/adjustment_factory.rb +5 -1
- data/lib/spree/testing_support/factories/order_factory.rb +26 -24
- data/lib/spree/testing_support/factories/payment_factory.rb +4 -0
- data/lib/spree/testing_support/factories/payment_method_factory.rb +3 -3
- data/lib/spree/testing_support/factories/shipment_factory.rb +7 -3
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +3 -1
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -4
- data/lib/tasks/migrations/migrate_user_addresses.rake +2 -2
- data/lib/tasks/migrations/rename_gateways.rake +19 -0
- data/solidus_core.gemspec +2 -3
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +32 -6
- data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +0 -1
- data/spec/lib/spree/core/current_store_spec.rb +6 -11
- data/spec/lib/spree/core/price_migrator_spec.rb +4 -4
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +199 -91
- data/spec/lib/spree/core/testing_support/factories/variant_factory_spec.rb +18 -0
- data/spec/lib/spree/localized_number_spec.rb +6 -0
- data/spec/mailers/carton_mailer_spec.rb +3 -3
- data/spec/models/spree/address_spec.rb +3 -3
- data/spec/models/spree/adjustment_spec.rb +71 -27
- data/spec/models/spree/calculator/default_tax_spec.rb +72 -1
- data/spec/models/spree/calculator/distributed_amount_spec.rb +32 -0
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +20 -1
- data/spec/models/spree/calculator/tiered_percent_spec.rb +20 -1
- data/spec/models/spree/distributed_amounts_handler_spec.rb +79 -0
- data/spec/models/spree/gateway/bogus_simple.rb +7 -13
- data/spec/models/spree/gateway/bogus_spec.rb +8 -4
- data/spec/models/spree/gateway_spec.rb +6 -105
- data/spec/models/spree/image_spec.rb +23 -0
- data/spec/models/spree/order/checkout_spec.rb +3 -18
- data/spec/models/spree/order/number_generator_spec.rb +45 -0
- data/spec/models/spree/order/outstanding_balance_integration_spec.rb +135 -0
- data/spec/models/spree/order/payment_spec.rb +7 -2
- data/spec/models/spree/order/state_machine_spec.rb +4 -2
- data/spec/models/spree/order_capturing_spec.rb +8 -8
- data/spec/models/spree/order_contents_spec.rb +8 -1
- data/spec/models/spree/order_shipping_spec.rb +5 -1
- data/spec/models/spree/order_spec.rb +156 -83
- data/spec/models/spree/order_taxation_spec.rb +126 -0
- data/spec/models/spree/order_update_attributes_spec.rb +1 -5
- data/spec/models/spree/order_updater_spec.rb +20 -21
- data/spec/models/spree/payment_create_spec.rb +14 -6
- data/spec/models/spree/payment_method/bogus_credit_card_spec.rb +8 -0
- data/spec/models/spree/payment_method/check_spec.rb +78 -0
- data/spec/models/spree/payment_method/credit_card_spec.rb +66 -0
- data/spec/models/spree/payment_method/simple_bogus_credit_card_spec.rb +18 -0
- data/spec/models/spree/payment_method_spec.rb +47 -2
- data/spec/models/spree/payment_spec.rb +6 -8
- data/spec/models/spree/preference_spec.rb +1 -1
- data/spec/models/spree/price_spec.rb +1 -1
- data/spec/models/spree/product/scopes_spec.rb +46 -0
- data/spec/models/spree/promotion_action_spec.rb +4 -0
- data/spec/models/spree/promotion_code/batch_builder_spec.rb +25 -3
- data/spec/models/spree/promotion_code_batch_spec.rb +0 -6
- data/spec/models/spree/promotion_handler/coupon_spec.rb +1 -1
- data/spec/models/spree/promotion_rule_spec.rb +5 -0
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +1 -1
- data/spec/models/spree/shipment_spec.rb +24 -3
- data/spec/models/spree/shipping_rate_spec.rb +5 -5
- data/spec/models/spree/state_spec.rb +31 -4
- data/spec/models/spree/stock/coordinator_spec.rb +24 -0
- data/spec/models/spree/stock/estimator_spec.rb +1 -1
- data/spec/models/spree/store_selector/by_server_name_spec.rb +26 -0
- data/spec/models/spree/store_selector/legacy_spec.rb +44 -0
- data/spec/models/spree/store_spec.rb +10 -2
- data/spec/models/spree/tax/order_adjuster_spec.rb +11 -21
- data/spec/models/spree/tax/shipping_rate_taxer_spec.rb +10 -3
- data/spec/models/spree/tax/taxation_integration_spec.rb +43 -8
- data/spec/models/spree/tax_calculator/default_spec.rb +54 -0
- data/spec/models/spree/tax_rate_spec.rb +92 -0
- data/spec/models/spree/variant/vat_price_generator_spec.rb +4 -4
- data/spec/models/spree/variant_spec.rb +8 -2
- data/spec/spec_helper.rb +2 -1
- data/spec/support/test_gateway.rb +1 -1
- metadata +45 -24
- data/app/models/spree/tax/item_adjuster.rb +0 -51
- data/spec/models/spree/tax/item_adjuster_spec.rb +0 -82
|
@@ -2,30 +2,21 @@ module Spree
|
|
|
2
2
|
module Tax
|
|
3
3
|
# Used to build shipping rate taxes
|
|
4
4
|
class ShippingRateTaxer
|
|
5
|
-
include TaxHelpers
|
|
6
|
-
|
|
7
5
|
# Build shipping rate taxes for a shipping rate
|
|
8
6
|
# Modifies the passed-in shipping rate with associated shipping rate taxes.
|
|
9
7
|
# @param [Spree::ShippingRate] shipping_rate The shipping rate to add taxes to.
|
|
10
8
|
# This parameter will be modified.
|
|
11
9
|
# @return [Spree::ShippingRate] The shipping rate with associated tax objects
|
|
12
10
|
def tax(shipping_rate)
|
|
13
|
-
|
|
11
|
+
taxes = Spree::Config.shipping_rate_tax_calculator_class.new(shipping_rate).calculate
|
|
12
|
+
taxes.each do |tax|
|
|
14
13
|
shipping_rate.taxes.build(
|
|
15
|
-
amount:
|
|
16
|
-
tax_rate: tax_rate
|
|
14
|
+
amount: tax.amount,
|
|
15
|
+
tax_rate: tax.tax_rate
|
|
17
16
|
)
|
|
18
17
|
end
|
|
19
18
|
shipping_rate
|
|
20
19
|
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def tax_rates_for_shipping_rate(shipping_rate)
|
|
25
|
-
applicable_rates(shipping_rate.order).select do |tax_rate|
|
|
26
|
-
tax_rate.tax_category == shipping_rate.tax_category
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
20
|
end
|
|
30
21
|
end
|
|
31
22
|
end
|
|
@@ -17,9 +17,9 @@ 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_category_ids = rates_for_order(order).map(&:
|
|
20
|
+
order_zone_tax_category_ids = rates_for_order(order).flat_map(&:tax_categories).map(&:id)
|
|
21
21
|
default_rates_with_unmatched_tax_category = rates_for_default_zone.to_a.delete_if do |default_rate|
|
|
22
|
-
order_zone_tax_category_ids.
|
|
22
|
+
(order_zone_tax_category_ids & default_rate.tax_categories.map(&:id)).any?
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
(rates_for_order(order) + default_rates_with_unmatched_tax_category).uniq
|
|
@@ -38,7 +38,9 @@ module Spree
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def rates_for_item(item)
|
|
41
|
-
applicable_rates(item.order).select
|
|
41
|
+
applicable_rates(item.order).select do |rate|
|
|
42
|
+
rate.tax_categories.map(&:id).include?(item.tax_category_id)
|
|
43
|
+
end
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module TaxCalculator
|
|
3
|
+
# Default implementation for tax calculations. Will go through all line
|
|
4
|
+
# items and shipments and calculate their tax based on tax rates in the DB.
|
|
5
|
+
#
|
|
6
|
+
# The class used for tax calculation is configurable, so that the
|
|
7
|
+
# calculation can easily be pushed to third-party services. Users looking
|
|
8
|
+
# to provide their own calculator should adhere to the API of this class.
|
|
9
|
+
#
|
|
10
|
+
# @api experimental
|
|
11
|
+
# @note This API is currently in development and likely to change.
|
|
12
|
+
# Specifically, the input format is not yet finalized.
|
|
13
|
+
class Default
|
|
14
|
+
include Spree::Tax::TaxHelpers
|
|
15
|
+
|
|
16
|
+
# Create a new tax calculator.
|
|
17
|
+
#
|
|
18
|
+
# @param [Spree::Order] order the order to calculator taxes on
|
|
19
|
+
# @return [Spree::TaxCalculator::Default] a Spree::TaxCalculator::Default object
|
|
20
|
+
def initialize(order)
|
|
21
|
+
@order = order
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Calculate taxes for an order.
|
|
25
|
+
#
|
|
26
|
+
# @return [Spree::Tax::OrderTax] the calculated taxes for the order
|
|
27
|
+
def calculate
|
|
28
|
+
Spree::Tax::OrderTax.new(
|
|
29
|
+
order_id: order.id,
|
|
30
|
+
line_item_taxes: line_item_rates,
|
|
31
|
+
shipment_taxes: shipment_rates
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
attr_reader :order
|
|
38
|
+
|
|
39
|
+
# Calculate the taxes for line items.
|
|
40
|
+
#
|
|
41
|
+
# @private
|
|
42
|
+
# @return [Array<Spree::Tax::ItemTax>] calculated taxes for the line items
|
|
43
|
+
def line_item_rates
|
|
44
|
+
order.line_items.flat_map do |line_item|
|
|
45
|
+
calculate_rates(line_item)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Calculate the taxes for shipments.
|
|
50
|
+
#
|
|
51
|
+
# @private
|
|
52
|
+
# @return [Array<Spree::Tax::ItemTax>] calculated taxes for the shipments
|
|
53
|
+
def shipment_rates
|
|
54
|
+
order.shipments.flat_map do |shipment|
|
|
55
|
+
calculate_rates(shipment)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Calculate the taxes for a single item.
|
|
60
|
+
#
|
|
61
|
+
# The item could be either a {Spree::LineItem} or a {Spree::Shipment}.
|
|
62
|
+
#
|
|
63
|
+
# Will go through all applicable rates for an item and create a new
|
|
64
|
+
# {Spree::Tax::ItemTax} containing the calculated taxes for the item.
|
|
65
|
+
#
|
|
66
|
+
# @private
|
|
67
|
+
# @return [Array<Spree::Tax::ItemTax>] calculated taxes for the item
|
|
68
|
+
def calculate_rates(item)
|
|
69
|
+
rates_for_item(item).map do |rate|
|
|
70
|
+
amount = rate.compute_amount(item)
|
|
71
|
+
|
|
72
|
+
Spree::Tax::ItemTax.new(
|
|
73
|
+
item_id: item.id,
|
|
74
|
+
label: rate.adjustment_label(amount),
|
|
75
|
+
tax_rate: rate,
|
|
76
|
+
amount: amount,
|
|
77
|
+
included_in_price: rate.included_in_price
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module TaxCalculator
|
|
3
|
+
# Default implementation for tax calculations on shipping rates.
|
|
4
|
+
#
|
|
5
|
+
# The class used for shipping rate tax calculation is configurable, so that
|
|
6
|
+
# the calculation can easily be pushed to third-party services. Users
|
|
7
|
+
# looking to provide their own calculator should adhere to the API of this
|
|
8
|
+
# class.
|
|
9
|
+
#
|
|
10
|
+
# @see Spree::Tax::ShippingRateTaxer
|
|
11
|
+
# @api experimental
|
|
12
|
+
# @note This API is currently in development and likely to change.
|
|
13
|
+
# Specifically, the input format is not yet finalized.
|
|
14
|
+
class ShippingRate
|
|
15
|
+
include Spree::Tax::TaxHelpers
|
|
16
|
+
|
|
17
|
+
attr_reader :shipping_rate
|
|
18
|
+
|
|
19
|
+
# Create a new tax calculator.
|
|
20
|
+
#
|
|
21
|
+
# @param [Spree::ShippingRate] shipping_rate the shipping rate to
|
|
22
|
+
# calculate taxes on
|
|
23
|
+
# @return [Spree::TaxCalculator::ShippingRate]
|
|
24
|
+
def initialize(shipping_rate)
|
|
25
|
+
@shipping_rate = shipping_rate
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Calculate taxes for a shipping rate.
|
|
29
|
+
#
|
|
30
|
+
# @return [Array<Spree::Tax::ItemTax>] the calculated taxes for the
|
|
31
|
+
# shipping rate
|
|
32
|
+
def calculate
|
|
33
|
+
rates_for_item(shipping_rate).map do |rate|
|
|
34
|
+
amount = rate.compute_amount(shipping_rate)
|
|
35
|
+
|
|
36
|
+
Spree::Tax::ItemTax.new(
|
|
37
|
+
item_id: shipping_rate.id,
|
|
38
|
+
label: rate.adjustment_label(amount),
|
|
39
|
+
tax_rate: rate,
|
|
40
|
+
amount: amount
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -4,7 +4,15 @@ module Spree
|
|
|
4
4
|
validates :name, presence: true
|
|
5
5
|
validates_uniqueness_of :name, unless: :deleted_at
|
|
6
6
|
|
|
7
|
-
has_many :
|
|
7
|
+
has_many :tax_rate_tax_categories,
|
|
8
|
+
class_name: 'Spree::TaxRateTaxCategory',
|
|
9
|
+
dependent: :destroy,
|
|
10
|
+
inverse_of: :tax_category
|
|
11
|
+
has_many :tax_rates,
|
|
12
|
+
through: :tax_rate_tax_categories,
|
|
13
|
+
class_name: 'Spree::TaxRate',
|
|
14
|
+
inverse_of: :tax_categories
|
|
15
|
+
|
|
8
16
|
after_save :ensure_one_default
|
|
9
17
|
|
|
10
18
|
def self.default
|
|
@@ -9,13 +9,20 @@ module Spree
|
|
|
9
9
|
include Spree::AdjustmentSource
|
|
10
10
|
|
|
11
11
|
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
has_many :tax_rate_tax_categories,
|
|
14
|
+
class_name: 'Spree::TaxRateTaxCategory',
|
|
15
|
+
dependent: :destroy,
|
|
16
|
+
inverse_of: :tax_rate
|
|
17
|
+
has_many :tax_categories,
|
|
18
|
+
through: :tax_rate_tax_categories,
|
|
19
|
+
class_name: 'Spree::TaxCategory',
|
|
20
|
+
inverse_of: :tax_rates
|
|
13
21
|
|
|
14
22
|
has_many :adjustments, as: :source
|
|
15
23
|
has_many :shipping_rate_taxes, class_name: "Spree::ShippingRateTax"
|
|
16
24
|
|
|
17
25
|
validates :amount, presence: true, numericality: true
|
|
18
|
-
validates :tax_category_id, presence: true
|
|
19
26
|
|
|
20
27
|
# Finds all tax rates whose zones match a given address
|
|
21
28
|
scope :for_address, ->(address) { joins(:zone).merge(Spree::Zone.for_address(address)) }
|
|
@@ -91,15 +98,32 @@ module Spree
|
|
|
91
98
|
calculator.compute(item)
|
|
92
99
|
end
|
|
93
100
|
|
|
94
|
-
|
|
101
|
+
def active?
|
|
102
|
+
(starts_at.nil? || starts_at < Time.current) &&
|
|
103
|
+
(expires_at.nil? || expires_at > Time.current)
|
|
104
|
+
end
|
|
95
105
|
|
|
96
106
|
def adjustment_label(amount)
|
|
97
|
-
Spree.t
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
Spree.t(
|
|
108
|
+
translation_key(amount),
|
|
109
|
+
scope: "adjustment_labels.tax_rates",
|
|
110
|
+
name: name.presence || tax_categories.map(&:name).join(", "),
|
|
111
|
+
amount: amount_for_adjustment_label
|
|
112
|
+
)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def tax_category=(category)
|
|
116
|
+
self.tax_categories = [category]
|
|
101
117
|
end
|
|
102
118
|
|
|
119
|
+
def tax_category
|
|
120
|
+
tax_categories[0]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
deprecate :tax_category => :tax_categories, :tax_category= => :tax_categories=, deprecator: Spree::Deprecation
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
103
127
|
def amount_for_adjustment_label
|
|
104
128
|
ActiveSupport::NumberHelper::NumberToPercentageConverter.convert(
|
|
105
129
|
amount * 100,
|
data/app/models/spree/taxon.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
|
|
12
12
|
before_create :set_permalink
|
|
13
13
|
before_update :set_permalink
|
|
14
|
-
after_update :update_child_permalinks, if: :
|
|
14
|
+
after_update :update_child_permalinks, if: :saved_change_to_permalink?
|
|
15
15
|
|
|
16
16
|
validates :name, presence: true
|
|
17
17
|
validates :meta_keywords, length: { maximum: 255 }
|
data/app/models/spree/variant.rb
CHANGED
|
@@ -20,7 +20,7 @@ module Spree
|
|
|
20
20
|
attr_writer :rebuild_vat_prices
|
|
21
21
|
include Spree::DefaultPrice
|
|
22
22
|
|
|
23
|
-
belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product', inverse_of: :variants
|
|
23
|
+
belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product', inverse_of: :variants, optional: false
|
|
24
24
|
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
|
|
25
25
|
|
|
26
26
|
delegate :name, :description, :slug, :available_on, :shipping_category_id,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<%= Spree.t('shipment_mailer.shipped_email.shipment_summary') %>
|
|
12
12
|
</p>
|
|
13
13
|
<table>
|
|
14
|
-
<% @
|
|
14
|
+
<% @manifest.each do |item| %>
|
|
15
15
|
<tr>
|
|
16
16
|
<td><%= item.variant.sku %></td>
|
|
17
17
|
<td><%= item.variant.product.name %></td>
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
<% end %>
|
|
21
21
|
</table>
|
|
22
22
|
<p>
|
|
23
|
-
<%= Spree.t('shipment_mailer.shipped_email.track_information', tracking: @
|
|
23
|
+
<%= Spree.t('shipment_mailer.shipped_email.track_information', tracking: @carton.tracking) if @carton.tracking %>
|
|
24
24
|
</p>
|
|
25
25
|
<p>
|
|
26
|
-
<%= Spree.t('shipment_mailer.shipped_email.track_link', :url => @
|
|
26
|
+
<%= Spree.t('shipment_mailer.shipped_email.track_link', :url => @carton.tracking_url) if @carton.tracking_url %>
|
|
27
27
|
</p>
|
|
28
28
|
<p>
|
|
29
29
|
<%= Spree.t('shipment_mailer.shipped_email.thanks') %>
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
<tr>
|
|
16
16
|
<td><%= item.variant.sku %></td>
|
|
17
17
|
<td>
|
|
18
|
-
<%=
|
|
19
|
-
<%=
|
|
18
|
+
<%= item.variant.product.name %>
|
|
19
|
+
<%= item.variant.options_text -%>
|
|
20
20
|
</td>
|
|
21
21
|
<td>(<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %></td>
|
|
22
22
|
</tr>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<% @order.adjustments.eligible.each do |adjustment| %>
|
|
30
30
|
<tr>
|
|
31
31
|
<td></td>
|
|
32
|
-
<td><%=
|
|
32
|
+
<td><%= sanitize(adjustment.label) %></td>
|
|
33
33
|
<td><%= adjustment.display_amount %></td>
|
|
34
34
|
</tr>
|
|
35
35
|
<% end %>
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
<tr>
|
|
16
16
|
<td><%= item.variant.sku %></td>
|
|
17
17
|
<td>
|
|
18
|
-
<%=
|
|
19
|
-
<%=
|
|
18
|
+
<%= item.variant.product.name %>
|
|
19
|
+
<%= item.variant.options_text -%>
|
|
20
20
|
</td>
|
|
21
21
|
<td>(<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %></td>
|
|
22
22
|
</tr>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<table>
|
|
2
|
+
<tr>
|
|
3
|
+
<td>
|
|
4
|
+
<p class="lede">
|
|
5
|
+
<%= Spree.t('order_mailer.inventory_cancellation.dear_customer') %>
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
<%= Spree.t('order_mailer.inventory_cancellation.instructions') %>
|
|
9
|
+
</p>
|
|
10
|
+
<p>
|
|
11
|
+
<%= Spree.t('order_mailer.inventory_cancellation.order_summary_canceled') %>
|
|
12
|
+
</p>
|
|
13
|
+
<table>
|
|
14
|
+
<% @inventory_units.each do |item| %>
|
|
15
|
+
<tr>
|
|
16
|
+
<td><%= item.variant.sku %></td>
|
|
17
|
+
<td><%= item.variant.product.name %></td>
|
|
18
|
+
<td><%= item.variant.options_text -%></td>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</table>
|
|
22
|
+
<p>
|
|
23
|
+
</td>
|
|
24
|
+
<td class="expander"></td>
|
|
25
|
+
</tr>
|
|
26
|
+
</table>
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
<% @reimbursement.return_items.exchange_requested.each do |return_item| %>
|
|
22
22
|
<tr>
|
|
23
23
|
<td>
|
|
24
|
-
<%= return_item.variant.sku %> <%=
|
|
24
|
+
<%= return_item.variant.sku %> <%= return_item.variant.name %> <%= "(#{return_item.variant.options_text})" if return_item.variant.options_text.present? %>
|
|
25
25
|
</td>
|
|
26
26
|
<td>
|
|
27
27
|
->
|
|
28
28
|
</td>
|
|
29
29
|
<td>
|
|
30
|
-
<%= return_item.exchange_variant.sku %> <%=
|
|
30
|
+
<%= return_item.exchange_variant.sku %> <%= return_item.exchange_variant.name %> <%= "(#{return_item.exchange_variant.options_text})" if return_item.exchange_variant.options_text.present? %>
|
|
31
31
|
</td>
|
|
32
32
|
</tr>
|
|
33
33
|
<% end %>
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
<p>
|
|
31
31
|
Also take note that Gmail does not support <code><style></code> tags.
|
|
32
32
|
Therefore, you will need a gem that will be able to remove your <code><style></code>
|
|
33
|
-
tags and place them inline. Gmail only supports inline styles. We
|
|
34
|
-
<a href="https://github.com/fphilipe/premailer-rails" target="_blank">Premailer for Rails</a
|
|
33
|
+
tags and place them inline. Gmail only supports inline styles. We suggest
|
|
34
|
+
<a href="https://github.com/fphilipe/premailer-rails" target="_blank">Premailer for Rails</a>.
|
|
35
35
|
</p>
|
|
36
36
|
|
|
37
37
|
</td>
|
data/config/locales/en.yml
CHANGED
|
@@ -33,9 +33,11 @@ en:
|
|
|
33
33
|
preferred_amount: Amount
|
|
34
34
|
spree/calculator/tiered_flat_rate:
|
|
35
35
|
preferred_base_amount: Base Amount
|
|
36
|
+
preferred_currency: Currency
|
|
36
37
|
preferred_tiers: Tiers
|
|
37
38
|
spree/calculator/tiered_percent:
|
|
38
39
|
preferred_base_percent: Base Percent
|
|
40
|
+
preferred_currency: Currency
|
|
39
41
|
preferred_tiers: Tiers
|
|
40
42
|
spree/carton:
|
|
41
43
|
tracking: Tracking
|
|
@@ -135,7 +137,7 @@ en:
|
|
|
135
137
|
display_on: Display
|
|
136
138
|
name: Name
|
|
137
139
|
preference_source: Preference Source
|
|
138
|
-
type:
|
|
140
|
+
type: Type
|
|
139
141
|
spree/price:
|
|
140
142
|
currency: Currency
|
|
141
143
|
amount: Price
|
|
@@ -175,6 +177,40 @@ en:
|
|
|
175
177
|
promotion_uses: Promotion Uses
|
|
176
178
|
starts_at: Start date
|
|
177
179
|
usage_limit: Overall Usage Limit
|
|
180
|
+
spree/promotion/actions/create_adjustment:
|
|
181
|
+
description: Creates a promotion credit adjustment on the order
|
|
182
|
+
spree/promotion/actions/create_item_adjustments:
|
|
183
|
+
description: Creates a promotion credit adjustment on a line item
|
|
184
|
+
spree/promotion/actions/create_quantity_adjustments:
|
|
185
|
+
description: Creates an adjustment on a line item based on quantity
|
|
186
|
+
spree/promotion/actions/free_shipping:
|
|
187
|
+
description: Makes all shipments for the order free
|
|
188
|
+
spree/promotion/rules/item_total:
|
|
189
|
+
description: Order total meets these criteria
|
|
190
|
+
spree/promotion/rules/first_order:
|
|
191
|
+
description: Must be the customer's first order
|
|
192
|
+
spree/promotion/rules/landing_page:
|
|
193
|
+
description: Customer must have visited the specified page
|
|
194
|
+
spree/promotion/rules/one_use_per_user:
|
|
195
|
+
description: Only One Use Per User
|
|
196
|
+
spree/promotion/rules/option_value:
|
|
197
|
+
description: Order includes specified product(s) with matching option value(s)
|
|
198
|
+
spree/promotion/rules/product:
|
|
199
|
+
description: Order includes specified product(s)
|
|
200
|
+
spree/promotion/rules/user:
|
|
201
|
+
description: Available only to the specified users
|
|
202
|
+
spree/promotion/rules/user_logged_in:
|
|
203
|
+
description: Available only to logged in users
|
|
204
|
+
spree/promotion/rules/taxon:
|
|
205
|
+
description: Order includes products with specified taxon(s)
|
|
206
|
+
spree/promotion/rules/nth_order:
|
|
207
|
+
description: Apply a promotion to every nth order a user has completed.
|
|
208
|
+
form_text: "Apply this promotion on the users Nth order: "
|
|
209
|
+
spree/promotion/rules/first_repeat_purchase_since:
|
|
210
|
+
description: Available only to user who have not purchased in a while
|
|
211
|
+
form_text: "Apply this promotion to users whose last order was more than X days ago: "
|
|
212
|
+
spree/promotion/rules/user_role:
|
|
213
|
+
description: Order includes User with specified Role(s)
|
|
178
214
|
spree/promotion_category:
|
|
179
215
|
name: Name
|
|
180
216
|
spree/property:
|
|
@@ -313,6 +349,8 @@ en:
|
|
|
313
349
|
included_in_price: Included In Price
|
|
314
350
|
name: Name
|
|
315
351
|
show_rate_in_label: Show Rate In Label
|
|
352
|
+
starts_at: Start date
|
|
353
|
+
expires_at: Expiration date
|
|
316
354
|
spree/taxon:
|
|
317
355
|
description: Description
|
|
318
356
|
icon: Icon
|
|
@@ -365,6 +403,9 @@ en:
|
|
|
365
403
|
spree/calculator/default_tax:
|
|
366
404
|
one: Default Tax
|
|
367
405
|
other: Default Tax
|
|
406
|
+
spree/calculator/distributed_amount:
|
|
407
|
+
one: Distributed Amount
|
|
408
|
+
other: Distributed Amount
|
|
368
409
|
spree/calculator/flat_percent_item_total:
|
|
369
410
|
one: Flat Percent
|
|
370
411
|
other: Flat Percent
|
|
@@ -467,6 +508,22 @@ en:
|
|
|
467
508
|
spree/promotion:
|
|
468
509
|
one: Promotion
|
|
469
510
|
other: Promotions
|
|
511
|
+
spree/promotion/actions/create_adjustment: Create whole-order adjustment
|
|
512
|
+
spree/promotion/actions/create_item_adjustments: Create per-line-item adjustment
|
|
513
|
+
spree/promotion/actions/create_quantity_adjustments: Create per-quantity adjustment
|
|
514
|
+
spree/promotion/actions/free_shipping: Free shipping
|
|
515
|
+
spree/promotion/rules/first_order: First order
|
|
516
|
+
spree/promotion/rules/item_total: Item total
|
|
517
|
+
spree/promotion/rules/landing_page: Landing Page
|
|
518
|
+
spree/promotion/rules/one_use_per_user: One Use Per User
|
|
519
|
+
spree/promotion/rules/option_value: Option Value(s)
|
|
520
|
+
spree/promotion/rules/product: Product(s)
|
|
521
|
+
spree/promotion/rules/user: User
|
|
522
|
+
spree/promotion/rules/user_logged_in: User Logged In
|
|
523
|
+
spree/promotion/rules/taxon: Taxon(s)
|
|
524
|
+
spree/promotion/rules/nth_order: Nth Order
|
|
525
|
+
spree/promotion/rules/first_repeat_purchase_since: First Repeat Purchase Since
|
|
526
|
+
spree/promotion/rules/user_role: User Role(s)
|
|
470
527
|
spree/promotion_category:
|
|
471
528
|
one: Promotion Category
|
|
472
529
|
other: Promotion Categories
|
|
@@ -1211,7 +1268,7 @@ en:
|
|
|
1211
1268
|
tax_category: "This determines what kind of taxation is applied to this product.<br/> Default: None"
|
|
1212
1269
|
spree/promotion:
|
|
1213
1270
|
starts_at: "This determines when the promotion can be applied to orders. <br/> If no value is specified, the promotion will be immediately available."
|
|
1214
|
-
expires_at: "This determines when the promotion expires. <br/> If no value is specified, the promotion will never
|
|
1271
|
+
expires_at: "This determines when the promotion expires. <br/> If no value is specified, the promotion will never expire."
|
|
1215
1272
|
spree/store:
|
|
1216
1273
|
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."
|
|
1217
1274
|
spree/variant:
|
|
@@ -1219,6 +1276,8 @@ en:
|
|
|
1219
1276
|
deleted: "Deleted Variant"
|
|
1220
1277
|
deleted_explanation: "This variant was deleted on %{date}."
|
|
1221
1278
|
deleted_explanation_with_replacement: "This variant was deleted on %{date}. It has since been replaced by another with the same SKU."
|
|
1279
|
+
spree/tax_rate:
|
|
1280
|
+
validity_period: "This determines the validity period within which the tax rate is valid and will be applied to eligible items. <br /> If no start date value is specified, the tax rate will be immediately available. <br /> If no expiration date value is specified, the tax rate will never expire"
|
|
1222
1281
|
failed_payment_attempts: Failed Payment Attempts
|
|
1223
1282
|
failure: Failure
|
|
1224
1283
|
filename: Filename
|
|
@@ -1298,14 +1357,14 @@ en:
|
|
|
1298
1357
|
intercept_email_instructions: Override email recipient and replace with this address.
|
|
1299
1358
|
internal_name: Internal Name
|
|
1300
1359
|
invalid_exchange_variant: Invalid exchange variant.
|
|
1301
|
-
|
|
1360
|
+
invalid_payment_method_type: Invalid payment method type.
|
|
1302
1361
|
invalid_promotion_action: Invalid promotion action.
|
|
1303
1362
|
invalid_promotion_rule: Invalid promotion rule.
|
|
1304
1363
|
invalidate: Invalidate
|
|
1305
1364
|
inventory: Inventory
|
|
1306
1365
|
inventory_adjustment: Inventory Adjustment
|
|
1307
1366
|
inventory_canceled: Inventory canceled
|
|
1308
|
-
inventory_error_flash_for_insufficient_quantity: "
|
|
1367
|
+
inventory_error_flash_for_insufficient_quantity: "%{names} became unavailable."
|
|
1309
1368
|
inventory_not_available: Inventory not available for %{item}.
|
|
1310
1369
|
inventory_state: Inventory State
|
|
1311
1370
|
inventory_states:
|
|
@@ -1612,19 +1671,6 @@ en:
|
|
|
1612
1671
|
promotion: Promotion
|
|
1613
1672
|
promotionable: Promotable
|
|
1614
1673
|
promotion_action: Promotion Action
|
|
1615
|
-
promotion_action_types:
|
|
1616
|
-
create_adjustment:
|
|
1617
|
-
description: Creates a promotion credit adjustment on the order
|
|
1618
|
-
name: Create whole-order adjustment
|
|
1619
|
-
create_item_adjustments:
|
|
1620
|
-
description: Creates a promotion credit adjustment on a line item
|
|
1621
|
-
name: Create per-line-item adjustment
|
|
1622
|
-
create_quantity_adjustments:
|
|
1623
|
-
description: Creates an adjustment on a line item based on quantity
|
|
1624
|
-
name: Create per-quantity adjustment
|
|
1625
|
-
free_shipping:
|
|
1626
|
-
description: Makes all shipments for the order free
|
|
1627
|
-
name: Free shipping
|
|
1628
1674
|
promotion_actions: Actions
|
|
1629
1675
|
promotion_code_batch_mailer:
|
|
1630
1676
|
promotion_code_batch_finished:
|
|
@@ -1642,45 +1688,6 @@ en:
|
|
|
1642
1688
|
all: Match all of these rules
|
|
1643
1689
|
any: Match any of these rules
|
|
1644
1690
|
promotion_rule: Promotion Rule
|
|
1645
|
-
promotion_rule_types:
|
|
1646
|
-
first_order:
|
|
1647
|
-
description: Must be the customer's first order
|
|
1648
|
-
name: First order
|
|
1649
|
-
item_total:
|
|
1650
|
-
description: Order total meets these criteria
|
|
1651
|
-
name: Item total
|
|
1652
|
-
landing_page:
|
|
1653
|
-
description: Customer must have visited the specified page
|
|
1654
|
-
name: Landing Page
|
|
1655
|
-
one_use_per_user:
|
|
1656
|
-
description: Only One Use Per User
|
|
1657
|
-
name: One Use Per User
|
|
1658
|
-
option_value:
|
|
1659
|
-
description: Order includes specified product(s) with matching option value(s)
|
|
1660
|
-
name: Option Value(s)
|
|
1661
|
-
product:
|
|
1662
|
-
description: Order includes specified product(s)
|
|
1663
|
-
name: Product(s)
|
|
1664
|
-
user:
|
|
1665
|
-
description: Available only to the specified users
|
|
1666
|
-
name: User
|
|
1667
|
-
user_logged_in:
|
|
1668
|
-
description: Available only to logged in users
|
|
1669
|
-
name: User Logged In
|
|
1670
|
-
taxon:
|
|
1671
|
-
description: Order includes products with specified taxon(s)
|
|
1672
|
-
name: Taxon(s)
|
|
1673
|
-
nth_order:
|
|
1674
|
-
description: Apply a promotion to every nth order a user has completed.
|
|
1675
|
-
name: Nth Order
|
|
1676
|
-
form_text: "Apply this promotion on the users Nth order: "
|
|
1677
|
-
first_repeat_purchase_since:
|
|
1678
|
-
description: Available only to user who have not purchased in a while
|
|
1679
|
-
name: First Repeat Purchase Since
|
|
1680
|
-
form_text: "Apply this promotion to users whose last order was more than X days ago: "
|
|
1681
|
-
user_role:
|
|
1682
|
-
description: Order includes User with specified Role(s)
|
|
1683
|
-
name: User Role(s)
|
|
1684
1691
|
promotions: Promotions
|
|
1685
1692
|
promotion_successfully_created: Promotion has been successfully created!
|
|
1686
1693
|
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."
|
|
@@ -1689,7 +1696,7 @@ en:
|
|
|
1689
1696
|
properties: Property Types
|
|
1690
1697
|
property: Property Type
|
|
1691
1698
|
provider: Provider
|
|
1692
|
-
|
|
1699
|
+
payment_method_settings_warning: If you are changing the payment method type, you must save first before you can edit the payment method settings
|
|
1693
1700
|
qty: Qty
|
|
1694
1701
|
quantity: Quantity
|
|
1695
1702
|
quantity_returned: Quantity Returned
|
|
@@ -1865,6 +1872,7 @@ en:
|
|
|
1865
1872
|
source_location: Source location
|
|
1866
1873
|
special_instructions: Special Instructions
|
|
1867
1874
|
split: Split
|
|
1875
|
+
split_failed: Unable to complete split
|
|
1868
1876
|
spree_gateway_error_flash_for_checkout: There was a problem with your payment information. Please check your information and try again.
|
|
1869
1877
|
ssl:
|
|
1870
1878
|
change_protocol: "Please switch to using HTTP (rather than HTTPS) and retry this request."
|
|
@@ -2031,6 +2039,7 @@ en:
|
|
|
2031
2039
|
is_too_large: is too large -- stock on hand cannot cover requested quantity!
|
|
2032
2040
|
must_be_int: must be an integer
|
|
2033
2041
|
must_be_non_negative: must be a non-negative value
|
|
2042
|
+
validity_period: Validity Period
|
|
2034
2043
|
value: Value
|
|
2035
2044
|
variant: Variant
|
|
2036
2045
|
variant_placeholder: Choose a variant
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Spree::RefundReason.find_or_create_by(name: "Return processing")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Spree::ShippingCategory.find_or_create_by(name: "Default")
|
data/db/default/spree/stores.rb
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
unless Spree::Store.where(code: 'spree').exists?
|
|
3
3
|
Spree::Store.new do |s|
|
|
4
4
|
s.code = 'spree'
|
|
5
|
-
s.name = '
|
|
6
|
-
s.url = '
|
|
7
|
-
s.mail_from_address = '
|
|
8
|
-
s.cart_tax_country_iso = 'US'
|
|
5
|
+
s.name = 'Sample Store'
|
|
6
|
+
s.url = 'example.com'
|
|
7
|
+
s.mail_from_address = 'store@example.com'
|
|
9
8
|
end.save!
|
|
10
9
|
end
|