Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Line Item Actions to solidus_legacy_promotions #5916

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions core/app/models/spree/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class LineItem < Spree::Base
has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :destroy
has_many :inventory_units, inverse_of: :line_item

has_many :line_item_actions, dependent: :destroy
has_many :actions, through: :line_item_actions

before_validation :normalize_quantity
before_validation :set_required_attributes

Expand Down
10 changes: 0 additions & 10 deletions core/db/migrate/20160101010000_solidus_one_four.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,6 @@ def up
t.index ["variant_id"], name: "index_inventory_units_on_variant_id"
end

create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end

create_table "spree_line_items", force: :cascade do |t|
t.integer "variant_id"
t.integer "order_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

module SolidusLegacyPromotions
module SpreeLineItemDecorator
def self.prepended(base)
base.has_many :line_item_actions, dependent: :destroy
base.has_many :actions, through: :line_item_actions
end

def total_before_tax
amount + adjustments.select { |value| !value.tax? && value.eligible? }.sum(&:amount)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,17 @@ def up
t.index ["starts_at"], name: "index_spree_promotions_on_starts_at"
end
end

unless table_exists?(:spree_line_item_actions)
tvdeyen marked this conversation as resolved.
Show resolved Hide resolved
create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end
end
end
end