solidus_core 1.0.0.pre → 1.0.0.pre2
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.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/mailers/spree/carton_mailer.rb +1 -1
- data/app/mailers/spree/reimbursement_mailer.rb +3 -2
- data/app/mailers/spree/test_mailer.rb +1 -1
- data/app/models/concerns/spree/user_methods.rb +49 -0
- data/app/models/spree/ability.rb +2 -0
- data/app/models/spree/adjustment.rb +1 -0
- data/app/models/spree/adjustment_reason.rb +12 -0
- data/app/models/spree/app_configuration.rb +1 -1
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/inventory_unit.rb +10 -6
- data/app/models/spree/legacy_user.rb +4 -12
- data/app/models/spree/order.rb +15 -15
- data/app/models/spree/order/checkout.rb +20 -15
- data/app/models/spree/order/payments.rb +1 -5
- data/app/models/spree/order_cancellations.rb +1 -1
- data/app/models/spree/order_capturing.rb +1 -1
- data/app/models/spree/order_mutex.rb +1 -1
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/payment/processing.rb +39 -13
- data/app/models/spree/payment_method.rb +2 -2
- data/app/models/spree/permission_sets/base.rb +17 -0
- data/app/models/spree/permission_sets/configuration_display.rb +24 -0
- data/app/models/spree/permission_sets/configuration_management.rb +24 -0
- data/app/models/spree/permission_sets/dashboard_display.rb +9 -0
- data/app/models/spree/permission_sets/order_display.rb +15 -0
- data/app/models/spree/permission_sets/order_management.rb +15 -0
- data/app/models/spree/permission_sets/product_display.rb +18 -0
- data/app/models/spree/permission_sets/product_management.rb +19 -0
- data/app/models/spree/permission_sets/promotion_display.rb +12 -0
- data/app/models/spree/permission_sets/promotion_management.rb +12 -0
- data/app/models/spree/permission_sets/report_display.rb +9 -0
- data/app/models/spree/permission_sets/stock_display.rb +10 -0
- data/app/models/spree/permission_sets/stock_management.rb +11 -0
- data/app/models/spree/permission_sets/user_display.rb +11 -0
- data/app/models/spree/permission_sets/user_management.rb +11 -0
- data/app/models/spree/promotion/rules/item_total.rb +12 -33
- data/app/models/spree/promotion/rules/user.rb +2 -2
- data/app/models/spree/promotion_rule.rb +2 -2
- data/app/models/spree/reimbursement.rb +0 -12
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/return_item.rb +1 -0
- data/app/models/spree/return_reason.rb +18 -0
- data/app/models/spree/role_user.rb +1 -1
- data/app/models/spree/shipment.rb +9 -26
- data/app/models/spree/store_credit.rb +31 -7
- data/app/models/spree/store_credit_event.rb +13 -11
- data/app/models/spree/store_credit_update_reason.rb +2 -0
- data/app/models/spree/user_class_handle.rb +21 -0
- data/app/models/spree/user_stock_location.rb +1 -1
- data/config/initializers/spree_user.rb +10 -0
- data/config/locales/en.yml +58 -16
- data/db/default/spree/return_reasons.rb +9 -0
- data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +11 -9
- data/db/migrate/20150618212517_create_spree_store_credit_update_reasons.rb +8 -0
- data/db/migrate/20150619160613_create_adjustment_reason.rb +18 -0
- data/db/migrate/20150622144655_add_update_reason_to_store_credit_events.rb +5 -0
- data/db/migrate/20150623194316_add_return_authorization_reason_id_to_return_items.rb +7 -0
- data/db/migrate/20150623214058_seed_store_credit_update_reasons.rb +9 -0
- data/db/migrate/20150626200816_remove_shipping_method_id_from_spree_orders.rb +9 -0
- data/db/seeds.rb +9 -0
- data/lib/spree/core.rb +1 -4
- data/lib/spree/core/controller_helpers/auth.rb +15 -20
- data/lib/spree/core/engine.rb +1 -0
- data/lib/spree/core/importer/order.rb +8 -5
- data/lib/spree/core/role_configuration.rb +70 -0
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +6 -0
- data/lib/spree/testing_support/factories/order_factory.rb +14 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +2 -4
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +3 -3
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -0
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +10 -0
- data/lib/spree/testing_support/factories/store_credit_update_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +2 -7
- metadata +36 -10
- data/app/assets/images/logo/solidus.png +0 -0
- data/app/models/spree/item_adjustments.rb.orig +0 -93
- data/app/models/spree/return_authorization_reason.rb +0 -7
- data/app/models/spree/static_model_preferences.rb +0 -32
- data/config/initializers/user_class_extensions.rb +0 -42
Binary file
|
@@ -1,93 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
# Manage (recalculate) item (LineItem or Shipment) adjustments
|
3
|
-
class ItemAdjustments
|
4
|
-
attr_reader :item
|
5
|
-
|
6
|
-
# @param item [Order, LineItem, Shipment] the item whose adjustments should be updated
|
7
|
-
def initialize(item)
|
8
|
-
@item = item
|
9
|
-
end
|
10
|
-
|
11
|
-
# Update the item's adjustments and totals
|
12
|
-
#
|
13
|
-
# If the item is an {Order}, this will update and select the best
|
14
|
-
# promotion adjustment.
|
15
|
-
#
|
16
|
-
# If it is a {LineItem} or {Shipment}, it will update and select the best
|
17
|
-
# promotion adjustment, update tax adjustments, update cancellation
|
18
|
-
# adjustments, and then update the total fields (promo_total,
|
19
|
-
# included_tax_total, additional_tax_total, and adjustment_total) on the
|
20
|
-
# item.
|
21
|
-
#
|
22
|
-
# This is a noop if the item is not persisted.
|
23
|
-
def update
|
24
|
-
return @item unless item.persisted?
|
25
|
-
|
26
|
-
# Promotion adjustments must be applied first, then tax adjustments.
|
27
|
-
# This fits the criteria for VAT tax as outlined here:
|
28
|
-
# http://www.hmrc.gov.uk/vat/managing/charging/discounts-etc.htm#1
|
29
|
-
#
|
30
|
-
# It also fits the criteria for sales tax as outlined here:
|
31
|
-
# http://www.boe.ca.gov/formspubs/pub113/
|
32
|
-
#
|
33
|
-
# Tax adjustments come in not one but *two* exciting flavours:
|
34
|
-
# Included & additional
|
35
|
-
|
36
|
-
# Included tax adjustments are those which are included in the price.
|
37
|
-
# These ones should not affect the eventual total price.
|
38
|
-
#
|
39
|
-
# Additional tax adjustments are the opposite, affecting the final total.
|
40
|
-
|
41
|
-
promotion_adjustments = adjustments.select(&:promotion?)
|
42
|
-
promotion_adjustments.each(&:update!)
|
43
|
-
|
44
|
-
promo_total = PromotionChooser.new(promotion_adjustments).update
|
45
|
-
|
46
|
-
# Calculating the totals for the order here would be incorrect. Order's
|
47
|
-
# totals are the sum of the adjustments on all child models, as well as
|
48
|
-
# its own.
|
49
|
-
#
|
50
|
-
# We want to select the best promotion for the order, but the remainder
|
51
|
-
# of the calculations here are done in the OrderUpdater instead.
|
52
|
-
return if Spree::Order === item
|
53
|
-
|
54
|
-
@item.promo_total = promo_total
|
55
|
-
|
56
|
-
tax = adjustments.select(&:tax?)
|
57
|
-
|
58
|
-
@item.included_tax_total = tax.select(&:included?).map(&:update!).compact.sum
|
59
|
-
@item.additional_tax_total = tax.reject(&:included?).map(&:update!).compact.sum
|
60
|
-
|
61
|
-
item_cancellation_total = adjustments.select(&:cancellation?).map(&:update!).compact.sum
|
62
|
-
|
63
|
-
@item.adjustment_total = @item.promo_total + @item.additional_tax_total + item_cancellation_total
|
64
|
-
|
65
|
-
@item.update_columns(
|
66
|
-
:promo_total => @item.promo_total,
|
67
|
-
:included_tax_total => @item.included_tax_total,
|
68
|
-
:additional_tax_total => @item.additional_tax_total,
|
69
|
-
:adjustment_total => @item.adjustment_total,
|
70
|
-
:updated_at => Time.now,
|
71
|
-
) if @item.changed?
|
72
|
-
|
73
|
-
@item
|
74
|
-
end
|
75
|
-
|
76
|
-
<<<<<<< HEAD
|
77
|
-
private
|
78
|
-
def adjustments
|
79
|
-
# This is done intentionally to avoid loading the association. If the
|
80
|
-
# association is loaded, the records may become stale due to code
|
81
|
-
# elsewhere in spree. When that is remedied, this should be changed to
|
82
|
-
# just item.adjustments
|
83
|
-
@adjustments ||= item.adjustments.all.to_a
|
84
|
-
||||||| parent of 12bada8... Replace order strings with symbols/arel_table.
|
85
|
-
def best_promotion_adjustment
|
86
|
-
@best_promotion_adjustment ||= adjustments.promotion.eligible.reorder("amount ASC, created_at DESC, id DESC").first
|
87
|
-
=======
|
88
|
-
def best_promotion_adjustment
|
89
|
-
@best_promotion_adjustment ||= adjustments.promotion.eligible.reorder(:amount, created_at: :desc, id: :desc).first
|
90
|
-
>>>>>>> 12bada8... Replace order strings with symbols/arel_table.
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class StaticModelPreferences
|
3
|
-
def initialize(model_class, name, preferences={})
|
4
|
-
@name = name
|
5
|
-
@model_class = model_class
|
6
|
-
@preferences = preferences.dup.freeze
|
7
|
-
|
8
|
-
validate_preferences
|
9
|
-
end
|
10
|
-
|
11
|
-
delegate :keys, :fetch, to: :@preferences
|
12
|
-
|
13
|
-
def []=(name, value)
|
14
|
-
puts "Ignoring assignment of preference #{name}"
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def validate_preferences
|
20
|
-
model_preferences = @model_class.defined_preferences
|
21
|
-
defined_preferences = @preferences.keys
|
22
|
-
|
23
|
-
(model_preferences - defined_preferences).each do |pref|
|
24
|
-
puts "WARNING: Missing definition for #{pref}"
|
25
|
-
end
|
26
|
-
|
27
|
-
(defined_preferences - model_preferences).each do |pref|
|
28
|
-
puts "WARNING: Unknown preference #{pref}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
Spree::Core::Engine.config.to_prepare do
|
2
|
-
if Spree.user_class
|
3
|
-
Spree.user_class.class_eval do
|
4
|
-
|
5
|
-
include Spree::UserApiAuthentication
|
6
|
-
include Spree::UserReporting
|
7
|
-
|
8
|
-
has_many :role_users, foreign_key: "user_id", class_name: "Spree::RoleUser"
|
9
|
-
has_many :spree_roles, through: :role_users, source: :role
|
10
|
-
|
11
|
-
has_many :user_stock_locations, foreign_key: "user_id", class_name: "Spree::UserStockLocation"
|
12
|
-
has_many :stock_locations, through: :user_stock_locations
|
13
|
-
|
14
|
-
has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
|
15
|
-
|
16
|
-
has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
|
17
|
-
has_many :store_credit_events, through: :store_credits
|
18
|
-
|
19
|
-
belongs_to :ship_address, class_name: 'Spree::Address'
|
20
|
-
belongs_to :bill_address, class_name: 'Spree::Address'
|
21
|
-
|
22
|
-
# has_spree_role? simply needs to return true or false whether a user has a role or not.
|
23
|
-
def has_spree_role?(role_in_question)
|
24
|
-
spree_roles.any? { |role| role.name == role_in_question.to_s }
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Spree::Order] the most-recently-created incomplete order
|
28
|
-
# since the customer's last complete order.
|
29
|
-
def last_incomplete_spree_order(store: nil, only_frontend_viewable: true)
|
30
|
-
self_orders = self.orders
|
31
|
-
self_orders = self_orders.where(frontend_viewable: true) if only_frontend_viewable
|
32
|
-
self_orders = self_orders.where(store: store) if store
|
33
|
-
last_order = self_orders.order(:created_at).last
|
34
|
-
last_order unless last_order.try!(:completed?)
|
35
|
-
end
|
36
|
-
|
37
|
-
def total_available_store_credit
|
38
|
-
store_credits.reload.to_a.sum{ |credit| credit.amount_remaining }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|